WPGlobus – Multilingual Everything! - Version 1.9.9

Version Description

  • FIXED
    • Core: Removed devmode switcher from the post-new.php page.
    • Core: Fix broken Add Language link. Code cleanup and cosmetics.
  • ADDED:
    • Core: styling and translations for the ON/OFF WPGlobus switcher on the edit pages.
Download this release

Release Info

Developer tivnet
Plugin Icon 128x128 WPGlobus – Multilingual Everything!
Version 1.9.9
Comparing to
See all releases

Version 1.9.9

Files changed (392) hide show
  1. data/paid_plugins.json +65 -0
  2. data/wpglobus-product-info.json +1 -0
  3. flags/ad.alt.png +0 -0
  4. flags/ad.png +0 -0
  5. flags/ae.png +0 -0
  6. flags/af.png +0 -0
  7. flags/ag.png +0 -0
  8. flags/ai.alt.png +0 -0
  9. flags/ai.png +0 -0
  10. flags/al.png +0 -0
  11. flags/am.png +0 -0
  12. flags/an.png +0 -0
  13. flags/ao.png +0 -0
  14. flags/aq.png +0 -0
  15. flags/ar.alt.png +0 -0
  16. flags/ar.png +0 -0
  17. flags/argm.jpg +0 -0
  18. flags/arle.png +0 -0
  19. flags/as.png +0 -0
  20. flags/asl.gif +0 -0
  21. flags/at.alt.png +0 -0
  22. flags/at.png +0 -0
  23. flags/au.png +0 -0
  24. flags/aw.png +0 -0
  25. flags/ax.png +0 -0
  26. flags/az.png +0 -0
  27. flags/ba.png +0 -0
  28. flags/bb.png +0 -0
  29. flags/bd.png +0 -0
  30. flags/be.png +0 -0
  31. flags/bf.png +0 -0
  32. flags/bg.png +0 -0
  33. flags/bh.png +0 -0
  34. flags/bi.alt.png +0 -0
  35. flags/bi.png +0 -0
  36. flags/bj.png +0 -0
  37. flags/bm.png +0 -0
  38. flags/bn.png +0 -0
  39. flags/bo.png +0 -0
  40. flags/br.png +0 -0
  41. flags/bs.png +0 -0
  42. flags/bt.png +0 -0
  43. flags/bv.png +0 -0
  44. flags/bw.png +0 -0
  45. flags/by.png +0 -0
  46. flags/bz.png +0 -0
  47. flags/ca.alt.png +0 -0
  48. flags/ca.png +0 -0
  49. flags/cc.alt.png +0 -0
  50. flags/cc.png +0 -0
  51. flags/cd.png +0 -0
  52. flags/cf.png +0 -0
  53. flags/cg.png +0 -0
  54. flags/ch.png +0 -0
  55. flags/ci.png +0 -0
  56. flags/ck.png +0 -0
  57. flags/cl.png +0 -0
  58. flags/cm.png +0 -0
  59. flags/cn.png +0 -0
  60. flags/co.png +0 -0
  61. flags/cr.alt.png +0 -0
  62. flags/cr.png +0 -0
  63. flags/cs.png +0 -0
  64. flags/cu.png +0 -0
  65. flags/cv.png +0 -0
  66. flags/cx.png +0 -0
  67. flags/cy.png +0 -0
  68. flags/cz.png +0 -0
  69. flags/de.png +0 -0
  70. flags/dj.png +0 -0
  71. flags/dk.png +0 -0
  72. flags/dm.png +0 -0
  73. flags/do.png +0 -0
  74. flags/dz.png +0 -0
  75. flags/ec.alt.png +0 -0
  76. flags/ec.png +0 -0
  77. flags/ee.png +0 -0
  78. flags/eg.png +0 -0
  79. flags/eh.alt.png +0 -0
  80. flags/eh.png +0 -0
  81. flags/en.png +0 -0
  82. flags/eo.png +0 -0
  83. flags/er.png +0 -0
  84. flags/es.alt.png +0 -0
  85. flags/es.png +0 -0
  86. flags/et.alt.png +0 -0
  87. flags/et.png +0 -0
  88. flags/eu.png +0 -0
  89. flags/eus.png +0 -0
  90. flags/fi.png +0 -0
  91. flags/fj.png +0 -0
  92. flags/fk.png +0 -0
  93. flags/fm.png +0 -0
  94. flags/fo.png +0 -0
  95. flags/fr.png +0 -0
  96. flags/fr_CA.png +0 -0
  97. flags/ga.png +0 -0
  98. flags/galego.png +0 -0
  99. flags/gb.png +0 -0
  100. flags/gd.png +0 -0
  101. flags/ge.png +0 -0
  102. flags/gf.png +0 -0
  103. flags/gg.png +0 -0
  104. flags/gh.png +0 -0
  105. flags/gi.png +0 -0
  106. flags/gl.png +0 -0
  107. flags/gm.png +0 -0
  108. flags/gn.png +0 -0
  109. flags/gp.png +0 -0
  110. flags/gq.png +0 -0
  111. flags/gr.png +0 -0
  112. flags/gs.png +0 -0
  113. flags/gt.alt.png +0 -0
  114. flags/gt.png +0 -0
  115. flags/gu.png +0 -0
  116. flags/gw.png +0 -0
  117. flags/gy.png +0 -0
  118. flags/hk.png +0 -0
  119. flags/hm.png +0 -0
  120. flags/hn.png +0 -0
  121. flags/hr.png +0 -0
  122. flags/ht.alt.png +0 -0
  123. flags/ht.png +0 -0
  124. flags/hu.png +0 -0
  125. flags/id.png +0 -0
  126. flags/ie.png +0 -0
  127. flags/il.png +0 -0
  128. flags/im.png +0 -0
  129. flags/in.png +0 -0
  130. flags/io.png +0 -0
  131. flags/iq.png +0 -0
  132. flags/ir.png +0 -0
  133. flags/is.png +0 -0
  134. flags/it.png +0 -0
  135. flags/je.png +0 -0
  136. flags/jm.png +0 -0
  137. flags/jo.png +0 -0
  138. flags/jp.png +0 -0
  139. flags/ke.png +0 -0
  140. flags/kg.png +0 -0
  141. flags/kh.png +0 -0
  142. flags/ki.png +0 -0
  143. flags/km.png +0 -0
  144. flags/kn.png +0 -0
  145. flags/kp.png +0 -0
  146. flags/kr.png +0 -0
  147. flags/ku.png +0 -0
  148. flags/kw.png +0 -0
  149. flags/ky.png +0 -0
  150. flags/kz.png +0 -0
  151. flags/la.png +0 -0
  152. flags/lb.png +0 -0
  153. flags/lc.png +0 -0
  154. flags/li.png +0 -0
  155. flags/lk.png +0 -0
  156. flags/lr.png +0 -0
  157. flags/ls.png +0 -0
  158. flags/lt.png +0 -0
  159. flags/lu.png +0 -0
  160. flags/lv.png +0 -0
  161. flags/ly.png +0 -0
  162. flags/ma.png +0 -0
  163. flags/mc.png +0 -0
  164. flags/md.png +0 -0
  165. flags/me.png +0 -0
  166. flags/mg.png +0 -0
  167. flags/mh.png +0 -0
  168. flags/mk.png +0 -0
  169. flags/ml.png +0 -0
  170. flags/mm.png +0 -0
  171. flags/mn.png +0 -0
  172. flags/mo.png +0 -0
  173. flags/mp.png +0 -0
  174. flags/mq.png +0 -0
  175. flags/mr.png +0 -0
  176. flags/ms.png +0 -0
  177. flags/mt.png +0 -0
  178. flags/mu.png +0 -0
  179. flags/mv.png +0 -0
  180. flags/mw.png +0 -0
  181. flags/mx.png +0 -0
  182. flags/my.png +0 -0
  183. flags/my_MM.png +0 -0
  184. flags/mz.png +0 -0
  185. flags/na.png +0 -0
  186. flags/nc.png +0 -0
  187. flags/ne.png +0 -0
  188. flags/nf.png +0 -0
  189. flags/ng.png +0 -0
  190. flags/ni.alt.png +0 -0
  191. flags/ni.png +0 -0
  192. flags/nl.png +0 -0
  193. flags/no.png +0 -0
  194. flags/np.png +0 -0
  195. flags/nr.png +0 -0
  196. flags/nu.png +0 -0
  197. flags/nz.png +0 -0
  198. flags/om.png +0 -0
  199. flags/pa.png +0 -0
  200. flags/pe.png +0 -0
  201. flags/pf.alt.png +0 -0
  202. flags/pf.png +0 -0
  203. flags/pg.png +0 -0
  204. flags/ph.png +0 -0
  205. flags/pk.png +0 -0
  206. flags/pl.png +0 -0
  207. flags/pm.png +0 -0
  208. flags/pn.png +0 -0
  209. flags/pr.png +0 -0
  210. flags/ps.png +0 -0
  211. flags/pt.png +0 -0
  212. flags/pw.png +0 -0
  213. flags/py.png +0 -0
  214. flags/qa.png +0 -0
  215. flags/re.png +0 -0
  216. flags/ro.png +0 -0
  217. flags/rs.png +0 -0
  218. flags/ru.png +0 -0
  219. flags/rw.png +0 -0
  220. flags/sa.png +0 -0
  221. flags/sb.png +0 -0
  222. flags/sc.png +0 -0
  223. flags/sd.png +0 -0
  224. flags/se.png +0 -0
  225. flags/sg.png +0 -0
  226. flags/sh.png +0 -0
  227. flags/si.png +0 -0
  228. flags/sj.png +0 -0
  229. flags/sk.png +0 -0
  230. flags/sl.png +0 -0
  231. flags/sm.png +0 -0
  232. flags/sn.png +0 -0
  233. flags/so.png +0 -0
  234. flags/sr.png +0 -0
  235. flags/st.png +0 -0
  236. flags/sv.alt.png +0 -0
  237. flags/sv.png +0 -0
  238. flags/sy.png +0 -0
  239. flags/sz.png +0 -0
  240. flags/tc.png +0 -0
  241. flags/td.png +0 -0
  242. flags/tf.png +0 -0
  243. flags/tg.png +0 -0
  244. flags/th.png +0 -0
  245. flags/tj.png +0 -0
  246. flags/tk.png +0 -0
  247. flags/tl.png +0 -0
  248. flags/tm.png +0 -0
  249. flags/tn.png +0 -0
  250. flags/to.png +0 -0
  251. flags/tr.png +0 -0
  252. flags/tt.png +0 -0
  253. flags/tv.png +0 -0
  254. flags/tw.png +0 -0
  255. flags/tz.png +0 -0
  256. flags/ua.png +0 -0
  257. flags/ug.png +0 -0
  258. flags/uk.png +0 -0
  259. flags/um.png +0 -0
  260. flags/us.png +0 -0
  261. flags/uy.png +0 -0
  262. flags/uz.png +0 -0
  263. flags/va.png +0 -0
  264. flags/vc.png +0 -0
  265. flags/ve.png +0 -0
  266. flags/vg.png +0 -0
  267. flags/vi.png +0 -0
  268. flags/vn.png +0 -0
  269. flags/vu.png +0 -0
  270. flags/wf.alt.png +0 -0
  271. flags/wf.png +0 -0
  272. flags/ws.png +0 -0
  273. flags/ye.png +0 -0
  274. flags/yt.png +0 -0
  275. flags/yu.png +0 -0
  276. flags/za.png +0 -0
  277. flags/zm.png +0 -0
  278. flags/zw.png +0 -0
  279. flags/zz.png +0 -0
  280. includes/admin/central/class-wpglobus-admin-central.php +172 -0
  281. includes/admin/class-wpglobus-about.php +181 -0
  282. includes/admin/class-wpglobus-admin-menu.php +52 -0
  283. includes/admin/class-wpglobus-admin-page.php +101 -0
  284. includes/admin/class-wpglobus-clean.php +733 -0
  285. includes/admin/class-wpglobus-customize-options.php +1564 -0
  286. includes/admin/class-wpglobus-dashboard-news.php +67 -0
  287. includes/admin/class-wpglobus-language-edit-request.php +255 -0
  288. includes/admin/class-wpglobus-language-edit.php +494 -0
  289. includes/admin/class-wpglobus-plugin-install.php +335 -0
  290. includes/admin/customize/class-wpglobus-customize140.php +282 -0
  291. includes/admin/customize/class-wpglobus-customize170.php +300 -0
  292. includes/admin/customize/class-wpglobus-customize190.php +467 -0
  293. includes/admin/customize/wpglobus-customize-filters.php +40 -0
  294. includes/admin/customize/wpglobus-customize.php +22 -0
  295. includes/admin/debug/class-wpglobus-admin-debug.php +238 -0
  296. includes/admin/helpdesk/beacon-loader.min.js +1 -0
  297. includes/admin/helpdesk/class-wpglobus-admin-helpdesk.php +208 -0
  298. includes/admin/helpdesk/wpglobus-admin-helpdesk-page.php +94 -0
  299. includes/admin/media/class-wpglobus-media.php +339 -0
  300. includes/admin/recommendations/class-wpglobus-admin-recommendations.php +160 -0
  301. includes/admin/wpglobus-admin.php +22 -0
  302. includes/class-wpglobus-config.php +701 -0
  303. includes/class-wpglobus-core.php +338 -0
  304. includes/class-wpglobus-filters.php +1154 -0
  305. includes/class-wpglobus-plugin.php +96 -0
  306. includes/class-wpglobus-redirect.php +99 -0
  307. includes/class-wpglobus-utils.php +457 -0
  308. includes/class-wpglobus-widget.php +278 -0
  309. includes/class-wpglobus-wp.php +254 -0
  310. includes/class-wpglobus.php +3648 -0
  311. includes/compat/mbstring.php +49 -0
  312. includes/css/images/btn_donateCC_LG_global.gif +0 -0
  313. includes/css/images/checkbox-icon.png +0 -0
  314. includes/css/images/edit.svg +8 -0
  315. includes/css/images/editicon.png +0 -0
  316. includes/css/images/error.png +0 -0
  317. includes/css/images/spinner.gif +0 -0
  318. includes/css/images/success.png +0 -0
  319. includes/css/images/ui-bg_flat40x100.png +0 -0
  320. includes/css/images/woocommerce-wpglobus-logo-300x300.png +0 -0
  321. includes/css/images/woocommerce-wpglobus-netaxeptcw-logo-300x300.jpg +0 -0
  322. includes/css/images/wpglobus-for-bridge-theme-logo-400x400.png +0 -0
  323. includes/css/images/wpglobus-hi-logo-400x400.png +0 -0
  324. includes/css/images/wpglobus-logo-180x180.png +0 -0
  325. includes/css/images/wpglobus-lw-logo-400x400.png +0 -0
  326. includes/css/images/wpglobus-menu-visibility-logo.png +0 -0
  327. includes/css/images/wpglobus-mobile-menu-logo-400x400.png +0 -0
  328. includes/css/images/wpglobus-multi-currency-logo.jpg +0 -0
  329. includes/css/images/wpglobus-plus-logo-150x150.png +0 -0
  330. includes/css/images/wpglobus-plus-logo-300x300.png +0 -0
  331. includes/css/images/wpglobus-revslider-logo-400x400.png +0 -0
  332. includes/css/wpglobus-admin-debug.css +57 -0
  333. includes/css/wpglobus-admin-debug.less +63 -0
  334. includes/css/wpglobus-admin-debug.min.css +1 -0
  335. includes/css/wpglobus-admin-tabs.css +262 -0
  336. includes/css/wpglobus-admin-tabs.less +240 -0
  337. includes/css/wpglobus-admin-tabs.min.css +1 -0
  338. includes/css/wpglobus-admin.css +280 -0
  339. includes/css/wpglobus-admin.less +347 -0
  340. includes/css/wpglobus-admin.min.css +1 -0
  341. includes/css/wpglobus-dialog-ui.css +232 -0
  342. includes/css/wpglobus-dialog-ui.less +277 -0
  343. includes/css/wpglobus-dialog-ui.min.css +1 -0
  344. includes/css/wpglobus-flags.mixin.less +37 -0
  345. includes/css/wpglobus-special-pages.css +57 -0
  346. includes/css/wpglobus-special-pages.less +64 -0
  347. includes/css/wpglobus-special-pages.min.css +1 -0
  348. includes/css/wpglobus-widget.mixin.less +124 -0
  349. includes/css/wpglobus.css +95 -0
  350. includes/css/wpglobus.less +2 -0
  351. includes/css/wpglobus.min.css +1 -0
  352. includes/js/wpglobus-admin-47.js +1649 -0
  353. includes/js/wpglobus-admin-47.min.js +1 -0
  354. includes/js/wpglobus-admin-49.js +1654 -0
  355. includes/js/wpglobus-admin-49.min.js +1 -0
  356. includes/js/wpglobus-admin-debug.js +38 -0
  357. includes/js/wpglobus-admin-debug.min.js +1 -0
  358. includes/js/wpglobus-admin.js +1601 -0
  359. includes/js/wpglobus-admin.min.js +1 -0
  360. includes/js/wpglobus-clean.js +104 -0
  361. includes/js/wpglobus-clean.min.js +1 -0
  362. includes/js/wpglobus-customize-control.js +176 -0
  363. includes/js/wpglobus-customize-control.min.js +1 -0
  364. includes/js/wpglobus-customize-control140.js +797 -0
  365. includes/js/wpglobus-customize-control140.min.js +1 -0
  366. includes/js/wpglobus-customize-control170.js +1069 -0
  367. includes/js/wpglobus-customize-control170.min.js +1 -0
  368. includes/js/wpglobus-customize-control190.js +1197 -0
  369. includes/js/wpglobus-customize-control190.min.js +1 -0
  370. includes/js/wpglobus-customize-options-preview.js +20 -0
  371. includes/js/wpglobus-customize-options-preview.min.js +1 -0
  372. includes/js/wpglobus-customize-options.js +411 -0
  373. includes/js/wpglobus-customize-options.min.js +1 -0
  374. includes/js/wpglobus-customize-preview.js +32 -0
  375. includes/js/wpglobus-customize-preview.min.js +1 -0
  376. includes/js/wpglobus-form.js +29 -0
  377. includes/js/wpglobus-form.min.js +1 -0
  378. includes/js/wpglobus-media-post-php.js +33 -0
  379. includes/js/wpglobus-media-post-php.min.js +1 -0
  380. includes/js/wpglobus-media.js +108 -0
  381. includes/js/wpglobus-media.min.js +1 -0
  382. includes/js/wpglobus-plugin-install.js +98 -0
  383. includes/js/wpglobus-plugin-install.min.js +1 -0
  384. includes/js/wpglobus-vendor-acf.js +114 -0
  385. includes/js/wpglobus-vendor-acf.min.js +1 -0
  386. includes/js/wpglobus-vendor-aioseop.js +108 -0
  387. includes/js/wpglobus-vendor-aioseop.min.js +1 -0
  388. includes/js/wpglobus-widgets.js +461 -0
  389. includes/js/wpglobus-widgets.min.js +1 -0
  390. includes/js/wpglobus-wpseo-21.js +497 -0
  391. includes/js/wpglobus-wpseo-21.min.js +1 -0
  392. includes/js/wpglobus-wpseo-22.js +406 -0
data/paid_plugins.json ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "woocommerce-wpglobus": {
3
+ "slug": "woocommerce-wpglobus",
4
+ "loader": "woocommerce-wpglobus.php",
5
+ "image_file": "woocommerce-wpglobus-logo-300x300.png",
6
+ "order": 100
7
+ },
8
+ "wpglobus-plus": {
9
+ "slug": "wpglobus-plus",
10
+ "loader": "wpglobus-plus.php",
11
+ "image_file": "wpglobus-plus-logo-300x300.png",
12
+ "order": 90
13
+ },
14
+ "wpglobus-multi-currency": {
15
+ "slug": "wpglobus-multi-currency",
16
+ "loader": "wpglobus-multi-currency.php",
17
+ "image_file": "wpglobus-multi-currency-logo.jpg",
18
+ "order": 80
19
+ },
20
+ "wpglobus-revslider": {
21
+ "slug": "wpglobus-revslider",
22
+ "loader": "wpglobus-revslider.php",
23
+ "product_slug": "wpglobus-for-slider-revolution",
24
+ "image_file": "wpglobus-revslider-logo-400x400.png",
25
+ "order": 60
26
+ },
27
+ "wpglobus-language-widgets": {
28
+ "slug": "wpglobus-language-widgets",
29
+ "loader": "wpglobus-language-widgets.php",
30
+ "image_file": "wpglobus-lw-logo-400x400.png",
31
+ "order": 50
32
+ },
33
+ "wpglobus-menu-visibility": {
34
+ "slug": "wpglobus-menu-visibility",
35
+ "loader": "wpglobus-menu-visibility.php",
36
+ "image_file": "wpglobus-menu-visibility-logo.png",
37
+ "order": 40
38
+ },
39
+ "wpglobus-header-images": {
40
+ "slug": "wpglobus-header-images",
41
+ "loader": "wpglobus-header-images.php",
42
+ "image_file": "wpglobus-hi-logo-400x400.png",
43
+ "order": 30
44
+ },
45
+ "wpglobus-mobile-menu": {
46
+ "slug": "wpglobus-mobile-menu",
47
+ "loader": "wpglobus-mobile-menu.php",
48
+ "image_file": "wpglobus-mobile-menu-logo-400x400.png",
49
+ "order": 20
50
+ },
51
+ "wpglobus-for-bridge-theme": {
52
+ "slug": "wpglobus-for-bridge-theme",
53
+ "loader": "wpglobus-for-bridge-theme.php",
54
+ "product_slug": "wpglobus-for-bridge-theme",
55
+ "image_file": "wpglobus-for-bridge-theme-logo-400x400.png",
56
+ "order": 10
57
+ },
58
+ "woocommerce-nets-netaxept": {
59
+ "slug": "woocommerce-nets-netaxept",
60
+ "loader": "woocommerce-nets-netaxept.php",
61
+ "product_slug": "multilingual-woocommerce-nets-netaxept",
62
+ "image_file": "woocommerce-wpglobus-netaxeptcw-logo-300x300.jpg",
63
+ "order": 1
64
+ }
65
+ }
data/wpglobus-product-info.json ADDED
@@ -0,0 +1 @@
 
1
+ {"multilingual-woocommerce-nets-netaxept":{"title":"{:en}Multilingual WooCommerce Nets Netaxept{:}{:ru}\u041c\u0443\u043b\u044c\u0442\u0438\u044f\u0437\u044b\u0447\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f WooCommerce Nets Netaxept{:}","_api_new_version":"1.0.3","_api_tested_up_to":"4.9.2"},"wpglobus-header-images":{"title":"{:en}WPGlobus Header Images{:}{:ru}WPGlobus Header Images{:}","_api_new_version":"1.1.0","_api_tested_up_to":"4.9.2"},"wpglobus-for-slider-revolution":{"title":"{:en}WPGlobus for Slider Revolution{:}{:ru}WPGlobus \u0434\u043b\u044f \u043f\u043b\u0430\u0433\u0438\u043d\u0430 Slider Revolution{:}","_api_new_version":"1.5.0","_api_tested_up_to":"4.9.2"},"wpglobus-menu-visibility":{"title":"WPGlobus Menu Visibility","_api_new_version":"1.0.3","_api_tested_up_to":"4.9.2"},"wpglobus-language-widgets":{"title":"{:en}WPGlobus Language Widgets{:}{:ru}\u042f\u0437\u044b\u043a\u0438 WPGlobus \u0434\u043b\u044f \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432{:}","_api_new_version":"1.1.0","_api_tested_up_to":"4.9.2"},"wpglobus-for-bridge-theme":{"title":"{:en}WPGlobus for the \"Bridge\" theme{:}{:ru}WPGlobus \u0434\u043b\u044f \u0442\u0435\u043c\u044b Bridge{:}","_api_new_version":"1.1.0","_api_tested_up_to":"4.9.2"},"woocommerce-wpglobus":{"title":"{:en}WooCommerce WPGlobus Add-on{:}{:ru}\u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 WooCommerce WPGlobus{:}","_api_new_version":"3.1.1","_api_tested_up_to":"4.9.2"},"wpglobus-multi-currency":{"title":"{:en}WPGlobus Multi-Currency for WooCommerce{:}{:ru}WPGlobus - \u041c\u0443\u043b\u044c\u0442\u0438\u0432\u0430\u043b\u044e\u0442\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f WooCommerce{:}","_api_new_version":"1.1.0","_api_tested_up_to":"4.9.2"},"wpglobus-mobile-menu":{"title":"{:en}WPGlobus Mobile Menu{:}{:ru}WPGlobus Mobile Menu{:}","_api_new_version":"1.2.1","_api_tested_up_to":"4.9.2"},"wpglobus-plus":{"title":"{:en}WPGlobus Plus multilingual extension{:}{:ru}WPGlobus \u041f\u043b\u044e\u0441{:}","_api_new_version":"1.1.37","_api_tested_up_to":"4.9.2"}}
flags/ad.alt.png ADDED
Binary file
flags/ad.png ADDED
Binary file
flags/ae.png ADDED
Binary file
flags/af.png ADDED
Binary file
flags/ag.png ADDED
Binary file
flags/ai.alt.png ADDED
Binary file
flags/ai.png ADDED
Binary file
flags/al.png ADDED
Binary file
flags/am.png ADDED
Binary file
flags/an.png ADDED
Binary file
flags/ao.png ADDED
Binary file
flags/aq.png ADDED
Binary file
flags/ar.alt.png ADDED
Binary file
flags/ar.png ADDED
Binary file
flags/argm.jpg ADDED
Binary file
flags/arle.png ADDED
Binary file
flags/as.png ADDED
Binary file
flags/asl.gif ADDED
Binary file
flags/at.alt.png ADDED
Binary file
flags/at.png ADDED
Binary file
flags/au.png ADDED
Binary file
flags/aw.png ADDED
Binary file
flags/ax.png ADDED
Binary file
flags/az.png ADDED
Binary file
flags/ba.png ADDED
Binary file
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.png ADDED
Binary file
flags/bh.png ADDED
Binary file
flags/bi.alt.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/br.png ADDED
Binary file
flags/bs.png ADDED
Binary file
flags/bt.png ADDED
Binary file
flags/bv.png ADDED
Binary file
flags/bw.png ADDED
Binary file
flags/by.png ADDED
Binary file
flags/bz.png ADDED
Binary file
flags/ca.alt.png ADDED
Binary file
flags/ca.png ADDED
Binary file
flags/cc.alt.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/ch.png ADDED
Binary file
flags/ci.png ADDED
Binary file
flags/ck.png ADDED
Binary file
flags/cl.png ADDED
Binary file
flags/cm.png ADDED
Binary file
flags/cn.png ADDED
Binary file
flags/co.png ADDED
Binary file
flags/cr.alt.png ADDED
Binary file
flags/cr.png ADDED
Binary file
flags/cs.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 ADDED
Binary file
flags/cz.png ADDED
Binary file
flags/de.png ADDED
Binary file
flags/dj.png ADDED
Binary file
flags/dk.png ADDED
Binary file
flags/dm.png ADDED
Binary file
flags/do.png ADDED
Binary file
flags/dz.png ADDED
Binary file
flags/ec.alt.png ADDED
Binary file
flags/ec.png ADDED
Binary file
flags/ee.png ADDED
Binary file
flags/eg.png ADDED
Binary file
flags/eh.alt.png ADDED
Binary file
flags/eh.png ADDED
Binary file
flags/en.png ADDED
Binary file
flags/eo.png ADDED
Binary file
flags/er.png ADDED
Binary file
flags/es.alt.png ADDED
Binary file
flags/es.png ADDED
Binary file
flags/et.alt.png ADDED
Binary file
flags/et.png ADDED
Binary file
flags/eu.png ADDED
Binary file
flags/eus.png ADDED
Binary file
flags/fi.png ADDED
Binary file
flags/fj.png ADDED
Binary file
flags/fk.png ADDED
Binary file
flags/fm.png ADDED
Binary file
flags/fo.png ADDED
Binary file
flags/fr.png ADDED
Binary file
flags/fr_CA.png ADDED
Binary file
flags/ga.png ADDED
Binary file
flags/galego.png ADDED
Binary file
flags/gb.png ADDED
Binary file
flags/gd.png ADDED
Binary file
flags/ge.png ADDED
Binary file
flags/gf.png ADDED
Binary file
flags/gg.png ADDED
Binary file
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/gr.png ADDED
Binary file
flags/gs.png ADDED
Binary file
flags/gt.alt.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/hk.png ADDED
Binary file
flags/hm.png ADDED
Binary file
flags/hn.png ADDED
Binary file
flags/hr.png ADDED
Binary file
flags/ht.alt.png ADDED
Binary file
flags/ht.png ADDED
Binary file
flags/hu.png ADDED
Binary file
flags/id.png ADDED
Binary file
flags/ie.png ADDED
Binary file
flags/il.png ADDED
Binary file
flags/im.png ADDED
Binary file
flags/in.png ADDED
Binary file
flags/io.png ADDED
Binary file
flags/iq.png ADDED
Binary file
flags/ir.png ADDED
Binary file
flags/is.png ADDED
Binary file
flags/it.png ADDED
Binary file
flags/je.png ADDED
Binary file
flags/jm.png ADDED
Binary file
flags/jo.png ADDED
Binary file
flags/jp.png ADDED
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/kr.png ADDED
Binary file
flags/ku.png ADDED
Binary file
flags/kw.png ADDED
Binary file
flags/ky.png ADDED
Binary file
flags/kz.png ADDED
Binary file
flags/la.png ADDED
Binary file
flags/lb.png ADDED
Binary file
flags/lc.png ADDED
Binary file
flags/li.png ADDED
Binary file
flags/lk.png ADDED
Binary file
flags/lr.png ADDED
Binary file
flags/ls.png ADDED
Binary file
flags/lt.png ADDED
Binary file
flags/lu.png ADDED
Binary file
flags/lv.png ADDED
Binary file
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.png ADDED
Binary file
flags/ml.png ADDED
Binary file
flags/mm.png ADDED
Binary file
flags/mn.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/mx.png ADDED
Binary file
flags/my.png ADDED
Binary file
flags/my_MM.png ADDED
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.alt.png ADDED
Binary file
flags/ni.png ADDED
Binary file
flags/nl.png ADDED
Binary file
flags/no.png ADDED
Binary file
flags/np.png ADDED
Binary file
flags/nr.png ADDED
Binary file
flags/nu.png ADDED
Binary file
flags/nz.png ADDED
Binary file
flags/om.png ADDED
Binary file
flags/pa.png ADDED
Binary file
flags/pe.png ADDED
Binary file
flags/pf.alt.png ADDED
Binary file
flags/pf.png ADDED
Binary file
flags/pg.png ADDED
Binary file
flags/ph.png ADDED
Binary file
flags/pk.png ADDED
Binary file
flags/pl.png ADDED
Binary file
flags/pm.png ADDED
Binary file
flags/pn.png ADDED
Binary file
flags/pr.png ADDED
Binary file
flags/ps.png ADDED
Binary file
flags/pt.png ADDED
Binary file
flags/pw.png ADDED
Binary file
flags/py.png ADDED
Binary file
flags/qa.png ADDED
Binary file
flags/re.png ADDED
Binary file
flags/ro.png ADDED
Binary file
flags/rs.png ADDED
Binary file
flags/ru.png ADDED
Binary file
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/sd.png ADDED
Binary file
flags/se.png ADDED
Binary file
flags/sg.png ADDED
Binary file
flags/sh.png ADDED
Binary file
flags/si.png ADDED
Binary file
flags/sj.png ADDED
Binary file
flags/sk.png ADDED
Binary file
flags/sl.png ADDED
Binary file
flags/sm.png ADDED
Binary file
flags/sn.png ADDED
Binary file
flags/so.png ADDED
Binary file
flags/sr.png ADDED
Binary file
flags/st.png ADDED
Binary file
flags/sv.alt.png ADDED
Binary file
flags/sv.png ADDED
Binary file
flags/sy.png ADDED
Binary file
flags/sz.png ADDED
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 ADDED
Binary file
flags/tj.png ADDED
Binary file
flags/tk.png ADDED
Binary file
flags/tl.png ADDED
Binary file
flags/tm.png ADDED
Binary file
flags/tn.png ADDED
Binary file
flags/to.png ADDED
Binary file
flags/tr.png ADDED
Binary file
flags/tt.png ADDED
Binary file
flags/tv.png ADDED
Binary file
flags/tw.png ADDED
Binary file
flags/tz.png ADDED
Binary file
flags/ua.png ADDED
Binary file
flags/ug.png ADDED
Binary file
flags/uk.png ADDED
Binary file
flags/um.png ADDED
Binary file
flags/us.png ADDED
Binary file
flags/uy.png ADDED
Binary file
flags/uz.png ADDED
Binary file
flags/va.png ADDED
Binary file
flags/vc.png ADDED
Binary file
flags/ve.png ADDED
Binary file
flags/vg.png ADDED
Binary file
flags/vi.png ADDED
Binary file
flags/vn.png ADDED
Binary file
flags/vu.png ADDED
Binary file
flags/wf.alt.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/yu.png ADDED
Binary file
flags/za.png ADDED
Binary file
flags/zm.png ADDED
Binary file
flags/zw.png ADDED
Binary file
flags/zz.png ADDED
Binary file
includes/admin/central/class-wpglobus-admin-central.php ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * File: class-wpglobus-admin-central.php
4
+ *
5
+ * @since 1.6.6
6
+ * @package WPGlobus\Admin\Central
7
+ */
8
+
9
+ /**
10
+ * Class WPGlobus_Admin_Central.
11
+ */
12
+ if ( ! class_exists( 'WPGlobus_Admin_Central' ) ) :
13
+
14
+ class WPGlobus_Admin_Central {
15
+
16
+ /**
17
+ * Link template.
18
+ * @var string
19
+ */
20
+ public static $link_template;
21
+
22
+ /**
23
+ * Constructor.
24
+ */
25
+ public static function construct() {
26
+
27
+ self::set_vars();
28
+
29
+ add_action( 'admin_menu', array( __CLASS__, 'add_menu' ) );
30
+
31
+ }
32
+
33
+ /**
34
+ * Set class variables.
35
+ */
36
+ public static function set_vars() {
37
+
38
+ self::$link_template = '<a href="{{href}}" class="{{link_class}}" data-tab-id="{{tab_id}}">';
39
+ self::$link_template .= '<span class="{{span_class}}" style="vertical-align: sub;"></span>';
40
+ self::$link_template .= '{{title}}';
41
+ self::$link_template .= '</a>';
42
+
43
+ }
44
+
45
+ /**
46
+ * Add a hidden admin menu item.
47
+ * It will become visible in @see WPGlobus_Admin_HelpDesk::show_submenu
48
+ */
49
+ public static function add_menu() {
50
+ add_submenu_page(
51
+ null,
52
+ '',
53
+ '',
54
+ 'administrator',
55
+ WPGlobus::PAGE_WPGLOBUS_ADMIN_CENTRAL,
56
+ array( __CLASS__, 'central_page' )
57
+ );
58
+ }
59
+
60
+ /**
61
+ * The admin central page.
62
+ */
63
+ public static function central_page() {
64
+
65
+ /**
66
+ * Filter tabs.
67
+ * Returning array.
68
+ * @since 1.6.6
69
+ *
70
+ * @param array $tabs Array of tabs.
71
+ * @param string $link_template The link template.
72
+ */
73
+ $tabs = apply_filters( 'wpglobus_admin_central_tabs', self::set_tabs(), self::$link_template );
74
+
75
+ WPGlobus_Admin_Page::print_header();
76
+
77
+ ?>
78
+ <h2 class="nav-tab-wrapper"> <?php
79
+ foreach ( $tabs as $type=>$tab ) :
80
+ $html = str_replace( '{{link_class}}', implode( ' ', $tab['link_class'] ), $tab['link'] );
81
+ $html = str_replace( '{{span_class}}', implode( ' ', $tab['span_class'] ), $html );
82
+ $html = str_replace( '{{title}}', $tab['title'], $html );
83
+ if ( ! empty( $tab['tab_id'] ) ) {
84
+ $html = str_replace( '{{href}}', '#' . $tab['tab_id'], $html );
85
+ $html = str_replace( '{{tab_id}}', $tab['tab_id'], $html );
86
+ } elseif ( ! empty( $tab['href'] ) ) {
87
+ $html = str_replace( '{{href}}', $tab['href'], $html );
88
+ $html = str_replace( '{{tab_id}}', '', $html );
89
+ } else {
90
+ $html = str_replace( '{{href}}', '#', $html );
91
+ $html = str_replace( '{{tab_id}}', '', $html );
92
+ }
93
+ echo $html; // WPCS: XSS ok.
94
+ endforeach; ?>
95
+ </h2> <?php
96
+
97
+ /**
98
+ * Fires to render a specific tab panel.
99
+ *
100
+ * @since 1.6.6
101
+ *
102
+ * @param array $tabs Array of tabs.
103
+ */
104
+ do_action( 'wpglobus_admin_central_panel', $tabs );
105
+
106
+ WPGlobus_Admin_Page::print_footer();
107
+
108
+ }
109
+
110
+ /**
111
+ * Add standard tabs.
112
+ * @return array
113
+ */
114
+ protected static function set_tabs() {
115
+
116
+ $tabs = array();
117
+
118
+ /**
119
+ * WPGlobus Guide tab.
120
+ */
121
+ $tab = array(
122
+ 'title' => __( 'Guide', 'wpglobus' ),
123
+ 'link_class' => array( 'nav-tab' ),
124
+ 'span_class' => array( 'dashicons', 'dashicons-book-alt' ),
125
+ 'link' => self::$link_template,
126
+ 'href' => WPGlobus::URL_WPGLOBUS_SITE . 'quick-start/',
127
+ 'tab_id' => ''
128
+ );
129
+ $tabs[ 'guide' ] = $tab;
130
+
131
+ /**
132
+ * WPGlobus Help Desk tab.
133
+ */
134
+ $href = add_query_arg(
135
+ array(
136
+ 'page' => WPGlobus::PAGE_WPGLOBUS_HELPDESK
137
+ ),
138
+ admin_url( 'admin.php' )
139
+ );
140
+
141
+ $tab = array(
142
+ 'title' => __( 'WPGlobus Help Desk', 'wpglobus' ),
143
+ 'link_class' => array( 'nav-tab' ),
144
+ 'span_class' => array( 'dashicons', 'dashicons-format-chat' ),
145
+ 'link' => self::$link_template,
146
+ 'href' => $href,
147
+ 'tab_id' => ''
148
+ );
149
+ $tabs[ 'helpdesk' ] = $tab;
150
+
151
+ /**
152
+ * WPGlobus Add-ons tab.
153
+ */
154
+ $href = WPGlobus_Admin_Page::url_addons();
155
+
156
+ $tab = array(
157
+ 'title' => __( 'Add-ons', 'wpglobus' ),
158
+ 'link_class' => array( 'nav-tab' ),
159
+ 'span_class' => array( 'dashicons', 'dashicons-admin-plugins' ),
160
+ 'link' => self::$link_template,
161
+ 'href' => $href,
162
+ 'tab_id' => ''
163
+ );
164
+ $tabs[ 'add_ons' ] = $tab;
165
+
166
+ return $tabs;
167
+
168
+ }
169
+ }
170
+
171
+ endif;
172
+ /* EOF */
includes/admin/class-wpglobus-about.php ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package WPGlobus\Admin
4
+ */
5
+
6
+ /**
7
+ * Class WPGlobus_About
8
+ */
9
+ class WPGlobus_About {
10
+
11
+ /**
12
+ * For Google Analytics
13
+ */
14
+ const QA_CAMPAIGN = '?utm_source=wpglobus-admin-about&utm_medium=link&utm_campaign=activate-plugin';
15
+
16
+ /**
17
+ * Output the about screen.
18
+ */
19
+ public static function about_screen() {
20
+
21
+ WPGlobus_Admin_Page::print_header();
22
+
23
+ ?>
24
+ <h2 class="nav-tab-wrapper">
25
+ <a href="#" class="nav-tab nav-tab-active">
26
+ <?php esc_html_e( 'Quick Start', 'wpglobus' ); ?>
27
+ </a>
28
+ <a href="<?php echo esc_url( WPGlobus_Admin_Page::url_settings() ); ?>"
29
+ class="nav-tab">
30
+ <?php WPGlobus_Admin_Page::nav_tab_icon_e( 'Settings' ); ?>
31
+ <?php
32
+ /// Do not translate
33
+ esc_html_e( 'Settings' );
34
+ ?>
35
+ </a>
36
+ <a href="<?php echo esc_url( WPGlobus_Admin_Page::url_addons() ); ?>"
37
+ class="nav-tab">
38
+ <?php WPGlobus_Admin_Page::nav_tab_icon_e( 'Add-ons' ); ?>
39
+ <?php esc_html_e( 'Add-ons', 'wpglobus' ); ?>
40
+ </a>
41
+ <a href="<?php echo esc_url( WPGlobus_Utils::url_wpglobus_site() . 'quick-start/' . self::QA_CAMPAIGN ); ?>"
42
+ target="_blank"
43
+ class="nav-tab">
44
+ <?php WPGlobus_Admin_Page::nav_tab_icon_e( 'Guide' ); ?>
45
+ <?php esc_html_e( 'Guide', 'wpglobus' ); ?>
46
+ </a>
47
+ <a href="<?php echo esc_url( WPGlobus_Utils::url_wpglobus_site() . 'faq/' . self::QA_CAMPAIGN ); ?>"
48
+ target="_blank"
49
+ class="nav-tab">
50
+ <?php WPGlobus_Admin_Page::nav_tab_icon_e( 'FAQ' ); ?>
51
+ <?php esc_html_e( 'FAQ', 'wpglobus' ); ?>
52
+ </a>
53
+ <a href="<?php echo esc_url( WPGlobus_Admin_HelpDesk::$admin_page_url ); ?>"
54
+ class="nav-tab">
55
+ <?php WPGlobus_Admin_Page::nav_tab_icon_e( 'Helpdesk' ); ?>
56
+ <?php echo esc_html( WPGlobus_Admin_HelpDesk::$page_title ); ?>
57
+ </a>
58
+ </h2>
59
+
60
+ <?php if ( ! extension_loaded( 'mbstring' ) ) : ?>
61
+ <div style="background: #fff;border-left: 4px solid #dc3232;margin: 15px 15px 2px;padding: 1px 12px;">
62
+ <h4><?php esc_html_e( 'Attention: the Multibyte String PHP extension (`mbstring`) is not loaded!', 'wpglobus' ); ?></h4>
63
+ <p><?php esc_html_e( 'The mbstring extension is required for the full UTF-8 compatibility and better performance. Without it, some parts of WordPress and WPGlobus may function incorrectly. Please contact your hosting company or systems administrator.', 'wpglobus' ); ?></p>
64
+ </div>
65
+ <?php endif; ?>
66
+
67
+ <div class="feature-main feature-section col two-col">
68
+ <div class="col">
69
+ <?php self::easy_1_2_3(); ?>
70
+ </div>
71
+ <div class="col last-feature">
72
+ <?php self::translation_help(); ?>
73
+ </div>
74
+ </div>
75
+
76
+ <div class="feature-main feature-section col two-col">
77
+ <div class="col">
78
+ <?php self::important_notes(); ?>
79
+ </div>
80
+ <div class="col last-feature">
81
+ <?php self::links(); ?>
82
+ </div>
83
+ </div>
84
+
85
+ <hr />
86
+
87
+ <div class="return-to-dashboard">
88
+ <a class="button button-primary"
89
+ href="<?php echo esc_url( WPGlobus_Admin_Page::url_settings() ); ?>">
90
+ <?php esc_html_e( 'Go to WPGlobus Settings', 'wpglobus' ); ?>
91
+ </a>
92
+ </div>
93
+
94
+ <?php
95
+ WPGlobus_Admin_Page::print_footer();
96
+ }
97
+
98
+ protected static function easy_1_2_3() {
99
+ ?>
100
+ <h4 class="dashicons-before dashicons-admin-settings bar">
101
+ <?php esc_html_e( 'Easy as 1-2-3:', 'wpglobus' ); ?>
102
+ </h4>
103
+ <ul class="wpglobus-checkmarks">
104
+ <li><?php esc_html_e( 'Go to WPGlobus admin menu and choose the countries / languages;', 'wpglobus' ); ?></li>
105
+ <li><?php esc_html_e( 'Enter the translations to the posts, pages, categories, tags and menus using a clean and simple interface.', 'wpglobus' ); ?></li>
106
+ <li><?php esc_html_e( 'Switch languages at the front-end using a drop-down menu with language names and country flags.', 'wpglobus' ); ?></li>
107
+ </ul>
108
+ <?php
109
+ }
110
+
111
+ protected static function links() {
112
+ ?>
113
+ <h4 class="dashicons-before dashicons-admin-links bar">
114
+ <?php esc_html_e( 'Links:', 'wpglobus' ); ?>
115
+ </h4>
116
+ <ul>
117
+ <li>&bull; <a href="<?php echo esc_url( WPGlobus_Utils::url_wpglobus_site() . self::QA_CAMPAIGN ); ?>"
118
+ target="_blank">WPGlobus.com</a></li>
119
+ <li>&bull; <a href="<?php echo esc_url( WPGlobus_Utils::url_wpglobus_site() . 'quick-start/' . self::QA_CAMPAIGN ); ?>"
120
+ target="_blank"><?php esc_html_e( 'Guide', 'wpglobus' ); ?></a></li>
121
+ <li>&bull; <a href="<?php echo esc_url( WPGlobus_Utils::url_wpglobus_site() . 'faq/' . self::QA_CAMPAIGN ); ?>"
122
+ target="_blank"><?php esc_html_e( 'FAQs', 'wpglobus' ); ?></a></li>
123
+ <li>&bull; <a href="<?php echo esc_url( WPGlobus_Admin_HelpDesk::$admin_page_url ); ?>"
124
+ target="_blank"><?php esc_html_e( 'Contact Us', 'wpglobus' ); ?></a></li>
125
+ <li>&bull; <a href="https://wordpress.org/support/plugin/wpglobus/reviews/?filter=5"
126
+ target="_blank"><?php esc_html_e( 'Please give us 5 stars!', 'wpglobus' ); ?></a>
127
+ <span class="wpglobus-stars">&#x2606;&#x2606;&#x2606;&#x2606;&#x2606;</span></li>
128
+
129
+ </ul>
130
+ <?php
131
+ }
132
+
133
+ protected static function translation_help() {
134
+ ?>
135
+ <h4 class="dashicons-before dashicons-translation highlight">
136
+ <?php esc_html_e( 'WPGlobus does not translate texts automatically!', 'wpglobus' ); ?>
137
+ </h4>
138
+ <p>
139
+ <?php esc_html_e( 'There are many translation companies and individual translators who can help you write and proofread the texts.', 'wpglobus' ); ?>
140
+ <?php esc_html_e( 'When you choose a translator, please look at their native language, country of residence, specialization and knowledge of WordPress.', 'wpglobus' ); ?>
141
+ </p>
142
+ <p>
143
+ <?php
144
+ printf(
145
+ /// translators: %s are used to insert HTML link. Keep them in place.
146
+ esc_html__( 'We are planning to maintain a %s list of translators %s on the WPGlobus website. This is not an endorsement, just a courtesy. Please contact them directly and let us know how did it work for you!', 'wpglobus' ),
147
+ '<a href="' . esc_url( WPGlobus_Utils::url_wpglobus_site() . 'translator/' . self::QA_CAMPAIGN ) . '">',
148
+ '</a>'
149
+ ); ?>
150
+ </p>
151
+ <?php
152
+ }
153
+
154
+ protected static function important_notes() {
155
+ ?>
156
+ <h4 class="dashicons-before dashicons-info highlight">
157
+ <?php esc_html_e( 'Important notes:', 'wpglobus' ); ?>
158
+ </h4>
159
+ <ul class="wpglobus-important">
160
+
161
+ <li>
162
+ <?php _e( 'WPGlobus only supports the localization URLs in the form of <code>example.com/xx/page/</code>. We do not plan to support subdomains <code>xx.example.com</code> and language queries <code>example.com?lang=xx</code>.', 'wpglobus' ); // WPCS: XSS ok. ?>
163
+ </li>
164
+ <li>
165
+ <?php _e( 'Some themes and plugins are <strong>not multilingual-ready</strong>.', 'wpglobus' ); // WPCS: XSS ok. ?>
166
+ <?php esc_html_e( 'They might display some texts with no translation, or with all languages mixed together.', 'wpglobus' ); ?>
167
+ <?php
168
+ printf(
169
+ /// translators: %s are used to insert HTML link. Keep them in place.
170
+ esc_html__( 'Please contact the theme / plugin author. If they are unable to assist, consider %s hiring the WPGlobus Team %s to write a custom code for you.', 'wpglobus' ),
171
+ '<a href="' . esc_url( WPGlobus_Utils::url_wpglobus_site() . 'professional-support/' . self::QA_CAMPAIGN ) . '">',
172
+ '</a>'
173
+ ); ?>
174
+ </li>
175
+
176
+ </ul>
177
+ <?php
178
+ }
179
+ } //class
180
+
181
+ /*EOF*/
includes/admin/class-wpglobus-admin-menu.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Show a sidebar menu item.
4
+ * This is a workaround because the WPGlobus options panel is made by ReduxFramework.
5
+ * @since 1.7.8
6
+ */
7
+
8
+ /**
9
+ * Class WPGlobus_Admin_Menu
10
+ */
11
+ class WPGlobus_Admin_Menu {
12
+
13
+ /**
14
+ * Static constructor.
15
+ */
16
+ public static function construct() {
17
+ add_action( 'admin_footer', array( __CLASS__, '_add_ons' ),
18
+ // Below the Help Desk
19
+ PHP_INT_MAX - 10
20
+ );
21
+ }
22
+
23
+ /**
24
+ * "Add-ons" menu.
25
+ */
26
+ public static function _add_ons() {
27
+ $icon_class = 'dashicons dashicons-before dashicons-admin-plugins';
28
+ $menu_title = __( 'Add-ons', 'wpglobus' );
29
+ $menu_tooltip = __( 'View free and premium WPGlobus extensions', 'wpglobus' );
30
+ $admin_page_url = WPGlobus_Admin_Page::url_addons();
31
+ ?>
32
+ <script>
33
+ jQuery(function ($) {
34
+ $('#toplevel_page_wpglobus_options')
35
+ .find("ul")
36
+ .prepend($("<li>")
37
+ .append($("<a>")
38
+ .attr({
39
+ href: "<?php echo $admin_page_url; // WPCS: XSS ok. ?>",
40
+ title: "<?php echo esc_js( $menu_tooltip ); ?>"
41
+ })
42
+ .html(' <?php echo esc_js( $menu_title ); ?>')
43
+ .prepend($("<span>")
44
+ .attr({"class": "<?php echo esc_js( $icon_class ); ?>"})
45
+ )
46
+ )
47
+ );
48
+ });
49
+ </script>
50
+ <?php
51
+ }
52
+ }
includes/admin/class-wpglobus-admin-page.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * File: class-wpglobus-admin-page.php
4
+ *
5
+ * @package WPGlobus\Admin
6
+ */
7
+
8
+ /**
9
+ * Helpers for building admin pages.
10
+ */
11
+ class WPGlobus_Admin_Page {
12
+
13
+ /**
14
+ * Print page header.
15
+ */
16
+ public static function print_header() {
17
+ $url_wpglobus_logo = WPGlobus::internal_images_url() . '/wpglobus-logo-180x180.png';
18
+ ?>
19
+ <style>
20
+ .wp-badge.wpglobus-badge {
21
+ background: #ffffff url(<?php echo esc_url( $url_wpglobus_logo ); ?>) no-repeat;
22
+ background-size: contain;
23
+ }
24
+ </style>
25
+
26
+ <?php echo '<div class="wrap about-wrap wpglobus-about-wrap">'; ?>
27
+
28
+ <h1 class="wpglobus"><span class="wpglobus-wp">WP</span>Globus
29
+ <span class="wpglobus-version"><?php echo esc_html( WPGLOBUS_VERSION ); ?></span>
30
+ </h1>
31
+
32
+ <div class="wpglobus-motto"><?php esc_html_e( 'Multilingual Everything!', 'wpglobus' ); ?></div>
33
+ <div class="about-text">
34
+ <?php esc_html_e( 'WPGlobus is a family of WordPress plugins assisting you in making multilingual WordPress blogs and sites.', 'wpglobus' ); ?>
35
+ </div>
36
+
37
+ <div class="wp-badge wpglobus-badge"></div>
38
+ <?php
39
+ }
40
+
41
+ /**
42
+ * Print page header.
43
+ */
44
+ public static function print_footer() {
45
+ echo '</div>';
46
+ }
47
+
48
+ /**
49
+ * URL of the WPGlobus Add-ons page.
50
+ * @return string
51
+ */
52
+ public static function url_addons() {
53
+ return add_query_arg(
54
+ array(
55
+ 'tab' => 'search',
56
+ 's' => 'WPGlobus',
57
+ 'source' => 'WPGlobus',
58
+ ),
59
+ self_admin_url( 'plugin-install.php' )
60
+ );
61
+ }
62
+
63
+ /**
64
+ * URL of the WPGlobus Settings page.
65
+ * @return string
66
+ */
67
+ public static function url_settings() {
68
+ return admin_url( 'admin.php' ) . '?page=wpglobus_options';
69
+ }
70
+
71
+ /**
72
+ * Print icon for navigation tab item.
73
+ *
74
+ * @param string $icon_class A Dashicon CSS class or our internal alias.
75
+ *
76
+ * @link https://developer.wordpress.org/resource/dashicons/
77
+ */
78
+ public static function nav_tab_icon_e( $icon_class ) {
79
+
80
+ static $aliases = array(
81
+ 'faq' => 'dashicons-editor-help',
82
+ 'settings' => 'dashicons-admin-settings',
83
+ 'add-ons' => 'dashicons-admin-plugins',
84
+ 'guide' => 'dashicons-book-alt',
85
+ 'helpdesk' => 'dashicons-format-chat',
86
+ 'globe' => 'dashicons-admin-site',
87
+ );
88
+
89
+ $icon_class = strtolower( $icon_class );
90
+
91
+ if ( isset( $aliases[ $icon_class ] ) ) {
92
+ // An alias passed.
93
+ $icon_class = $aliases[ $icon_class ];
94
+ }
95
+
96
+ echo '<span class="dashicons ' . esc_attr( $icon_class ) .
97
+ '" style="vertical-align: middle"></span>';
98
+ }
99
+ }
100
+
101
+ /* EOF */
includes/admin/class-wpglobus-clean.php ADDED
@@ -0,0 +1,733 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package WPGlobus/Admin
4
+ * @since 1.4.3
5
+ */
6
+
7
+ if ( ! class_exists( 'WPGlobus_Clean' ) ) :
8
+
9
+ /**
10
+ * Class WPGlobus_Clean
11
+ */
12
+ class WPGlobus_Clean {
13
+
14
+ const LOG_BASENAME = 'wpglobus-clean';
15
+
16
+ protected static $tables = array();
17
+
18
+ protected static $log_file = '';
19
+
20
+ /**
21
+ * Controller
22
+ */
23
+ public static function controller() {
24
+
25
+ self::_set_log_file();
26
+
27
+ self::get_table();
28
+
29
+ self::screen();
30
+
31
+ add_action( 'admin_footer', array(
32
+ 'WPGlobus_Clean',
33
+ 'action__admin_print_scripts'
34
+ ),
35
+ 99
36
+ );
37
+
38
+ }
39
+
40
+ /**
41
+ * Initialize the class variable `log_file`.
42
+ * Note: 'wp-content' can be set to a different path, so we are using the standard WP method.
43
+ * @todo Check if the folder exists and file is writeable.
44
+ */
45
+ protected static function _set_log_file() {
46
+ $upload_dir = wp_upload_dir();
47
+ $wpglobus_logs_dir = $upload_dir['basedir'] . '/' . 'wpglobus-logs';
48
+
49
+ wp_mkdir_p( $wpglobus_logs_dir );
50
+ // Protect the folder from reading via URL
51
+ if ( ! file_exists( $wpglobus_logs_dir . '/.htaccess' ) ) {
52
+ file_put_contents( $wpglobus_logs_dir . '/.htaccess', 'deny from all' );
53
+ }
54
+ if ( ! file_exists( $wpglobus_logs_dir . '/index.php' ) ) {
55
+ file_put_contents( $wpglobus_logs_dir . '/index.php', '' );
56
+ }
57
+
58
+ self::$log_file = $wpglobus_logs_dir . '/' . self::LOG_BASENAME . '.log';
59
+ }
60
+
61
+ /**
62
+ * Get table
63
+ *
64
+ * @param string $table Table name to set data.
65
+ *
66
+ * @return void
67
+ */
68
+ public static function get_table( $table = '' ) {
69
+
70
+ $get_all = false;
71
+ if ( '' === $table ) {
72
+ $get_all = true;
73
+ }
74
+
75
+ if ( 'posts' === $table || $get_all ) {
76
+
77
+ /**
78
+ * table posts
79
+ */
80
+ $posts = new stdClass();
81
+ $posts->include_fields = array(
82
+ 'post_content',
83
+ 'post_title',
84
+ 'post_excerpt',
85
+ 'post_content_filtered'
86
+ );
87
+ $posts->id_field = 'ID';
88
+ $posts->post_status = array(
89
+ 'publish',
90
+ 'draft'
91
+ );
92
+
93
+ self::$tables['posts'] = $posts;
94
+
95
+ }
96
+
97
+ if ( 'postmeta' === $table || $get_all ) {
98
+
99
+ /**
100
+ * table postmeta
101
+ */
102
+ $postmeta = new stdClass();
103
+ $postmeta->include_fields = array(
104
+ 'meta_value'
105
+ );
106
+ $postmeta->id_field = 'meta_id';
107
+
108
+ self::$tables['postmeta'] = $postmeta;
109
+
110
+ }
111
+
112
+ if ( 'options' === $table || $get_all ) {
113
+
114
+ /**
115
+ * table options
116
+ */
117
+ $options = new stdClass();
118
+ $options->include_fields = array(
119
+ 'option_value'
120
+ );
121
+ $options->id_field = 'option_id';
122
+
123
+ self::$tables['options'] = $options;
124
+
125
+ }
126
+
127
+ if ( 'terms' === $table || $get_all ) {
128
+
129
+ /**
130
+ * table terms
131
+ */
132
+ $terms = new stdClass();
133
+ $terms->include_fields = array(
134
+ 'name'
135
+ );
136
+ $terms->id_field = 'term_id';
137
+
138
+ self::$tables['terms'] = $terms;
139
+
140
+ }
141
+
142
+ if ( 'term_taxonomy' === $table || $get_all ) {
143
+
144
+ /**
145
+ * table term_taxonomy
146
+ */
147
+ $term_taxonomy = new stdClass();
148
+ $term_taxonomy->include_fields = array(
149
+ 'description'
150
+ );
151
+ $term_taxonomy->id_field = 'term_taxonomy_id';
152
+
153
+ self::$tables['term_taxonomy'] = $term_taxonomy;
154
+
155
+ }
156
+
157
+ if ( 'usermeta' === $table || $get_all ) {
158
+
159
+ /**
160
+ * table usermeta
161
+ */
162
+ $usermeta = new stdClass();
163
+ $usermeta->include_fields = array(
164
+ 'meta_value'
165
+ );
166
+
167
+ $usermeta->id_field = 'umeta_id';
168
+
169
+ self::$tables['usermeta'] = $usermeta;
170
+
171
+ }
172
+
173
+
174
+ if ( class_exists( 'WooCommerce' ) ) :
175
+
176
+ /**
177
+ * WooCommerce tables
178
+ */
179
+ if ( 'woocommerce_attribute_taxonomies' === $table || $get_all ) {
180
+ /**
181
+ * table woocommerce_attribute_taxonomies
182
+ */
183
+ $woocommerce_attribute_taxonomies = new stdClass();
184
+ $woocommerce_attribute_taxonomies->include_fields = array(
185
+ 'attribute_label'
186
+ );
187
+ $woocommerce_attribute_taxonomies->id_field = 'attribute_id';
188
+
189
+ self::$tables['woocommerce_attribute_taxonomies'] = $woocommerce_attribute_taxonomies;
190
+ }
191
+
192
+ if ( 'woocommerce_order_items' === $table || $get_all ) {
193
+ /**
194
+ * table woocommerce_order_items
195
+ */
196
+ $woocommerce_order_items = new stdClass();
197
+ $woocommerce_order_items->include_fields = array(
198
+ 'order_item_name'
199
+ );
200
+ $woocommerce_order_items->id_field = 'order_item_id';
201
+
202
+ self::$tables['woocommerce_order_items'] = $woocommerce_order_items;
203
+ }
204
+
205
+ endif;
206
+
207
+ }
208
+
209
+ /**
210
+ * Get table list
211
+ */
212
+ public static function get_table_list() {
213
+
214
+ $spinner = WPGlobus::$PLUGIN_DIR_URL . 'includes/css/images/spinner.gif';
215
+
216
+ $list = '<ul>';
217
+ foreach ( self::$tables as $table => $data ) {
218
+
219
+ $list .= '<li id="' . $table . '">';
220
+ /** @noinspection DisconnectedForeachInstructionInspection */
221
+ $list .= '<span class="wpglobus-spinner" style="float:left;margin-right:10px;"><img src="' . $spinner . '" /></span>';
222
+ $list .= '<span class="wpglobus-result" style="float:left;width:20px;height:20px;"></span>';
223
+ $list .= '<span class=""><input type="checkbox" id="cb-' . $table . '" checked disabled /></span>';
224
+ $list .= $table;
225
+ $list .= '</li>';
226
+
227
+ }
228
+ $list .= '<li id="wpglobus_options">';
229
+ $list .= '<span class="wpglobus-spinner" style="float:left;margin-right:10px;"><img src="' . $spinner . '" /></span>';
230
+ $list .= '<span class="wpglobus-result" style="float:left;width:20px;height:20px;"></span>';
231
+ $list .= '<span class=""><input type="checkbox" id="cb-wpglobus_options" name="cb-wpglobus_options" /></span>';
232
+ $list .= esc_html( __( 'Remove the WPGlobus settings (not recommended)', 'wpglobus' ) );
233
+ $list .= '</li>';
234
+ $list .= '</ul>';
235
+
236
+ return $list;
237
+
238
+ }
239
+
240
+ /**
241
+ * Ajax action handler
242
+ *
243
+ * @param string[] $order
244
+ */
245
+ public static function process_ajax( $order ) {
246
+
247
+ self::_set_log_file();
248
+
249
+ $_log = false;
250
+
251
+ if ( 'true' === $order['log'] ) {
252
+ $_log = true;
253
+ }
254
+
255
+ if ( $order['action'] === 'die' ) {
256
+ wp_send_json_success( $order );
257
+ }
258
+
259
+ if ( $order['action'] === 'wpglobus-reset' ) {
260
+
261
+ /**
262
+ * SELECT * FROM `wp_options` WHERE `option_name` REGEXP 'wpglobus'
263
+ */
264
+
265
+ global $wpdb;
266
+
267
+ /**
268
+ * Make table with prefix
269
+ */
270
+ $table = $wpdb->prefix . 'options';
271
+
272
+ $query = "SELECT `option_id`, `option_name` FROM `$table` WHERE `option_name` REGEXP 'wpglobus'";
273
+
274
+ $ids = $wpdb->get_results( $query, ARRAY_A );
275
+
276
+ $records = array();
277
+ $fields = array();
278
+
279
+ foreach ( $ids as $data ) {
280
+ foreach ( $data as $field_id => $record_id ) {
281
+ if ( 'option_id' === $field_id ) {
282
+ $records[] = $record_id;
283
+ } else if ( 'option_name' === $field_id ) {
284
+ $fields[] = $record_id;
285
+ }
286
+ }
287
+ }
288
+
289
+ $result = true;
290
+ if ( ! empty( $records ) ) {
291
+
292
+ if ( $_log ) {
293
+ self::_log( $table, '', $fields, '' );
294
+ }
295
+
296
+ $set = implode( ',', $records );
297
+ $query = "DELETE FROM $table WHERE `option_id` IN ($set)";
298
+ $result = $wpdb->query( $query );
299
+ }
300
+
301
+ if ( false === $result ) {
302
+ wp_send_json_error( $order );
303
+ }
304
+
305
+ wp_send_json_success( $order );
306
+
307
+ }
308
+
309
+ if ( $order['action'] !== 'clean' ) {
310
+ wp_send_json_error( $order );
311
+ }
312
+
313
+ self::get_table( $order['table'] );
314
+
315
+ /**
316
+ * Set of examples of sql queries
317
+ * @see http://dev.mysql.com/doc/refman/5.7/en/pattern-matching.html
318
+ * @see http://dev.mysql.com/doc/refman/5.7/en/regexp.html
319
+ */
320
+
321
+ /**
322
+ * SELECT * FROM `wp_posts` WHERE 1=1 AND `post_status` REGEXP 'publish|draft' AND (
323
+ * `post_content` REGEXP '{:[a-z]{2}|[[.[.]]:[a-z]{2}|<!--:[a-z]{2}' OR
324
+ * `post_title` REGEXP '{:[a-z]{2}|[[.[.]]:[a-z]{2}|<!--:[a-z]{2}' OR
325
+ * `post_excerpt` REGEXP '{:[a-z]{2}|[[.[.]]:[a-z]{2}|<!--:[a-z]{2}' OR
326
+ * `post_content_filtered` REGEXP '{:[a-z]{2}|[[.[.]]:[a-z]{2}|<!--:[a-z]{2}' )
327
+ */
328
+
329
+ /**
330
+ * SELECT * FROM `wp_postmeta` WHERE `meta_value` REGEXP '{:[a-z]{2}|[[.[.]]:[a-z]{2}|<!--:[a-z]{2}'
331
+ */
332
+
333
+ /**
334
+ * SELECT * FROM `wp_options` WHERE `option_value` REGEXP '{:[a-z]{2}|[[.[.]]:[a-z]{2}|<!--:[a-z]{2}'
335
+ */
336
+
337
+ /**
338
+ * SELECT * FROM `wp_terms` WHERE `name` REGEXP '{:[a-z]{2}|[[.[.]]:[a-z]{2}|<!--:[a-z]{2}'
339
+ */
340
+
341
+ /**
342
+ * SELECT * FROM `wp_term_taxonomy` WHERE `description` REGEXP '{:[a-z]{2}|[[.[.]]:[a-z]{2}|<!--:[a-z]{2}'
343
+ */
344
+
345
+ /**
346
+ * SELECT * FROM `wp_usermeta` WHERE `meta_value` REGEXP '{:[a-z]{2}|[[.[.]]:[a-z]{2}|<!--:[a-z]{2}'
347
+ */
348
+
349
+ /**
350
+ * SELECT * FROM `wp_woocommerce_attribute_taxonomies` WHERE `attribute_label` REGEXP '{:[a-z]{2}|[[.[.]]:[a-z]{2}|<!--:[a-z]{2}'
351
+ */
352
+
353
+ /**
354
+ * SELECT * FROM `wp_woocommerce_order_items` WHERE `order_item_name` REGEXP '{:[a-z]{2}|[[.[.]]:[a-z]{2}|<!--:[a-z]{2}'
355
+ */
356
+
357
+ global $wpdb;
358
+
359
+ /**
360
+ * Make table with prefix
361
+ */
362
+ $table = $wpdb->prefix . $order['table'];
363
+
364
+ /**
365
+ * Standard regexp
366
+ */
367
+ $wpg_regexp = '{:[a-z]{2}|[[.[.]]:[a-z]{2}|<!--:[a-z]{2}';
368
+
369
+ /**
370
+ * Post status
371
+ */
372
+ $post_status = '';
373
+ if ( ! empty( self::$tables[ $order['table'] ]->post_status ) ) {
374
+ /**
375
+ * Example: AND `post_status` REGEXP 'publish|draft'
376
+ */
377
+ $post_status = "AND post_status REGEXP '" . implode( '|', self::$tables[ $order['table'] ]->post_status ) . "' ";
378
+ }
379
+
380
+ /**
381
+ * Set condition
382
+ */
383
+ $condition = false;
384
+ if ( count( self::$tables[ $order['table'] ]->include_fields ) === 0 ) {
385
+ /** do nothing */
386
+ } else if ( count( self::$tables[ $order['table'] ]->include_fields ) === 1 ) {
387
+ /**
388
+ * one field
389
+ */
390
+ $field = self::$tables[ $order['table'] ]->include_fields[0];
391
+ $condition = "AND $field REGEXP '$wpg_regexp'";
392
+
393
+ } else {
394
+ /**
395
+ * multiple fields
396
+ */
397
+ $temp = array();
398
+ foreach ( self::$tables[ $order['table'] ]->include_fields as $field ) {
399
+ $temp[] = "$field REGEXP '$wpg_regexp'";
400
+ }
401
+
402
+ $condition = 'AND ( ' . implode( ' OR ', $temp ) . ' )';
403
+
404
+ }
405
+
406
+ /**
407
+ * Set record ID
408
+ */
409
+ $id = false;
410
+ if ( ! empty( self::$tables[ $order['table'] ]->id_field ) ) {
411
+ $id = self::$tables[ $order['table'] ]->id_field;
412
+ }
413
+
414
+ if ( ! $id ) {
415
+ wp_send_json_error( $order );
416
+ }
417
+
418
+ if ( ! $condition ) {
419
+ wp_send_json_error( $order );
420
+ }
421
+
422
+ $query = "SELECT $id FROM $table WHERE 1=1 $post_status $condition";
423
+
424
+ $ids = $wpdb->get_results( $query, ARRAY_A );
425
+
426
+ $result = true;
427
+
428
+ foreach ( $ids as $data ) {
429
+
430
+ foreach ( $data as $field_id => $record_id ) {
431
+
432
+ /** @noinspection DisconnectedForeachInstructionInspection */
433
+ $ifields = implode( ', ', self::$tables[ $order['table'] ]->include_fields );
434
+
435
+ $query1 = "SELECT $ifields FROM $table WHERE $field_id = '$record_id'";
436
+
437
+ /** @var array $record */
438
+ $record = $wpdb->get_results( $query1 );
439
+
440
+ $update_fields = array();
441
+
442
+ foreach ( self::$tables[ $order['table'] ]->include_fields as $include_field ) {
443
+
444
+ $value = $record[0]->$include_field;
445
+
446
+ $value = trim( $value );
447
+ if ( empty( $value ) ) {
448
+ continue;
449
+ }
450
+
451
+ $serialized = false;
452
+ if ( is_serialized( $value ) ) {
453
+ $serialized = true;
454
+ $value = maybe_unserialize( $value );
455
+ }
456
+
457
+ $converted = self::convert( $value );
458
+
459
+ if ( $_log ) {
460
+ self::_log( $table, $record_id, $value, $converted );
461
+ }
462
+
463
+ if ( $serialized ) {
464
+ $converted = maybe_serialize( $converted );
465
+ }
466
+
467
+ $update_fields[] = $include_field . "='" . $converted . "'";
468
+
469
+ } // endforeach;
470
+
471
+ if ( ! empty( $update_fields ) ) {
472
+ /**
473
+ * UPDATE record
474
+ */
475
+ $updates = implode( ', ', $update_fields );
476
+ $upd_query = "UPDATE `$table` SET $updates WHERE `$field_id` = $record_id";
477
+
478
+ $res = $wpdb->query( $upd_query );
479
+
480
+ if ( false === $res ) {
481
+ $result = false;
482
+ }
483
+
484
+ }
485
+
486
+ } // endforeach
487
+
488
+ } // endforeach
489
+
490
+ if ( false === $result ) {
491
+ wp_send_json_error( $order );
492
+ }
493
+
494
+ wp_send_json_success( $order );
495
+
496
+ }
497
+
498
+ /**
499
+ * Logger
500
+ *
501
+ * @param string $table
502
+ * @param string $id
503
+ * @param string $initial
504
+ * @param string $converted
505
+ */
506
+ public static function _log( $table = '', $id = '', $initial = '', $converted = '' ) {
507
+ error_log( date( DATE_ATOM ) . "\n", 3, self::$log_file );
508
+ error_log( 'TABLE: ' . $table . "\n", 3, self::$log_file );
509
+ error_log( 'ID: ' . $id . "\n", 3, self::$log_file );
510
+ error_log( "BEFORE: \n" . print_r( $initial, true ) . "\n", 3, self::$log_file );
511
+ error_log( "AFTER: \n" . print_r( $converted, true ) . "\n", 3, self::$log_file );
512
+ error_log( '=================' . "\n\n", 3, self::$log_file );
513
+ }
514
+
515
+ /**
516
+ * Enqueue js
517
+ *
518
+ * @return void
519
+ */
520
+ public static function action__admin_print_scripts() {
521
+
522
+ $src = WPGlobus::$PLUGIN_DIR_URL . 'includes/js/wpglobus-clean' . WPGlobus::SCRIPT_SUFFIX() . '.js';
523
+
524
+ $result_icons['success'] = WPGlobus::$PLUGIN_DIR_URL . 'includes/css/images/success.png';
525
+ $result_icons['error'] = WPGlobus::$PLUGIN_DIR_URL . 'includes/css/images/error.png';
526
+
527
+ wp_enqueue_script(
528
+ 'wpglobus-clean',
529
+ $src,
530
+ array( 'jquery' ),
531
+ WPGLOBUS_VERSION,
532
+ true
533
+ );
534
+
535
+ wp_localize_script(
536
+ 'wpglobus-clean',
537
+ 'WPGlobusClean',
538
+ array(
539
+ 'version' => WPGLOBUS_VERSION,
540
+ 'icons' => $result_icons,
541
+ 'data' => array_merge( self::$tables, array( 'wpglobus_options' => new stdClass() ) )
542
+ )
543
+ );
544
+
545
+
546
+ }
547
+
548
+ /**
549
+ * Output the clean screen.
550
+ *
551
+ * @return void
552
+ */
553
+ public static function screen() {
554
+
555
+ /**
556
+ * For Google Analytics
557
+ */
558
+ $ga_campaign = '?utm_source=wpglobus-admin-clean&utm_medium=link&utm_campaign=clean-up-tool';
559
+
560
+ $url_wpglobus_site = WPGlobus_Utils::url_wpglobus_site();
561
+ // $url_wpglobus_site_home = $url_wpglobus_site . $ga_campaign;
562
+ $url_wpglobus_site_contact = $url_wpglobus_site . 'pg/contact-us/' . $ga_campaign;
563
+ $url_wpglobus_site_quick_start = $url_wpglobus_site . 'quick-start/' . $ga_campaign;
564
+ // $url_wpglobus_site_faq = $url_wpglobus_site . 'faq/' . $ga_campaign;
565
+ // $url_wpglobus_site_pro_support = $url_wpglobus_site . 'professional-support/' . $ga_campaign;
566
+
567
+ $url_wpglobus_logo = WPGlobus::$PLUGIN_DIR_URL . 'includes/css/images/wpglobus-logo-180x180.png';
568
+
569
+ ?>
570
+ <style>
571
+ .wp-badge.wpglobus-badge {
572
+ background: #ffffff url(<?php echo esc_url( $url_wpglobus_logo ); ?>) no-repeat;
573
+ background-size: contain;
574
+ }
575
+ </style>
576
+ <div class="wrap about-wrap wpglobus-about-wrap clean-wrap wpglobus-clean">
577
+ <h1 class="wpglobus"><span class="wpglobus-wp">WP</span>Globus
578
+ <span class="wpglobus-version"><?php echo esc_html( WPGLOBUS_VERSION ); ?></span>
579
+ </h1>
580
+
581
+ <div class="wpglobus-motto"><?php esc_html_e( 'Multilingual Everything!', 'wpglobus' ); ?></div>
582
+
583
+ <div class="about-text">
584
+ <?php esc_html_e( 'WPGlobus is a family of WordPress plugins assisting you in making multilingual WordPress blogs and sites.', 'wpglobus' ); ?>
585
+ </div>
586
+
587
+ <div class="wp-badge wpglobus-badge"></div>
588
+
589
+ <h2 class="nav-tab-wrapper">
590
+ <a href="#" class="nav-tab nav-tab-active">
591
+ <?php esc_html_e( 'Clean-up Tool', 'wpglobus' ); ?>
592
+ </a>
593
+ <a href="<?php echo esc_url( $url_wpglobus_site_quick_start ); ?>"
594
+ target="_blank"
595
+ class="nav-tab">
596
+ <?php esc_html_e( 'Guide', 'wpglobus' ); ?>
597
+ </a>
598
+ <a href="admin.php?page=wpglobus_options" class="nav-tab">
599
+ <?php esc_html_e( 'Settings' ); ?>
600
+ </a>
601
+ <a href="<?php echo WPGlobus_Admin_Page::url_addons(); // WPCS: XSS ok. ?>" class="nav-tab">
602
+ <?php esc_html_e( 'Add-ons', 'wpglobus' ); ?>
603
+ </a>
604
+ <a href="<?php echo esc_url( $url_wpglobus_site_contact ); ?>"
605
+ class="nav-tab">
606
+ <?php esc_html_e( 'Support', 'wpglobus' ); ?>
607
+ </a>
608
+ </h2>
609
+
610
+ <div style="color: white; background-color: red; padding: .5em; margin-top: 1em;">
611
+ <?php esc_html_e( 'WARNING: this operation is non-reversible. It is strongly recommended that you backup your database before proceeding.', 'wpglobus' ); ?>
612
+ </div>
613
+
614
+ <div style="padding: .5em"><strong>
615
+ <?php esc_html_e( 'This tool should be used only if you plan to completely uninstall WPGlobus. By running it, you will remove ALL translations you have entered to your post, pages, etc., keeping only the MAIN language texts. Please make sure that all entries have some content in the main language. Otherwise, you might end up with empty titles, no content, no excerpts, blank comments and so on.', 'wpglobus' ); ?>
616
+ </strong></div>
617
+
618
+ <div style="color:red; background-color: white; padding: .5em">
619
+ <?php
620
+ echo esc_html( sprintf(
621
+ /// translators: %1$s - language name, %1$s - language code. Do not remove.
622
+ __( 'The main language is currently set to %1$s (%2$s). ALL TEXTS THAT ARE NOT IN %1$s WILL BE DELETED! To change the main language, please go to Settings.', 'wpglobus' ),
623
+ WPGlobus::Config()->en_language_name[ WPGlobus::Config()->default_language ],
624
+ WPGlobus::Config()->default_language ) );
625
+
626
+ ?>
627
+ </div>
628
+
629
+ <hr />
630
+ <h3 id="about-to-clean">
631
+ <?php esc_html_e( 'You are about to clean the content of the following database tables:', 'wpglobus' ); ?>
632
+ </h3>
633
+
634
+ <?php echo self::get_table_list(); // WPCS: XSS ok. ?>
635
+
636
+ <hr />
637
+
638
+ <h3>
639
+ <?php esc_html_e( 'The operations log', 'wpglobus' ); ?>
640
+ </h3>
641
+ <div>
642
+ <?php esc_html_e( 'We are going to write a detailed log of all the database changes performed. It should help in the case you need to restore something important. The log will be written to the file:', 'wpglobus' ); ?>
643
+ </div>
644
+ <br />
645
+ <code>
646
+ <?php echo self::$log_file; // WPCS: XSS ok. ?>
647
+ </code>
648
+ <br />
649
+ <br />
650
+ <label>
651
+ <input type="checkbox" name="wpglobus-clean-log" id="wpglobus-clean-log" checked="checked" />
652
+ <?php esc_html_e( 'Uncheck if you do not want to write the operations log (we recommend to keep it checked)', 'wpglobus' ); ?>
653
+
654
+ </label>
655
+ <hr />
656
+ <h3>
657
+ <?php esc_html_e( 'You have been warned...', 'wpglobus' ); ?>
658
+ </h3>
659
+ <?php esc_html_e( 'Please confirm by checking the box below:', 'wpglobus' ); ?>
660
+ <div style="color:red; background-color: white; padding: .5em; margin: 1em 0;">
661
+ <?php esc_html_e( 'I have read and understood everything written on this page. I am aware that by using this tool I may loose some content of my website. I have made a database backup and know how to restore it if necessary. I am fully responsible for the results.', 'wpglobus' ); ?>
662
+ </div>
663
+
664
+ <label><input type="checkbox" name="wpglobus-clean-activate" id="wpglobus-clean-activate" /><?php esc_html_e( 'YES, I CONFIRM', 'wpglobus' ); ?>
665
+ </label>
666
+ <div class="return-to-dashboard">
667
+ <a id="wpglobus-clean-button" class="button button-primary hidden" href="#about-to-clean">
668
+ <?php esc_html_e( 'Process with the Clean-up', 'wpglobus' ); ?>
669
+ </a>
670
+ </div>
671
+
672
+ </div>
673
+
674
+ <?php
675
+ }
676
+
677
+ /**
678
+ * Convert string to text with default language
679
+ *
680
+ * @param mixed $data
681
+ *
682
+ * @return mixed $data
683
+ */
684
+ public static function convert( $data ) {
685
+
686
+ if ( empty( $data ) ) {
687
+ return '';
688
+ }
689
+
690
+ if ( is_null( $data ) ) {
691
+ return $data;
692
+ }
693
+
694
+ if ( is_bool( $data ) ) {
695
+ return $data;
696
+ }
697
+
698
+ if ( is_float( $data ) ) {
699
+ return $data;
700
+ }
701
+
702
+ if ( is_int( $data ) ) {
703
+ return $data;
704
+ }
705
+
706
+ if ( is_string( $data ) ) {
707
+ $data = WPGlobus_Core::text_filter( $data, WPGlobus::Config()->default_language, WPGlobus::RETURN_EMPTY );
708
+
709
+ /**
710
+ * Set double apostrophe for mySQL UPDATE
711
+ */
712
+ return str_replace( "'", "''", $data );
713
+ }
714
+
715
+ foreach ( $data as $key => $value ) {
716
+ if ( is_array( $data ) ) {
717
+ /** @noinspection AlterInForeachInspection */
718
+ $data[ $key ] = self::convert( $value );
719
+ } else if ( is_object( $data ) ) {
720
+ $data->$key = self::convert( $value );
721
+ }
722
+ }
723
+
724
+ return $data;
725
+
726
+ }
727
+
728
+
729
+ } //class
730
+
731
+ endif;
732
+
733
+ # --- EOF
includes/admin/class-wpglobus-customize-options.php ADDED
@@ -0,0 +1,1564 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WPGlobus_Customize_Options
4
+ *
5
+ * @package WPGlobus\Admin\Customizer
6
+ * @since 1.4.6
7
+ *
8
+ * @see http://www.narga.net/comprehensive-guide-wordpress-theme-options-with-customization-api/
9
+ * @see https://developer.wordpress.org/themes/advanced-topics/customizer-api/#top
10
+ * @see https://codex.wordpress.org/Theme_Customization_API
11
+ * @see #customize-controls
12
+ */
13
+
14
+ /**
15
+ * wpglobus_option
16
+ * wpglobus_option_flags
17
+ * wpglobus_option_locale
18
+ * wpglobus_option_en_language_names
19
+ * wpglobus_option_language_names
20
+ * wpglobus_option_post_meta_settings
21
+ */
22
+
23
+ /**
24
+ * WPGlobus option Customizer setting @see $wp_customize->add_setting
25
+ *
26
+ * wpglobus_option[last_tab] => are not used in customizer
27
+ *
28
+ * wpglobus_option[enabled_languages] => wpglobus_customize_enabled_languages
29
+ *
30
+ * wpglobus_option[more_languages] => are not used in customizer
31
+ *
32
+ * wpglobus_option[show_flag_name] => wpglobus_customize_language_selector_mode
33
+ *
34
+ * wpglobus_option[use_nav_menu] => wpglobus_customize_language_selector_menu
35
+ *
36
+ * wpglobus_option[selector_wp_list_pages]
37
+ * => Array
38
+ * (
39
+ * [show_selector] => 1 => wpglobus_customize_selector_wp_list_pages
40
+ * )
41
+ *
42
+ * wpglobus_option[css_editor] => wpglobus_customize_css_editor
43
+ *
44
+ */
45
+ if ( ! class_exists( 'WPGlobus_Customize_Options' ) ) :
46
+
47
+
48
+ if ( ! class_exists( 'WP_Customize_Control' ) ) {
49
+ require_once( ABSPATH . WPINC . '/class-wp-customize-control.php' );
50
+ }
51
+
52
+ /**
53
+ * Class WPGlobusTextBox.
54
+ * Adds textbox support to the theme customizer.
55
+ *
56
+ * @see wp-includes\class-wp-customize-control.php
57
+ */
58
+ class WPGlobusTextBox extends WP_Customize_Control {
59
+
60
+ public $type = 'textbox';
61
+
62
+ public $content = '';
63
+
64
+ /**
65
+ * Constructor.
66
+ *
67
+ * @param WP_Customize_Manager $manager Customizer bootstrap instance.
68
+ * @param string $id Control ID.
69
+ * @param array $args Optional. Arguments to override class property defaults.
70
+ */
71
+ public function __construct( $manager, $id, $args = array() ) {
72
+ $this->content = empty( $args['content'] ) ? '' : $args['content'];
73
+ $this->statuses = array( '' => esc_html__( 'Default', 'wpglobus' ) );
74
+ parent::__construct( $manager, $id, $args );
75
+ }
76
+
77
+ public function render_content() {
78
+
79
+ echo $this->content;
80
+
81
+ }
82
+
83
+ }
84
+
85
+ /**
86
+ * Adds checkbox with title support to the theme customizer.
87
+ *
88
+ * @see wp-includes\class-wp-customize-control.php
89
+ */
90
+ class WPGlobusCheckBox extends WP_Customize_Control {
91
+
92
+ public $type = 'wpglobus_checkbox';
93
+
94
+ public $title = '';
95
+
96
+ public function __construct( $manager, $id, $args = array() ) {
97
+
98
+ $this->title = empty( $args['title'] ) ? '' : $args['title'];
99
+
100
+ $this->statuses = array( '' => esc_html__( 'Default', 'wpglobus' ) );
101
+
102
+ parent::__construct( $manager, $id, $args );
103
+
104
+ }
105
+
106
+ public function render_content() {
107
+
108
+ ?>
109
+
110
+ <label>
111
+ <?php if ( ! empty( $this->title ) ) : ?>
112
+ <span class="customize-control-title"><?php echo esc_html( $this->title ); ?></span>
113
+ <?php endif; ?>
114
+ <div style="display:flex;">
115
+ <div style="flex:1">
116
+ <input type="checkbox" value="<?php echo esc_attr( $this->value() ); ?>" <?php $this->link(); checked( $this->value() ); ?> />
117
+ </div>
118
+ <div style="flex:8">
119
+ <?php echo esc_html( $this->label ); ?>
120
+ </div>
121
+ </div>
122
+ <?php if ( ! empty( $this->description ) ) : ?>
123
+ <span class="description customize-control-description"><?php echo esc_html($this->description); ?></span>
124
+ <?php endif; ?>
125
+ </label> <?php
126
+
127
+ }
128
+ }
129
+
130
+ /**
131
+ * Adds link support to the theme customizer.
132
+ *
133
+ * @see wp-includes\class-wp-customize-control.php
134
+ */
135
+ class WPGlobusLink extends WP_Customize_Control {
136
+
137
+ public $type = 'wpglobus_link';
138
+
139
+ public $args = array();
140
+
141
+ public function __construct( $manager, $id, $args = array() ) {
142
+
143
+ $this->args = $args;
144
+
145
+ $this->statuses = array( '' => esc_html__( 'Default', 'wpglobus' ) );
146
+
147
+ parent::__construct( $manager, $id, $args );
148
+
149
+ }
150
+
151
+ public function render_content() {
152
+
153
+ ?>
154
+
155
+ <label>
156
+ <?php if ( ! empty( $this->args['title'] ) ) : ?>
157
+ <span class="customize-control-title"><?php echo esc_html( $this->args['title'] ); ?></span>
158
+ <?php endif; ?>
159
+ <a href="<?php echo $this->args['href']; // WPCS: XSS ok. ?>" target="_blank"><?php echo $this->args['text']; // WPCS: XSS ok. ?></a>
160
+ <?php if ( ! empty( $this->description ) ) : ?>
161
+ <span class="description customize-control-description"><?php echo esc_html($this->description); ?></span>
162
+ <?php endif; ?>
163
+ </label> <?php
164
+
165
+ }
166
+ }
167
+
168
+ /**
169
+ * Adds CheckBoxSet support to the theme customizer.
170
+ *
171
+ * @see wp-includes\class-wp-customize-control.php
172
+ */
173
+ class WPGlobusCheckBoxSet extends WP_Customize_Control {
174
+
175
+ public $type = 'checkbox_set';
176
+
177
+ public $skeleton = '';
178
+
179
+ public $args = array();
180
+
181
+ public function __construct( $manager, $id, $args = array() ) {
182
+ $this->args = $args;
183
+ $this->statuses = array( '' => esc_html__( 'Default', 'wpglobus' ) );
184
+
185
+ $this->skeleton =
186
+ '<a href="{{edit-link}}" target="_blank"><span style="cursor:pointer;">Edit</span></a>&nbsp;' .
187
+ '<img style="cursor:move;" {{flag}} />&nbsp;' .
188
+ '<input name="wpglobus_item_{{name}}" id="wpglobus_item_{{id}}" type="checkbox" checked="{{checked}}" ' .
189
+ ' class="{{class}}" ' .
190
+ ' data-order="{{order}}" data-language="{{language}}" disabled="{{disabled}}" />' .
191
+ '<span style="cursor:move;">{{item}}</span>';
192
+
193
+ parent::__construct( $manager, $id, $args );
194
+
195
+ }
196
+
197
+ public function render_content() { ?>
198
+
199
+ <label>
200
+ <?php if ( ! empty( $this->label ) ) : ?>
201
+ <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
202
+ <?php endif;
203
+ if ( ! empty( $this->description ) ) : ?>
204
+ <span class="description customize-control-description"><?php echo esc_html($this->description); ?></span>
205
+ <?php endif;
206
+
207
+ $new_item = str_replace( '{{class}}', 'wpglobus-checkbox ' . $this->args['checkbox_class'], $this->skeleton );
208
+ echo '<div style="display:none;" id="wpglobus-item-skeleton">' . $new_item . '</div>'; // WPCS: XSS ok.
209
+
210
+ echo '<ul id="wpglobus-sortable" style="margin-top:10px;margin-left:20px;">';
211
+
212
+ foreach ( $this->args['items'] as $order => $item ) {
213
+
214
+ $disabled = $order == 0 ? ' disabled="disabled" ' : '';
215
+
216
+ $li_item = str_replace(
217
+ '{{flag}}',
218
+ 'src="' . WPGlobus::Config()->flags_url . WPGlobus::Config()->flag[ $item ] . '"',
219
+ $this->skeleton
220
+ );
221
+ $li_item = str_replace( '{{name}}', $item, $li_item );
222
+ $li_item = str_replace( '{{id}}', $item, $li_item );
223
+ $li_item = str_replace( 'checked="{{checked}}"', 'checked="checked"', $li_item );
224
+ $li_item = str_replace( 'disabled="{{disabled}}"', $disabled, $li_item );
225
+ $li_item = str_replace( '{{class}}', 'wpglobus-checkbox ' . $this->args['checkbox_class'], $li_item );
226
+ $li_item = str_replace( '{{item}}', WPGlobus::Config()->en_language_name[ $item ] . ' (' . $item . ')', $li_item );
227
+ $li_item = str_replace( '{{order}}', $order, $li_item );
228
+ $li_item = str_replace( '{{language}}', $item, $li_item );
229
+ $li_item = str_replace(
230
+ '{{edit-link}}',
231
+ admin_url() . 'admin.php?page=' . WPGlobus::LANGUAGE_EDIT_PAGE . '&action=edit&lang=' . $item . '"', $li_item
232
+ );
233
+
234
+ echo '<li>' . $li_item . '</li>'; // WPCS: XSS ok.
235
+
236
+ }
237
+
238
+ echo '</ul>'; ?>
239
+
240
+ </label> <hr /> <?php
241
+
242
+ }
243
+
244
+ }
245
+
246
+ /**
247
+ * Adds Fields Settings Control support to the theme customizer.
248
+ *
249
+ * @see wp-includes\class-wp-customize-control.php
250
+ */
251
+ class WPGlobusFieldsSettingsControl extends WP_Customize_Control {
252
+
253
+ public $type = 'wpglobus_fields_settings_control';
254
+
255
+ public $args = array();
256
+
257
+ public $section_template = '';
258
+
259
+ public function __construct( $manager, $id, $args = array() ) {
260
+
261
+ $this->args = $args;
262
+
263
+ $this->section_template = "<div id='wpglobus-settings-{{section}}' style='border-bottom:1px solid black;margin-bottom:5px;padding:5px;' class='items-box' data-section='{{section}}'>";
264
+ $this->section_template .= esc_html__( 'Section', 'wpglobus' ) . ": <a href='#' onclick='wp.customize.section({{section_id}}).expand();'><b>{{section_title}}</b></a>";
265
+ $this->section_template .= "<div class='items' style='padding-top:10px;'>{{items}}</div>";
266
+ $this->section_template .= "</div>";
267
+
268
+ parent::__construct( $manager, $id, $args );
269
+
270
+ }
271
+
272
+ public function render_content() {
273
+ ?>
274
+ <div class="wpglobus-fields_settings_control_box" data-section-template="<?php echo $this->section_template; // WPCS: XSS ok. ?>">
275
+ <?php if ( $this->args['start_section'] ) : ?>
276
+ <div style="border-bottom:1px solid black;margin: 0 0 5px;padding-left:5px;">
277
+ <a href="#" onclick="jQuery('.wpglobus-fields_settings_control_box .items-box' ).css('display','block');"><b><?php esc_html_e( 'Show all sections', 'wpglobus' ); ?></b></a>
278
+ </div>
279
+ <input type="submit" style="float:right;" name="<?php echo WPGlobus_Customize_Options::$controls_save_button; // WPCS: XSS ok. ?>" id="<?php echo WPGlobus_Customize_Options::$controls_save_button; // WPCS: XSS ok. ?>" class="button button-primary save" value="<?php esc_html_e( 'Save &amp; Reload', 'wpglobus' ); ?>">
280
+ <?php else: ?>
281
+ <div>
282
+ <?php if ( ! empty( $this->args['message'] ) ) {
283
+ echo $this->args['message']; // WPCS: XSS ok.
284
+ } ?>
285
+ </div>
286
+ <?php endif; ?>
287
+ </div> <!-- .wpglobus-fields_settings_control_box --> <?php
288
+ }
289
+ }
290
+
291
+ /**
292
+ * Class WPGlobus_Customize_Options
293
+ */
294
+ class WPGlobus_Customize_Options {
295
+
296
+ /**
297
+ * Array of sections
298
+ */
299
+ public static $sections = array();
300
+
301
+ /**
302
+ * Array of settings
303
+ */
304
+ public static $settings = array();
305
+
306
+ /**
307
+ * Set transient key
308
+ */
309
+ public static $enabled_post_types_key = 'wpglobus_customize_enabled_post_types';
310
+
311
+ /**
312
+ * Set option key for customizer
313
+ */
314
+ public static $options_key = 'wpglobus_customize_options';
315
+
316
+ /**
317
+ * Save button ID
318
+ */
319
+ public static $controls_save_button = 'wpglobus-user-controls-save';
320
+
321
+ /**
322
+ * Current theme.
323
+ *
324
+ * @var WP_Theme
325
+ */
326
+ public static $theme;
327
+
328
+ /**
329
+ * Current theme name.
330
+ *
331
+ * @var string
332
+ */
333
+ public static $theme_name = '';
334
+
335
+ /**
336
+ * Array of disabled themes.
337
+ * @var string[]
338
+ */
339
+ public static $disabled_themes = array();
340
+
341
+ public static function controller() {
342
+
343
+ self::$theme = wp_get_theme();
344
+ self::$theme_name = self::get_theme( 'name' );
345
+
346
+ self::$disabled_themes = array(
347
+ 'customizr',
348
+ 'customizr pro'
349
+ );
350
+
351
+ /**
352
+ * @since 1.7.7
353
+ * Don't standard loading of the option 'theme_mods_experon'. Theme uses redux.
354
+ * Don't standard behavior in customizer.
355
+ * @see https://wordpress.org/themes/experon/
356
+ */
357
+ self::$disabled_themes[] = 'experon';
358
+
359
+ add_action( 'wp_loaded', array( __CLASS__, 'init' ) );
360
+
361
+ /**
362
+ * @see \WP_Customize_Manager::wp_loaded
363
+ * It calls the `customize_register` action first,
364
+ * and then - the `customize_preview_init` action
365
+ */
366
+ add_action( 'customize_register', array(
367
+ 'WPGlobus_Customize_Options',
368
+ 'action__customize_register'
369
+ ) );
370
+
371
+ /**
372
+ * @since 1.6.0
373
+ */
374
+ add_action( 'customize_register', array(
375
+ 'WPGlobus_Customize_Options',
376
+ 'action__customize_fields_settings'
377
+ ) );
378
+
379
+ add_action( 'customize_preview_init', array(
380
+ 'WPGlobus_Customize_Options',
381
+ 'action__customize_preview_init'
382
+ ), 11 );
383
+
384
+ /**
385
+ * This is called by wp-admin/customize.php
386
+ */
387
+
388
+ add_action( 'customize_controls_enqueue_scripts', array(
389
+ 'WPGlobus_Customize_Options',
390
+ 'action__customize_controls_enqueue_scripts'
391
+ ), 1010 );
392
+
393
+ add_action( 'wp_ajax_' . __CLASS__ . '_process_ajax', array(
394
+ 'WPGlobus_Customize_Options',
395
+ 'action__process_ajax'
396
+ ) );
397
+
398
+ /**
399
+ * @since 1.9.8
400
+ */
401
+ add_filter( 'wpglobus_customize_disabled_setting_mask', array(
402
+ __CLASS__,
403
+ 'filter__disabled_setting_mask'
404
+ ) );
405
+
406
+ }
407
+
408
+ /**
409
+ * Delayed processes.
410
+ * @since 1.6.0
411
+ */
412
+ public static function init() {
413
+
414
+ /**
415
+ * Hook to modify the `$disabled_themes` array.
416
+ *
417
+ * @param string[] self ::$disabled_themes
418
+ * Enter the lowercase theme name (not slug, no dashes).
419
+ * For example, to disable the "Parallax One" theme,
420
+ * enter 'parallax one'.
421
+ *
422
+ * @see second param.
423
+ *
424
+ * @param string self::$theme_name Name of current theme.
425
+ * @param WP_Theme Object self::$theme Current theme.
426
+ */
427
+ self::$disabled_themes = apply_filters( 'wpglobus_customizer_disabled_themes', self::$disabled_themes, self::$theme_name, self::$theme );
428
+ }
429
+
430
+ /**
431
+ * Ajax handler.
432
+ */
433
+ public static function action__process_ajax() {
434
+
435
+ $result = true;
436
+ $ajax_return = array();
437
+
438
+ $post_order = isset( $_POST['order'] ) ? $_POST['order'] : null; // WPCS: input var ok, sanitization ok.
439
+
440
+ $order = array();
441
+ if ( $post_order ) {
442
+ $order['action'] = sanitize_text_field( $post_order['action'] );
443
+ $order['options'] = $post_order['options'];
444
+ }
445
+
446
+ switch ( $order['action'] ) {
447
+ case 'wpglobus_customize_save':
448
+ /**
449
+ * Options array.
450
+ *
451
+ * @var array
452
+ */
453
+ $options = get_option( WPGlobus::Config()->option );
454
+
455
+ foreach ( $order['options'] as $key => $value ) {
456
+
457
+ switch ( $key ) :
458
+ case 'show_selector':
459
+ $options['selector_wp_list_pages'][ $key ] = $value;
460
+ break;
461
+ case 'redirect_by_language':
462
+ // @todo check this option which do we really need?
463
+ $options['browser_redirect'][ $key ] = $value;
464
+ $options[ $key ] = $value;
465
+ break;
466
+ case 'use_nav_menu':
467
+ if ( '0' == $value ) {
468
+ $value = '';
469
+ } else {
470
+ $value = sanitize_text_field( $value );
471
+ }
472
+ $options[ $key ] = $value;
473
+ break;
474
+ case 'js_editor':
475
+ $value = trim($value);
476
+ if ( ! empty( $value ) ) {
477
+ $value = str_replace( '\"', '"', $value );
478
+ $value = str_replace( "\'", "'", $value );
479
+ $value = esc_html( $value );
480
+ }
481
+ $options[ $key ] = $value;
482
+ break;
483
+ default:
484
+ $options[ $key ] = $value;
485
+ endswitch;
486
+
487
+ }
488
+
489
+ update_option( WPGlobus::Config()->option, $options );
490
+ break;
491
+
492
+ case 'cb-controls-save':
493
+ $options = get_option( self::$options_key );
494
+
495
+ if ( empty( $order['controls'] ) ) {
496
+ if ( ! empty( $options['customize_user_control'][ self::$theme_name ] ) ) {
497
+ unset( $options['customize_user_control'][ self::$theme_name ] );
498
+ }
499
+ } else {
500
+
501
+ $cntrls = array();
502
+ foreach ( $order['controls'] as $cntr => $status ) {
503
+ $cntr = str_replace( '{{', '[', $cntr );
504
+ $cntr = str_replace( '}}', ']', $cntr );
505
+
506
+ $cntrls[ $cntr ] = $status;
507
+ }
508
+
509
+ $options['customize_user_control'][ self::$theme_name ] = $cntrls;
510
+ }
511
+
512
+ if ( empty( $options['customize_user_control'] ) ) {
513
+ unset( $options['customize_user_control'] );
514
+ }
515
+
516
+ if ( empty( $options ) ) {
517
+ delete_option( self::$options_key );
518
+ } else {
519
+ $result = update_option( self::$options_key, $options, false );
520
+
521
+ }
522
+
523
+ break;
524
+ }
525
+
526
+ if ( false === $result ) {
527
+ wp_send_json_error( $ajax_return );
528
+ }
529
+
530
+ wp_send_json_success( $ajax_return );
531
+ }
532
+
533
+ /**
534
+ * Section for message about unsupported theme.
535
+ *
536
+ * @param WP_Customize_Manager $wp_customize
537
+ * @param WP_Theme $theme
538
+ */
539
+ public static function sorry_section( $wp_customize, $theme ) {
540
+
541
+ /**
542
+ * Sorry section
543
+ */
544
+ $wp_customize->add_section( 'wpglobus_sorry_section', array(
545
+ 'title' => esc_html__( 'WPGlobus', 'wpglobus' ),
546
+ 'priority' => 0,
547
+ 'panel' => 'wpglobus_settings_panel'
548
+ ) );
549
+
550
+ $wp_customize->add_setting( 'sorry_message', array(
551
+ 'type' => 'option',
552
+ 'capability' => 'manage_options',
553
+ 'transport' => 'postMessage'
554
+ ) );
555
+ $wp_customize->add_control( new WPGlobusTextBox( $wp_customize,
556
+ 'sorry_message', array(
557
+ 'section' => 'wpglobus_sorry_section',
558
+ 'settings' => 'sorry_message',
559
+ 'priority' => 0,
560
+ 'content' => self::get_content( 'sorry_message', $theme )
561
+
562
+ )
563
+ ) );
564
+
565
+ }
566
+
567
+ /**
568
+ * Callback for register fields settings section.
569
+ *
570
+ * @since 1.6.0
571
+ *
572
+ * @param WP_Customize_Manager $wp_customize
573
+ */
574
+ public static function action__customize_fields_settings( WP_Customize_Manager $wp_customize ) {
575
+
576
+ if ( ! self::is_theme_enabled() ) {
577
+ return;
578
+ }
579
+
580
+ /**
581
+ * SECTION: fields settings
582
+ */
583
+ if ( 1 ) {
584
+
585
+ /**
586
+ * @since WP 4.5
587
+ * @see https://make.wordpress.org/core/2016/03/10/customizer-improvements-in-4-5/
588
+ */
589
+
590
+ global $wp_version;
591
+
592
+ $start_section = true;
593
+ $message = '';
594
+ if ( version_compare( $wp_version, '4.5-RC1', '<' ) ) :
595
+ $start_section = false;
596
+ $message = esc_html__( 'You need to update WordPress to 4.5 or later to get Fields Settings section', 'wpglobus' );
597
+ endif;
598
+
599
+ self::$sections['wpglobus_fields_settings_section'] = 'wpglobus_fields_settings_section';
600
+
601
+ $wp_customize->add_section( self::$sections['wpglobus_fields_settings_section'], array(
602
+ 'title' => esc_html__( 'Fields Settings', 'wpglobus' ),
603
+ 'priority' => 500,
604
+ 'panel' => 'wpglobus_settings_panel',
605
+ 'description' => '<div class="inner" style="background-color:#fff;padding:0 5px;">' .
606
+ self::get_content( 'settings_section_help' ) .
607
+ '</div>'
608
+ ) );
609
+
610
+ /** setting */
611
+ $wp_customize->add_setting( 'wpglobus_fields_settings_setting', array(
612
+ 'type' => 'option',
613
+ 'capability' => 'manage_options',
614
+ 'transport' => 'postMessage'
615
+ ) );
616
+
617
+ /** control */
618
+ $wp_customize->add_control( new WPGlobusFieldsSettingsControl( $wp_customize,
619
+ self::$sections['wpglobus_fields_settings_section'], array(
620
+ 'section' => self::$sections['wpglobus_fields_settings_section'],
621
+ 'settings' => 'wpglobus_fields_settings_setting',
622
+ 'priority' => 0,
623
+ 'start_section' => $start_section,
624
+ 'message' => $message
625
+
626
+ )
627
+ ) );
628
+
629
+ }
630
+
631
+ }
632
+
633
+ /**
634
+ * Callback for customize_register.
635
+ *
636
+ * @param WP_Customize_Manager $wp_customize
637
+ */
638
+ public static function action__customize_register( WP_Customize_Manager $wp_customize ) {
639
+
640
+ /**
641
+ * WPGlobus panel
642
+ */
643
+ $wp_customize->add_panel( 'wpglobus_settings_panel', array(
644
+ 'priority' => 1010,
645
+ 'capability' => 'edit_theme_options',
646
+ 'theme_supports' => '',
647
+ 'title' => esc_html__( 'WPGlobus Settings', 'wpglobus' ),
648
+ 'description' => '<div style="background-color:#eee;padding:10px 5px;">' .
649
+ self::get_content( 'welcome_message' ) .
650
+ '</div>' . self::get_content( 'deactivate_message' ),
651
+ ) );
652
+
653
+ if ( ! self::is_theme_enabled() ) {
654
+
655
+ self::sorry_section( $wp_customize, self::$theme );
656
+
657
+ return;
658
+
659
+ }
660
+
661
+ /**
662
+ * Updating options for customizer accordingly with WPGlobus::Config().
663
+ */
664
+ /** wpglobus_customize_language_selector_mode <=> wpglobus_option[show_flag_name] */
665
+ update_option( 'wpglobus_customize_language_selector_mode', WPGlobus::Config()->show_flag_name );
666
+
667
+ /** */
668
+ if ( empty( WPGlobus::Config()->nav_menu ) ) {
669
+ /**
670
+ * Menu item '--- select navigation menu ---' has value 0.
671
+ * It is used when 'Language Selector Menu' setting is not selected.
672
+ */
673
+ update_option( 'wpglobus_customize_language_selector_menu', '0' );
674
+ } else {
675
+ update_option( 'wpglobus_customize_language_selector_menu', WPGlobus::Config()->nav_menu );
676
+ }
677
+
678
+ /** wpglobus_customize_selector_wp_list_pages <=> wpglobus_option[selector_wp_list_pages][show_selector] */
679
+ update_option( 'wpglobus_customize_selector_wp_list_pages', WPGlobus::Config()->selector_wp_list_pages );
680
+
681
+ /** wpglobus_customize_css_editor <=> wpglobus_option[css_editor] */
682
+ update_option( 'wpglobus_customize_css_editor', WPGlobus::Config()->css_editor );
683
+
684
+ /** wpglobus_customize_redirect_by_language <=> wpglobus_option[browser_redirect][redirect_by_language] */
685
+ if ( empty( WPGlobus::Config()->browser_redirect['redirect_by_language'] ) || (int) WPGlobus::Config()->browser_redirect['redirect_by_language'] == 0 ) {
686
+ update_option( 'wpglobus_customize_redirect_by_language', '' );
687
+ } else {
688
+ update_option( 'wpglobus_customize_redirect_by_language', WPGlobus::Config()->browser_redirect['redirect_by_language'] );
689
+ }
690
+
691
+ /** wpglobus_customize_js_editor <=> wpglobus_option[js_editor] */
692
+ if ( empty( WPGlobus::Config()->js_editor ) ) {
693
+ update_option( 'wpglobus_customize_js_editor', '' );
694
+ } else {
695
+ update_option( 'wpglobus_customize_js_editor', WPGlobus::Config()->js_editor );
696
+ }
697
+
698
+
699
+ /** end updating options */
700
+
701
+ /**
702
+ * Init section priority.
703
+ */
704
+ $section_priority = 0;
705
+
706
+ /**
707
+ * SECTION: Help.
708
+ */
709
+ if ( 0 ) {
710
+
711
+ $section_priority = $section_priority + 0;
712
+
713
+ self::$sections['wpglobus_help_section'] = 'wpglobus_help_section';
714
+ $wp_customize->add_section( self::$sections['wpglobus_help_section'], array(
715
+ 'title' => esc_html__( 'Help', 'wpglobus' ),
716
+ 'priority' => $section_priority,
717
+ 'panel' => 'wpglobus_settings_panel',
718
+ ) );
719
+
720
+ $wp_customize->add_control( 'wpglobus_customize_add_onsZZZ', array(
721
+ 'section' => self::$sections['wpglobus_help_section'],
722
+ 'settings' => array(),
723
+ 'type' => 'button',
724
+ )
725
+ );
726
+ }
727
+ /** end SECTION: Help */
728
+
729
+ /**
730
+ * SECTION: Language.
731
+ */
732
+ if ( 1 ) {
733
+
734
+ $section_priority = $section_priority + 10;
735
+
736
+ $wp_customize->add_section( 'wpglobus_languages_section', array(
737
+ 'title' => esc_html__( 'Languages', 'wpglobus' ),
738
+ 'priority' => $section_priority,
739
+ 'panel' => 'wpglobus_settings_panel'
740
+ ) );
741
+ self::$sections['wpglobus_languages_section'] = 'wpglobus_languages_section';
742
+
743
+ /**
744
+ * Setting: Enabled languages.
745
+ */
746
+ $wp_customize->add_setting( 'wpglobus_customize_enabled_languages', array(
747
+ 'type' => 'option',
748
+ 'capability' => 'manage_options',
749
+ 'transport' => 'postMessage'
750
+ ) );
751
+ $wp_customize->add_control( new WPGlobusCheckBoxSet( $wp_customize,
752
+ 'wpglobus_customize_enabled_languages', array(
753
+ 'section' => 'wpglobus_languages_section',
754
+ 'settings' => 'wpglobus_customize_enabled_languages',
755
+ 'priority' => 0,
756
+ 'items' => WPGlobus::Config()->enabled_languages,
757
+ 'label' => esc_html__( 'Enabled Languages', 'wpglobus' ),
758
+ 'checkbox_class' => 'wpglobus-listen-change wpglobus-language-item',
759
+ 'description' => esc_html__( 'These languages are currently enabled on your site.', 'wpglobus' )
760
+
761
+ )
762
+ ) );
763
+ self::$settings['wpglobus_languages_section']['wpglobus_customize_enabled_languages']['type'] = 'checkbox_set';
764
+ /** @see option wpglobus_option['enabled_languages'] */
765
+ self::$settings['wpglobus_languages_section']['wpglobus_customize_enabled_languages']['option'] = 'enabled_languages';
766
+
767
+ /**
768
+ * Setting: Add languages.
769
+ */
770
+ /** Generate array $more_languages */
771
+ /** @var array $more_languages */
772
+ $more_languages = array();
773
+ $more_languages['select'] = '---- select ----';
774
+
775
+ foreach ( WPGlobus::Config()->flag as $code => $file ) {
776
+ if ( ! in_array( $code, WPGlobus::Config()->enabled_languages ) ) {
777
+ $lang_in_en = '';
778
+ if ( ! empty( WPGlobus::Config()->en_language_name[ $code ] ) ) {
779
+ $lang_in_en = ' (' . WPGlobus::Config()->en_language_name[ $code ] . ')';
780
+ }
781
+ // '<img src="' . WPGlobus::Config()->flags_url . $file . '" />'
782
+ $more_languages[ $code ] = WPGlobus::Config()->language_name[ $code ] . $lang_in_en;
783
+ }
784
+ }
785
+
786
+ $desc_add_languages =
787
+ esc_html__( 'Choose a language you would like to enable.', 'wpglobus' ).
788
+ '<br />'.
789
+ esc_html__( 'Press the [Save & Publish] button to confirm.', 'wpglobus' ).
790
+ '<br />';
791
+ $desc_add_languages .= sprintf(
792
+ /// translators: %1$s and %2$s - placeholders to insert HTML link around 'here'
793
+ esc_html__( 'or Add new Language %1$s here %2$s', 'wpglobus' ),
794
+ '<a style="text-decoration:underline;" href="' . admin_url() . 'admin.php?page=' . WPGlobus::LANGUAGE_EDIT_PAGE . '&action=add" target="_blank">',
795
+ '</a>'
796
+ );
797
+
798
+ $wp_customize->add_setting( 'wpglobus_customize_add_language', array(
799
+ 'type' => 'option',
800
+ 'capability' => 'manage_options',
801
+ 'transport' => 'postMessage'
802
+ ) );
803
+ $wp_customize->add_control( 'wpglobus_add_languages_select_box', array(
804
+ 'settings' => 'wpglobus_customize_add_language',
805
+ 'label' => esc_html__( 'Add Languages', 'wpglobus' ),
806
+ 'section' => 'wpglobus_languages_section',
807
+ 'type' => 'select',
808
+ 'priority' => 10,
809
+ 'choices' => $more_languages,
810
+ 'description' => $desc_add_languages
811
+ ) );
812
+ //self::$settings[ 'wpglobus_languages_section' ][ 'wpglobus_customize_add_language' ] = 'select';
813
+
814
+ /**
815
+ * Setting: Language Selector Mode.
816
+ */
817
+ $wp_customize->add_setting( 'wpglobus_customize_language_selector_mode', array(
818
+ 'type' => 'option',
819
+ 'capability' => 'manage_options',
820
+ 'transport' => 'refresh'
821
+ #'transport' => 'postMessage'
822
+ ) );
823
+ $wp_customize->add_control( 'wpglobus_customize_language_selector_mode', array(
824
+ 'settings' => 'wpglobus_customize_language_selector_mode',
825
+ 'label' => esc_html__( 'Language Selector Mode', 'wpglobus' ),
826
+ 'section' => 'wpglobus_languages_section',
827
+ 'type' => 'select',
828
+ 'priority' => 20,
829
+ 'choices' => array(
830
+ 'code' => esc_html__( 'Two-letter Code with flag (en, ru, it, etc.)', 'wpglobus' ),
831
+ 'full_name' => esc_html__( 'Full Name (English, Russian, Italian, etc.)', 'wpglobus' ),
832
+ /* @since 1.2.1 */
833
+ 'name' => esc_html__( 'Full Name with flag (English, Russian, Italian, etc.)', 'wpglobus' ),
834
+ 'empty' => esc_html__( 'Flags only', 'wpglobus' )
835
+ ),
836
+ 'description' => esc_html__( 'Choose the way language name and country flag are shown in the drop-down menu', 'wpglobus' )
837
+ ) );
838
+ self::$settings['wpglobus_languages_section']['wpglobus_customize_language_selector_mode']['type'] = 'select';
839
+ /** @see option wpglobus_option['show_flag_name'] */
840
+ self::$settings['wpglobus_languages_section']['wpglobus_customize_language_selector_mode']['option'] = 'show_flag_name';
841
+
842
+ /**
843
+ * @see https://make.wordpress.org/core/2016/03/22/implementing-selective-refresh-support-for-widgets/
844
+ * @see https://make.wordpress.org/core/2016/03/10/customizer-improvements-in-4-5/
845
+ *
846
+ * $wp_customize->selective_refresh->add_partial( 'wpglobus_customize_language_selector_mode', array(
847
+ * 'selector' => '#site-navigation',
848
+ * 'render_callback' => function() {
849
+ * wp_nav_menu();
850
+ * },
851
+ * ) );
852
+ * // */
853
+
854
+ /**
855
+ * Setting: Language Selector Menu.
856
+ */
857
+ /** @var array $nav_menus */
858
+ $nav_menus = WPGlobus::_get_nav_menus();
859
+
860
+ $menus = array();
861
+
862
+ foreach ( $nav_menus as $menu ) {
863
+ $menus[ $menu->slug ] = $menu->name;
864
+ }
865
+ if ( ! empty( $nav_menus ) && count( $nav_menus ) > 1 ) {
866
+ $menus['all'] = 'All';
867
+ }
868
+ if ( ! empty( $nav_menus ) ) {
869
+ array_unshift(
870
+ $menus,
871
+ '--- ' . esc_html__('select navigation menu', 'wpglobus'). ' ---'
872
+ );
873
+ }
874
+
875
+ if ( empty( $menus ) ) {
876
+
877
+ $wp_customize->add_control( new WPGlobusLink( $wp_customize,
878
+ 'wpglobus_customize_language_selector_menu', array(
879
+ 'section' => 'wpglobus_languages_section',
880
+ 'title' => esc_html__( 'Language Selector Menu', 'wpglobus' ),
881
+ 'settings' => array(),
882
+ 'priority' => 30,
883
+ 'type' => 'wpglobus_link',
884
+ /**
885
+ * We are in Customizer, so we can "focus" to the menus and not go to menus in admin.
886
+ * The JS code and the message below are copied from
887
+ * @see WP_Nav_Menu_Widget::form
888
+ */
889
+ 'href' => esc_attr( 'javascript: wp.customize.panel( "nav_menus" ).focus();' ),
890
+ 'text' => esc_html__( 'No menus have been created yet. Create some.', 'wpglobus' ),
891
+ 'description' => esc_html__( 'Choose the navigation menu where the language selector will be shown', 'wpglobus' ),
892
+ )
893
+ ) );
894
+
895
+ self::$settings['wpglobus_languages_section']['wpglobus_customize_language_selector_menu']['type'] = 'wpglobus_link';
896
+ self::$settings['wpglobus_languages_section']['wpglobus_customize_language_selector_menu']['option'] = array();
897
+
898
+ } else {
899
+
900
+ $wp_customize->add_setting( 'wpglobus_customize_language_selector_menu', array(
901
+ 'type' => 'option',
902
+ 'capability' => 'manage_options',
903
+ 'transport' => 'postMessage'
904
+ ) );
905
+ $wp_customize->add_control( 'wpglobus_customize_language_selector_menu', array(
906
+ 'settings' => 'wpglobus_customize_language_selector_menu',
907
+ 'label' => esc_html__( 'Language Selector Menu', 'wpglobus' ),
908
+ 'section' => 'wpglobus_languages_section',
909
+ 'type' => 'select',
910
+ 'priority' => 30,
911
+ 'choices' => $menus,
912
+ 'description' => esc_html__( 'Choose the navigation menu where the language selector will be shown', 'wpglobus' ),
913
+ ) );
914
+
915
+ self::$settings['wpglobus_languages_section']['wpglobus_customize_language_selector_menu']['type'] = 'select';
916
+ /** @see option wpglobus_option['use_nav_menu'] */
917
+ self::$settings['wpglobus_languages_section']['wpglobus_customize_language_selector_menu']['option'] = 'use_nav_menu';
918
+
919
+ }
920
+
921
+ /**
922
+ * Setting: "All Pages" menus Language selector.
923
+ */
924
+ $wp_customize->add_setting( 'wpglobus_customize_selector_wp_list_pages', array(
925
+ 'type' => 'option',
926
+ 'capability' => 'manage_options',
927
+ 'transport' => 'postMessage'
928
+ ) );
929
+ $wp_customize->add_control( new WPGlobusCheckBox( $wp_customize,
930
+ 'wpglobus_customize_selector_wp_list_pages', array(
931
+ 'settings' => 'wpglobus_customize_selector_wp_list_pages',
932
+ 'title' => esc_html__( '"All Pages" menus Language selector', 'wpglobus' ),
933
+ 'section' => 'wpglobus_languages_section',
934
+ 'priority' => 40,
935
+ 'label' => esc_html__( 'Adds language selector to the menus that automatically list all existing pages (using `wp_list_pages`)', 'wpglobus' ),
936
+ )
937
+ ) );
938
+ self::$settings['wpglobus_languages_section']['wpglobus_customize_selector_wp_list_pages']['type'] = 'wpglobus_checkbox';
939
+ /** @see option wpglobus_option['selector_wp_list_pages']['show_selector'] */
940
+ self::$settings['wpglobus_languages_section']['wpglobus_customize_selector_wp_list_pages']['option'] = 'show_selector';
941
+
942
+ /**
943
+ * Setting: Custom CSS.
944
+ */
945
+ $wp_customize->add_setting( 'wpglobus_customize_css_editor', array(
946
+ 'type' => 'option',
947
+ 'capability' => 'manage_options',
948
+ 'transport' => 'postMessage'
949
+ ) );
950
+ $wp_customize->add_control( 'wpglobus_customize_css_editor', array(
951
+ 'settings' => 'wpglobus_customize_css_editor',
952
+ 'label' => esc_html__( 'Custom CSS', 'wpglobus' ),
953
+ 'section' => 'wpglobus_languages_section',
954
+ 'type' => 'textarea',
955
+ 'priority' => 50,
956
+ 'description' => esc_html__( 'Here you can enter the CSS rules to adjust the language selector menu for your theme. Look at the examples in the `style-samples.css` file.', 'wpglobus' ),
957
+ ) );
958
+ self::$settings['wpglobus_languages_section']['wpglobus_customize_css_editor']['type'] = 'textarea';
959
+ /** @see option wpglobus_option['css_editor'] */
960
+ self::$settings['wpglobus_languages_section']['wpglobus_customize_css_editor']['option'] = 'css_editor';
961
+
962
+ }
963
+ /** end SECTION: Language */
964
+
965
+ /**
966
+ * SECTION: Post types.
967
+ */
968
+ if ( 1 ) {
969
+
970
+ $section_priority = $section_priority + 10;
971
+
972
+ $section = 'wpglobus_post_types_section';
973
+
974
+ $wp_customize->add_section( $section, array(
975
+ 'title' => esc_html__( 'Post types', 'wpglobus' ),
976
+ 'priority' => $section_priority,
977
+ 'panel' => 'wpglobus_settings_panel'
978
+ ) );
979
+ self::$sections[ $section ] = $section;
980
+
981
+ if ( false === ( $enabled_post_types = get_transient( self::$enabled_post_types_key ) ) ) {
982
+
983
+ $post_types = get_post_types();
984
+
985
+ $enabled_post_types = array();
986
+ foreach ( $post_types as $post_type ) {
987
+ /**
988
+ * @see "SECTION: Post types" in includes\options\class-wpglobus-options.php for complete post type array.
989
+ */
990
+ if ( ! in_array( $post_type, array( 'attachment', 'revision', 'nav_menu_item', 'custom_css', 'customize_changeset', 'oembed_cache' ), true ) ) {
991
+
992
+ if ( in_array( $post_type, array( 'post', 'page' ) ) ) {
993
+ $enabled_post_types[ $post_type ] = $post_type;
994
+ continue;
995
+ }
996
+
997
+ foreach ( WPGlobus::O()->vendors_scripts as $script => $status ) {
998
+
999
+ if ( empty( $status ) ) {
1000
+ continue;
1001
+ }
1002
+
1003
+ if ( $script == 'ACF' || $script == 'ACFPRO' ) {
1004
+ /**
1005
+ * get list @see class-wpglobus.php:145
1006
+ */
1007
+ if ( in_array( $post_type, array( 'acf-field-group', 'acf-field', 'acf' ) ) ) {
1008
+ continue 2;
1009
+ }
1010
+ }
1011
+
1012
+ if ( $script == 'WOOCOMMERCE' ) {
1013
+ /**
1014
+ * get list @see class-wpglobus.php:171
1015
+ */
1016
+ if ( in_array(
1017
+ $post_type,
1018
+ array(
1019
+ 'product',
1020
+ 'product_tag',
1021
+ 'product_cat',
1022
+ 'shop_order',
1023
+ 'shop_coupon',
1024
+ 'product_variation',
1025
+ 'shop_order_refund',
1026
+ 'shop_webhook'
1027
+ )
1028
+ ) ) {
1029
+ continue 2;
1030
+ }
1031
+ }
1032
+
1033
+ if ( $script == 'WPCF7' ) {
1034
+ /**
1035
+ * get list @see class-wpglobus.php:195
1036
+ */
1037
+ if ( in_array( $post_type, array( 'wpcf7_contact_form' ) ) ) {
1038
+ continue 2;
1039
+ }
1040
+ }
1041
+
1042
+ }
1043
+
1044
+ $enabled_post_types[ $post_type ] = $post_type;
1045
+
1046
+ }
1047
+ }
1048
+
1049
+ set_transient( self::$enabled_post_types_key, $enabled_post_types, 60 );
1050
+
1051
+ }
1052
+
1053
+ foreach ( $enabled_post_types as $post_type ) :
1054
+
1055
+ $status = '';
1056
+
1057
+ if ( isset( WPGlobus::Config()->extended_options['post_type'][ $post_type ] ) ) {
1058
+
1059
+ if ( WPGlobus::Config()->extended_options['post_type'][ $post_type ] == 1 ) {
1060
+ $status = '1';
1061
+ }
1062
+
1063
+ } else {
1064
+ $status = '1';
1065
+ }
1066
+
1067
+ update_option( 'wpglobus_customize_post_type_' . $post_type, $status );
1068
+
1069
+ endforeach;
1070
+
1071
+ $i = 0;
1072
+ foreach ( $enabled_post_types as $post_type ) :
1073
+
1074
+ $pst = 'wpglobus_customize_post_type_' . $post_type;
1075
+
1076
+ $wp_customize->add_setting( $pst, array(
1077
+ 'type' => 'option',
1078
+ 'capability' => 'manage_options',
1079
+ 'transport' => 'postMessage'
1080
+ ) );
1081
+
1082
+ $title = '';
1083
+ if ( $i == 0 ) {
1084
+ $title = esc_html__( 'Uncheck to disable WPGlobus', 'wpglobus' );
1085
+ }
1086
+
1087
+ $wp_customize->add_control( new WPGlobusCheckBox( $wp_customize,
1088
+ $pst, array(
1089
+ 'settings' => $pst,
1090
+ 'title' => $title,
1091
+ 'label' => $post_type,
1092
+ 'section' => $section,
1093
+ #'default' => '1',
1094
+ 'priority' => 10,
1095
+ )
1096
+ ) );
1097
+
1098
+ $i ++;
1099
+ self::$settings[ $section ][ $pst ]['type'] = 'wpglobus_checkbox';
1100
+ /** @see option wpglobus_option['post_type'] */
1101
+ self::$settings[ $section ][ $pst ]['option'] = 'post_type';
1102
+
1103
+ endforeach;
1104
+
1105
+ };
1106
+ /** end SECTION: Post types */
1107
+
1108
+ /**
1109
+ * SECTION: Redirect.
1110
+ */
1111
+ if ( 1 ) {
1112
+
1113
+ $section_priority = $section_priority + 10;
1114
+
1115
+ self::$sections['wpglobus_redirect_section'] = 'wpglobus_redirect_section';
1116
+
1117
+ $wp_customize->add_section( self::$sections['wpglobus_redirect_section'], array(
1118
+ 'title' => esc_html__( 'Redirect', 'wpglobus' ),
1119
+ 'priority' => $section_priority,
1120
+ 'panel' => 'wpglobus_settings_panel',
1121
+ ) );
1122
+
1123
+ /**
1124
+ * Option
1125
+ * [browser_redirect] => Array
1126
+ * (
1127
+ * [redirect_by_language] => 0
1128
+ * )
1129
+ */
1130
+
1131
+ /**
1132
+ * Setting wpglobus_customize_redirect_by_language.
1133
+ */
1134
+ $wp_customize->add_setting( 'wpglobus_customize_redirect_by_language', array(
1135
+ 'type' => 'option',
1136
+ 'capability' => 'manage_options',
1137
+ 'transport' => 'postMessage'
1138
+ ) );
1139
+ $wp_customize->add_control( new WPGlobusCheckBox( $wp_customize,
1140
+ 'wpglobus_customize_redirect_by_language', array(
1141
+ 'section' => self::$sections['wpglobus_redirect_section'],
1142
+ 'settings' => 'wpglobus_customize_redirect_by_language',
1143
+ 'title' => esc_html__( 'Choose the language automatically, based on:', 'wpglobus' ),
1144
+ 'priority' => 10,
1145
+ 'label' => esc_html__( 'Preferred language set in the browser', 'wpglobus' ),
1146
+ 'description' => esc_html__('When a user comes to the site for the first time, try to find the best matching language version of the page.', 'wpglobus')
1147
+ )
1148
+ ) );
1149
+
1150
+ self::$settings[ self::$sections['wpglobus_redirect_section'] ]['wpglobus_customize_redirect_by_language']['type'] = 'wpglobus_checkbox';
1151
+ /** @see option wpglobus_option[browser_redirect][redirect_by_language] */
1152
+ self::$settings[ self::$sections['wpglobus_redirect_section'] ]['wpglobus_customize_redirect_by_language']['option'] = 'redirect_by_language';
1153
+
1154
+ }
1155
+ /** end SECTION: Redirect */
1156
+
1157
+ /**
1158
+ * SECTION: Custom JS Code.
1159
+ */
1160
+ if ( 1 ) {
1161
+
1162
+ $section_priority = $section_priority + 10;
1163
+
1164
+ self::$sections['wpglobus_js_editor_section'] = 'wpglobus_js_editor_section';
1165
+
1166
+ /**
1167
+ * Setting 'wpglobus_customize_js_editor'.
1168
+ */
1169
+
1170
+ /**
1171
+ * class WP_Customize_Code_Editor_Control
1172
+ * @since WordPress 4.9.0
1173
+ * @see https://developer.wordpress.org/reference/classes/wp_customize_code_editor_control/
1174
+ */
1175
+ if ( ! class_exists('WP_Customize_Code_Editor_Control') ) {
1176
+
1177
+ $content = esc_html__( 'To add a Custom JS Code in Customizer, you need to upgrade WordPress to version 4.9 or later.', 'wpglobus' );
1178
+ $content .= '<br /><br />' .
1179
+ esc_html__( 'With your version of WordPress, please use the', 'wpglobus' ) .
1180
+ ' <a style="text-decoration:underline;" target="_blank" href="' . esc_url( admin_url() . 'admin.php?page=' . WPGlobus::OPTIONS_PAGE_SLUG . '&tab=0' ) . '">' .
1181
+ esc_html__( 'WPGlobus Settings page', 'wpglobus' ) .
1182
+ '.</a>';
1183
+
1184
+ $wp_customize->add_section( self::$sections['wpglobus_js_editor_section'], array(
1185
+ 'title' => esc_html__( 'Custom JS Code', 'wpglobus' ),
1186
+ 'priority' => $section_priority,
1187
+ 'panel' => 'wpglobus_settings_panel',
1188
+ ) );
1189
+
1190
+ $wp_customize->add_setting( 'wpglobus_customize_js_editor', array(
1191
+ 'type' => 'option',
1192
+ 'capability' => 'manage_options',
1193
+ 'transport' => 'postMessage'
1194
+ ) );
1195
+
1196
+ $wp_customize->add_control( new WPGlobusTextBox( $wp_customize,
1197
+ 'wpglobus_customize_js_editor', array(
1198
+ 'section' => self::$sections['wpglobus_js_editor_section'],
1199
+ 'settings' => 'wpglobus_customize_js_editor',
1200
+ 'content' => $content
1201
+ )
1202
+ ) );
1203
+
1204
+ } else {
1205
+
1206
+ $wp_customize->add_section( self::$sections['wpglobus_js_editor_section'], array(
1207
+ 'title' => esc_html__( 'Custom JS Code', 'wpglobus' ),
1208
+ 'priority' => $section_priority,
1209
+ 'panel' => 'wpglobus_settings_panel',
1210
+ ) );
1211
+
1212
+
1213
+ $wp_customize->add_setting( 'wpglobus_customize_js_editor', array(
1214
+ 'type' => 'option',
1215
+ 'capability' => 'manage_options',
1216
+ 'transport' => 'postMessage'
1217
+ ) );
1218
+ $wp_customize->add_control( new WP_Customize_Code_Editor_Control( $wp_customize,
1219
+ 'wpglobus_customize_js_editor', array(
1220
+ 'code_type' => 'javascript',
1221
+ #'mode' => 'javascript',
1222
+ 'input_attrs' => array('rows'=>80),
1223
+ 'section' => self::$sections['wpglobus_js_editor_section'],
1224
+ 'settings' => 'wpglobus_customize_js_editor',
1225
+ 'title' => esc_html__( 'Title', 'wpglobus' ),
1226
+ 'priority' => 10,
1227
+ 'label' => esc_html__( 'Custom JS Code', 'wpglobus' ),
1228
+ 'description' => esc_html__( '(Paste your JS code here.)', 'wpglobus' )
1229
+ )
1230
+ ) );
1231
+
1232
+ self::$settings[ self::$sections['wpglobus_js_editor_section'] ]['wpglobus_customize_js_editor']['type'] = 'code_editor';
1233
+ /** @see option wpglobus_option['css_editor'] */
1234
+ self::$settings[ self::$sections['wpglobus_js_editor_section'] ]['wpglobus_customize_js_editor']['option'] = 'js_editor';
1235
+
1236
+ }
1237
+ }
1238
+ /** end SECTION: Custom JS Code */
1239
+
1240
+ /**
1241
+ * SECTION: Add ons.
1242
+ */
1243
+ if ( 1 ) {
1244
+
1245
+ $section_priority = $section_priority + 10;
1246
+
1247
+ global $wp_version;
1248
+
1249
+ self::$sections['wpglobus_addons_section'] = 'wpglobus_addons_section';
1250
+
1251
+ if ( version_compare( $wp_version, '4.5-RC1', '<' ) ) {
1252
+
1253
+ $wp_customize->add_section( self::$sections['wpglobus_addons_section'], array(
1254
+ 'title' => esc_html__( 'Add-ons', 'wpglobus' ),
1255
+ 'priority' => $section_priority,
1256
+ 'panel' => 'wpglobus_settings_panel',
1257
+ ) );
1258
+
1259
+ /** Add ons setting */
1260
+ $wp_customize->add_setting( 'wpglobus_customize_add_ons', array(
1261
+ 'type' => 'option',
1262
+ 'capability' => 'manage_options',
1263
+ 'transport' => 'postMessage',
1264
+ ) );
1265
+
1266
+ $wp_customize->add_control( new WPGlobusCheckBox( $wp_customize,
1267
+ 'wpglobus_customize_add_ons', array(
1268
+ 'settings' => 'wpglobus_customize_add_ons',
1269
+ 'title' => esc_html__( 'Title', 'wpglobus' ),
1270
+ 'label' => esc_html__( 'Label', 'wpglobus' ),
1271
+ 'section' => self::$sections['wpglobus_addons_section'],
1272
+ 'type' => 'checkbox',
1273
+ 'priority' => 10,
1274
+ 'description' => esc_html__( 'Description', 'wpglobus' ),
1275
+ )
1276
+ ) );
1277
+
1278
+ } else {
1279
+
1280
+ /**
1281
+ * Changes in WP 4.5
1282
+ * @link https://make.wordpress.org/core/2016/03/10/customizer-improvements-in-4-5/
1283
+ */
1284
+
1285
+ $wp_customize->add_section( self::$sections['wpglobus_addons_section'], array(
1286
+ 'title' => esc_html__( 'Add-ons', 'wpglobus' ),
1287
+ 'priority' => $section_priority,
1288
+ 'panel' => 'wpglobus_settings_panel',
1289
+ ) );
1290
+
1291
+ $wp_customize->add_control( 'wpglobus_customize_add_ons', array(
1292
+ 'section' => self::$sections['wpglobus_addons_section'],
1293
+ 'settings' => array(),
1294
+ 'type' => 'button',
1295
+ )
1296
+ );
1297
+ }
1298
+ }
1299
+ /** end SECTION: Add ons */
1300
+
1301
+ /**
1302
+ * Fires to add customize settings.
1303
+ *
1304
+ * @since 1.4.6
1305
+ *
1306
+ * @param WP_Customize_Manager $wp_customize The WP Customize Manager.
1307
+ */
1308
+ do_action( 'wpglobus_customize_register', $wp_customize );
1309
+
1310
+ /** @var array $res */
1311
+ $res = apply_filters( 'wpglobus_customize_data', array(
1312
+ 'sections' => self::$sections,
1313
+ 'settings' => self::$settings,
1314
+ ) );
1315
+
1316
+ self::$sections = $res['sections'];
1317
+ self::$settings = $res['settings'];
1318
+
1319
+ }
1320
+
1321
+ /**
1322
+ * Get content for WPGlobusTextBox element.
1323
+ *
1324
+ * @param string $control
1325
+ * @param mixed $attrs
1326
+ *
1327
+ * @return string
1328
+ */
1329
+ public static function get_content( $control = '', $attrs = null ) {
1330
+
1331
+ if ( '' == $control ) {
1332
+ return '';
1333
+ }
1334
+
1335
+ $content = '';
1336
+ switch ( $control ) :
1337
+ case 'settings_section_help' :
1338
+ $content = esc_html__( 'Here you can specify which fields should be considered multilingual by WPGlobus. To exclude a field, uncheck it and then press the button below.', 'wpglobus' );
1339
+
1340
+ break;
1341
+ case 'welcome_message' :
1342
+
1343
+ $content = '<div style="width:100%;">' .
1344
+ esc_html__( 'Thank you for installing WPGlobus!', 'wpglobus' ) .
1345
+ '<br/>' .
1346
+ '&bull; ' .
1347
+ '<a style="text-decoration:underline;" target="_blank" href="' . admin_url() . 'admin.php?page=' . WPGlobus::PAGE_WPGLOBUS_ABOUT . '">' .
1348
+ esc_html__( 'Read About WPGlobus', 'wpglobus' ) .
1349
+ '</a>' .
1350
+ '<br/>' .
1351
+ '&bull; ' . esc_html__( 'Click the <strong>[Languages]</strong> tab at the left to setup the options.', 'wpglobus' ) .
1352
+ #'<br/>' .
1353
+ #'&bull; ' . esc_html__( 'Use the <strong>[Languages Table]</strong> section to add a new language or to edit the language attributes: name, code, flag icon, etc.', 'wpglobus' ) .
1354
+ '<br/>' .
1355
+ '<br/>' .
1356
+ esc_html__( 'Should you have any questions or comments, please do not hesitate to contact us.', 'wpglobus' ) .
1357
+ '<br/>' .
1358
+ '<br/>' .
1359
+ '<em>' .
1360
+ esc_html__( 'Sincerely Yours,', 'wpglobus' ) .
1361
+ '<br/>' .
1362
+ esc_html__( 'The WPGlobus Team', 'wpglobus' ) .
1363
+ '</em>' .
1364
+ '</div>';
1365
+
1366
+ break;
1367
+ case 'deactivate_message' :
1368
+
1369
+ /**
1370
+ * For Google Analytics
1371
+ */
1372
+ $ga_campaign = '?utm_source=wpglobus-admin-clean&utm_medium=link&utm_campaign=talk-to-us';
1373
+
1374
+ $url_wpglobus_site = WPGlobus_Utils::url_wpglobus_site();
1375
+ $url_wpglobus_site_submit_ticket = $url_wpglobus_site . 'support/submit-ticket/' . $ga_campaign;
1376
+
1377
+ $content = '<p><em>' .
1378
+ sprintf(
1379
+ esc_html(
1380
+ /// translators: %?$s: HTML codes for hyperlink. Do not remove.
1381
+ __( 'We would hate to see you go. If something goes wrong, do not uninstall WPGlobus yet. Please %1$stalk to us%2$s and let us help!', 'wpglobus' ) ),
1382
+ '<a href="' . $url_wpglobus_site_submit_ticket . '" target="_blank" style="text-decoration:underline;">',
1383
+ '</a>'
1384
+ ) .
1385
+ '</em></p>' .
1386
+ '<hr/>' .
1387
+ '<p><i class="el el-exclamation-sign" style="color:red"></i> <strong>' .
1388
+ esc_html( __( 'Please note that if you deactivate WPGlobus, your site will show all the languages together, mixed up. You will need to remove all translations, keeping only one language.', 'wpglobus' ) ) .
1389
+ '</strong></p>' .
1390
+ '<p>' .
1391
+ sprintf(
1392
+ /// translators: %s: link to the Clean-up Tool
1393
+ esc_html__( 'If there are just a few places, you should edit them manually. To automatically remove all translations at once, you can use the %s. WARNING: The clean-up operation is irreversible, so use it only if you need to completely uninstall WPGlobus.', 'wpglobus' ),
1394
+ sprintf(
1395
+ /// translators: %?$s: HTML codes for hyperlink. Do not remove.
1396
+ esc_html__( '%1$sClean-up Tool%2$s', 'wpglobus' ),
1397
+ '<a style="text-decoration:underline;" target="_blank" href="' . admin_url() . 'admin.php?page=' . WPGlobus::PAGE_WPGLOBUS_CLEAN . '">',
1398
+ '</a>'
1399
+ ) ) .
1400
+ '</p>';
1401
+
1402
+ break;
1403
+ case 'sorry_message' :
1404
+
1405
+ $content = '<p><strong>' .
1406
+ sprintf(
1407
+ /// translators: %s: name of current theme
1408
+ esc_html__( 'Sorry, WPGlobus customizer doesn\'t support current theme %s.', 'wpglobus' ),
1409
+ '<em>' . $attrs->__get( 'name' ) . '</em>'
1410
+ ) .
1411
+ '<br />' .
1412
+ sprintf(
1413
+ /// translators: %?$s: HTML codes for hyperlink. Do not remove.
1414
+ esc_html__( 'Please use %1$sWPGlobus options page%2$s instead.', 'wpglobus' ),
1415
+ '<a style="text-decoration:underline;" target="_blank" href="' . admin_url() . 'admin.php?page=' . WPGlobus::OPTIONS_PAGE_SLUG . '&tab=0">',
1416
+ '</a>'
1417
+ ) .
1418
+ '</strong></p>';
1419
+
1420
+ break;
1421
+ endswitch;
1422
+
1423
+ return $content;
1424
+
1425
+ }
1426
+
1427
+ /**
1428
+ * Load Customize Preview JS.
1429
+ *
1430
+ * Used by hook: 'customize_preview_init'
1431
+ * @see 'customize_preview_init'
1432
+ */
1433
+ public static function action__customize_preview_init() {
1434
+
1435
+ /*
1436
+ wp_enqueue_script(
1437
+ 'wpglobus-customize-options-preview',
1438
+ WPGlobus::$PLUGIN_DIR_URL . 'includes/js/wpglobus-customize-options-preview' .
1439
+ WPGlobus::SCRIPT_SUFFIX() . '.js',
1440
+ array( 'jquery' ),
1441
+ WPGLOBUS_VERSION,
1442
+ true
1443
+ );
1444
+ // */
1445
+ /*
1446
+ wp_localize_script(
1447
+ 'wpglobus-customize-options-preview',
1448
+ 'WPGlobusCustomize',
1449
+ array(
1450
+ 'version' => WPGLOBUS_VERSION,
1451
+ #'blogname' => WPGlobus_Core::text_filter( get_option( 'blogname' ), WPGlobus::Config()->language ),
1452
+ #'blogdescription' => WPGlobus_Core::text_filter( get_option( 'blogdescription' ), WPGlobus::Config()->language )
1453
+ )
1454
+ ); // */
1455
+
1456
+ }
1457
+
1458
+ /**
1459
+ * Load Customize Control JS.
1460
+ */
1461
+ public static function action__customize_controls_enqueue_scripts() {
1462
+
1463
+ /**
1464
+ * Get customize_user_control options which there are specifically for every theme.
1465
+ */
1466
+ $options = get_option( self::$options_key );
1467
+ if ( $options == '' ) {
1468
+ $options = null;
1469
+ } else {
1470
+ if ( empty( $options['customize_user_control'] ) ) {
1471
+ $options = null;
1472
+ } else {
1473
+ $options = $options['customize_user_control'];
1474
+ }
1475
+ }
1476
+
1477
+ $i18n = array();
1478
+ $i18n['expandShrink'] = esc_html__('Expand/Shrink', 'wpglobus');
1479
+
1480
+ wp_register_script(
1481
+ 'wpglobus-customize-options',
1482
+ WPGlobus::$PLUGIN_DIR_URL . 'includes/js/wpglobus-customize-options' . WPGlobus::SCRIPT_SUFFIX() . '.js',
1483
+ array( 'jquery', 'jquery-ui-draggable' ),
1484
+ WPGLOBUS_VERSION,
1485
+ true
1486
+ );
1487
+ wp_enqueue_script( 'wpglobus-customize-options' );
1488
+ wp_localize_script(
1489
+ 'wpglobus-customize-options',
1490
+ 'WPGlobusCustomizeOptions',
1491
+ array(
1492
+ 'version' => WPGLOBUS_VERSION,
1493
+ 'i18n' => $i18n,
1494
+ 'config' => WPGlobus::Config(),
1495
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
1496
+ 'process_ajax' => __CLASS__ . '_process_ajax',
1497
+ 'editLink' => admin_url() . 'admin.php?page=' . WPGlobus::LANGUAGE_EDIT_PAGE . '&action=edit&lang={{language}}"',
1498
+ 'settings' => self::$settings,
1499
+ 'sections' => self::$sections,
1500
+ 'addonsPage' => admin_url() . 'plugin-install.php?tab=search&s=WPGlobus&source=WPGlobus',
1501
+ 'themeName' => self::$theme_name,
1502
+ 'themeEnabled' => self::is_theme_enabled() ? 'true' : 'false',
1503
+ 'helpButton' => '<span style="float:right;cursor:pointer;" class="wpglobus-customize-icon-help customize-help-toggle dashicons dashicons-editor-help" tabindex="0" aria-expanded="false"></span>',
1504
+ 'userControl' => $options,
1505
+ 'userControlSaveButton' => self::$controls_save_button,
1506
+ 'userControlIcon' => WPGlobus::$PLUGIN_DIR_URL . 'includes/css/images/checkbox-icon.png',
1507
+ 'userControlIconClass' => 'wpglobus-customize-user-control-icon',
1508
+ 'userControlBoxSelector' => '.wpglobus-fields_settings_control_box .items-box'
1509
+ # @see WPGlobusFieldsSettingsControl class
1510
+ )
1511
+ );
1512
+
1513
+ }
1514
+
1515
+ /**
1516
+ * Get current theme or its property.
1517
+ *
1518
+ * @since 1.6.0
1519
+ *
1520
+ * @param string $param
1521
+ *
1522
+ * @return string|WP_Theme
1523
+ */
1524
+ public static function get_theme( $param = '' ) {
1525
+
1526
+ if ( 'name' === $param ) {
1527
+ return strtolower( self::$theme->name );
1528
+ }
1529
+
1530
+ return self::$theme;
1531
+
1532
+ }
1533
+
1534
+ /**
1535
+ * Check for enabled theme.
1536
+ *
1537
+ * @since 1.6.0
1538
+ * @return boolean
1539
+ */
1540
+ public static function is_theme_enabled() {
1541
+
1542
+ if ( in_array( self::$theme_name, self::$disabled_themes ) ) {
1543
+ return false;
1544
+ }
1545
+
1546
+ return true;
1547
+ }
1548
+
1549
+
1550
+ /**
1551
+ * Filter to disable the making multilingual our own settings.
1552
+ *
1553
+ * @since 1.9.8
1554
+ * @return array
1555
+ */
1556
+ public static function filter__disabled_setting_mask($disabled_setting_mask) {
1557
+ $disabled_setting_mask[] = 'wpglobus_customize_js_editor';
1558
+ return $disabled_setting_mask;
1559
+ }
1560
+
1561
+ } // class
1562
+
1563
+ endif;
1564
+ # --- EOF
includes/admin/class-wpglobus-dashboard-news.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class WPGlobus_Dashboard_News
5
+ * @since 1.7.7
6
+ */
7
+ class WPGlobus_Dashboard_News {
8
+
9
+ /**
10
+ * WPGlobus_Dashboard_News constructor.
11
+ */
12
+ public function __construct() {
13
+ add_action( 'wp_dashboard_setup', array(
14
+ $this,
15
+ 'action__wp_dashboard_setup'
16
+ ) );
17
+
18
+ add_filter( 'wpglobus_localize_feed_url', array(
19
+ $this,
20
+ 'filter__wpglobus_localize_feed_url'
21
+ ), 0, 2 );
22
+
23
+ }
24
+
25
+ /**
26
+ * Do not localize feed URL because we have news only in English.
27
+ *
28
+ * @param bool $need_to_localize
29
+ * @param SimplePie $feed
30
+ *
31
+ * @return bool
32
+ */
33
+ public function filter__wpglobus_localize_feed_url( $need_to_localize, $feed ) {
34
+
35
+ return $need_to_localize && WPGlobus::URL_WPGLOBUS_SITE . 'feed/' !== $feed->feed_url;
36
+ }
37
+
38
+ /**
39
+ * Setup the dashboard widget.
40
+ */
41
+ public function action__wp_dashboard_setup() {
42
+ add_meta_box( 'wpglobus_dashboard_news',
43
+ esc_html__( 'WPGlobus News', 'wpglobus' ),
44
+ array(
45
+ $this,
46
+ 'dashboard_widget'
47
+ ),
48
+ 'dashboard', 'side', 'high'
49
+ );
50
+ }
51
+
52
+ /**
53
+ * Output the widget content.
54
+ */
55
+ public function dashboard_widget() {
56
+ echo '<div class="rss-widget">';
57
+ wp_widget_rss_output( array(
58
+ 'url' => WPGlobus::URL_WPGLOBUS_SITE . 'feed/',
59
+ 'title' => esc_html__( 'WPGlobus News', 'wpglobus' ),
60
+ 'items' => 3,
61
+ 'show_summary' => 1,
62
+ 'show_author' => 0,
63
+ 'show_date' => 1
64
+ ) );
65
+ echo '</div>';
66
+ }
67
+ }
includes/admin/class-wpglobus-language-edit-request.php ADDED
@@ -0,0 +1,255 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WPGlobus / Admin / Language Edit / Request
4
+ * plugins/wpglobus/includes/admin/class-wpglobus-language-edit-request.php
5
+ *
6
+ * @package WPGlobus\Admin
7
+ * @since 1.9.7.1
8
+ */
9
+
10
+ /**
11
+ * Class WPGlobus_Language_Edit_Request
12
+ */
13
+ class WPGlobus_Language_Edit_Request {
14
+
15
+ const NONCE_ACTION = 'wpglobus-language-edit';
16
+
17
+ const ACTION_NONE = '';
18
+
19
+ const ACTION_EDIT = 'edit';
20
+
21
+ const ACTION_DELETE = 'delete';
22
+
23
+ const ACTION_ADD = 'add';
24
+
25
+ const ACTION_DONE = 'done';
26
+
27
+ /**
28
+ * GET['action']
29
+ *
30
+ * @var string
31
+ */
32
+ protected $action = self::ACTION_NONE;
33
+
34
+ /**
35
+ * GET['lang']
36
+ *
37
+ * @var string
38
+ */
39
+ protected $lang = '';
40
+
41
+ /**
42
+ * POST['submit']
43
+ *
44
+ * @var bool
45
+ */
46
+ protected $is_submit = false;
47
+
48
+ /**
49
+ * POST['delete']
50
+ *
51
+ * @var bool
52
+ */
53
+ protected $is_delete = false;
54
+
55
+
56
+ /**
57
+ * POST['wpglobus_language_code']
58
+ *
59
+ * @var string
60
+ */
61
+ protected $wpglobus_language_code = '';
62
+
63
+ /**
64
+ * POST['wpglobus_flags']
65
+ *
66
+ * @var string
67
+ */
68
+ protected $wpglobus_flags = '';
69
+
70
+ /**
71
+ * POST['wpglobus_language_name']
72
+ *
73
+ * @var string
74
+ */
75
+ protected $wpglobus_language_name = '';
76
+
77
+ /**
78
+ * POST['wpglobus_en_language_name']
79
+ *
80
+ * @var string
81
+ */
82
+ protected $wpglobus_en_language_name = '';
83
+
84
+ /**
85
+ * POST['wpglobus_locale']
86
+ *
87
+ * @var string
88
+ */
89
+ protected $wpglobus_locale = '';
90
+
91
+ /**
92
+ * WPGlobus_Language_Edit_Request constructor.
93
+ */
94
+ public function __construct() {
95
+ $this->parse_request();
96
+ }
97
+
98
+ /**
99
+ * Parse GET and POST.
100
+ */
101
+ protected function parse_request() {
102
+
103
+ check_admin_referer( self::NONCE_ACTION );
104
+
105
+ if ( isset( $_GET['action'] ) && is_string( $_GET['action'] ) ) { // WPCS: input var ok, sanitization ok.
106
+ $action = sanitize_text_field( wp_unslash( $_GET['action'] ) ); // Input var okay.
107
+ if ( in_array( $action, array(
108
+ self::ACTION_ADD,
109
+ self::ACTION_EDIT,
110
+ self::ACTION_DELETE,
111
+ self::ACTION_DONE,
112
+ ), true ) ) {
113
+ $this->action = $action;
114
+ } else {
115
+ $this->action = self::ACTION_NONE;
116
+ }
117
+ }
118
+
119
+ if ( isset( $_GET['lang'] ) && is_string( $_GET['lang'] ) ) { // WPCS: input var ok, sanitization ok.
120
+ $this->lang = sanitize_text_field( wp_unslash( $_GET['lang'] ) ); // Input var okay.
121
+ }
122
+
123
+ if ( isset( $_POST['submit'] ) ) { // Input var okay.
124
+ $this->is_submit = true;
125
+ }
126
+
127
+ if ( isset( $_POST['delete'] ) ) { // Input var okay.
128
+ $this->is_delete = true;
129
+ }
130
+
131
+ foreach (
132
+ array(
133
+ 'wpglobus_language_code',
134
+ 'wpglobus_flags',
135
+ 'wpglobus_language_name',
136
+ 'wpglobus_en_language_name',
137
+ 'wpglobus_locale',
138
+ ) as $var_name
139
+ ) {
140
+ if ( isset( $_POST[ $var_name ] ) && is_string( $_POST[ $var_name ] ) ) { // WPCS: input var ok, sanitization ok.
141
+ $this->$var_name = sanitize_text_field( wp_unslash( $_POST[ $var_name ] ) ); // Input var okay.
142
+ }
143
+ }
144
+ }
145
+
146
+ /**
147
+ * Getter.
148
+ *
149
+ * @return string
150
+ */
151
+ public function get_action() {
152
+ return $this->action;
153
+ }
154
+
155
+ /**
156
+ * Getter.
157
+ *
158
+ * @return string
159
+ */
160
+ public function get_lang() {
161
+ return $this->lang;
162
+ }
163
+
164
+ /**
165
+ * Getter.
166
+ *
167
+ * @return bool
168
+ */
169
+ public function is_submit() {
170
+ return $this->is_submit;
171
+ }
172
+
173
+ /**
174
+ * Getter.
175
+ *
176
+ * @return bool
177
+ */
178
+ public function is_delete() {
179
+ return $this->is_delete;
180
+ }
181
+
182
+ /**
183
+ * Getter.
184
+ *
185
+ * @return string
186
+ */
187
+ public function get_wpglobus_language_code() {
188
+ return $this->wpglobus_language_code;
189
+ }
190
+
191
+ /**
192
+ * Getter.
193
+ *
194
+ * @return string
195
+ */
196
+ public function get_wpglobus_flags() {
197
+ return $this->wpglobus_flags;
198
+ }
199
+
200
+ /**
201
+ * Getter.
202
+ *
203
+ * @return string
204
+ */
205
+ public function get_wpglobus_language_name() {
206
+ return $this->wpglobus_language_name;
207
+ }
208
+
209
+ /**
210
+ * Getter.
211
+ *
212
+ * @return string
213
+ */
214
+ public function get_wpglobus_en_language_name() {
215
+ return $this->wpglobus_en_language_name;
216
+ }
217
+
218
+ /**
219
+ * Getter.
220
+ *
221
+ * @return string
222
+ */
223
+ public function get_wpglobus_locale() {
224
+ return $this->wpglobus_locale;
225
+ }
226
+
227
+ public static function url_language_add() {
228
+ $url = add_query_arg( array(
229
+ 'page' => WPGlobus::LANGUAGE_EDIT_PAGE,
230
+ 'action' => self::ACTION_ADD,
231
+ ), admin_url( 'admin.php' ) );
232
+
233
+ return wp_nonce_url( $url, self::NONCE_ACTION );
234
+ }
235
+
236
+ public static function url_language_edit( $language_code ) {
237
+ $url = add_query_arg( array(
238
+ 'page' => WPGlobus::LANGUAGE_EDIT_PAGE,
239
+ 'lang' => $language_code,
240
+ 'action' => self::ACTION_EDIT,
241
+ ), admin_url( 'admin.php' ) );
242
+
243
+ return wp_nonce_url( $url, self::NONCE_ACTION );
244
+ }
245
+
246
+ public static function url_language_delete( $language_code ) {
247
+ $url = add_query_arg( array(
248
+ 'page' => WPGlobus::LANGUAGE_EDIT_PAGE,
249
+ 'lang' => $language_code,
250
+ 'action' => self::ACTION_DELETE,
251
+ ), admin_url( 'admin.php' ) );
252
+
253
+ return wp_nonce_url( $url, self::NONCE_ACTION );
254
+ }
255
+ }
includes/admin/class-wpglobus-language-edit.php ADDED
@@ -0,0 +1,494 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WPGlobus / Admin / Language Edit
4
+ *
5
+ * @package WPGlobus\Admin
6
+ */
7
+
8
+ // Load the Request class.
9
+ require_once dirname( __FILE__ ) . '/class-wpglobus-language-edit-request.php';
10
+
11
+ /**
12
+ * Class WPGlobus_Language_Edit
13
+ */
14
+ class WPGlobus_Language_Edit {
15
+
16
+ /**
17
+ * All flag files.
18
+ *
19
+ * @var array
20
+ */
21
+ protected $all_flags = array();
22
+
23
+ /**
24
+ * Current action
25
+ *
26
+ * @var string
27
+ */
28
+ protected $action = WPGlobus_Language_Edit_Request::ACTION_ADD;
29
+
30
+ /**
31
+ * Language code
32
+ *
33
+ * @var string
34
+ */
35
+ protected $language_code = '';
36
+
37
+ /**
38
+ * Language name
39
+ *
40
+ * @var string
41
+ */
42
+ protected $language_name = '';
43
+
44
+ /**
45
+ * Language name in English
46
+ *
47
+ * @var string
48
+ */
49
+ protected $en_language_name = '';
50
+
51
+ /**
52
+ * Locale
53
+ *
54
+ * @var string
55
+ */
56
+ protected $locale = '';
57
+
58
+ /**
59
+ * Flag for the current language
60
+ *
61
+ * @var string
62
+ */
63
+ protected $flag = '';
64
+
65
+ /**
66
+ * Set to true when the form is submitted
67
+ *
68
+ * @var bool
69
+ */
70
+ protected $submit = false;
71
+
72
+ /**
73
+ * Diagnostic messages
74
+ *
75
+ * @var string[]
76
+ */
77
+ protected $submit_messages = array();
78
+
79
+ /**
80
+ * The Request object
81
+ *
82
+ * @var WPGlobus_Language_Edit_Request
83
+ */
84
+ protected $request;
85
+
86
+ /**
87
+ * Constructor
88
+ */
89
+ public function __construct() {
90
+
91
+ $this->request = new WPGlobus_Language_Edit_Request();
92
+
93
+ if ( WPGlobus_Language_Edit_Request::ACTION_DELETE === $this->request->get_action() ) {
94
+ $this->action = WPGlobus_Language_Edit_Request::ACTION_DELETE;
95
+ } elseif ( WPGlobus_Language_Edit_Request::ACTION_EDIT === $this->request->get_action() ) {
96
+ $this->action = WPGlobus_Language_Edit_Request::ACTION_EDIT;
97
+ }
98
+
99
+ $this->language_code = $this->request->get_lang();
100
+
101
+ if ( $this->request->is_submit() ) {
102
+ $this->submit = true;
103
+ $this->process_submit();
104
+ } elseif ( $this->request->is_delete() ) {
105
+ $this->process_delete();
106
+ $this->action = WPGlobus_Language_Edit_Request::ACTION_DONE;
107
+ } else {
108
+ $this->get_data();
109
+ }
110
+
111
+ if ( WPGlobus_Language_Edit_Request::ACTION_DONE !== $this->action ) {
112
+ $this->display_table();
113
+ }
114
+
115
+ add_action( 'admin_footer', array( $this, 'on_print_scripts' ), 99 );
116
+
117
+ }
118
+
119
+ /**
120
+ * Add script in admin footer
121
+ */
122
+ public function on_print_scripts() {
123
+
124
+ if ( WPGlobus_Language_Edit_Request::ACTION_DONE === $this->action ) {
125
+ $location = '?page=' . WPGlobus::OPTIONS_PAGE_SLUG;
126
+ // @formatter:off
127
+ ?>
128
+ <script>jQuery(document).ready(function () {window.location = window.location.protocol + '//' + window.location.host + window.location.pathname + '<?php echo $location; // WPCS: XSS ok. ?>'});</script>
129
+ <?php
130
+ // @formatter:on
131
+ }
132
+
133
+ wp_enqueue_script(
134
+ 'wpglobus-form',
135
+ WPGlobus::plugin_dir_url() . 'includes/js/wpglobus-form' . WPGlobus::SCRIPT_SUFFIX() . '.js',
136
+ array( 'jquery' ),
137
+ WPGLOBUS_VERSION,
138
+ true
139
+ );
140
+
141
+ }
142
+
143
+ /**
144
+ * Process delete language action
145
+ */
146
+ protected function process_delete() {
147
+
148
+ $config = WPGlobus::Config();
149
+
150
+ /**
151
+ * Get options
152
+ *
153
+ * @var array
154
+ */
155
+ $opts = get_option( $config->option );
156
+
157
+ if ( isset( $opts['enabled_languages'][ $this->language_code ] ) ) {
158
+
159
+ unset( $opts['enabled_languages'][ $this->language_code ] );
160
+
161
+ /** FIX: reset $opts['more_languages'] */
162
+ if ( array_key_exists( 'more_languages', $opts ) ) {
163
+ $opts['more_languages'] = '';
164
+ }
165
+ update_option( $config->option, $opts );
166
+
167
+ }
168
+
169
+ unset( $config->language_name[ $this->language_code ] );
170
+ update_option( $config->option_language_names, $config->language_name );
171
+
172
+ unset( $config->flag[ $this->language_code ] );
173
+ update_option( $config->option_flags, $config->flag );
174
+
175
+ unset( $config->en_language_name[ $this->language_code ] );
176
+ update_option( $config->option_en_language_names, $config->en_language_name );
177
+
178
+ unset( $config->locale[ $this->language_code ] );
179
+ update_option( $config->option_locale, $config->locale );
180
+
181
+ }
182
+
183
+ /**
184
+ * Process submit action
185
+ */
186
+ protected function process_submit() {
187
+
188
+ $code = $this->request->get_wpglobus_language_code();
189
+ if ( $code && $this->language_code === $code ) {
190
+ if ( $this->check_fields( $code, false ) ) {
191
+ $this->save();
192
+ $this->submit_messages['success'][] = __( 'Options updated', 'wpglobus' );
193
+ }
194
+ } else {
195
+ if ( $this->check_fields( $code ) ) {
196
+ $this->save( true );
197
+ $this->submit_messages['success'][] = __( 'Options updated', 'wpglobus' );
198
+ }
199
+ }
200
+ $this->get_flags();
201
+
202
+ }
203
+
204
+ /**
205
+ * Save data language to DB
206
+ *
207
+ * @param bool $update_code If need to change language code.
208
+ */
209
+ protected function save( $update_code = false ) {
210
+
211
+ $config = WPGlobus::Config();
212
+
213
+ $old_code = '';
214
+ if ( $update_code && WPGlobus_Language_Edit_Request::ACTION_EDIT === $this->action ) {
215
+ $old_code = $this->language_code ? $this->language_code : $old_code;
216
+ if ( isset( $config->language_name[ $old_code ] ) ) {
217
+ unset( $config->language_name[ $old_code ] );
218
+ }
219
+
220
+ /**
221
+ * Get options
222
+ *
223
+ * @var array
224
+ */
225
+ $opts = get_option( $config->option );
226
+ if ( isset( $opts['enabled_languages'][ $old_code ] ) ) {
227
+ unset( $opts['enabled_languages'][ $old_code ] );
228
+ update_option( $config->option, $opts );
229
+ }
230
+ if ( isset( $opts['more_languages'] ) && $old_code === $opts['more_languages'] ) {
231
+ unset( $opts['more_languages'] );
232
+ update_option( $config->option, $opts );
233
+ }
234
+ }
235
+ $config->language_name[ $this->language_code ] = $this->language_name;
236
+ update_option( $config->option_language_names, $config->language_name );
237
+
238
+ if ( $update_code && isset( $config->flag[ $old_code ] ) ) {
239
+ unset( $config->flag[ $old_code ] );
240
+ }
241
+ $config->flag[ $this->language_code ] = $this->flag;
242
+ update_option( $config->option_flags, $config->flag );
243
+
244
+ if ( $update_code && isset( $config->en_language_name[ $old_code ] ) ) {
245
+ unset( $config->en_language_name[ $old_code ] );
246
+ }
247
+ $config->en_language_name[ $this->language_code ] = $this->en_language_name;
248
+ update_option( $config->option_en_language_names, $config->en_language_name );
249
+
250
+ if ( $update_code && isset( $config->locale[ $old_code ] ) ) {
251
+ unset( $config->locale[ $old_code ] );
252
+ }
253
+ $config->locale[ $this->language_code ] = $this->locale;
254
+ update_option( $config->option_locale, $config->locale );
255
+
256
+ if ( $update_code ) {
257
+ $this->action = WPGlobus_Language_Edit_Request::ACTION_DONE;
258
+ }
259
+ }
260
+
261
+ /**
262
+ * Check form fields
263
+ *
264
+ * @param string $lang_code Language code.
265
+ * @param bool $check_code Use for language code existence check.
266
+ *
267
+ * @return bool True if no errors, false otherwise.
268
+ */
269
+ protected function check_fields( $lang_code, $check_code = true ) {
270
+ $this->submit_messages['errors'] = array();
271
+ if ( $check_code && empty( $lang_code ) ) {
272
+ $this->submit_messages['errors'][] = __( 'Please enter a language code!', 'wpglobus' );
273
+ }
274
+
275
+ if ( $check_code && $this->language_exists( $lang_code ) ) {
276
+ $this->submit_messages['errors'][] = __( 'Language code already exists!', 'wpglobus' );
277
+ }
278
+
279
+ if ( ! $this->request->get_wpglobus_flags() ) {
280
+ $this->submit_messages['errors'][] = __( 'Please specify the language flag!', 'wpglobus' );
281
+ }
282
+
283
+ if ( ! $this->request->get_wpglobus_language_name() ) {
284
+ $this->submit_messages['errors'][] = __( 'Please enter the language name!', 'wpglobus' );
285
+ }
286
+
287
+ if ( ! $this->request->get_wpglobus_en_language_name() ) {
288
+ $this->submit_messages['errors'][] = __( 'Please enter the language name in English!', 'wpglobus' );
289
+ }
290
+
291
+ if ( ! $this->request->get_wpglobus_locale() ) {
292
+ $this->submit_messages['errors'][] = __( 'Please enter the locale!', 'wpglobus' );
293
+ }
294
+
295
+ $this->language_code = $lang_code;
296
+ $this->flag = $this->request->get_wpglobus_flags();
297
+ $this->language_name = $this->request->get_wpglobus_language_name();
298
+ $this->en_language_name = $this->request->get_wpglobus_en_language_name();
299
+ $this->locale = $this->request->get_wpglobus_locale();
300
+
301
+ if ( empty( $this->submit_messages['errors'] ) ) {
302
+ return true;
303
+ }
304
+
305
+ return false;
306
+ }
307
+
308
+ /**
309
+ * Check existing language code in global $WPGlobus_Config
310
+ *
311
+ * @param string $code Language code.
312
+ *
313
+ * @return bool true if language code exists
314
+ */
315
+ protected function language_exists( $code ) {
316
+
317
+ if ( array_key_exists( $code, WPGlobus::Config()->language_name ) ) {
318
+ return true;
319
+ }
320
+
321
+ return false;
322
+ }
323
+
324
+ /**
325
+ * Get data for form fields
326
+ */
327
+ protected function get_data() {
328
+
329
+ if ( WPGlobus_Language_Edit_Request::ACTION_EDIT === $this->action
330
+ || WPGlobus_Language_Edit_Request::ACTION_DELETE === $this->action ) {
331
+
332
+ $config = WPGlobus::Config();
333
+
334
+ $this->language_name = $config->language_name[ $this->language_code ];
335
+ $this->en_language_name = $config->en_language_name[ $this->language_code ];
336
+ $this->locale = $config->locale[ $this->language_code ];
337
+ $this->flag = $config->flag[ $this->language_code ];
338
+ }
339
+ $this->get_flags();
340
+ }
341
+
342
+ /**
343
+ * Display language form
344
+ */
345
+ protected function display_table() {
346
+
347
+ $disabled = '';
348
+ if ( WPGlobus_Language_Edit_Request::ACTION_EDIT === $this->action ) {
349
+ $header = __( 'Edit Language', 'wpglobus' );
350
+ } elseif ( WPGlobus_Language_Edit_Request::ACTION_DELETE === $this->action ) {
351
+ $header = __( 'Delete Language', 'wpglobus' );
352
+ $disabled = 'disabled';
353
+ } else {
354
+ $header = __( 'Add Language', 'wpglobus' );
355
+ }
356
+ ?>
357
+ <div class="wrap">
358
+ <h1>WPGlobus: <?php echo esc_html( $header ); ?></h1>
359
+ <?php
360
+ if ( $this->submit ) {
361
+ if ( ! empty( $this->submit_messages['errors'] ) ) {
362
+ $mess = '';
363
+ foreach ( $this->submit_messages['errors'] as $message ) {
364
+ $mess .= $message . '<br />';
365
+ }
366
+ ?>
367
+ <div class="error"><p><?php echo wp_kses( $mess, array( 'br' => array() ) ); ?></p></div>
368
+ <?php
369
+ } elseif ( ! empty( $this->submit_messages['success'] ) ) {
370
+ $mess = '';
371
+ foreach ( $this->submit_messages['success'] as $message ) {
372
+ $mess .= $message . '<br />';
373
+ }
374
+ ?>
375
+ <div class="updated"><p><?php echo wp_kses( $mess, array( 'br' => array() ) ); ?></p></div>
376
+ <?php
377
+ }
378
+ }
379
+ ?>
380
+ <form id="wpglobus_edit_form" method="post" action="">
381
+ <table class="form-table">
382
+ <tr>
383
+ <th scope="row"><label
384
+ for="wpglobus_language_code"><?php esc_html_e( 'Language Code', 'wpglobus' ); ?></label>
385
+ </th>
386
+ <td>
387
+ <input name="wpglobus_language_code" <?php echo esc_attr( $disabled ); ?> type="text"
388
+ id="wpglobus_language_code"
389
+ value="<?php echo esc_attr( $this->language_code ); ?>" class="regular-text"/>
390
+
391
+ <p class="description"><?php esc_html_e( '2-Letter ISO Language Code for the Language you want to insert. (Example: en)', 'wpglobus' ); ?></p>
392
+ </td>
393
+ </tr>
394
+ <tr>
395
+ <th scope="row"><label
396
+ for="wpglobus_flags"><?php esc_html_e( 'Language flag', 'wpglobus' ); ?></label>
397
+ </th>
398
+ <td>
399
+ <select id="wpglobus_flags" name="wpglobus_flags" style="width:300px;"
400
+ class="populate">
401
+ <?php
402
+ foreach ( $this->all_flags as $file_name ) :
403
+ ?>
404
+ <option <?php selected( $this->flag === $file_name ); ?>
405
+ value="<?php echo esc_attr( $file_name ); ?>"><?php echo esc_html( $file_name ); ?></option>
406
+ <?php endforeach; ?>
407
+ </select>
408
+ </td>
409
+ </tr>
410
+ <tr>
411
+ <th scope="row"><label
412
+ for="wpglobus_language_name"><?php esc_html_e( 'Name', 'wpglobus' ); ?></label>
413
+ </th>
414
+ <td><input name="wpglobus_language_name" type="text" id="wpglobus_language_name"
415
+ value="<?php echo esc_attr( $this->language_name ); ?>" class="regular-text"/>
416
+
417
+ <p class="description"><?php esc_html_e( 'The name of the language in its native alphabet. (Examples: English, Русский)', 'wpglobus' ); ?></p>
418
+ </td>
419
+ </tr>
420
+ <tr>
421
+ <th scope="row"><label
422
+ for="wpglobus_en_language_name"><?php esc_html_e( 'Name in English', 'wpglobus' ); ?></label>
423
+ </th>
424
+ <td><input name="wpglobus_en_language_name" type="text" id="wpglobus_en_language_name"
425
+ value="<?php echo esc_attr( $this->en_language_name ); ?>" class="regular-text"/>
426
+
427
+ <p class="description"><?php esc_html_e( 'The name of the language in English', 'wpglobus' ); ?></p>
428
+ </td>
429
+ </tr>
430
+ <tr>
431
+ <th scope="row"><label
432
+ for="wpglobus_locale"><?php esc_html_e( 'Locale', 'wpglobus' ); ?></label></th>
433
+ <td><input name="wpglobus_locale" type="text" id="wpglobus_locale"
434
+ value="<?php echo esc_attr( $this->locale ); ?>"
435
+ class="regular-text"/>
436
+
437
+ <p class="description"><?php esc_html_e( 'PHP/WordPress Locale of the language. (Examples: en_US, ru_RU)', 'wpglobus' ); ?></p>
438
+ </td>
439
+ </tr>
440
+ </table>
441
+ <?php
442
+
443
+ if ( WPGlobus_Language_Edit_Request::ACTION_EDIT === $this->action
444
+ || WPGlobus_Language_Edit_Request::ACTION_ADD === $this->action ) {
445
+ ?>
446
+ <input class="button button-primary" type="submit" name="submit"
447
+ value="<?php esc_attr_e( 'Save Changes', 'wpglobus' ); ?>">
448
+ <?php
449
+
450
+ if ( WPGlobus_Language_Edit_Request::ACTION_EDIT === $this->action ) {
451
+ ?>
452
+
453
+ <a class="button button-link-delete" style="margin-left: 1em" href="<?php echo esc_url( WPGlobus_Language_Edit_Request::url_language_delete( $this->language_code ) ); ?>">
454
+ <i class="dashicons dashicons-trash" style="line-height: inherit;"></i>
455
+ <?php esc_html_e( 'Delete Language', 'wpglobus' ); ?>&hellip;</a>
456
+ <?php
457
+ }
458
+ } elseif ( WPGlobus_Language_Edit_Request::ACTION_DELETE === $this->action ) {
459
+ ?>
460
+ <div class="notice-large wp-ui-notification"><?php esc_html_e( 'Are you sure you want to delete?', 'wpglobus' ); ?></div>
461
+ <p class="submit"><input class="button button-primary" type="submit" name="delete"
462
+ value="<?php esc_attr_e( 'Delete Language', 'wpglobus' ); ?>"></p>
463
+ <?php } ?>
464
+
465
+ </form>
466
+
467
+ <hr/>
468
+ <span class="dashicons dashicons-admin-site"></span>
469
+ <a href="<?php echo esc_url( admin_url( 'admin.php?page=wpglobus_options' ) ); ?>">
470
+ <?php esc_html_e( 'Back to the WPGlobus Settings', 'wpglobus' ); ?>
471
+ </a>
472
+ </div>
473
+ <?php
474
+ }
475
+
476
+ /**
477
+ * Get flag files from directory
478
+ */
479
+ protected function get_flags() {
480
+
481
+ $dir = new DirectoryIterator( WPGlobus::plugin_dir_path() . 'flags/' );
482
+
483
+ foreach ( $dir as $file ) {
484
+ /**
485
+ * File object
486
+ *
487
+ * @var DirectoryIterator $file
488
+ */
489
+ if ( $file->isFile() ) {
490
+ $this->all_flags[] = $file->getFilename();
491
+ }
492
+ }
493
+ }
494
+ }
includes/admin/class-wpglobus-plugin-install.php ADDED
@@ -0,0 +1,335 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * File: class-wpglobus-plugin-install.php
4
+ *
5
+ * @package WPGlobus\Admin
6
+ * @since 1.5.9
7
+ */
8
+
9
+ if ( ! class_exists( 'WPGlobus_Plugin_Install' ) ) :
10
+
11
+ /**
12
+ * Class WPGlobus_Plugin_Install
13
+ */
14
+ class WPGlobus_Plugin_Install {
15
+
16
+ /**
17
+ * Fake version for paid plugins to prevent the "Update Now" button from appearing.
18
+ *
19
+ * @var string
20
+ */
21
+ const FAKE_VERSION = '999';
22
+
23
+ /**
24
+ * Fake active installs for paid plugins.
25
+ *
26
+ * @var int
27
+ */
28
+ const FAKE_ACTIVE_INSTALLS = 0;
29
+
30
+ /**
31
+ * Fake "Compatible with your version of WordPress" for paid plugins.
32
+ *
33
+ * @var string
34
+ */
35
+ protected static $fake_compatible_with = '';
36
+
37
+ /**
38
+ * Array of plugin cards.
39
+ *
40
+ * @var array
41
+ */
42
+ static protected $plugin_card = array();
43
+
44
+ /**
45
+ * Array of paid plugins data.
46
+ *
47
+ * @var array
48
+ */
49
+ static protected $paid_plugins = array();
50
+
51
+ /**
52
+ * Array of free plugins data.
53
+ *
54
+ * @var array
55
+ */
56
+ static protected $free_plugins = array();
57
+
58
+ /**
59
+ * Controller.
60
+ */
61
+ public static function controller() {
62
+
63
+ if ( empty( $_GET['source'] ) ) { // WPCS: input var ok, sanitization ok.
64
+ return;
65
+ }
66
+
67
+ if ( empty( $_GET['s'] ) ) { // WPCS: input var ok, sanitization ok.
68
+ return;
69
+ }
70
+
71
+ if ( 'WPGlobus' !== $_GET['source'] || 'WPGlobus' !== $_GET['s'] ) { // WPCS: input var ok, sanitization ok.
72
+ return;
73
+ }
74
+
75
+ self::$fake_compatible_with = $GLOBALS['wp_version'];
76
+
77
+ self::$plugin_card['free'] = array();
78
+ self::$plugin_card['paid'] = array();
79
+
80
+ self::_setup_paid_plugins();
81
+
82
+ // Enqueue the CSS & JS scripts.
83
+ add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ) );
84
+
85
+ add_filter( 'plugins_api_result', array( __CLASS__, 'filter__plugins_api_result' ), 10, 3 );
86
+ }
87
+
88
+ /**
89
+ * List of the premium WPGlobus extensions.
90
+ * This file is created manually.
91
+ */
92
+ protected static function _setup_paid_plugins() {
93
+
94
+ self::$paid_plugins = array();
95
+
96
+ $data_file = WPGlobus::data_path() . '/paid_plugins.json';
97
+
98
+ if ( is_readable( $data_file ) ) {
99
+ $_json = file_get_contents( $data_file );
100
+ self::$paid_plugins = json_decode( $_json, true );
101
+ uasort( self::$paid_plugins, array( __CLASS__, 'sort_paid_plugins' ) );
102
+ }
103
+ }
104
+
105
+ /**
106
+ * Callback for sorting the paid_plugins array.
107
+ *
108
+ * @param array $a First.
109
+ * @param array $b Second.
110
+ *
111
+ * @return int
112
+ */
113
+ public static function sort_paid_plugins( $a, $b ) {
114
+ return $a['order'] > $b['order'];
115
+ }
116
+
117
+ /**
118
+ * Filter api results
119
+ *
120
+ * @param stdClass|WP_Error $res Response object or WP_Error.
121
+ * @param string $action The type of information being requested from the Plugin Install API.
122
+ * @param stdClass $args Plugin API arguments.
123
+ *
124
+ * @return stdClass|WP_Error
125
+ */
126
+ public static function filter__plugins_api_result(
127
+ $res,
128
+ // @formatter:off
129
+ /* @noinspection PhpUnusedParameterInspection */ $action,
130
+ /* @noinspection PhpUnusedParameterInspection */ $args
131
+ // @formatter:on
132
+ ) {
133
+
134
+ if ( is_wp_error( $res ) ) {
135
+ return $res;
136
+ }
137
+
138
+ if ( empty( $res->plugins ) ) {
139
+ return $res;
140
+ }
141
+
142
+ foreach ( (array) $res->plugins as $key => $plugin ) {
143
+ if ( false === strpos( $plugin->slug, 'wpglobus' ) ) {
144
+ unset( $res->plugins[ $key ] );
145
+ } else {
146
+
147
+ if ( 'wpglobus-for-black-studio-tinymce-widget' === $plugin->slug ) {
148
+
149
+ /**
150
+ * Set correct slug for the
151
+ * `WPGlobus for Black Studio TinyMCE Widget` plugin.
152
+ *
153
+ * @since 1.6.3
154
+ */
155
+ $plugin->slug = 'wpglobus-for-black-studio-widget';
156
+
157
+ self::$plugin_card['free'][] = $plugin->slug;
158
+
159
+ self::$free_plugins[ $plugin->slug ]['extra_data']['correctLink'] = 'wpglobus-for-black-studio-tinymce-widget';
160
+
161
+ } else {
162
+ self::$plugin_card['free'][] = $plugin->slug;
163
+ }
164
+ }
165
+ }
166
+
167
+ $url_wpglobus_site = WPGlobus_Utils::url_wpglobus_site();
168
+
169
+ $all_products = self::_get_all_product_info();
170
+
171
+ foreach ( self::$paid_plugins as $plugin => $plugin_data ) {
172
+
173
+ $plugin_file = implode( '/', array( WP_PLUGIN_DIR, $plugin_data['slug'], $plugin_data['loader'] ) );
174
+
175
+ if ( is_readable( $plugin_file ) ) {
176
+ // Plugin is installed.
177
+ self::$paid_plugins[ $plugin ]['plugin_data'] = get_plugin_data( $plugin_file, false );
178
+ } else {
179
+ self::$paid_plugins[ $plugin ]['plugin_data'] = null;
180
+
181
+ $product_slug = ( isset( $plugin_data['product_slug'] ) ? $plugin_data['product_slug'] : $plugin );
182
+
183
+ if ( isset( $all_products[ $product_slug ] ) ) {
184
+ $plugin_info = $all_products[ $product_slug ];
185
+
186
+ /**
187
+ * Titles come as multilingual strings but only in 2 languages ['en','ru']
188
+ * because the WPGlobus website has only those.
189
+ * So we need to force `en` language code if the admin language
190
+ * is out of the list.
191
+ */
192
+ $language = WPGlobus::Config()->language;
193
+ if ( ! in_array( $language, array( 'en', 'ru' ), true ) ) {
194
+ $language = 'en';
195
+ }
196
+ $_plugin_title = WPGlobus_Core::text_filter( $plugin_info['title'], $language );
197
+
198
+ self::$paid_plugins[ $plugin ]['plugin_data'] = array(
199
+ 'Description' => '', // TODO.
200
+ 'Name' => $_plugin_title,
201
+ 'Title' => $_plugin_title,
202
+ 'Version' => $plugin_info['_api_new_version'],
203
+ 'PluginURI' => $url_wpglobus_site . 'product/' .
204
+ $product_slug . '/',
205
+ );
206
+ }
207
+ }
208
+ }
209
+
210
+ /**
211
+ * Prepend the premium add-ons to the list of plugins.
212
+ */
213
+ foreach ( self::$paid_plugins as $slug => $paid_plugin ) :
214
+
215
+ $_info = self::_plugin_info_template();
216
+
217
+ $_info->slug = $slug;
218
+
219
+ $_info->icons['default'] =
220
+ $_info->icons['1x'] =
221
+ $_info->icons['2x'] = WPGlobus::internal_images_url() . '/' .
222
+ $paid_plugin['image_file'];
223
+
224
+ if ( ! empty( $paid_plugin['plugin_data'] ) ) {
225
+ $_info->name = $paid_plugin['plugin_data']['Name'];
226
+ $_info->short_description = $paid_plugin['plugin_data']['Description'];
227
+ $_info->homepage = $paid_plugin['plugin_data']['PluginURI'];
228
+ } else {
229
+ $_info->name = $slug;
230
+ }
231
+
232
+ self::$plugin_card['paid'][] = $slug;
233
+
234
+ self::$paid_plugins[ $slug ]['card'] = $_info;
235
+
236
+ self::$paid_plugins[ $slug ]['extra_data']['product_url'] =
237
+ self::$paid_plugins[ $slug ]['extra_data']['details_url'] =
238
+ $_info->homepage;
239
+
240
+ array_unshift( $res->plugins, $_info );
241
+
242
+ endforeach;
243
+
244
+ $res->info['results'] = count( $res->plugins );
245
+
246
+ return $res;
247
+ }
248
+
249
+ /**
250
+ * Get information about all premium plugins.
251
+ * This file is created automatically at build. Do not edit!
252
+ *
253
+ * @return array[]
254
+ */
255
+ protected static function _get_all_product_info() {
256
+ $all_product_info = array();
257
+
258
+ $data_file = WPGlobus::data_path() . '/wpglobus-product-info.json';
259
+
260
+ if ( is_readable( $data_file ) ) {
261
+ $all_product_info_json = file_get_contents( $data_file );
262
+ $all_product_info = json_decode( $all_product_info_json, true );
263
+ }
264
+
265
+ return $all_product_info;
266
+ }
267
+
268
+ /**
269
+ * Template for plugin info.
270
+ *
271
+ * @return stdClass
272
+ */
273
+ protected static function _plugin_info_template() {
274
+ $url_wpglobus_site = WPGlobus_Utils::url_wpglobus_site();
275
+
276
+ $template = new stdClass();
277
+ $template->name = '';
278
+ $template->short_description = '';
279
+ $template->author = '<a href="' . $url_wpglobus_site . '">WPGlobus</a>';
280
+ $template->author_profile = $url_wpglobus_site;
281
+ $template->homepage = $url_wpglobus_site;
282
+ $template->slug = '';
283
+ $template->rating = 100;
284
+ $template->num_ratings = 0;
285
+ $template->active_installs = self::FAKE_ACTIVE_INSTALLS;
286
+ $template->version = self::FAKE_VERSION;
287
+ $template->tested = self::$fake_compatible_with;
288
+ $template->icons['default'] = '';
289
+ $template->icons['2x'] = '';
290
+ $template->icons['1x'] = '';
291
+ $template->last_updated = date( 'c' );
292
+
293
+ return $template;
294
+ }
295
+
296
+ /**
297
+ * Enqueue admin JS scripts.
298
+ *
299
+ * @param string $hook_page The current admin page.
300
+ */
301
+ static public function enqueue_scripts( $hook_page ) {
302
+
303
+ if ( 'plugin-install.php' === $hook_page ) {
304
+
305
+ $i18n = array();
306
+ $i18n['current_version'] = esc_html__( 'Current Version', 'wpglobus' );
307
+ $i18n['get_it'] = esc_html__( 'Get it now!', 'wpglobus' );
308
+ $i18n['card_header'] = esc_html__( 'Premium add-on', 'wpglobus' );
309
+ $i18n['installed'] = esc_html__( 'Installed', 'wpglobus' );
310
+
311
+ wp_register_script(
312
+ 'wpglobus-plugin-install',
313
+ WPGlobus::$PLUGIN_DIR_URL . '/includes/js/wpglobus-plugin-install' . WPGlobus::SCRIPT_SUFFIX() . '.js',
314
+ array( 'jquery' ),
315
+ WPGLOBUS_VERSION,
316
+ true
317
+ );
318
+ wp_enqueue_script( 'wpglobus-plugin-install' );
319
+ wp_localize_script(
320
+ 'wpglobus-plugin-install',
321
+ 'WPGlobusPluginInstall',
322
+ array(
323
+ 'version' => WPGLOBUS_VERSION,
324
+ 'hookPage' => $hook_page,
325
+ 'pluginCard' => self::$plugin_card,
326
+ 'pluginData' => array_merge( self::$paid_plugins, self::$free_plugins ),
327
+ 'i18n' => $i18n,
328
+ )
329
+ );
330
+ }
331
+ }
332
+ }
333
+
334
+ endif;
335
+ /*EOF*/
includes/admin/customize/class-wpglobus-customize140.php ADDED
@@ -0,0 +1,282 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Multilingual Customizer
4
+ * @package WPGlobus\Admin\Customizer
5
+ * @since 1.4.0
6
+ */
7
+
8
+ if ( ! class_exists( 'WPGlobus_Customize' ) ) :
9
+
10
+ /**
11
+ * Class WPGlobus_Customize
12
+ */
13
+ class WPGlobus_Customize {
14
+
15
+ public static function controller() {
16
+ /**
17
+ * @see \WP_Customize_Manager::wp_loaded
18
+ * It calls the `customize_register` action first,
19
+ * and then - the `customize_preview_init` action
20
+ */
21
+ /*
22
+ add_action( 'customize_register', array(
23
+ 'WPGlobus_Customize',
24
+ 'action__customize_register'
25
+ ) ); */
26
+
27
+ /**
28
+ * @since 1.5.0
29
+ */
30
+ if ( WPGlobus_WP::is_pagenow( 'customize.php' ) ) {
31
+ require_once 'wpglobus-customize-filters.php';
32
+ }
33
+
34
+ add_action( 'customize_preview_init', array(
35
+ 'WPGlobus_Customize',
36
+ 'action__customize_preview_init'
37
+ ) );
38
+
39
+ /**
40
+ * This is called by wp-admin/customize.php
41
+ */
42
+ add_action( 'customize_controls_enqueue_scripts', array(
43
+ 'WPGlobus_Customize',
44
+ 'action__customize_controls_enqueue_scripts'
45
+ ), 1000 );
46
+
47
+ if ( WPGlobus_WP::is_admin_doing_ajax() ) {
48
+ add_filter( 'clean_url', array(
49
+ 'WPGlobus_Customize',
50
+ 'filter__clean_url'
51
+ ), 10, 2 );
52
+ }
53
+
54
+ }
55
+
56
+ /**
57
+ * Filter a string to check translations for URL.
58
+ * // We build multilingual URLs in customizer using the ':::' delimiter.
59
+ * We build multilingual URLs in customizer using the '|||' delimiter.
60
+ * See wpglobus-customize-control.js
61
+ *
62
+ * @note To work correctly, value of $url should begin with URL for default language.
63
+ * @see esc_url() - the 'clean_url' filter
64
+ * @since 1.3.0
65
+ *
66
+ * @param string $url The cleaned URL.
67
+ * @param string $original_url The URL prior to cleaning.
68
+ *
69
+ * @return string
70
+ */
71
+ public static function filter__clean_url( $url, $original_url ) {
72
+
73
+ if ( false !== strpos( $original_url, '|||' ) ) {
74
+ $arr1 = array();
75
+ $arr = explode( '|||', $original_url );
76
+ foreach ( $arr as $k => $val ) {
77
+ // Note: 'null' is a string, not real `null`.
78
+ if ( 'null' !== $val ) {
79
+ $arr1[ WPGlobus::Config()->enabled_languages[ $k ] ] = $val;
80
+ }
81
+ }
82
+ return WPGlobus_Utils::build_multilingual_string( $arr1 );
83
+ }
84
+
85
+ return $url;
86
+ }
87
+
88
+ /**
89
+ * Add multilingual controls.
90
+ * The original controls will be hidden.
91
+ * @param WP_Customize_Manager $wp_customize
92
+ */
93
+ public static function action__customize_register( WP_Customize_Manager $wp_customize ) {}
94
+
95
+ /**
96
+ * Load Customize Preview JS
97
+ * Used by hook: 'customize_preview_init'
98
+ * @see 'customize_preview_init'
99
+ */
100
+ public static function action__customize_preview_init() {
101
+ wp_enqueue_script(
102
+ 'wpglobus-customize-preview',
103
+ WPGlobus::$PLUGIN_DIR_URL . 'includes/js/wpglobus-customize-preview' .
104
+ WPGlobus::SCRIPT_SUFFIX() . '.js',
105
+ array( 'jquery', 'customize-preview' ),
106
+ WPGLOBUS_VERSION,
107
+ true
108
+ );
109
+ wp_localize_script(
110
+ 'wpglobus-customize-preview',
111
+ 'WPGlobusCustomize',
112
+ array(
113
+ 'version' => WPGLOBUS_VERSION,
114
+ 'blogname' => WPGlobus_Core::text_filter( get_option( 'blogname' ), WPGlobus::Config()->language ),
115
+ 'blogdescription' => WPGlobus_Core::text_filter( get_option( 'blogdescription' ), WPGlobus::Config()->language )
116
+ )
117
+ );
118
+ }
119
+
120
+ /**
121
+ * Load Customize Control JS
122
+ */
123
+ public static function action__customize_controls_enqueue_scripts() {
124
+
125
+ /**
126
+ * @see wp.customize.control elements
127
+ * for example wp.customize.control('blogname');
128
+ */
129
+ $disabled_setting_mask = array();
130
+
131
+ /** navigation menu elements */
132
+ $disabled_setting_mask[] = 'nav_menu_item';
133
+ $disabled_setting_mask[] = 'nav_menu[';
134
+ $disabled_setting_mask[] = 'nav_menu_locations';
135
+ $disabled_setting_mask[] = 'new_menu_name';
136
+
137
+ /** widgets */
138
+ $disabled_setting_mask[] = 'widgets';
139
+
140
+ /** color elements */
141
+ $disabled_setting_mask[] = 'color';
142
+
143
+ /** yoast seo */
144
+ $disabled_setting_mask[] = 'wpseo';
145
+
146
+ /** css elements */
147
+ $disabled_setting_mask[] = 'css';
148
+
149
+ /** social networks elements */
150
+ $disabled_setting_mask[] = 'facebook';
151
+ $disabled_setting_mask[] = 'twitter';
152
+ $disabled_setting_mask[] = 'linkedin';
153
+ $disabled_setting_mask[] = 'behance';
154
+ $disabled_setting_mask[] = 'dribbble';
155
+ $disabled_setting_mask[] = 'instagram';
156
+ /** since 1.4.4 */
157
+ $disabled_setting_mask[] = 'tumblr';
158
+ $disabled_setting_mask[] = 'flickr';
159
+ $disabled_setting_mask[] = 'wordpress';
160
+ $disabled_setting_mask[] = 'youtube';
161
+ $disabled_setting_mask[] = 'pinterest';
162
+ $disabled_setting_mask[] = 'github';
163
+ $disabled_setting_mask[] = 'rss';
164
+ $disabled_setting_mask[] = 'google';
165
+ $disabled_setting_mask[] = 'email';
166
+ /** since 1.5.9 */
167
+ $disabled_setting_mask[] = 'dropbox';
168
+ $disabled_setting_mask[] = 'foursquare';
169
+ $disabled_setting_mask[] = 'vine';
170
+ $disabled_setting_mask[] = 'vimeo';
171
+ /** since 1.6.0 */
172
+ $disabled_setting_mask[] = 'yelp';
173
+
174
+ /**
175
+ * Filter to disable fields in customizer.
176
+ * @see wp.customize.control elements
177
+ * Returning array.
178
+ * @since 1.4.0
179
+ *
180
+ * @param array $disabled_setting_mask An array of disabled masks.
181
+ */
182
+ $disabled_setting_mask = apply_filters( 'wpglobus_customize_disabled_setting_mask', $disabled_setting_mask );
183
+
184
+ $element_selector = array( 'input[type=text]', 'textarea' );
185
+
186
+ /**
187
+ * Filter for element selectors.
188
+ * Returning array.
189
+ * @since 1.4.0
190
+ *
191
+ * @param array $element_selector An array of selectors.
192
+ */
193
+ $element_selector = apply_filters( 'wpglobus_customize_element_selector', $element_selector );
194
+
195
+ $set_link_by = array( 'link', 'url' );
196
+
197
+ /**
198
+ * Filter of masks to determine links.
199
+ * @see value data-customize-setting-link of element
200
+ * Returning array.
201
+ * @since 1.4.0
202
+ *
203
+ * @param array $set_link_by An array of masks.
204
+ */
205
+ $set_link_by = apply_filters( 'wpglobus_customize_setlinkby', $set_link_by );
206
+
207
+ /**
208
+ * Filter of disabled sections.
209
+ *
210
+ * Returning array.
211
+ * @since 1.5.0
212
+ *
213
+ * @param array $disabled_sections An array of sections.
214
+ */
215
+ $disabled_sections = array();
216
+
217
+ $disabled_sections = apply_filters( 'wpglobus_customize_disabled_sections', $disabled_sections );
218
+
219
+ /**
220
+ * Generate language select button for customizer
221
+ * @since 1.6.0
222
+ *
223
+ * @todo http://stackoverflow.com/questions/9607252/how-to-detect-when-an-element-over-another-element-in-javascript
224
+ */
225
+ $attributes['href'] = '#';
226
+ $attributes['style'] = 'margin-left:48px;';
227
+ $attributes['class'] = 'customize-controls-close wpglobus-customize-selector';
228
+
229
+ /**
230
+ * Filter of attributes to generate language selector button.
231
+ * For example @see Divi theme http://www.elegantthemes.com/gallery/divi/ .
232
+ *
233
+ * Returning array.
234
+ * @since 1.6.0
235
+ *
236
+ * @param array $attributes An array of attributes.
237
+ * @param string Name of current theme.
238
+ */
239
+ $attributes = apply_filters( 'wpglobus_customize_language_selector_attrs', $attributes, WPGlobus_Customize_Options::get_theme( 'name' ) );
240
+
241
+ $string = '';
242
+
243
+ foreach ( $attributes as $attribute => $value ) {
244
+ if ( null !== $value ){
245
+ $string .= esc_attr( $attribute ) . '="' . esc_attr( $value ) . '" ';
246
+ }
247
+ }
248
+
249
+ $selector_button = sprintf(
250
+ '<a %1$s>%2$s</a>',
251
+ trim( $string ),
252
+ '<span class="wpglobus-globe"></span>'
253
+ );
254
+
255
+ wp_enqueue_script(
256
+ 'wpglobus-customize-control140',
257
+ WPGlobus::$PLUGIN_DIR_URL . 'includes/js/wpglobus-customize-control140' . WPGlobus::SCRIPT_SUFFIX() . '.js',
258
+ array( 'jquery' ),
259
+ WPGLOBUS_VERSION,
260
+ true
261
+ );
262
+ wp_localize_script(
263
+ 'wpglobus-customize-control140',
264
+ 'WPGlobusCustomize',
265
+ array(
266
+ 'version' => WPGLOBUS_VERSION,
267
+ 'selectorButton' => $selector_button,
268
+ 'languageAdmin' => WPGlobus::Config()->language,
269
+ 'disabledSettingMask' => $disabled_setting_mask,
270
+ 'elementSelector' => $element_selector,
271
+ 'setLinkBy' => $set_link_by,
272
+ 'disabledSections' => $disabled_sections,
273
+ 'controlClass' => 'wpglobus-customize-control',
274
+ )
275
+ );
276
+
277
+ }
278
+
279
+ } // class
280
+
281
+ endif;
282
+ # --- EOF
includes/admin/customize/class-wpglobus-customize170.php ADDED
@@ -0,0 +1,300 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Multilingual Customizer
4
+ * @package WPGlobus\Admin\Customizer
5
+ * @since 1.7.0
6
+ */
7
+
8
+ if ( ! class_exists( 'WPGlobus_Customize' ) ) :
9
+
10
+ /**
11
+ * Class WPGlobus_Customize
12
+ */
13
+ class WPGlobus_Customize {
14
+
15
+ public static function controller() {
16
+ /**
17
+ * @see \WP_Customize_Manager::wp_loaded
18
+ * It calls the `customize_register` action first,
19
+ * and then - the `customize_preview_init` action
20
+ */
21
+ /*
22
+ add_action( 'customize_register', array(
23
+ 'WPGlobus_Customize',
24
+ 'action__customize_register'
25
+ ) ); */
26
+
27
+ /**
28
+ * @since 1.5.0
29
+ */
30
+ if ( WPGlobus_WP::is_pagenow( 'customize.php' ) ) {
31
+ require_once 'wpglobus-customize-filters.php';
32
+ }
33
+
34
+ add_action( 'customize_preview_init', array(
35
+ 'WPGlobus_Customize',
36
+ 'action__customize_preview_init'
37
+ ) );
38
+
39
+ /**
40
+ * This is called by wp-admin/customize.php
41
+ */
42
+ add_action( 'customize_controls_enqueue_scripts', array(
43
+ 'WPGlobus_Customize',
44
+ 'action__customize_controls_enqueue_scripts'
45
+ ), 1000 );
46
+
47
+ if ( WPGlobus_WP::is_admin_doing_ajax() ) {
48
+ add_filter( 'clean_url', array(
49
+ 'WPGlobus_Customize',
50
+ 'filter__clean_url'
51
+ ), 10, 2 );
52
+ }
53
+
54
+ }
55
+
56
+ /**
57
+ * Filter a string to check translations for URL.
58
+ * // We build multilingual URLs in customizer using the ':::' delimiter.
59
+ * We build multilingual URLs in customizer using the '|||' delimiter.
60
+ * See wpglobus-customize-control.js
61
+ *
62
+ * @note To work correctly, value of $url should begin with URL for default language.
63
+ * @see esc_url() - the 'clean_url' filter
64
+ * @since 1.3.0
65
+ *
66
+ * @param string $url The cleaned URL.
67
+ * @param string $original_url The URL prior to cleaning.
68
+ *
69
+ * @return string
70
+ */
71
+ public static function filter__clean_url( $url, $original_url ) {
72
+
73
+ if ( false !== strpos( $original_url, '|||' ) ) {
74
+ $arr1 = array();
75
+ $arr = explode( '|||', $original_url );
76
+ foreach ( $arr as $k => $val ) {
77
+ // Note: 'null' is a string, not real `null`.
78
+ if ( 'null' !== $val ) {
79
+ $arr1[ WPGlobus::Config()->enabled_languages[ $k ] ] = $val;
80
+ }
81
+ }
82
+ return WPGlobus_Utils::build_multilingual_string( $arr1 );
83
+ }
84
+
85
+ return $url;
86
+ }
87
+
88
+ /**
89
+ * Add multilingual controls.
90
+ * The original controls will be hidden.
91
+ * @param WP_Customize_Manager $wp_customize
92
+ */
93
+ public static function action__customize_register( WP_Customize_Manager $wp_customize ) {}
94
+
95
+ /**
96
+ * Load Customize Preview JS
97
+ * Used by hook: 'customize_preview_init'
98
+ * @see 'customize_preview_init'
99
+ */
100
+ public static function action__customize_preview_init() {
101
+ wp_enqueue_script(
102
+ 'wpglobus-customize-preview',
103
+ WPGlobus::$PLUGIN_DIR_URL . 'includes/js/wpglobus-customize-preview' .
104
+ WPGlobus::SCRIPT_SUFFIX() . '.js',
105
+ array( 'jquery', 'customize-preview' ),
106
+ WPGLOBUS_VERSION,
107
+ true
108
+ );
109
+ wp_localize_script(
110
+ 'wpglobus-customize-preview',
111
+ 'WPGlobusCustomize',
112
+ array(
113
+ 'version' => WPGLOBUS_VERSION,
114
+ 'blogname' => WPGlobus_Core::text_filter( get_option( 'blogname' ), WPGlobus::Config()->language ),
115
+ 'blogdescription' => WPGlobus_Core::text_filter( get_option( 'blogdescription' ), WPGlobus::Config()->language )
116
+ )
117
+ );
118
+ }
119
+
120
+ /**
121
+ * Load Customize Control JS
122
+ */
123
+ public static function action__customize_controls_enqueue_scripts() {
124
+
125
+ /**
126
+ * @see wp.customize.control elements
127
+ * for example wp.customize.control('blogname');
128
+ */
129
+ $disabled_setting_mask = array();
130
+
131
+ /** navigation menu elements */
132
+ $disabled_setting_mask[] = 'nav_menu_item';
133
+ $disabled_setting_mask[] = 'nav_menu[';
134
+ $disabled_setting_mask[] = 'nav_menu_locations';
135
+ $disabled_setting_mask[] = 'new_menu_name';
136
+
137
+ /** widgets */
138
+ $disabled_setting_mask[] = 'widgets';
139
+
140
+ /** color elements */
141
+ $disabled_setting_mask[] = 'color';
142
+
143
+ /** yoast seo */
144
+ $disabled_setting_mask[] = 'wpseo';
145
+
146
+ /** css elements */
147
+ $disabled_setting_mask[] = 'css';
148
+
149
+ /** social networks elements */
150
+ $disabled_setting_mask[] = 'facebook';
151
+ $disabled_setting_mask[] = 'twitter';
152
+ $disabled_setting_mask[] = 'linkedin';
153
+ $disabled_setting_mask[] = 'behance';
154
+ $disabled_setting_mask[] = 'dribbble';
155
+ $disabled_setting_mask[] = 'instagram';
156
+ /** since 1.4.4 */
157
+ $disabled_setting_mask[] = 'tumblr';
158
+ $disabled_setting_mask[] = 'flickr';
159
+ $disabled_setting_mask[] = 'wordpress';
160
+ $disabled_setting_mask[] = 'youtube';
161
+ $disabled_setting_mask[] = 'pinterest';
162
+ $disabled_setting_mask[] = 'github';
163
+ $disabled_setting_mask[] = 'rss';
164
+ $disabled_setting_mask[] = 'google';
165
+ $disabled_setting_mask[] = 'email';
166
+ /** since 1.5.9 */
167
+ $disabled_setting_mask[] = 'dropbox';
168
+ $disabled_setting_mask[] = 'foursquare';
169
+ $disabled_setting_mask[] = 'vine';
170
+ $disabled_setting_mask[] = 'vimeo';
171
+ /** since 1.6.0 */
172
+ $disabled_setting_mask[] = 'yelp';
173
+
174
+ /**
175
+ * Exclude fields from Static Front Page section.
176
+ * It may be added to customizer in many themes.
177
+ *
178
+ * @since 1.7.6
179
+ */
180
+ $disabled_setting_mask[] = 'page_on_front';
181
+ $disabled_setting_mask[] = 'page_for_posts';
182
+
183
+ /**
184
+ * Filter to disable fields in customizer.
185
+ * @see wp.customize.control elements
186
+ * Returning array.
187
+ * @since 1.4.0
188
+ *
189
+ * @param array $disabled_setting_mask An array of disabled masks.
190
+ */
191
+ $disabled_setting_mask = apply_filters( 'wpglobus_customize_disabled_setting_mask', $disabled_setting_mask );
192
+
193
+ $element_selector = array( 'input[type=text]', 'textarea' );
194
+
195
+ /**
196
+ * Filter for element selectors.
197
+ * Returning array.
198
+ * @since 1.4.0
199
+ *
200
+ * @param array $element_selector An array of selectors.
201
+ */
202
+ $element_selector = apply_filters( 'wpglobus_customize_element_selector', $element_selector );
203
+
204
+ $set_link_by = array( 'link', 'url' );
205
+
206
+ /**
207
+ * Filter of masks to determine links.
208
+ * @see value data-customize-setting-link of element
209
+ * Returning array.
210
+ * @since 1.4.0
211
+ *
212
+ * @param array $set_link_by An array of masks.
213
+ */
214
+ $set_link_by = apply_filters( 'wpglobus_customize_setlinkby', $set_link_by );
215
+
216
+ /**
217
+ * Filter of disabled sections.
218
+ *
219
+ * Returning array.
220
+ * @since 1.5.0
221
+ *
222
+ * @param array $disabled_sections An array of sections.
223
+ */
224
+ $disabled_sections = array();
225
+
226
+ $disabled_sections = apply_filters( 'wpglobus_customize_disabled_sections', $disabled_sections );
227
+
228
+ /**
229
+ * Generate language select button for customizer
230
+ * @since 1.6.0
231
+ *
232
+ * @todo http://stackoverflow.com/questions/9607252/how-to-detect-when-an-element-over-another-element-in-javascript
233
+ */
234
+ $attributes['href'] = '#';
235
+ $attributes['style'] = 'margin-left:48px;';
236
+ $attributes['class'] = 'customize-controls-close wpglobus-customize-selector';
237
+
238
+ /**
239
+ * Filter of attributes to generate language selector button.
240
+ * For example @see Divi theme http://www.elegantthemes.com/gallery/divi/ .
241
+ *
242
+ * Returning array.
243
+ * @since 1.6.0
244
+ *
245
+ * @param array $attributes An array of attributes.
246
+ * @param string Name of current theme.
247
+ */
248
+ $attributes = apply_filters( 'wpglobus_customize_language_selector_attrs', $attributes, WPGlobus_Customize_Options::get_theme( 'name' ) );
249
+
250
+ $string = '';
251
+
252
+ foreach ( $attributes as $attribute => $value ) {
253
+ if ( null !== $value ){
254
+ $string .= esc_attr( $attribute ) . '="' . esc_attr( $value ) . '" ';
255
+ }
256
+ }
257
+
258
+ $selector_button = sprintf(
259
+ '<a %1$s>%2$s</a>',
260
+ trim( $string ),
261
+ '<span class="wpglobus-globe"></span>'
262
+ );
263
+
264
+ /**
265
+ * Since 1.7.9
266
+ */
267
+ $changeset_uuid = null;
268
+ if ( ! empty( $_GET['changeset_uuid'] ) ) { // WPCS: input var ok, sanitization ok.
269
+ $changeset_uuid = sanitize_text_field( wp_unslash( $_GET['changeset_uuid'] ) ); // WPCS: input var ok.
270
+ }
271
+
272
+ wp_enqueue_script(
273
+ 'wpglobus-customize-control170',
274
+ WPGlobus::$PLUGIN_DIR_URL . 'includes/js/wpglobus-customize-control170' . WPGlobus::SCRIPT_SUFFIX() . '.js',
275
+ array( 'jquery' ),
276
+ WPGLOBUS_VERSION,
277
+ true
278
+ );
279
+ wp_localize_script(
280
+ 'wpglobus-customize-control170',
281
+ 'WPGlobusCustomize',
282
+ array(
283
+ 'version' => WPGLOBUS_VERSION,
284
+ 'selectorButton' => $selector_button,
285
+ 'languageAdmin' => WPGlobus::Config()->language,
286
+ 'disabledSettingMask' => $disabled_setting_mask,
287
+ 'elementSelector' => $element_selector,
288
+ 'setLinkBy' => $set_link_by,
289
+ 'disabledSections' => $disabled_sections,
290
+ 'controlClass' => 'wpglobus-customize-control',
291
+ 'changeset_uuid' => $changeset_uuid
292
+ )
293
+ );
294
+
295
+ }
296
+
297
+ } // class
298
+
299
+ endif;
300
+ # --- EOF
includes/admin/customize/class-wpglobus-customize190.php ADDED
@@ -0,0 +1,467 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Multilingual Customizer
4
+ * @package WPGlobus\Admin\Customizer
5
+ * @since 1.9.0
6
+ */
7
+
8
+ if ( ! class_exists( 'WPGlobus_Customize' ) ) :
9
+
10
+ /**
11
+ * Class WPGlobus_Customize
12
+ */
13
+ class WPGlobus_Customize {
14
+
15
+ public static function controller() {
16
+
17
+ add_action('admin_init', array( __CLASS__, 'on__admin_init'), 1);
18
+
19
+ /**
20
+ * @see \WP_Customize_Manager::wp_loaded
21
+ * It calls the `customize_register` action first,
22
+ * and then - the `customize_preview_init` action
23
+ */
24
+ /*
25
+ add_action( 'customize_register', array(
26
+ 'WPGlobus_Customize',
27
+ 'action__customize_register'
28
+ ) ); */
29
+
30
+ /**
31
+ * @since 1.5.0
32
+ */
33
+ if ( WPGlobus_WP::is_pagenow( 'customize.php' ) ) {
34
+ require_once 'wpglobus-customize-filters.php';
35
+ }
36
+
37
+ add_action( 'customize_preview_init', array(
38
+ 'WPGlobus_Customize',
39
+ 'action__customize_preview_init'
40
+ ) );
41
+
42
+ /**
43
+ * This is called by wp-admin/customize.php
44
+ */
45
+ add_action( 'customize_controls_enqueue_scripts', array(
46
+ 'WPGlobus_Customize',
47
+ 'action__customize_controls_enqueue_scripts'
48
+ ), 1000 );
49
+
50
+ if ( WPGlobus_WP::is_admin_doing_ajax() ) {
51
+ add_filter( 'clean_url', array(
52
+ 'WPGlobus_Customize',
53
+ 'filter__clean_url'
54
+ ), 10, 2 );
55
+ }
56
+
57
+ /**
58
+ * @see wp-includes\class-wp-customize-manager.php
59
+ * @since 1.9.3
60
+ */
61
+ add_filter( 'customize_changeset_save_data', array(
62
+ __CLASS__,
63
+ 'filter__customize_changeset_save_data'
64
+ ), 1, 2 );
65
+
66
+ }
67
+
68
+ /**
69
+ * @since 1.9.3
70
+ */
71
+ public static function on__admin_init() {
72
+
73
+ $excluded_mods = array(
74
+ '0',
75
+ 'nav_menu_locations',
76
+ 'sidebars_widgets',
77
+ 'custom_css_post_id',
78
+ 'wpglobus_blogname',
79
+ 'wpglobus_blogdescription'
80
+ );
81
+
82
+ $mods = get_theme_mods();
83
+
84
+ $filtered_mods = array();
85
+ foreach( $mods as $mod_key=>$mod_value ) {
86
+
87
+ if ( in_array($mod_key, $excluded_mods) ) {
88
+ continue;
89
+ }
90
+
91
+ if ( ! is_string($mod_value) ) {
92
+ continue;
93
+ }
94
+
95
+ $filtered_mods[$mod_key] = $mod_value;
96
+
97
+ }
98
+
99
+ /**
100
+ * Filters the theme mods before save.
101
+ *
102
+ * @since 1.9.3
103
+ *
104
+ * @param array $filtered_mods Filtered theme modifications.
105
+ * @param array|void $mods Theme modifications.
106
+ */
107
+ $filtered_mods = apply_filters('wpglobus_customize_filtered_mods', $filtered_mods, $mods);
108
+
109
+ foreach( $filtered_mods as $mod_key=>$mod_value ) {
110
+
111
+ /**
112
+ * @see filter "pre_set_theme_mod_{$name}" in \wp-includes\theme.php
113
+ */
114
+ add_filter( "pre_set_theme_mod_{$mod_key}", array(
115
+ __CLASS__,
116
+ 'filter__pre_set_theme_mod'
117
+ ), 1, 2 );
118
+
119
+ }
120
+ }
121
+
122
+ /**
123
+ * Filter a theme mod.
124
+ *
125
+ * @since 1.9.3
126
+ */
127
+ public static function filter__pre_set_theme_mod($value, $old_value) {
128
+
129
+ if ( ! is_string($value) ) {
130
+ return $value;
131
+ }
132
+
133
+ $new_value = self::_build_multilingual_string($value);
134
+
135
+ if ( $new_value ) {
136
+ return $new_value;
137
+ }
138
+
139
+ return $value;
140
+
141
+ }
142
+
143
+ /**
144
+ * Save/update a changeset.
145
+ *
146
+ * @since 1.9.3
147
+ */
148
+ public static function filter__customize_changeset_save_data($data, $filter_context) {
149
+
150
+ foreach( $data as $option=>$value ) {
151
+
152
+ $new_value = self::_build_multilingual_string($value['value']);
153
+
154
+ if ( $new_value ) {
155
+ $data[$option]['value'] = $new_value;
156
+ }
157
+
158
+ }
159
+
160
+ return $data;
161
+
162
+ }
163
+
164
+ /**
165
+ * Build standard WPGlobus multilingual string.
166
+ *
167
+ * @since 1.9.3
168
+ */
169
+ public static function _build_multilingual_string($value) {
170
+
171
+ /**
172
+ * @since 1.9.6
173
+ */
174
+ if ( ! is_string($value) ) {
175
+ return $value;
176
+ }
177
+
178
+ $new_value = '';
179
+
180
+ if ( false === strpos( $value, '|||' ) ) {
181
+ $new_value = false;
182
+ } else {
183
+
184
+ $arr1 = array();
185
+ $arr = explode( '|||', $value );
186
+ foreach ( $arr as $k => $val ) {
187
+ // Note: 'null' is a string, not real `null`.
188
+ if ( 'null' !== $val ) {
189
+ $arr1[ WPGlobus::Config()->enabled_languages[ $k ] ] = $val;
190
+ }
191
+ }
192
+
193
+ $new_value = WPGlobus_Utils::build_multilingual_string( $arr1 );
194
+
195
+ }
196
+
197
+ return $new_value;
198
+
199
+ }
200
+
201
+ /**
202
+ * Filter a string to check translations for URL.
203
+ * // We build multilingual URLs in customizer using the ':::' delimiter.
204
+ * We build multilingual URLs in customizer using the '|||' delimiter.
205
+ * See wpglobus-customize-control.js
206
+ *
207
+ * @note To work correctly, value of $url should begin with URL for default language.
208
+ * @see esc_url() - the 'clean_url' filter
209
+ * @since 1.3.0
210
+ *
211
+ * @param string $url The cleaned URL.
212
+ * @param string $original_url The URL prior to cleaning.
213
+ *
214
+ * @return string
215
+ */
216
+ public static function filter__clean_url( $url, $original_url ) {
217
+
218
+ if ( false !== strpos( $original_url, '|||' ) ) {
219
+ $arr1 = array();
220
+ $arr = explode( '|||', $original_url );
221
+ foreach ( $arr as $k => $val ) {
222
+ // Note: 'null' is a string, not real `null`.
223
+ if ( 'null' !== $val ) {
224
+ $arr1[ WPGlobus::Config()->enabled_languages[ $k ] ] = $val;
225
+ }
226
+ }
227
+ return WPGlobus_Utils::build_multilingual_string( $arr1 );
228
+ }
229
+
230
+ return $url;
231
+ }
232
+
233
+ /**
234
+ * Add multilingual controls.
235
+ * The original controls will be hidden.
236
+ * @param WP_Customize_Manager $wp_customize
237
+ */
238
+ public static function action__customize_register( WP_Customize_Manager $wp_customize ) {}
239
+
240
+ /**
241
+ * Load Customize Preview JS
242
+ * Used by hook: 'customize_preview_init'
243
+ * @see 'customize_preview_init'
244
+ */
245
+ public static function action__customize_preview_init() {
246
+ wp_enqueue_script(
247
+ 'wpglobus-customize-preview',
248
+ WPGlobus::$PLUGIN_DIR_URL . 'includes/js/wpglobus-customize-preview' .
249
+ WPGlobus::SCRIPT_SUFFIX() . '.js',
250
+ array( 'jquery', 'customize-preview' ),
251
+ WPGLOBUS_VERSION,
252
+ true
253
+ );
254
+ wp_localize_script(
255
+ 'wpglobus-customize-preview',
256
+ 'WPGlobusCustomize',
257
+ array(
258
+ 'version' => WPGLOBUS_VERSION,
259
+ 'blogname' => WPGlobus_Core::text_filter( get_option( 'blogname' ), WPGlobus::Config()->language ),
260
+ 'blogdescription' => WPGlobus_Core::text_filter( get_option( 'blogdescription' ), WPGlobus::Config()->language )
261
+ )
262
+ );
263
+ }
264
+
265
+ /**
266
+ * Load Customize Control JS
267
+ */
268
+ public static function action__customize_controls_enqueue_scripts() {
269
+
270
+ /**
271
+ * @see wp.customize.control elements
272
+ * for example wp.customize.control('blogname');
273
+ */
274
+ $disabled_setting_mask = array();
275
+
276
+ /** navigation menu elements */
277
+ $disabled_setting_mask[] = 'nav_menu_item';
278
+ $disabled_setting_mask[] = 'nav_menu[';
279
+ $disabled_setting_mask[] = 'nav_menu_locations';
280
+ $disabled_setting_mask[] = 'new_menu_name';
281
+
282
+ /** widgets */
283
+ $disabled_setting_mask[] = 'widgets';
284
+
285
+ /** color elements */
286
+ $disabled_setting_mask[] = 'color';
287
+
288
+ /** yoast seo */
289
+ $disabled_setting_mask[] = 'wpseo';
290
+
291
+ /** css elements */
292
+ $disabled_setting_mask[] = 'css';
293
+
294
+ /** social networks elements */
295
+ $disabled_setting_mask[] = 'facebook';
296
+ $disabled_setting_mask[] = 'twitter';
297
+ $disabled_setting_mask[] = 'linkedin';
298
+ $disabled_setting_mask[] = 'behance';
299
+ $disabled_setting_mask[] = 'dribbble';
300
+ $disabled_setting_mask[] = 'instagram';
301
+ /** since 1.4.4 */
302
+ $disabled_setting_mask[] = 'tumblr';
303
+ $disabled_setting_mask[] = 'flickr';
304
+ $disabled_setting_mask[] = 'wordpress';
305
+ $disabled_setting_mask[] = 'youtube';
306
+ $disabled_setting_mask[] = 'pinterest';
307
+ $disabled_setting_mask[] = 'github';
308
+ $disabled_setting_mask[] = 'rss';
309
+ $disabled_setting_mask[] = 'google';
310
+ $disabled_setting_mask[] = 'email';
311
+ /** since 1.5.9 */
312
+ $disabled_setting_mask[] = 'dropbox';
313
+ $disabled_setting_mask[] = 'foursquare';
314
+ $disabled_setting_mask[] = 'vine';
315
+ $disabled_setting_mask[] = 'vimeo';
316
+ /** since 1.6.0 */
317
+ $disabled_setting_mask[] = 'yelp';
318
+
319
+ /**
320
+ * Exclude fields from Static Front Page section.
321
+ * It may be added to customizer in many themes.
322
+ *
323
+ * @since 1.7.6
324
+ */
325
+ $disabled_setting_mask[] = 'page_on_front';
326
+ $disabled_setting_mask[] = 'page_for_posts';
327
+
328
+ /**
329
+ * Filter to disable fields in customizer.
330
+ * @see wp.customize.control elements
331
+ * Returning array.
332
+ * @since 1.4.0
333
+ *
334
+ * @param array $disabled_setting_mask An array of disabled masks.
335
+ */
336
+ $disabled_setting_mask = apply_filters( 'wpglobus_customize_disabled_setting_mask', $disabled_setting_mask );
337
+
338
+ $element_selector = array( 'input[type=text]', 'textarea' );
339
+
340
+ /**
341
+ * Filter for element selectors.
342
+ * Returning array.
343
+ * @since 1.4.0
344
+ *
345
+ * @param array $element_selector An array of selectors.
346
+ */
347
+ $element_selector = apply_filters( 'wpglobus_customize_element_selector', $element_selector );
348
+
349
+ $set_link_by = array( 'link', 'url' );
350
+
351
+ /**
352
+ * Filter of masks to determine links.
353
+ * @see value data-customize-setting-link of element
354
+ * Returning array.
355
+ * @since 1.4.0
356
+ *
357
+ * @param array $set_link_by An array of masks.
358
+ */
359
+ $set_link_by = apply_filters( 'wpglobus_customize_setlinkby', $set_link_by );
360
+
361
+ /**
362
+ * Filter of disabled sections.
363
+ *
364
+ * Returning array.
365
+ * @since 1.5.0
366
+ *
367
+ * @param array $disabled_sections An array of sections.
368
+ */
369
+ $disabled_sections = array();
370
+
371
+ $disabled_sections = apply_filters( 'wpglobus_customize_disabled_sections', $disabled_sections );
372
+
373
+ /**
374
+ * Generate language select button for customizer
375
+ * @since 1.6.0
376
+ *
377
+ * @todo http://stackoverflow.com/questions/9607252/how-to-detect-when-an-element-over-another-element-in-javascript
378
+ */
379
+ $attributes['href'] = '#';
380
+ $attributes['style'] = 'margin-left:48px;';
381
+ $attributes['class'] = 'customize-controls-close wpglobus-customize-selector';
382
+
383
+ /**
384
+ * Filter of attributes to generate language selector button.
385
+ * For example @see Divi theme http://www.elegantthemes.com/gallery/divi/ .
386
+ *
387
+ * Returning array.
388
+ * @since 1.6.0
389
+ *
390
+ * @param array $attributes An array of attributes.
391
+ * @param string Name of current theme.
392
+ */
393
+ $attributes = apply_filters( 'wpglobus_customize_language_selector_attrs', $attributes, WPGlobus_Customize_Options::get_theme( 'name' ) );
394
+
395
+ $string = '';
396
+
397
+ foreach ( $attributes as $attribute => $value ) {
398
+ if ( null !== $value ){
399
+ $string .= esc_attr( $attribute ) . '="' . esc_attr( $value ) . '" ';
400
+ }
401
+ }
402
+
403
+ $selector_button = sprintf(
404
+ '<a %1$s data-language="'.WPGlobus::Config()->default_language.'">%2$s</a>',
405
+ trim( $string ),
406
+ '<span class="wpglobus-globe"></span>'
407
+ );
408
+
409
+ /**
410
+ * Since 1.7.9
411
+ */
412
+ $changeset_uuid = null;
413
+ if ( ! empty( $_GET['changeset_uuid'] ) ) { // WPCS: input var ok, sanitization ok.
414
+ $changeset_uuid = sanitize_text_field( wp_unslash( $_GET['changeset_uuid'] ) ); // WPCS: input var ok.
415
+ }
416
+
417
+ /**
418
+ * Since 1.9.0
419
+ */
420
+ $selector_type = 'dropdown';
421
+ $selector_types = array('dropdown', 'switch');
422
+
423
+ /**
424
+ * Filter selector type.
425
+ *
426
+ * @since 1.9.0
427
+ *
428
+ * @param string $selector_type Name of the current selector type.
429
+ * @param array $selector_types An array of existing selector types.
430
+ * @return string
431
+ */
432
+ $selector_type = apply_filters( 'wpglobus_customize_language_selector_type', $selector_type, $selector_types );
433
+
434
+ if ( ! in_array( $selector_type, $selector_types ) ) {
435
+ $selector_type = 'dropdown';
436
+ }
437
+
438
+ wp_enqueue_script(
439
+ 'wpglobus-customize-control190',
440
+ WPGlobus::$PLUGIN_DIR_URL . 'includes/js/wpglobus-customize-control190' . WPGlobus::SCRIPT_SUFFIX() . '.js',
441
+ array( 'jquery' ),
442
+ WPGLOBUS_VERSION,
443
+ true
444
+ );
445
+ wp_localize_script(
446
+ 'wpglobus-customize-control190',
447
+ 'WPGlobusCustomize',
448
+ array(
449
+ 'version' => WPGLOBUS_VERSION,
450
+ 'selectorType' => $selector_type,
451
+ 'selectorButton' => $selector_button,
452
+ 'languageAdmin' => WPGlobus::Config()->language,
453
+ 'disabledSettingMask' => $disabled_setting_mask,
454
+ 'elementSelector' => $element_selector,
455
+ 'setLinkBy' => $set_link_by,
456
+ 'disabledSections' => $disabled_sections,
457
+ 'controlClass' => 'wpglobus-customize-control',
458
+ 'changeset_uuid' => $changeset_uuid
459
+ )
460
+ );
461
+
462
+ }
463
+
464
+ } // class
465
+
466
+ endif;
467
+ # --- EOF
includes/admin/customize/wpglobus-customize-filters.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Filters for customizer
4
+ *
5
+ * All add_filter and add_action calls should be placed here
6
+ *
7
+ * @package WPGlobus\Admin\Customizer
8
+ */
9
+ add_filter( 'wpglobus_customize_disabled_sections', array( 'WPGlobus_Customize_Filters', 'disable_sections' ) );
10
+
11
+ if ( ! class_exists( 'WPGlobus_Customize_Filters' ) ) :
12
+
13
+ /**
14
+ * Class WPGlobus_Customize_Filters
15
+ */
16
+ class WPGlobus_Customize_Filters {
17
+
18
+ /**
19
+ * Disable sections in customizer.
20
+ *
21
+ * @param array $disabled_sections
22
+ *
23
+ * @return array
24
+ */
25
+ public static function disable_sections( $disabled_sections ) {
26
+
27
+ if ( class_exists( 'Easy_Google_Fonts' ) ) {
28
+ /**
29
+ * @see https://wordpress.org/plugins/easy-google-fonts/
30
+ */
31
+ $disabled_sections[] = 'tt_font_typography';
32
+ }
33
+
34
+ return $disabled_sections;
35
+
36
+ }
37
+
38
+ }
39
+
40
+ endif;
includes/admin/customize/wpglobus-customize.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * File: wpglobus-customize.php
4
+ *
5
+ * @package WPGlobus\Admin\Customizer
6
+ */
7
+
8
+ global $wp_version;
9
+
10
+ if ( !defined('WPGLOBUS_CUSTOMIZE') || WPGLOBUS_CUSTOMIZE ) {
11
+
12
+ if ( version_compare( $wp_version, '4.9-Beta1', '>=' ) ) {
13
+ require_once 'class-wpglobus-customize190.php';
14
+ } else if( version_compare( $wp_version, '4.6', '>=' ) ) {
15
+ require_once 'class-wpglobus-customize170.php';
16
+ } else {
17
+ require_once 'class-wpglobus-customize140.php';
18
+ }
19
+ WPGlobus_Customize::controller();
20
+
21
+ }
22
+ # --- EOF
includes/admin/debug/class-wpglobus-admin-debug.php ADDED
@@ -0,0 +1,238 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WPGlobus / Admin / Debug
4
+ *
5
+ * @package WPGlobus\Admin
6
+ */
7
+
8
+ // .
9
+ if ( ! class_exists( 'WPGlobus_Admin_Debug' ) ) :
10
+
11
+ /**
12
+ * Class WPGlobus_Admin_Debug.
13
+ *
14
+ * @since 1.8.1
15
+ */
16
+ class WPGlobus_Admin_Debug {
17
+
18
+ /**
19
+ * Instance.
20
+ *
21
+ * @var WPGlobus_Admin_Debug
22
+ */
23
+ protected static $instance;
24
+
25
+ /**
26
+ * Get instance.
27
+ */
28
+ public static function get_instance() {
29
+ if ( null === self::$instance ) {
30
+ self::$instance = new self();
31
+ }
32
+
33
+ return self::$instance;
34
+ }
35
+
36
+ /**
37
+ * Constructor.
38
+ */
39
+ public function __construct() {
40
+
41
+ /**
42
+ * Action.
43
+ *
44
+ * @scope admin
45
+ * @since 1.8.1
46
+ */
47
+ add_action( 'admin_print_scripts', array( $this, 'on__admin_scripts' ), 99 );
48
+
49
+ /**
50
+ * Action.
51
+ *
52
+ * @scope admin
53
+ * @since 1.8.1
54
+ */
55
+ add_action( 'admin_print_styles', array( $this, 'on__admin_styles' ), 99 );
56
+
57
+ /**
58
+ * Action.
59
+ *
60
+ * @scope admin
61
+ * @since 1.8.1
62
+ */
63
+ add_action( 'admin_footer', array( $this, 'on__admin_footer' ), 9999 );
64
+
65
+ }
66
+
67
+ /**
68
+ * Enqueue admin styles.
69
+ *
70
+ * @scope admin
71
+ * @since 1.8.1
72
+ */
73
+ public function on__admin_styles() {
74
+
75
+ wp_register_style(
76
+ 'wpglobus-admin-debug',
77
+ WPGlobus::plugin_dir_url() . 'includes/css/wpglobus-admin-debug' . WPGlobus::SCRIPT_SUFFIX() . '.css',
78
+ array(),
79
+ WPGLOBUS_VERSION
80
+ );
81
+ wp_enqueue_style( 'wpglobus-admin-debug' );
82
+
83
+ }
84
+
85
+ /**
86
+ * Enqueue admin scripts.
87
+ *
88
+ * @scope admin
89
+ * @since 1.8.1
90
+ */
91
+ public function on__admin_scripts() {
92
+
93
+ wp_register_script(
94
+ 'wpglobus-admin-debug',
95
+ WPGlobus::plugin_dir_url() . 'includes/js/wpglobus-admin-debug' . WPGlobus::SCRIPT_SUFFIX() . '.js',
96
+ array( 'jquery' ),
97
+ WPGLOBUS_VERSION,
98
+ true
99
+ );
100
+ wp_enqueue_script( 'wpglobus-admin-debug' );
101
+ wp_localize_script(
102
+ 'wpglobus-admin-debug',
103
+ 'WPGlobusAdminDebug',
104
+ array(
105
+ 'version' => WPGLOBUS_VERSION,
106
+ 'data' => '',
107
+ )
108
+ );
109
+
110
+ }
111
+
112
+ /**
113
+ * Output table.
114
+ *
115
+ * @scope admin
116
+ * @since 1.8.1
117
+ */
118
+ public function on__admin_footer() {
119
+
120
+ global $post;
121
+
122
+ if ( ! is_object( $post ) ) {
123
+ return;
124
+ }
125
+
126
+ if ( empty( $post->ID ) || 0 === (int) $post->ID ) {
127
+ return;
128
+ }
129
+
130
+ /**
131
+ * Get metadata.
132
+ *
133
+ * @var array $metas
134
+ */
135
+ $metas = get_metadata( 'post', $post->ID );
136
+
137
+ ?>
138
+ <div id="wpglobus-admin-debug-box" class="" style="display:none;">
139
+ <h4>WPGlobus debug box</h4>
140
+ <?php
141
+ /**
142
+ * Get metadata.
143
+ */
144
+ ?>
145
+ <table class="table1" cellspacing="0">
146
+ <caption><?php echo 'get_metadata( "post", ' . esc_html( $post->ID ) . ' )'; ?></caption>
147
+ <thead>
148
+ <tr>
149
+ <th>№</th>
150
+ <th>meta</th>
151
+ <th>value</th>
152
+ </tr>
153
+ </thead>
154
+ <tbody>
155
+ <?php
156
+ $order = 1;
157
+
158
+ foreach ( $metas as $meta_key => $meta ) {
159
+ $code = false;
160
+ if ( is_array( $meta ) ) {
161
+ foreach ( $meta as $key => $val ) {
162
+ $meta[ $key ] = htmlspecialchars( $val );
163
+ }
164
+ } elseif ( is_string( $meta ) ) {
165
+ $meta = htmlspecialchars( $meta );
166
+ }
167
+ ?>
168
+ <tr>
169
+ <td><?php echo esc_html( $order ); ?></td>
170
+ <td><?php echo esc_html( print_r( $meta_key, true ) ); ?></td>
171
+ <?php if ( $code ) { ?>
172
+ <td>
173
+ <pre><?php echo esc_html( print_r( $meta, true ) ); ?></pre>
174
+ </td>
175
+ <?php } else { ?>
176
+ <td><?php echo esc_html( print_r( $meta, true ) ); ?></td>
177
+ <?php } ?>
178
+ </tr>
179
+ <?php $order ++; ?>
180
+ <?php } ?>
181
+ </tbody>
182
+ </table>
183
+ <?php
184
+ /**
185
+ * Get options.
186
+ */
187
+ global $wpdb;
188
+ $query = "SELECT * FROM $wpdb->options WHERE option_name LIKE '%wpglobus%'";
189
+ $results = $wpdb->get_results( $query );
190
+ ?>
191
+ <table class="table2" cellspacing="0">
192
+ <caption><?php echo '"SELECT * FROM $wpdb->options WHERE option_name LIKE \'%wpglobus%\'"'; ?></caption>
193
+ <caption><?php echo 'Option count: ' . count( $results ); ?></caption>
194
+ <thead>
195
+ <tr>
196
+ <th>Option ID</th>
197
+ <th>Option Name</th>
198
+ <th>Option Value</th>
199
+ </tr>
200
+ </thead>
201
+ <tbody>
202
+ <?php
203
+
204
+ $order = 1;
205
+
206
+ foreach ( $results as $option_key => $option ) {
207
+ $code = false;
208
+ if ( is_array( $option->option_value ) ) {
209
+ foreach ( $option->option_value as $key => $value ) {
210
+ $option->option_value[ $key ] = htmlspecialchars( $value );
211
+ }
212
+ } elseif ( is_string( $option->option_value ) ) {
213
+ $option->option_value = htmlspecialchars( $option->option_value );
214
+ }
215
+ ?>
216
+ <tr>
217
+ <td><?php echo esc_html( $option->option_id ); ?></td>
218
+ <td><?php echo esc_html( print_r( $option->option_name, true ) ); ?></td>
219
+ <?php if ( $code ) { ?>
220
+ <td>
221
+ <pre><?php echo esc_html( print_r( $option->option_value, true ) ); ?></pre>
222
+ </td>
223
+ <?php } else { ?>
224
+ <td><?php echo esc_html( print_r( $option->option_value, true ) ); ?></td>
225
+ <?php } ?>
226
+ </tr>
227
+ <?php $order ++; ?>
228
+ <?php } ?>
229
+ </tbody>
230
+ </table>
231
+ </div>
232
+
233
+ <?php
234
+ }
235
+
236
+ }
237
+
238
+ endif;
includes/admin/helpdesk/beacon-loader.min.js ADDED
@@ -0,0 +1 @@
 
1
+ !function(e,o,n){window.HSCW=o,window.HS=n,n.beacon=n.beacon||{};var t=n.beacon;t.userConfig={},t.readyQueue=[],t.config=function(e){this.userConfig=e},t.ready=function(e){this.readyQueue.push(e)},o.config={docs:{enabled:!1,baseUrl:""},contact:{enabled:!0,formId:"2f91ec29-4d3d-11e6-aae8-0a7d6919297d"}};var r=e.getElementsByTagName("script")[0],c=e.createElement("script");c.type="text/javascript",c.async=!0,c.src="https://djtflbt20bdde.cloudfront.net/",r.parentNode.insertBefore(c,r)}(document,window.HSCW||{},window.HS||{});
includes/admin/helpdesk/class-wpglobus-admin-helpdesk.php ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * File: class-wpglobus-admin-helpdesk.php
4
+ *
5
+ * @package WPGlobus\Admin\HelpDesk
6
+ */
7
+
8
+
9
+ /**
10
+ * Class WPGlobus_Admin_HelpDesk.
11
+ * The Contact Support form.
12
+ */
13
+ class WPGlobus_Admin_HelpDesk {
14
+
15
+ /**
16
+ * CSS class for the menu icon.
17
+ * @var string
18
+ */
19
+ const ICON_CLASS = 'dashicons dashicons-before dashicons-format-chat';
20
+
21
+ /**
22
+ * Admin page title.
23
+ * @var string
24
+ */
25
+ public static $page_title;
26
+ /**
27
+ * Admin menu title.
28
+ * @var string
29
+ */
30
+ protected static $menu_title;
31
+ /**
32
+ * Admin menu tooltip.
33
+ * @var string
34
+ */
35
+ protected static $menu_tooltip;
36
+ /**
37
+ * Admin page URL.
38
+ * @var string
39
+ */
40
+ public static $admin_page_url;
41
+
42
+ /**
43
+ * Static "constructor".
44
+ */
45
+ public static function construct() {
46
+ self::set_hooks();
47
+ }
48
+
49
+ /**
50
+ * Set class variables.
51
+ */
52
+ public static function set_vars() {
53
+ self::$page_title = __( 'WPGlobus Help Desk', 'wpglobus' );
54
+ self::$menu_title = __( 'Help Desk', 'wpglobus' );
55
+ self::$menu_tooltip = __( 'Contact WPGlobus Support', 'wpglobus' );
56
+
57
+ self::$admin_page_url = admin_url( 'admin.php?page=' ) .
58
+ WPGlobus::PAGE_WPGLOBUS_HELPDESK;
59
+ }
60
+
61
+ /**
62
+ * Setup actions and filters.
63
+ */
64
+ protected static function set_hooks() {
65
+ add_action( 'admin_init', array( __CLASS__, 'set_vars' ) );
66
+ add_action( 'admin_menu', array( __CLASS__, 'add_menu' ) );
67
+ add_action( 'admin_footer', array( __CLASS__, 'show_submenu' ), PHP_INT_MAX );
68
+ }
69
+
70
+ /**
71
+ * Add a hidden admin menu item.
72
+ * It will become visible in @see WPGlobus_Admin_HelpDesk::show_submenu
73
+ */
74
+ public static function add_menu() {
75
+ add_submenu_page(
76
+ null,
77
+ '',
78
+ '',
79
+ 'administrator',
80
+ WPGlobus::PAGE_WPGLOBUS_HELPDESK,
81
+ array( __CLASS__, 'helpdesk_page' )
82
+ );
83
+ }
84
+
85
+ /**
86
+ * Make the admin menu item visible.
87
+ * This is a workaround because the WPGlobus options panel is made by ReduxFramework.
88
+ */
89
+ public static function show_submenu() {
90
+ ?>
91
+ <script>
92
+ jQuery(function ($) {
93
+ $('#toplevel_page_wpglobus_options')
94
+ .find("ul")
95
+ .prepend($("<li>")
96
+ .append($("<a>")
97
+ .attr({
98
+ href: "<?php echo esc_url( self::$admin_page_url ); ?>",
99
+ title: "<?php echo esc_js( self::$menu_tooltip ); ?>"
100
+ })
101
+ .html(' <?php echo esc_js( self::$menu_title ); ?>')
102
+ .prepend($("<span>")
103
+ .attr({"class": "<?php echo esc_js( self::ICON_CLASS ); ?>"})
104
+ )
105
+ )
106
+ );
107
+ });
108
+ </script>
109
+ <?php
110
+ }
111
+
112
+ /**
113
+ * The admin page.
114
+ */
115
+ public static function helpdesk_page() {
116
+ $data = self::get_data();
117
+
118
+ include dirname( __FILE__ ) . '/wpglobus-admin-helpdesk-page.php';
119
+
120
+ // Split one-cell formatted list of plugins into the separate rows.
121
+ $active_plugins = explode( ', ', $data['active_plugins'] );
122
+ unset( $data['active_plugins'] );
123
+ foreach ( $active_plugins as $active_plugin ) {
124
+ list( $name, $version ) = explode( ':', $active_plugin );
125
+ $data[ $name ] = $version;
126
+ }
127
+ ?>
128
+
129
+ <script>
130
+ <?php require dirname( __FILE__ ) . '/beacon-loader.min.js'; ?>
131
+ HS.beacon.config({
132
+ icon: 'message',
133
+ attachment: 1,
134
+ poweredBy: 0
135
+ });
136
+
137
+ jQuery(function ($) {
138
+ HS.beacon.ready(function () {
139
+ //noinspection JSUnresolvedFunction
140
+ HS.beacon.identify(<?php echo wp_kses( wp_json_encode( $data ), array() );?>);
141
+ });
142
+
143
+ // Set a special class for the menu item.
144
+ $(".wpglobus_admin_hs_beacon_toggle").on("click", function (e) {
145
+ e.preventDefault();
146
+ HS.beacon.toggle();
147
+ });
148
+ });
149
+ </script>
150
+ <?php
151
+ }
152
+
153
+ /**
154
+ * Collect data for the beacon.
155
+ * @return array
156
+ */
157
+ protected static function get_data() {
158
+ $user = wp_get_current_user();
159
+ $theme = wp_get_theme();
160
+
161
+ /**
162
+ * @see php_uname can be disabled in php.ini for security reasons
163
+ * disable_functions=php_uname
164
+ * @since 1.7.13
165
+ */
166
+ $OS = 'Unknown';
167
+ if ( function_exists( 'php_uname' ) ) {
168
+ $OS = implode( ' ', array(
169
+ php_uname( 's' ),
170
+ php_uname( 'r' ),
171
+ php_uname( 'v' ),
172
+ ) );
173
+ }
174
+
175
+ $data = array(
176
+ 'name' => WPGlobus_Filters::filter__text( $user->display_name ),
177
+ 'email' => $user->user_email,
178
+ 'home_url' => home_url(),
179
+ 'site_url' => site_url(),
180
+ 'REMOTE_ADDR' => sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ), // WPCS: input var ok, sanitization ok.
181
+ 'SERVER_PORT' => sanitize_text_field( wp_unslash( $_SERVER['SERVER_PORT'] ) ), // WPCS: input var ok, sanitization ok.
182
+ 'OS' => $OS,
183
+ 'PHP_SAPI' => PHP_SAPI,
184
+ 'PHP_VERSION' => PHP_VERSION,
185
+ 'loaded_extensions' => implode( ', ', get_loaded_extensions() ),
186
+ 'wp_version' => $GLOBALS['wp_version'],
187
+ 'is_multisite' => is_multisite() ? 'Y' : 'N',
188
+ 'theme' => $theme->display( 'Name' ) . ' ' . $theme->display( 'ThemeURI' ) . ' by ' . $theme->get( 'Author' ) . ' ' . $theme->get( 'AuthorURI' ) . ( is_child_theme() ? '; child of ' . $theme->display( 'Template' ) : '' ),
189
+ 'enabled_languages' => implode( ', ', WPGlobus::Config()->enabled_languages ),
190
+ );
191
+
192
+ // The list of plugins is formatted here for display on the admin page,
193
+ // to fit into one table cell.
194
+ $active_plugins = array();
195
+ foreach ( wp_get_active_and_valid_plugins() as $plugin ) {
196
+ $plugin_data = get_plugin_data( $plugin );
197
+ $plugin_file = str_replace( trailingslashit( WP_PLUGIN_DIR ), '', dirname( $plugin ) );
198
+
199
+ $active_plugins[] = $plugin_file . ':' . $plugin_data['Version'];
200
+ }
201
+ $data['active_plugins'] = implode( ', ', $active_plugins );
202
+
203
+ return $data;
204
+
205
+ }
206
+ }
207
+
208
+ /* EOF */
includes/admin/helpdesk/wpglobus-admin-helpdesk-page.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * File: view-page.php
4
+ *
5
+ * @package WPGlobus\Admin\HelpDesk
6
+ * @global string[] $data
7
+ */
8
+
9
+ // Exit if accessed directly
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit;
12
+ }
13
+
14
+ WPGlobus_Admin_Page::print_header();
15
+
16
+ ?>
17
+
18
+ <h2 class="nav-tab-wrapper wp-clearfix">
19
+ <a href="#" class="nav-tab nav-tab-active">
20
+ <?php WPGlobus_Admin_Page::nav_tab_icon_e( 'Helpdesk' ); ?>
21
+ <?php echo esc_html( WPGlobus_Admin_HelpDesk::$page_title ); ?>
22
+ </a>
23
+ <a href="<?php echo esc_url( WPGlobus_Admin_Page::url_settings() ); ?>"
24
+ class="nav-tab">
25
+ <?php WPGlobus_Admin_Page::nav_tab_icon_e( 'Settings' ); ?>
26
+ <?php esc_html_e( 'Settings' ); ?>
27
+ </a>
28
+ <a href="<?php echo esc_url( WPGlobus_Admin_Page::url_addons() ); ?>"
29
+ class="nav-tab">
30
+ <?php WPGlobus_Admin_Page::nav_tab_icon_e( 'Add-ons' ); ?>
31
+ <?php esc_html_e( 'Add-ons', 'wpglobus' ); ?>
32
+ </a>
33
+ <a href="<?php echo esc_url( WPGlobus_Utils::url_wpglobus_site() . 'quick-start/' ); ?>"
34
+ target="_blank"
35
+ class="nav-tab">
36
+ <?php WPGlobus_Admin_Page::nav_tab_icon_e( 'Guide' ); ?>
37
+ <?php esc_html_e( 'Guide', 'wpglobus' ); ?>
38
+ </a>
39
+ <a href="<?php echo esc_url( WPGlobus_Utils::url_wpglobus_site() . 'faq/' ); ?>"
40
+ target="_blank"
41
+ class="nav-tab">
42
+ <?php WPGlobus_Admin_Page::nav_tab_icon_e( 'FAQ' ); ?>
43
+ <?php esc_html_e( 'FAQ', 'wpglobus' ); ?>
44
+ </a>
45
+ <a href="<?php echo esc_url( WPGlobus_Utils::url_wpglobus_site() ); ?>"
46
+ target="_blank"
47
+ class="nav-tab">
48
+ <?php WPGlobus_Admin_Page::nav_tab_icon_e( 'globe' ); ?>
49
+ <?php echo esc_html( 'WPGlobus.com' ); ?>
50
+ </a>
51
+ </h2>
52
+ <div class="feature-main feature-section col two-col">
53
+ <div class="col">
54
+ <p><em>
55
+ <?php esc_html_e( 'Thank you for using WPGlobus!', 'wpglobus' ); ?>
56
+ <?php esc_html_e( 'Our Support Team is here to answer your questions or concerns.', 'wpglobus' ); ?>
57
+ </em></p>
58
+ <p>&bull; <a href="#" class="wpglobus_admin_hs_beacon_toggle"><?php esc_html_e( 'Click the blue round button at the bottom right to open the Contact Form.', 'wpglobus' ); ?></a></p>
59
+ <p>&bull; <?php esc_html_e( 'Type in your name, email, subject and the detailed message.', 'wpglobus' ); ?></p>
60
+ <p>&bull; <?php esc_html_e( 'If you can make a screenshot demonstrating the problem, please attach it.', 'wpglobus' ); ?></p>
61
+ <p class="highlight"><?php esc_html_e( 'Please note: we will receive some debug data together with your request. See the "Technical Information" table for the details.', 'wpglobus' ); ?></p>
62
+
63
+ <h4><?php esc_html_e( 'To help us serve you better:', 'wpglobus' ); ?></h4>
64
+ <ul>
65
+ <li><?php esc_html_e( 'Please check if the problem persists if you switch to a standard WordPress theme.', 'wpglobus' ); ?></li>
66
+ <li><?php esc_html_e( 'Try deactivating other plugins to see if any of them conflicts with WPGlobus.', 'wpglobus' ); ?></li>
67
+ </ul>
68
+ <hr />
69
+ <p><em><?php esc_html_e( 'Sincerely Yours,', 'wpglobus' ); ?></em></p>
70
+ <p><em><?php esc_html_e( 'The WPGlobus Team', 'wpglobus' ); ?></em></p>
71
+ </div>
72
+ <div class="col last-feature">
73
+ <h4><?php esc_html_e( 'Technical Information', 'wpglobus' ); ?></h4>
74
+ <table class="widefat striped">
75
+ <tbody>
76
+ <?php
77
+ foreach ( $data as $key => $value ) {
78
+ if ( in_array( $key, array( 'name', 'email' ), true ) ) {
79
+ continue;
80
+ }
81
+ echo '<tr><th>' . esc_html( $key ) .
82
+ '</th><td>' . esc_html( $value ) .
83
+ '</td></tr>';
84
+ }
85
+ ?>
86
+ </tbody>
87
+ </table>
88
+ </div>
89
+ </div>
90
+ <?php
91
+
92
+ WPGlobus_Admin_Page::print_footer();
93
+
94
+ /* EOF */
includes/admin/media/class-wpglobus-media.php ADDED
@@ -0,0 +1,339 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package WPGlobus
4
+ */
5
+
6
+ /**
7
+ * Class WPGlobus_Media.
8
+ *
9
+ * @since 1.7.3
10
+ */
11
+ if ( ! class_exists( 'WPGlobus_Media' ) ) :
12
+
13
+ class WPGlobus_Media {
14
+
15
+ /**
16
+ * Instance.
17
+ */
18
+ protected static $instance;
19
+
20
+ /**
21
+ * Post types to work on media page.
22
+ */
23
+ protected $enabled_post_types = array();
24
+
25
+ /**
26
+ * Get instance.
27
+ */
28
+ public static function get_instance(){
29
+ if( null == self::$instance ){
30
+ self::$instance = new self();
31
+ }
32
+ return self::$instance;
33
+ }
34
+
35
+ /**
36
+ * Constructor.
37
+ */
38
+ public function __construct() {
39
+
40
+ $this->enabled_post_types[] = 'attachment';
41
+
42
+ /**
43
+ * @scope admin
44
+ * @since 1.7.3
45
+ */
46
+ add_action( 'edit_form_after_editor', array(
47
+ $this,
48
+ 'language_tabs'
49
+ ) );
50
+
51
+ /**
52
+ * @scope admin
53
+ * @since 1.7.3
54
+ */
55
+ add_action( 'admin_print_scripts', array(
56
+ $this,
57
+ 'media__admin_scripts'
58
+ ) );
59
+
60
+ /**
61
+ * @scope admin
62
+ * @since 1.7.3
63
+ */
64
+ add_action( 'admin_print_scripts', array(
65
+ $this,
66
+ 'post_php__admin_scripts'
67
+ ), 5 );
68
+
69
+ /**
70
+ * @scope admin
71
+ * @since 1.7.3
72
+ */
73
+ add_action( 'admin_print_styles', array(
74
+ $this,
75
+ 'action__admin_styles'
76
+ ) );
77
+
78
+ /**
79
+ * @scope admin
80
+ * @see filter 'media_send_to_editor' in media.php
81
+ * @since 1.7.3
82
+ */
83
+ add_filter( 'media_send_to_editor', array(
84
+ $this,
85
+ 'filter__media_send_to_editor'
86
+ ), 5, 3 );
87
+
88
+
89
+ }
90
+
91
+ /**
92
+ * Check for enabled post types.
93
+ *
94
+ * @scope admin
95
+ * @since 1.7.3
96
+ *
97
+ * @param string $html HTML.
98
+ * @param int $id Unused.
99
+ * @param array $attachment Attachment.
100
+ *
101
+ * @return boolean
102
+ */
103
+ public function filter__media_send_to_editor( $html, $id, $attachment ) {
104
+
105
+ $fields = array(
106
+ 'post_content',
107
+ 'post_excerpt',
108
+ 'image_alt',
109
+ );
110
+
111
+ $current_language = WPGlobus::Config()->default_language;
112
+ if ( ! empty( $_POST['wpglobusLanguageTab'] ) ) { // WPCS: input var ok, sanitization ok.
113
+ /**
114
+ * See wpglobus-media.js
115
+ */
116
+ $current_language = sanitize_text_field( wp_unslash( $_POST['wpglobusLanguageTab'] ) ); // WPCS: input var ok, sanitization ok.
117
+
118
+ if ( ! in_array( $current_language, WPGlobus::Config()->enabled_languages, true ) ) {
119
+ return $html;
120
+ }
121
+ }
122
+
123
+ foreach ( $fields as $field ) {
124
+ if ( ! empty( $attachment[ $field ] ) && WPGlobus_Core::has_translations( $attachment[ $field ] ) ) {
125
+ $html = str_replace( $attachment[ $field ], WPGlobus_Core::text_filter( $attachment[ $field ], $current_language ), $html );
126
+ }
127
+ }
128
+
129
+ return $html;
130
+ }
131
+
132
+ /**
133
+ * Check for enabled post types.
134
+ *
135
+ * @scope admin
136
+ * @since 1.7.3
137
+ * @access public
138
+ *
139
+ * @return boolean
140
+ */
141
+ public function is_enabled() {
142
+
143
+ global $post;
144
+
145
+ if ( empty( $post ) ) {
146
+ return false;
147
+ }
148
+
149
+ if ( in_array( $post->post_type, $this->enabled_post_types ) ) {
150
+ return true;
151
+ }
152
+
153
+ return false;
154
+
155
+ }
156
+
157
+ /**
158
+ * Enqueue admin scripts on post.php page.
159
+ *
160
+ * @scope admin
161
+ * @since 1.7.3
162
+ * @access public
163
+ *
164
+ * @return void
165
+ */
166
+ public function post_php__admin_scripts() {
167
+
168
+ global $post;
169
+
170
+ if ( empty( $post ) ) {
171
+ return;
172
+ }
173
+
174
+ if ( in_array( $post->post_type, array( 'attachment' ) ) ) {
175
+ /**
176
+ * Don't load on edit media page.
177
+ */
178
+ return;
179
+ }
180
+
181
+ wp_register_script(
182
+ 'wpglobus-media-post-php',
183
+ WPGlobus::$PLUGIN_DIR_URL . 'includes/js/wpglobus-media-post-php' . WPGlobus::SCRIPT_SUFFIX() . '.js',
184
+ array(),
185
+ WPGLOBUS_VERSION,
186
+ true
187
+ );
188
+ wp_enqueue_script( 'wpglobus-media-post-php' );
189
+
190
+ }
191
+
192
+ /**
193
+ * Enqueue admin scripts.
194
+ *
195
+ * @scope admin
196
+ * @since 1.7.3
197
+ * @access public
198
+ *
199
+ * @return void
200
+ */
201
+ public function media__admin_scripts() {
202
+
203
+ if ( ! $this->is_enabled() ) {
204
+ return;
205
+ }
206
+
207
+ /**
208
+ * WordPress 4.7+ needs a new version of our admin JS.
209
+ * @since 1.7.0
210
+ */
211
+ $version = '';
212
+ if ( version_compare( $GLOBALS['wp_version'], '4.6.999', '>' ) ) {
213
+ $version = '-47';
214
+ }
215
+
216
+ wp_register_script(
217
+ 'wpglobus-admin',
218
+ WPGlobus::$PLUGIN_DIR_URL . "includes/js/wpglobus-admin$version" . WPGlobus::SCRIPT_SUFFIX() . ".js",
219
+ array( 'jquery', 'jquery-ui-dialog', 'jquery-ui-tabs' ),
220
+ WPGLOBUS_VERSION,
221
+ true
222
+ );
223
+ wp_enqueue_script( 'wpglobus-admin' );
224
+ wp_localize_script(
225
+ 'wpglobus-admin',
226
+ 'WPGlobusAdmin',
227
+ array(
228
+ 'version' => WPGLOBUS_VERSION,
229
+ 'i18n' => array(),
230
+ 'data' => array(
231
+ 'default_language' => WPGlobus::Config()->default_language
232
+ )
233
+ )
234
+ );
235
+
236
+ wp_localize_script(
237
+ 'wpglobus-admin',
238
+ 'WPGlobusCoreData',
239
+ array(
240
+ 'multisite' => 'false',
241
+ 'default_language' => WPGlobus::Config()->default_language,
242
+ 'enabled_languages' => WPGlobus::Config()->enabled_languages,
243
+ 'locale_tag_start' => WPGlobus::LOCALE_TAG_START,
244
+ 'locale_tag_end' => WPGlobus::LOCALE_TAG_END
245
+ )
246
+ );
247
+
248
+ wp_register_script(
249
+ 'wpglobus-media',
250
+ WPGlobus::$PLUGIN_DIR_URL . "includes/js/wpglobus-media" . WPGlobus::SCRIPT_SUFFIX() . ".js",
251
+ array( 'jquery', 'wpglobus-admin' ),
252
+ WPGLOBUS_VERSION,
253
+ true
254
+ );
255
+ wp_enqueue_script( 'wpglobus-media' );
256
+ wp_localize_script(
257
+ 'wpglobus-media',
258
+ 'WPGlobusMedia',
259
+ array(
260
+ 'version' => WPGLOBUS_VERSION,
261
+ 'language' => WPGlobus::Config()->default_language,
262
+ 'defaultLanguage' => WPGlobus::Config()->default_language,
263
+ 'enabledLanguages' => WPGlobus::Config()->enabled_languages,
264
+ 'attachment' => array(
265
+ 'caption' => 'attachment_caption',
266
+ 'alt' => 'attachment_alt',
267
+ 'description' => 'attachment_content',
268
+ 'title' => 'title'
269
+ )
270
+ )
271
+ );
272
+ }
273
+
274
+ /**
275
+ * Enqueue admin styles.
276
+ *
277
+ * @scope admin
278
+ * @since 1.7.3
279
+ * @access public
280
+ *
281
+ * @return void
282
+ */
283
+ public function action__admin_styles() {
284
+
285
+ if ( ! $this->is_enabled() ) {
286
+ return;
287
+ }
288
+
289
+ wp_register_style(
290
+ 'wpglobus-admin-tabs',
291
+ WPGlobus::$PLUGIN_DIR_URL . 'includes/css/wpglobus-admin-tabs' . WPGlobus::SCRIPT_SUFFIX() . '.css',
292
+ array(),
293
+ WPGLOBUS_VERSION,
294
+ 'all'
295
+ );
296
+ wp_enqueue_style( 'wpglobus-admin-tabs' );
297
+
298
+ }
299
+
300
+ /**
301
+ * Add language tabs on media page.
302
+ *
303
+ * @scope admin
304
+ * @since 1.7.3
305
+ * @access public
306
+ *
307
+ * @return void
308
+ */
309
+ public function language_tabs() {
310
+
311
+ if ( ! $this->is_enabled() ) {
312
+ return;
313
+ }
314
+
315
+ ?>
316
+ <div id="wpglobus-media-body-tabs" style="margin-top:20px;" class="wpglobus-post-body-tabs">
317
+ <ul class="wpglobus-post-body-tabs-list"> <?php
318
+ $order = 0;
319
+ foreach ( WPGlobus::Config()->open_languages as $language ) {
320
+ $tab_suffix = $language == WPGlobus::Config()->default_language ? 'default' : $language; ?>
321
+ <li id="link-tab-<?php echo esc_attr( $tab_suffix ); ?>" data-language="<?php echo esc_attr( $language ); ?>"
322
+ data-order="<?php echo esc_attr( $order ); ?>"
323
+ class="wpglobus-post-tab">
324
+ <a href="#tab-<?php echo esc_attr( $tab_suffix ); ?>"><?php echo esc_html( WPGlobus::Config()->en_language_name[ $language ] ); ?></a>
325
+ </li> <?php
326
+ $order ++;
327
+ } ?>
328
+ </ul> <?php
329
+ foreach ( WPGlobus::Config()->open_languages as $language ) {
330
+ $tab_suffix = $language == WPGlobus::Config()->default_language ? 'default' : $language; ?>
331
+ <div id="tab-<?php echo esc_attr( $tab_suffix ); ?>" style="display:none;"></div> <?php
332
+ } ?>
333
+ </div>
334
+ <?php
335
+ }
336
+
337
+ }
338
+
339
+ endif;
includes/admin/recommendations/class-wpglobus-admin-recommendations.php ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WPGlobus Recommendations.
4
+ *
5
+ * @package WPGlobus\Admin
6
+ *
7
+ * @since 1.8.7
8
+ */
9
+
10
+ /**
11
+ * Class Admin Recommendations.
12
+ */
13
+ class WPGlobus_Admin_Recommendations {
14
+
15
+ /**
16
+ * Setup actions and filters.
17
+ */
18
+ public static function setup_hooks() {
19
+ add_filter( 'woocommerce_general_settings', array( __CLASS__, 'for_woocommerce' ) );
20
+ add_filter( 'wpglobus_edit_slug_box', array( __CLASS__, 'wpg_plus_slug' ) );
21
+ }
22
+
23
+ /**
24
+ * Recommendations for WooCommerce.
25
+ *
26
+ * @internal
27
+ *
28
+ * @param array $settings Passed by WooCommerce.
29
+ *
30
+ * @return array
31
+ */
32
+ public static function for_woocommerce( $settings ) {
33
+ // Ugly set of "IFs" to display heading only if needed, and only once.
34
+ $need_to_show_wc_heading = false;
35
+ $need_to_recommend_wpg_wc = false;
36
+ $need_to_recommend_wpg_mc = false;
37
+
38
+ if ( ! is_plugin_active( 'woocommerce-wpglobus/woocommerce-wpglobus.php' ) ) {
39
+ $need_to_show_wc_heading = true;
40
+ $need_to_recommend_wpg_wc = true;
41
+ }
42
+
43
+ if ( ! is_plugin_active( 'wpglobus-multi-currency/wpglobus-multi-currency.php' ) ) {
44
+ $need_to_show_wc_heading = true;
45
+ $need_to_recommend_wpg_mc = true;
46
+ }
47
+
48
+ if ( $need_to_show_wc_heading ) {
49
+ $id = 'wpglobus-recommend-wc-heading';
50
+ $title = '';
51
+ $desc =
52
+ '<h2><span class="wp-ui-notification" style="padding:10px 20px;">' .
53
+ '<span class="dashicons dashicons-admin-site"></span> ' .
54
+ esc_html__( 'WPGlobus Recommends:', 'wpglobus' ) .
55
+ '</span></h2>';
56
+
57
+ self::add_wc_section( $settings, $id, $title, $desc );
58
+ }
59
+
60
+ if ( $need_to_recommend_wpg_wc ) {
61
+ $url = WPGlobus_Utils::url_wpglobus_site() . 'product/woocommerce-wpglobus/';
62
+ $id = 'wpglobus-recommend-wpg-wc';
63
+ $title = '&bull; ' . esc_html__( 'WPGlobus for WooCommerce', 'wpglobus' );
64
+ $desc =
65
+ '<p class="wp-ui-text-notification">' .
66
+ '<strong>' .
67
+ esc_html__( 'Translate product titles and descriptions, product categories, tags and attributes.', 'wpglobus' ) .
68
+ '</strong>' .
69
+ '</p>' .
70
+ '<p>' .
71
+ '<strong>' .
72
+ esc_html__( 'Get it now:', 'wpglobus' ) . ' ' .
73
+ '</strong>' .
74
+ '<a href="' . esc_url( $url ) . '">' . esc_html( $url ) . '</a>' .
75
+ '</p>';
76
+ self::add_wc_section( $settings, $id, $title, $desc );
77
+ }
78
+
79
+ if ( $need_to_recommend_wpg_mc ) {
80
+ $url = WPGlobus_Utils::url_wpglobus_site() . 'product/wpglobus-multi-currency/';
81
+ $id = 'wpglobus-recommend-wpg-mc';
82
+ $title = '&bull; ' . __( 'WPGlobus Multi-Currency', 'wpglobus' );
83
+ $desc =
84
+ '<p class="wp-ui-text-notification">' .
85
+ '<strong>' .
86
+ esc_html__( 'Accept multiple currencies in your online store!', 'wpglobus' ) .
87
+ '</strong>' .
88
+ '</p>' .
89
+ '<p>' .
90
+ '<strong>' .
91
+ esc_html__( 'Check it out:', 'wpglobus' ) .
92
+ '</strong>' .
93
+ ' ' .
94
+ '<a href="' . $url . '">' . $url . '</a>' .
95
+ '</p>';
96
+ self::add_wc_section( $settings, $id, $title, $desc );
97
+ }
98
+
99
+ return $settings;
100
+
101
+ }
102
+
103
+ /**
104
+ * Generic WC option section consisting of one block of text only.
105
+ *
106
+ * @param array $settings Array of WC settings, passed by reference.
107
+ * @param string $id Section ID, must be unique.
108
+ * @param string $title Section title, no HTML.
109
+ * @param string $desc The text to display, HTML is allowed.
110
+ *
111
+ * @return void
112
+ */
113
+ protected static function add_wc_section( &$settings, $id, $title, $desc ) {
114
+ $settings[] =
115
+ array(
116
+ 'type' => 'title',
117
+ 'id' => $id,
118
+ 'title' => $title,
119
+ 'desc' => $desc,
120
+ );
121
+
122
+ $settings[] =
123
+ array(
124
+ 'type' => 'sectionend',
125
+ 'id' => $id,
126
+ );
127
+ }
128
+
129
+ /**
130
+ * Recommend WPGlobus Plus to edit permalinks.
131
+ *
132
+ * @since 1.9.6
133
+ */
134
+ public static function wpg_plus_slug() {
135
+
136
+ $container_start = '<p style="padding:5px; font-weight: bold"><span class="dashicons dashicons-admin-site"></span> ';
137
+ $container_end = '</p>';
138
+
139
+ if ( ! is_plugin_active( 'wpglobus-plus/wpglobus-plus.php' ) ) {
140
+ $url = WPGlobus_Utils::url_wpglobus_site() . 'product/wpglobus-plus/#slug';
141
+ echo $container_start; // WPCS: XSS ok.
142
+ esc_html_e( 'Translate permalinks with our premium add-on, WPGlobus Plus!', 'wpglobus' );
143
+ echo ' ';
144
+ esc_html_e( 'Check it out:', 'wpglobus' );
145
+ echo ' ';
146
+ echo '<a href="' . esc_url( $url ) . '" target="_blank">' . esc_html( $url ) . '</a>';
147
+ echo $container_end; // WPCS: XSS ok.
148
+ } elseif ( ! class_exists( 'WPGlobusPlus_Slug', false ) ) {
149
+ $url = admin_url( 'admin.php' ) . '?page=' . WPGlobusPlus::WPGLOBUS_PLUS_OPTIONS_PAGE . '&tab=modules';
150
+ echo $container_start; // WPCS: XSS ok.
151
+ esc_html_e( 'To translate permalinks, please activate the module Slug.', 'wpglobus' );
152
+ echo ' ';
153
+ /// Do not translate
154
+ $msg = __( 'Go to WPGlobus Plus Options page', 'wpglobus-plus' );
155
+
156
+ echo '<a href="' . esc_url( $url ) . '" target="_blank">' . esc_html( $msg ) . '.</a>';
157
+ echo $container_end; // WPCS: XSS ok.
158
+ }
159
+ }
160
+ }
includes/admin/wpglobus-admin.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @since 1.8.1
4
+ * @package WPGlobus
5
+ */
6
+
7
+ /**
8
+ * Admin page central.
9
+ *
10
+ * @since 1.6.6
11
+ */
12
+ require_once dirname( __FILE__ ) . '/central/class-wpglobus-admin-central.php';
13
+ WPGlobus_Admin_Central::construct();
14
+
15
+ if ( ! empty( $_GET['wpglobus-debug'] ) && 'godmode' === $_GET['wpglobus-debug'] ) { // WPCS: input var ok, sanitization ok.
16
+ /**
17
+ * To load debug info
18
+ * site/wp-admin/post.php?post={{post_ID}}&action=edit&wpglobus-debug=godmode
19
+ */
20
+ require_once dirname( __FILE__ ) . '/debug/class-wpglobus-admin-debug.php';
21
+ WPGlobus_Admin_Debug::get_instance();
22
+ }
includes/class-wpglobus-config.php ADDED
@@ -0,0 +1,701 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package WPGlobus
4
+ */
5
+
6
+ /**
7
+ * Class WPGlobus_Config
8
+ */
9
+ class WPGlobus_Config {
10
+
11
+ /**
12
+ * Language by default
13
+ * @var string
14
+ */
15
+ public $default_language = 'en';
16
+
17
+ /**
18
+ * Current language. Should be set to default initially.
19
+ * @var string
20
+ */
21
+ public $language = 'en';
22
+
23
+ /**
24
+ * Enabled languages
25
+ * @var string[]
26
+ */
27
+ public $enabled_languages = array(
28
+ 'en',
29
+ 'es',
30
+ 'de',
31
+ 'fr',
32
+ 'ru',
33
+ );
34
+
35
+ /**
36
+ * Hide from URL language by default
37
+ * @var bool
38
+ */
39
+ public $hide_default_language = true;
40
+
41
+ /**
42
+ * Opened languages
43
+ * @var string[]
44
+ */
45
+ public $open_languages = array();
46
+
47
+ /**
48
+ * Flag images configuration
49
+ * Look in /flags/ directory for a huge list of flags for usage
50
+ * @var array
51
+ */
52
+ public $flag = array();
53
+
54
+ /**
55
+ * Location of flags (needs trailing slash!)
56
+ * @var string
57
+ */
58
+ public $flags_url = '';
59
+
60
+ /**
61
+ * Stores languages in pairs code=>name
62
+ * @var array
63
+ */
64
+ public $language_name = array();
65
+
66
+ /**
67
+ * Stores languages names in English
68
+ * @var array
69
+ */
70
+ public $en_language_name = array();
71
+
72
+ /**
73
+ * Stores locales
74
+ * @var array
75
+ */
76
+ public $locale = array();
77
+
78
+ /**
79
+ * Stores enabled locales
80
+ * @since 1.0.10
81
+ * @var array
82
+ */
83
+ public $enabled_locale = array();
84
+
85
+ /**
86
+ * Stores version and update from WPGlobus Mini info
87
+ * @var array
88
+ */
89
+ public $version = array();
90
+
91
+ /**
92
+ * Use flag name for navigation menu : 'name' || 'code' || ''
93
+ * @var string
94
+ */
95
+ public $show_flag_name = 'code';
96
+
97
+ /**
98
+ * Use navigation menu by slug
99
+ * for use in all nav menu set value to 'all'
100
+ * @var string
101
+ */
102
+ public $nav_menu = '';
103
+
104
+ /**
105
+ * Add language selector to navigation menu which was created with wp_list_pages
106
+ * @since 1.0.7
107
+ * @var bool
108
+ */
109
+ public $selector_wp_list_pages = true;
110
+
111
+ /**
112
+ * Custom CSS
113
+ * @var string
114
+ */
115
+ public $custom_css = '';
116
+
117
+ /**
118
+ * WPGlobus option key
119
+ * @var string
120
+ */
121
+ public $option = 'wpglobus_option';
122
+
123
+ /**
124
+ * WPGlobus option versioning key
125
+ * @var string
126
+ */
127
+ public static $option_versioning = 'wpglobus_option_versioning';
128
+
129
+ /**
130
+ * WPGlobus option key for $language_name
131
+ * @var string
132
+ */
133
+ public $option_language_names = 'wpglobus_option_language_names';
134
+
135
+ /**
136
+ * WPGlobus option key for $en_language_name
137
+ * @var string
138
+ */
139
+ public $option_en_language_names = 'wpglobus_option_en_language_names';
140
+
141
+ /**
142
+ * WPGlobus option key for $locale
143
+ * @var string
144
+ */
145
+ public $option_locale = 'wpglobus_option_locale';
146
+
147
+ /**
148
+ * WPGlobus option key for $flag
149
+ * @var string
150
+ */
151
+ public $option_flags = 'wpglobus_option_flags';
152
+
153
+ /**
154
+ * WPGlobus option key for meta settings
155
+ * @var string
156
+ */
157
+ public $option_post_meta_settings = 'wpglobus_option_post_meta_settings';
158
+
159
+ /**
160
+ * @var string
161
+ */
162
+ public $css_editor = '';
163
+
164
+ /**
165
+ * @var string
166
+ */
167
+ public $js_editor = '';
168
+
169
+ /**
170
+ * WPGlobus devmode.
171
+ * @var string
172
+ */
173
+ public $toggle = 'on';
174
+
175
+ /**
176
+ * @todo Refactor this
177
+ * Duplicate var @see WPGlobus
178
+ * @var array
179
+ */
180
+ public $disabled_entities = array();
181
+
182
+ /**
183
+ * WPGlobus extended options can be added via filter 'wpglobus_option_sections'
184
+ *
185
+ * @since 1.2.3
186
+ * @var array
187
+ */
188
+ public $extended_options = array();
189
+
190
+ /**
191
+ * @var array
192
+ * @since 1.8.0
193
+ */
194
+ public $browser_redirect;
195
+
196
+ /**
197
+ * Used to temporarily store the language detected from the URL processed by oembed.
198
+ * @var string
199
+ * @since 1.8.4
200
+ */
201
+ protected $language_for_oembed = '';
202
+
203
+ /**
204
+ * Can get it only once.
205
+ * @return string
206
+ * @since 1.8.4
207
+ */
208
+ public function getAndResetLanguageForOembed() {
209
+ $to_return = $this->language_for_oembed;
210
+ $this->language_for_oembed = '';
211
+ return $to_return;
212
+ }
213
+
214
+ /**
215
+ * Setter.
216
+ * @param string $language_for_oembed
217
+ * @since 1.8.4
218
+ */
219
+ public function setLanguageForOembed( $language_for_oembed ) {
220
+ $this->language_for_oembed = $language_for_oembed;
221
+ }
222
+
223
+ /**
224
+ * Constructor
225
+ */
226
+ public function __construct() {
227
+
228
+ /**
229
+ * @since 1.0.9 Hooked to 'plugins_loaded'. The 'init' is too late, because it happens after all plugins already loaded their translations.
230
+ */
231
+ add_action( 'plugins_loaded', array(
232
+ $this,
233
+ 'init_current_language'
234
+ ), 0 );
235
+
236
+ add_action( 'plugins_loaded', array(
237
+ $this,
238
+ 'on_load_textdomain'
239
+ ), 1 );
240
+
241
+ add_action( 'upgrader_process_complete', array( $this, 'on_activate' ), 10, 2 );
242
+
243
+
244
+ $this->_get_options();
245
+ }
246
+
247
+ /**
248
+ * Set the current language: if not found in the URL or REFERER, then keep the default
249
+ * @since 1.1.1
250
+ */
251
+ public function init_current_language() {
252
+
253
+ /**
254
+ * Keep the default language if any of the code before does not detect another one.
255
+ */
256
+ $this->language = $this->default_language;
257
+
258
+ /**
259
+ * Theoretically, we might not have any URL to get the language info from.
260
+ */
261
+ $url_to_check = '';
262
+
263
+ if ( WPGlobus_WP::is_doing_ajax() ) {
264
+ /**
265
+ * If DOING_AJAX, we cannot retrieve the language information from the URL,
266
+ * because it's always `admin-ajax`.
267
+ * Therefore, we'll rely on the HTTP_REFERER (if it exists).
268
+ */
269
+ if ( ! empty( $_SERVER['HTTP_REFERER'] ) ) { // WPCS: input var ok, sanitization ok.
270
+ $url_to_check = $_SERVER['HTTP_REFERER']; // WPCS: input var ok, sanitization ok.
271
+ }
272
+ } else {
273
+ /**
274
+ * If not AJAX and not ADMIN then we are at the front. Will use the current URL.
275
+ */
276
+ if ( ! is_admin() ) {
277
+ $url_to_check = WPGlobus_Utils::current_url();
278
+ }
279
+ }
280
+
281
+ /**
282
+ * If we have an URL, extract language from it.
283
+ * If extracted, set it as a current.
284
+ */
285
+ if ( $url_to_check ) {
286
+ $language_from_url = WPGlobus_Utils::extract_language_from_url( $url_to_check );
287
+ if ( $language_from_url ) {
288
+ $this->language = $language_from_url;
289
+ }
290
+ }
291
+
292
+ }
293
+
294
+
295
+ /**
296
+ * Check plugin version and update versioning option
297
+ *
298
+ * @param stdClass $object Plugin_Upgrader
299
+ * @param array $options
300
+ *
301
+ * @return void
302
+ */
303
+ public function on_activate(
304
+ /** @noinspection PhpUnusedParameterInspection */
305
+ $object = null,
306
+ $options = array()
307
+ ) {
308
+
309
+ if (
310
+ empty( $options['plugin'] ) or $options['plugin'] !== WPGLOBUS_PLUGIN_BASENAME or
311
+ empty( $options['action'] ) or $options['action'] !== 'update'
312
+ ) {
313
+ /**
314
+ * Not our business
315
+ */
316
+ return;
317
+ }
318
+
319
+ /**
320
+ * Here we can read the previous version value and do some actions if necessary.
321
+ * For example, warn the users about breaking changes.
322
+ * $version = get_option( self::$option_versioning );
323
+ * ...
324
+ */
325
+
326
+ /**
327
+ * Store the current version
328
+ */
329
+ update_option( self::$option_versioning, array(
330
+ 'current_version' => WPGLOBUS_VERSION
331
+ ) );
332
+
333
+ }
334
+
335
+ /**
336
+ * Set current language
337
+ *
338
+ * @param string $locale
339
+ */
340
+ public function set_language( $locale ) {
341
+ /**
342
+ * @todo Maybe use option for disable/enable setting current language corresponding with $locale ?
343
+ */
344
+ foreach ( $this->locale as $language => $value ) {
345
+ if ( $locale === $value ) {
346
+ $this->language = $language;
347
+ break;
348
+ }
349
+ }
350
+ }
351
+
352
+ /**
353
+ * Check for enabled locale
354
+ * @since 1.0.10
355
+ *
356
+ * @param string $locale
357
+ *
358
+ * @return boolean
359
+ */
360
+ public function is_enabled_locale( $locale ) {
361
+ return in_array( $locale, $this->enabled_locale, true );
362
+ }
363
+
364
+ /**
365
+ * Load textdomain
366
+ * @since 1.0.0
367
+ * @return void
368
+ */
369
+ public function on_load_textdomain() {
370
+ // load_plugin_textdomain( 'wpglobus', false, basename( dirname( dirname( __FILE__ ) ) ) . '/languages' );
371
+ self::load_mofile();
372
+ }
373
+
374
+ /**
375
+ * Load .MO file from the plugin's `languages` folder.
376
+ * Used instead of @see load_plugin_textdomain to ignore translation files from WordPress.org, which are incorrect.
377
+ * To force loading from a different place, use the `load_textdomain_mofile` filter.
378
+ * @since 1.9.6
379
+ *
380
+ */
381
+ protected function load_mofile() {
382
+ $domain = 'wpglobus';
383
+ $locale = apply_filters( 'plugin_locale', is_admin() ? get_user_locale() : get_locale(), $domain );
384
+
385
+ $mofile = WPGlobus::languages_path() . '/' . $domain . '-' . $locale . '.mo';
386
+
387
+ return load_textdomain( $domain, $mofile );
388
+ }
389
+
390
+ /**
391
+ * Set flags URL
392
+ * @return void
393
+ */
394
+ public function _set_flags_url() {
395
+ $this->flags_url = WPGlobus::$PLUGIN_DIR_URL . 'flags/';
396
+ }
397
+
398
+ /**
399
+ * Set languages by default
400
+ */
401
+ public function _set_languages() {
402
+
403
+ /**
404
+ * Names, flags and locales
405
+ * Useful links
406
+ * - languages in ISO 639-1 format http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
407
+ * - regions http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
408
+ * - WordPress locales https://make.wordpress.org/polyglots/teams/
409
+ * - converter https://www.unicodetools.com/unicode/convert-to-html.php
410
+ */
411
+
412
+ /* @noinspection SpellCheckingInspection */
413
+ $language_table = array(
414
+ // Prefix => Name, Native name, locale, flag.
415
+ 'ar' => array( 'Arabic', '&#1575;&#1604;&#1593;&#1585;&#1576;&#1610;&#1577;', 'ar', 'arle.png' ),
416
+ 'en' => array( 'English', 'English', 'en_US', 'us.png' ),
417
+ 'au' => array( 'English (AU)', 'English (AU)', 'en_AU', 'au.png' ),
418
+ 'ca' => array( 'English (CA)', 'English (CA)', 'en_CA', 'ca.png' ),
419
+ 'gb' => array( 'English (UK)', 'English (UK)', 'en_GB', 'uk.png' ),
420
+ 'zh' => array( 'Chinese', '&#31616;&#20307;&#20013;&#25991;', 'zh_CN', 'cn.png' ),
421
+ 'tw' => array( 'Chinese (TW)', '&#32321;&#39636;&#20013;&#25991;', 'zh_CN', 'cn.png' ),
422
+ 'da' => array( 'Danish', 'Dansk', 'da_DK', 'dk.png' ),
423
+ 'nl' => array( 'Dutch', 'Nederlands', 'nl_NL', 'nl.png' ),
424
+ 'gl' => array( 'Galician', 'Galego', 'gl_ES', 'galego.png' ),
425
+ 'de' => array( 'German', 'Deutsch', 'de_DE', 'de.png' ),
426
+ 'fi' => array( 'Finnish', 'Suomi', 'fi', 'fi.png' ),
427
+ 'fr' => array( 'French', 'Français', 'fr_FR', 'fr.png' ),
428
+ 'qc' => array( 'French (CA)', 'Français (CA)', 'fr_CA', 'fr_CA.png' ),
429
+ 'he' => array( 'Hebrew', '&#1506;&#1489;&#1512;&#1497;&#1514;', 'he_IL', 'il.png' ),
430
+ 'hi' => array( 'Hindi', '&#2361;&#2367;&#2344;&#2381;&#2342;&#2368;', 'hi_IN', 'in.png' ),
431
+ 'hu' => array( 'Hungarian', 'Magyar', 'hu_HU', 'hu.png' ),
432
+ 'it' => array( 'Italian', 'Italiano', 'it_IT', 'it.png' ),
433
+ 'ja' => array( 'Japanese', '&#26085;&#26412;&#35486;', 'ja', 'jp.png' ),
434
+ 'ko' => array( 'Korean', '&#54620;&#44397;&#50612;', 'ko_KR', 'kr.png' ),
435
+ 'no' => array( 'Norwegian', 'Norsk', 'nb_NO', 'no.png' ),
436
+ 'fa' => array( 'Persian', '&#1601;&#1575;&#1585;&#1587;&#1740;', 'fa_IR', 'ir.png' ),
437
+ 'pl' => array( 'Polish', 'Polski', 'pl_PL', 'pl.png' ),
438
+ 'pt' => array( 'Portuguese', 'Português', 'pt_PT', 'pt.png' ),
439
+ 'br' => array( 'Portuguese (BR)', 'Português (BR)', 'pt_BR', 'br.png' ),
440
+ 'ro' => array( 'Romanian', 'Română', 'ro_RO', 'ro.png' ),
441
+ 'ru' => array( 'Russian', 'Русский', 'ru_RU', 'ru.png' ),
442
+ 'es' => array( 'Spanish', 'Español', 'es_ES', 'es.png' ),
443
+ 'mx' => array( 'Spanish (MX)', 'Español (MX)', 'es_MX', 'mx.png' ),
444
+ 'sv' => array( 'Swedish', 'Svenska', 'sv_SE', 'se.png' ),
445
+ 'tr' => array( 'Turkish', 'Türkçe', 'tr_TR', 'tr.png' ),
446
+ 'uk' => array( 'Ukrainian', 'Українська', 'uk', 'ua.png' ),
447
+ 'vi' => array( 'Vietnamese', 'Tiếng Việt', 'vi', 'vn.png' ),
448
+ 'cy' => array( 'Welsh', 'Cymraeg', 'cy', 'cy.png' ),
449
+ );
450
+
451
+ foreach ( $language_table as $language => $data ) {
452
+ list(
453
+ $this->en_language_name[ $language ],
454
+ $this->language_name[ $language ],
455
+ $this->locale[ $language ],
456
+ $this->flag[ $language ]
457
+ ) = $data;
458
+ }
459
+
460
+ }
461
+
462
+ /**
463
+ * Initialize the language table with the hard-coded names, locales and flags.
464
+ *
465
+ * @see _set_languages For the hard-coded table.
466
+ */
467
+ protected function _init_language_table() {
468
+
469
+ update_option( $this->option_language_names, $this->language_name );
470
+ update_option( $this->option_en_language_names, $this->en_language_name );
471
+ update_option( $this->option_locale, $this->locale );
472
+ update_option( $this->option_flags, $this->flag );
473
+
474
+ }
475
+
476
+ /**
477
+ * Get options from DB and wp-config.php
478
+ * @return void
479
+ */
480
+ protected function _get_options() {
481
+
482
+ /**
483
+ * For developers use only. Re-creates language table with no warning! Irreversible!
484
+ *
485
+ * @link wp-admin/?wpglobus-reset-language-table=1
486
+ */
487
+ if ( ! defined( 'DOING_AJAX' ) && ! empty( $_GET['wpglobus-reset-language-table'] ) && is_admin() ) { // WPCS: input var ok, sanitization ok.
488
+ delete_option( $this->option_language_names );
489
+ }
490
+
491
+
492
+ $wpglobus_option = get_option( $this->option );
493
+
494
+ /**
495
+ * FIX: after "Reset All" Redux options we must reset all WPGlobus options
496
+ * first of all look at $wpglobus_option['more_languages']
497
+ */
498
+ if ( isset( $wpglobus_option['more_languages'] ) && is_array( $wpglobus_option['more_languages'] ) ) {
499
+
500
+ $wpglobus_option = array();
501
+ delete_option( $this->option );
502
+ delete_option( $this->option_language_names );
503
+ delete_option( $this->option_en_language_names );
504
+ delete_option( $this->option_locale );
505
+ delete_option( $this->option_flags );
506
+
507
+ }
508
+
509
+ if ( isset( $wpglobus_option['more_languages'] ) ) {
510
+ unset( $wpglobus_option['more_languages'] );
511
+ }
512
+
513
+ /**
514
+ * Get enabled languages and default language ( just one main language )
515
+ */
516
+ if ( isset( $wpglobus_option['enabled_languages'] ) && ! empty( $wpglobus_option['enabled_languages'] ) ) {
517
+ $this->enabled_languages = array();
518
+ foreach ( $wpglobus_option['enabled_languages'] as $lang => $value ) {
519
+ if ( ! empty( $value ) ) {
520
+ $this->enabled_languages[] = $lang;
521
+ }
522
+ }
523
+
524
+ /**
525
+ * Set default language
526
+ */
527
+ $this->default_language = $this->enabled_languages[0];
528
+
529
+ unset( $wpglobus_option['enabled_languages'] );
530
+ }
531
+
532
+ /**
533
+ * Set available languages for editors
534
+ */
535
+ $this->open_languages = $this->enabled_languages;
536
+
537
+ /**
538
+ * Set flags URL
539
+ */
540
+ $this->_set_flags_url();
541
+
542
+ /**
543
+ * Get languages name
544
+ * big array of used languages
545
+ */
546
+ $this->language_name = get_option( $this->option_language_names );
547
+
548
+ if ( empty( $this->language_name ) ) {
549
+
550
+ $this->_set_languages();
551
+ $this->_init_language_table();
552
+
553
+ }
554
+
555
+ /**
556
+ * Get locales
557
+ */
558
+ $this->locale = get_option( $this->option_locale );
559
+ if ( empty( $this->locale ) ) {
560
+
561
+ $this->_set_languages();
562
+ $this->_init_language_table();
563
+
564
+ }
565
+
566
+ /**
567
+ * Get enabled locales
568
+ */
569
+ foreach ( $this->enabled_languages as $language ) {
570
+ $this->enabled_locale[] = $this->locale[ $language ];
571
+ }
572
+
573
+ /**
574
+ * Get en_language_name
575
+ */
576
+ $this->en_language_name = get_option( $this->option_en_language_names );
577
+
578
+ /**
579
+ * Get option 'show_flag_name'
580
+ */
581
+ if ( isset( $wpglobus_option['show_flag_name'] ) ) {
582
+ $this->show_flag_name = $wpglobus_option['show_flag_name'];
583
+ unset( $wpglobus_option['show_flag_name'] );
584
+ }
585
+ if ( defined( 'WPGLOBUS_SHOW_FLAG_NAME' ) ) {
586
+ if ( 'name' === WPGLOBUS_SHOW_FLAG_NAME ) {
587
+ $this->show_flag_name = 'name';
588
+ } elseif ( false === WPGLOBUS_SHOW_FLAG_NAME || '' === WPGLOBUS_SHOW_FLAG_NAME ) {
589
+ $this->show_flag_name = '';
590
+ }
591
+ }
592
+
593
+ /**
594
+ * Get navigation menu slug for add flag in front-end 'use_nav_menu'
595
+ */
596
+ $this->nav_menu = '';
597
+ if ( isset( $wpglobus_option['use_nav_menu'] ) ) {
598
+ $this->nav_menu = $wpglobus_option['use_nav_menu'];
599
+ unset( $wpglobus_option['use_nav_menu'] );
600
+ }
601
+ // This can be used in `wp-config` to override the options settings.
602
+ if ( defined( 'WPGLOBUS_USE_NAV_MENU' ) ) {
603
+ $this->nav_menu = WPGLOBUS_USE_NAV_MENU;
604
+ }
605
+
606
+
607
+ /**
608
+ * Get selector_wp_list_pages option
609
+ * @since 1.0.7
610
+ */
611
+ if ( empty( $wpglobus_option['selector_wp_list_pages']['show_selector'] ) ||
612
+ (int) $wpglobus_option['selector_wp_list_pages']['show_selector'] === 0
613
+ ) {
614
+ $this->selector_wp_list_pages = false;
615
+ }
616
+ if ( isset( $wpglobus_option['selector_wp_list_pages'] ) ) {
617
+ unset( $wpglobus_option['selector_wp_list_pages'] );
618
+ }
619
+
620
+ /**
621
+ * Get custom CSS
622
+ */
623
+ if ( isset( $wpglobus_option['css_editor'] ) ) {
624
+ $this->css_editor = $wpglobus_option['css_editor'];
625
+ unset( $wpglobus_option['css_editor'] );
626
+ }
627
+
628
+ /**
629
+ * Get custom JS.
630
+ * @since 1.7.6
631
+ */
632
+ if ( isset( $wpglobus_option['js_editor'] ) ) {
633
+ $this->js_editor = $wpglobus_option['js_editor'];
634
+ unset( $wpglobus_option['js_editor'] );
635
+ }
636
+
637
+ /**
638
+ * Get flag files without path
639
+ */
640
+ $option = get_option( $this->option_flags );
641
+ if ( ! empty( $option ) ) {
642
+ $this->flag = $option;
643
+ }
644
+
645
+ /**
646
+ * Get versioning info
647
+ */
648
+ $option = get_option( self::$option_versioning );
649
+ if ( empty( $option ) ) {
650
+ $this->version = array();
651
+ } else {
652
+ $this->version = $option;
653
+ }
654
+
655
+ /**
656
+ * WPGlobus devmode.
657
+ */
658
+ if ( isset( $_GET['wpglobus'] ) && 'off' === $_GET['wpglobus'] ) { // WPCS: input var ok, sanitization ok.
659
+ $this->toggle = 'off';
660
+ } else {
661
+ $this->toggle = 'on';
662
+ }
663
+
664
+ /**
665
+ * Need additional check for devmode (toggle=OFF)
666
+ * in case 'wpglobus' was not set to 'off' at /wp-admin/post.php
667
+ * and $_SERVER[QUERY_STRING] is empty at the time of `wp_insert_post_data` action
668
+ * @see WPGlobus::on_save_post_data
669
+ */
670
+ if (
671
+ empty( $_SERVER['QUERY_STRING'] ) // WPCS: input var ok, sanitization ok.
672
+ && isset( $_SERVER['HTTP_REFERER'] ) // WPCS: input var ok, sanitization ok.
673
+ && WPGlobus_WP::is_pagenow( 'post.php' )
674
+ && false !== strpos( $_SERVER['HTTP_REFERER'], 'wpglobus=off' ) // WPCS: input var ok, sanitization ok.
675
+ ) {
676
+ $this->toggle = 'off';
677
+ }
678
+
679
+ if ( isset( $wpglobus_option['last_tab'] ) ) {
680
+ unset( $wpglobus_option['last_tab'] );
681
+ }
682
+
683
+ /**
684
+ * Remaining wpglobus options after unset() is extended options
685
+ * @since 1.2.3
686
+ */
687
+ $this->extended_options = $wpglobus_option;
688
+
689
+ /**
690
+ * Option browser_redirect.
691
+ * @since 1.8.0
692
+ */
693
+ if ( isset( $wpglobus_option['browser_redirect'] ) ) {
694
+ $this->browser_redirect = $wpglobus_option['browser_redirect'];
695
+ unset( $wpglobus_option['browser_redirect'] );
696
+ }
697
+ }
698
+
699
+ } //class
700
+
701
+ # --- EOF
includes/class-wpglobus-core.php ADDED
@@ -0,0 +1,338 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * File: class-wpglobus-core.php
4
+ *
5
+ * @package WPGlobus
6
+ */
7
+
8
+ /**
9
+ * Class WPGlobus_Core
10
+ */
11
+ class WPGlobus_Core {
12
+
13
+ /**
14
+ * The main filter function.
15
+ * Default behavior: extracts text in one language from multi-lingual strings.
16
+ *
17
+ * @param string $text Multilingual text, with special delimiters between languages
18
+ * @param string $language The code of the language to be extracted from the `$text`
19
+ * @param string $return What to do if the text in the `$language` was not found
20
+ * @param string $default_language Pass this if you want to return a non-default language content, when the content in `$language` is not available
21
+ *
22
+ * @return string
23
+ */
24
+ public static function text_filter(
25
+ $text = '',
26
+ $language = '',
27
+ $return = WPGlobus::RETURN_IN_DEFAULT_LANGUAGE,
28
+ $default_language = ''
29
+ ) {
30
+
31
+ if ( empty( $text ) ) {
32
+ // Nothing to do
33
+ return $text;
34
+ }
35
+
36
+ /**
37
+ * There are cases when numeric terms are passed here. We should not tamper with them.
38
+ * @since 1.0.8.1 Before, was returning empty string, which was incorrect.
39
+ */
40
+ if ( ! is_string( $text ) ) {
41
+ return $text;
42
+ }
43
+
44
+ /**
45
+ * `$default_language` not passed
46
+ */
47
+ if ( ! $default_language ) {
48
+ if ( class_exists( 'WPGlobus_Config' ) ) {
49
+ $default_language = WPGlobus::Config()->default_language;
50
+ } else {
51
+ // When in unit tests
52
+ $default_language = 'en';
53
+ }
54
+ }
55
+
56
+ /**
57
+ * `$language` not passed
58
+ */
59
+ if ( empty( $language ) ) {
60
+ $language = $default_language;
61
+ }
62
+
63
+ /**
64
+ * Fix for the case
65
+ * &lt;!--:en--&gt;ENG&lt;!--:--&gt;&lt;!--:ru--&gt;RUS&lt;!--:--&gt;
66
+ * @todo need careful investigation
67
+ */
68
+ $text = htmlspecialchars_decode( $text );
69
+
70
+
71
+ $possible_delimiters =
72
+ array(
73
+ /**
74
+ * Our delimiters
75
+ */
76
+ array(
77
+ 'start' => sprintf( WPGlobus::LOCALE_TAG_START, $language ),
78
+ 'end' => WPGlobus::LOCALE_TAG_END,
79
+ ),
80
+ /**
81
+ * qTranslate compatibility
82
+ * qTranslate uses these two types of delimiters
83
+ * @example
84
+ * <!--:en-->English<!--:--><!--:ru-->Russian<!--:-->
85
+ * [:en]English S[:ru]Russian S
86
+ * The [] delimiter does not have the closing tag, so we will look for the next opening [: or
87
+ * take the rest until end of end of the string
88
+ */
89
+ array(
90
+ 'start' => "<!--:{$language}-->",
91
+ 'end' => '<!--:-->',
92
+ ),
93
+ array(
94
+ 'start' => "[:{$language}]",
95
+ 'end' => '[:',
96
+ ),
97
+ );
98
+
99
+ /**
100
+ * We'll use this flag after the loop to see if the loop was successful. See the `break` clause in the loop.
101
+ */
102
+ $is_local_text_found = false;
103
+
104
+ /**
105
+ * We do not know which delimiter was used, so we'll try both, in a loop
106
+ */
107
+ /* @noinspection LoopWhichDoesNotLoopInspection */
108
+ foreach ( $possible_delimiters as $delimiters ) {
109
+
110
+ /**
111
+ * Try the starting position. If not found, continue the loop to the next set of delimiters.
112
+ */
113
+ $pos_start = strpos( $text, $delimiters['start'] );
114
+ if ( false === $pos_start ) {
115
+ continue;
116
+ }
117
+
118
+ /**
119
+ * The starting position found..adjust the pointer to the text start
120
+ * (Do not need mb_strlen here, because we expect delimiters to be Latin only)
121
+ */
122
+ $pos_start += strlen( $delimiters['start'] );
123
+
124
+ /**
125
+ * Try to find the ending position.
126
+ * If could not find, will extract the text until end of string.
127
+ */
128
+ $pos_end = strpos( $text, $delimiters['end'], $pos_start );
129
+ if ( false === $pos_end ) {
130
+ // - Until end of string
131
+ $text = substr( $text, $pos_start );
132
+ } else {
133
+ $text = substr( $text, $pos_start, $pos_end - $pos_start );
134
+ }
135
+
136
+ /**
137
+ * Set the "found" flag and end the loop.
138
+ */
139
+ $is_local_text_found = true;
140
+ break;
141
+
142
+ }
143
+
144
+ /**
145
+ * If we could not find anything in the current language...
146
+ */
147
+ if ( ! $is_local_text_found ) {
148
+ if ( $return === WPGlobus::RETURN_EMPTY ) {
149
+ if ( $language === $default_language && ! self::has_translations( $text ) ) {
150
+ /**
151
+ * @todo Check the above condition. What if only one part is true?
152
+ * If text does not contain language delimiters nothing to do
153
+ */
154
+ } else {
155
+ /** We are forced to return empty string. */
156
+ $text = '';
157
+ }
158
+ } else {
159
+ /**
160
+ * Try RETURN_IN_DEFAULT_LANGUAGE
161
+ */
162
+ if ( $language === $default_language ) {
163
+ if ( self::has_translations( $text ) ) {
164
+ /**
165
+ * Rare case of text in default language doesn't exist
166
+ * @todo make option for return warning message or maybe another action
167
+ */
168
+ $text = '';
169
+ }
170
+ } else {
171
+ /**
172
+ * Try the default language (recursion)
173
+ * @qa covered by the 'one_tag' case
174
+ * @see WPGlobus_QA::_test_string_parsing()
175
+ */
176
+ $text = self::text_filter( $text, $default_language );
177
+ }
178
+ }
179
+ /** else - we do not change the input string, and it will be returned as-is */
180
+ }
181
+
182
+ return $text;
183
+
184
+ }
185
+
186
+ /**
187
+ * Extract text from a string which is either:
188
+ * - in the requested language (could be multiple blocks)
189
+ * - or does not have the language marks
190
+ * @todo Works with single line of text only. If the text contains line breaks, they will be removed.
191
+ * @todo May fail on large texts because regex are used.
192
+ *
193
+ * @example
194
+ * Input:
195
+ * '{:en}first_EN{:}{:ru}first_RU{:} blah-blah {:en}second_EN{:}{:ru}second_RU{:}'
196
+ * Language: en
197
+ * Output:
198
+ * 'first_EN blah-blah second_EN'
199
+ *
200
+ * @param string $text Input text.
201
+ * @param string $language Language to extract. Default is the current language.
202
+ *
203
+ * @return string
204
+ * @since 1.7.9
205
+ */
206
+ public static function extract_text( $text = '', $language = '' ) {
207
+ if ( ! $text ) {
208
+ return $text;
209
+ }
210
+
211
+ /**
212
+ * `$language` not passed
213
+ */
214
+ if ( ! $language ) {
215
+ // When in unit tests:
216
+ $language = 'en';
217
+ // Normally:
218
+ if ( class_exists( 'WPGlobus_Config', false ) ) {
219
+ $language = WPGlobus::Config()->language;
220
+ }
221
+ }
222
+
223
+ // Pass 1. Remove the language marks surrounding the language we need.
224
+ // Pass 2. Remove the texts surrounded with other language marks, together with the marks.
225
+ return preg_replace(
226
+ array( '/{:' . $language . '}(.+?){:}/m', '/{:.+?}.+?{:}/m' ),
227
+ array( '\\1', '' ),
228
+ $text
229
+ );
230
+ }
231
+
232
+ /**
233
+ * Check if string has language delimiters
234
+ *
235
+ * @param string $string
236
+ *
237
+ * @return bool
238
+ */
239
+ public static function has_translations( $string ) {
240
+
241
+ /**
242
+ * This should detect majority of the strings with our delimiters without calling preg_match
243
+ * @var int $pos_start
244
+ */
245
+ $pos_start = strpos( $string, WPGlobus::LOCALE_TAG_OPEN );
246
+ if ( $pos_start !== false ) {
247
+ if ( ctype_lower( $string[ $pos_start + 2 ] ) && ctype_lower( $string[ $pos_start + 3 ] ) ) {
248
+ return true;
249
+ }
250
+ }
251
+
252
+ /**
253
+ * For compatibility, etc. - the universal procedure with regexp
254
+ */
255
+
256
+ return (bool) preg_match( '/(\{:|\[:|<!--:)[a-z]{2}/', $string );
257
+ }
258
+
259
+ /**
260
+ * Keeps only one language in all textual fields of the `$post` object.
261
+ *
262
+ * @see \WPGlobus_Core::text_filter for the parameters description
263
+ *
264
+ * @param WP_Post|mixed $post The Post object. Object always passed by reference.
265
+ * @param string $language
266
+ * @param string $return
267
+ * @param string $default_language
268
+ */
269
+ public static function translate_wp_post(
270
+ &$post,
271
+ $language = '',
272
+ $return = WPGlobus::RETURN_IN_DEFAULT_LANGUAGE,
273
+ $default_language = ''
274
+ ) {
275
+
276
+ /**
277
+ * `$default_language` not passed
278
+ */
279
+ if ( ! $default_language ) {
280
+ if ( class_exists( 'WPGlobus_Config' ) ) {
281
+ $default_language = WPGlobus::Config()->default_language;
282
+ } else {
283
+ // When in unit tests
284
+ $default_language = 'en';
285
+ }
286
+ }
287
+
288
+ /**
289
+ * `$language` not passed
290
+ */
291
+ if ( empty( $language ) ) {
292
+ $language = $default_language;
293
+ }
294
+
295
+ $fields = array(
296
+ 'post_title',
297
+ 'post_content',
298
+ 'post_excerpt',
299
+ 'title',
300
+ 'attr_title',
301
+ );
302
+
303
+ foreach ( $fields as $_ ) {
304
+ if ( ! empty( $post->$_ ) ) {
305
+ $post->$_ = self::text_filter( $post->$_, $language, $return, $default_language );
306
+ }
307
+ }
308
+
309
+ }
310
+
311
+ /**
312
+ * Translate a term (category, post_tag, etc.)
313
+ * Term can be an object (default for the @see wp_get_object_terms() filter)
314
+ * or a string (for example, when wp_get_object_terms is called with the 'fields'=>'names' argument)
315
+ *
316
+ * @param string|object $term
317
+ * @param string $language
318
+ */
319
+ public static function translate_term( &$term, $language = '' ) {
320
+ if ( is_object( $term ) ) {
321
+ if ( ! empty( $term->name ) ) {
322
+ $term->name = self::text_filter( $term->name, $language );
323
+ }
324
+ if ( ! empty( $term->description ) ) {
325
+ $term->description = self::text_filter( $term->description, $language );
326
+ }
327
+ } else {
328
+ if ( ! empty( $term ) ) {
329
+ $term = self::text_filter( $term, $language );
330
+ }
331
+ }
332
+
333
+ }
334
+
335
+
336
+ } // class
337
+
338
+ # --- EOF
includes/class-wpglobus-filters.php ADDED
@@ -0,0 +1,1154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Filters and actions
4
+ * Only methods here. The add_filter calls are in the Controller
5
+ *
6
+ * @package WPGlobus
7
+ */
8
+
9
+ /**
10
+ * Class WPGlobus_Filters
11
+ */
12
+ class WPGlobus_Filters {
13
+
14
+ /** @var string[] Meta keys where data can be multilingual */
15
+ protected static $multilingual_meta_keys = array();
16
+
17
+ /**
18
+ * This is the basic filter used to extract the text portion in the current language from a string.
19
+ * Applied to the main WP texts, such as post title, content and excerpt.
20
+ *
21
+ * @param string $text
22
+ *
23
+ * @return string
24
+ */
25
+ public static function filter__text( $text ) {
26
+
27
+ return WPGlobus_Core::text_filter(
28
+ $text,
29
+ WPGlobus::Config()->language,
30
+ null,
31
+ WPGlobus::Config()->default_language
32
+ );
33
+
34
+ }
35
+
36
+ /**
37
+ * This filter is needed to display correctly the posts with the '--- MORE ---' separator
38
+ * in archives.
39
+ * Without it, the post content is truncated at the beginning of <!--more-->, thus keeping
40
+ * only the first language.
41
+ * *
42
+ * 'the_posts' filter is used by @see get_posts(), which is commonly used in all sorts of places,
43
+ * including, for instance, @see wp_get_associated_nav_menu_items while deleting a post.
44
+ * So, to minimize potential side effects, we limit the scope to main queries, or
45
+ * when the 'wpglobus_force_filter__the_posts' is set
46
+ * (@see WPGlobus_QA::_test_get_posts for example).
47
+ *
48
+ * @param array $posts
49
+ * @param WP_Query $query
50
+ *
51
+ * @return array
52
+ * @since 1.0.14
53
+ */
54
+ public static function filter__the_posts( $posts, $query ) {
55
+
56
+ if ( $query->is_main_query() || $query->get( 'wpglobus_force_filter__the_posts' ) ) {
57
+ foreach ( $posts as $post ) {
58
+ WPGlobus_Core::translate_wp_post(
59
+ $post,
60
+ WPGlobus::Config()->language,
61
+ WPGlobus::RETURN_IN_DEFAULT_LANGUAGE
62
+ );
63
+ }
64
+ }
65
+
66
+ return $posts;
67
+
68
+ }
69
+
70
+ /**
71
+ * This is similar to the @see filter__text filter,
72
+ * but it returns text in the DEFAULT language.
73
+ *
74
+ * @param string $text
75
+ *
76
+ * @return string
77
+ * @since 1.0.8
78
+ */
79
+ public static function filter__text_default_language( $text ) {
80
+
81
+ return WPGlobus_Core::text_filter(
82
+ $text,
83
+ WPGlobus::Config()->default_language,
84
+ null,
85
+ WPGlobus::Config()->default_language
86
+ );
87
+
88
+ }
89
+
90
+
91
+ /**
92
+ * Filter @see get_terms
93
+ *
94
+ * @scope admin
95
+ * @scope front
96
+ *
97
+ * @param string[]|object[] $terms
98
+ *
99
+ * @return array
100
+ */
101
+ public static function filter__get_terms( Array $terms ) {
102
+
103
+ /**
104
+ * @todo Example of a "stopper" filter
105
+ * if ( apply_filters( 'wpglobus_do_filter__get_terms', true ) ) {}
106
+ * Because it might affect the performance, this is a to-do for now.
107
+ */
108
+
109
+ foreach ( $terms as &$_term ) {
110
+ WPGlobus_Core::translate_term( $_term, WPGlobus::Config()->language );
111
+ }
112
+ unset( $_term );
113
+
114
+ reset( $terms );
115
+
116
+ return $terms;
117
+ }
118
+
119
+ /**
120
+ * Filter @see get_the_terms
121
+ *
122
+ * @scope admin
123
+ *
124
+ * @param stdClass[]|WP_Error $terms List of attached terms, or WP_Error on failure.
125
+ *
126
+ * @return array
127
+ */
128
+ public static function filter__get_the_terms( $terms ) {
129
+
130
+ /**
131
+ * @internal 15.01.31
132
+ * Theoretically, we should not have this filter because @see get_the_terms
133
+ * calls @see wp_get_object_terms, which is already filtered.
134
+ * However, there is a case when the terms are retrieved from @see get_object_term_cache,
135
+ * and when we do a Quick Edit / inline-save, we ourselves write raw terms to the cache.
136
+ * As of now, we know only one such case, so we activate this filter only in admin,
137
+ * and only on the 'single_row' call
138
+ * @todo Keep watching this
139
+ */
140
+
141
+ if ( ! is_wp_error( $terms ) && WPGlobus_WP::is_function_in_backtrace( 'single_row' ) ) {
142
+
143
+ // Casting $terms to (array) causes syntax error in PHP 5.3 and older.
144
+ /* @noinspection ForeachSourceInspection */
145
+ foreach ( $terms as &$_term ) {
146
+ WPGlobus_Core::translate_term( $_term, WPGlobus::Config()->language );
147
+ }
148
+ unset( $_term );
149
+
150
+ reset( $terms );
151
+ }
152
+
153
+ return $terms;
154
+ }
155
+
156
+ /**
157
+ * Filter @see wp_get_object_terms()
158
+ *
159
+ * @scope admin
160
+ * @scope front
161
+ *
162
+ * @param string[]|stdClass[] $terms An array of terms for the given object or objects.
163
+ *
164
+ * @return array
165
+ */
166
+ public static function filter__wp_get_object_terms( array $terms ) {
167
+
168
+ /**
169
+ * @internal
170
+ * Do not need to check for is_wp_error($terms),
171
+ * because the WP_Error is returned by wp_get_object_terms() before applying filter.
172
+ */
173
+
174
+ if ( ! count( $terms ) ) {
175
+ return $terms;
176
+ }
177
+
178
+ /**
179
+ * Don't filter term names when saving or publishing posts
180
+ *
181
+ * @todo Check this before add_filter and not here
182
+ * @todo Describe exactly how to check this visually, and is possible - write the acceptance test
183
+ */
184
+ if (
185
+ is_admin() &&
186
+ WPGlobus_WP::is_pagenow( 'post.php' ) &&
187
+ ( ! empty( $_POST['save'] ) || ! empty( $_POST['publish'] ) ) // WPCS: input var ok, sanitization ok.
188
+ ) {
189
+ return $terms;
190
+ }
191
+
192
+ /**
193
+ * Don't filter term names for trash and un-trash single post
194
+ *
195
+ * @see we check post.php page instead of edit.php because redirect
196
+ */
197
+ if ( is_admin() && WPGlobus_WP::is_pagenow( 'post.php' ) && isset( $_GET['action'] ) && ( 'trash' === $_GET['action'] || 'untrash' === $_GET['action'] ) // WPCS: input var ok, sanitization ok.
198
+ ) {
199
+ return $terms;
200
+ }
201
+
202
+ /**
203
+ * Don't filter term names bulk trash and untrash posts
204
+ */
205
+ if ( is_admin() && WPGlobus_WP::is_pagenow( 'edit.php' ) && isset( $_GET['action'] ) && ( 'trash' === $_GET['action'] || 'untrash' === $_GET['action'] ) // WPCS: input var ok, sanitization ok.
206
+ ) {
207
+ return $terms;
208
+ }
209
+
210
+ /**
211
+ * Don't filter term names for bulk edit post from edit.php page
212
+ */
213
+ if ( is_admin() && WPGlobus_WP::is_function_in_backtrace( 'bulk_edit_posts' ) ) {
214
+ return $terms;
215
+ }
216
+
217
+ /**
218
+ * Don't filter term names for inline-save ajax action from edit.php page
219
+ *
220
+ * @see wp_ajax_inline_save
221
+ * ...except when the same AJAX refreshes the table row @see WP_Posts_List_Table::single_row
222
+ * -
223
+ * @qa At the "All posts" admin page, do Quick Edit on any post. After update, categories and tags
224
+ * must not show multilingual strings with delimiters.
225
+ * @qa At Quick Edit, enter an existing tag. After save, check if there is no additional tag
226
+ * on the "Tags" page. If a new tag is created then the "is tag exists" check was checking
227
+ * only a single language representation of the tag, while there is a multilingual tag in the DB.
228
+ */
229
+ if ( WPGlobus_WP::is_http_post_action( 'inline-save' ) &&
230
+ WPGlobus_WP::is_pagenow( 'admin-ajax.php' )
231
+ ) {
232
+ if ( ! WPGlobus_WP::is_function_in_backtrace( 'single_row' ) ) {
233
+ return $terms;
234
+ }
235
+ }
236
+
237
+ /**
238
+ * Don't filter term names for heartbeat autosave
239
+ */
240
+ if ( WPGlobus_WP::is_http_post_action( 'heartbeat' ) &&
241
+ WPGlobus_WP::is_pagenow( 'admin-ajax.php' ) &&
242
+ ! empty( $_POST['data']['wp_autosave'] ) // WPCS: input var ok, sanitization ok.
243
+ ) {
244
+ return $terms;
245
+ }
246
+
247
+ /**
248
+ * Don't filter term name at time generate checklist categories in metabox
249
+ */
250
+ if (
251
+ empty( $_POST ) && // WPCS: input var ok, sanitization ok.
252
+ is_admin() &&
253
+ WPGlobus_WP::is_pagenow( 'post.php' ) &&
254
+ WPGlobus_WP::is_function_in_backtrace( 'wp_terms_checklist' )
255
+ ) {
256
+ return $terms;
257
+ }
258
+
259
+ foreach ( $terms as &$_term ) {
260
+ WPGlobus_Core::translate_term( $_term, WPGlobus::Config()->language );
261
+ }
262
+ unset( $_term );
263
+
264
+ reset( $terms );
265
+
266
+ return $terms;
267
+ }
268
+
269
+ /**
270
+ * This filter is needed to build correct permalink (slug, post_name)
271
+ * using only the main part of the post title (in the default language).
272
+ * -
273
+ * Because 'sanitize_title' is a commonly used function, we have to apply our filter
274
+ * only on very specific calls. Therefore, there are (ugly) debug_backtrace checks.
275
+ * -
276
+ * Case 1
277
+ * When a draft post is created,
278
+ * the post title is converted to the slug in the @see get_sample_permalink function,
279
+ * using the 'sanitize_title' filter.
280
+ * -
281
+ * Case 2
282
+ * When the draft is published, @see wp_insert_post calls
283
+ *
284
+ * @see sanitize_title to set the slug
285
+ * -
286
+ * @see WPGLobus_QA::_test_post_name
287
+ * -
288
+ * @see WPSEO_Metabox::localize_script
289
+ * @todo Check what's going on in localize_script of WPSEO?
290
+ * @todo What if there is no EN language? Only ru and kz but - we cannot use 'en' for permalink
291
+ * @todo check guid
292
+ *
293
+ * @param string $title
294
+ *
295
+ * @return string
296
+ */
297
+ public static function filter__sanitize_title( $title ) {
298
+
299
+ if (
300
+ WPGlobus_WP::is_filter_called_by( 'get_sample_permalink' ) ||
301
+ WPGlobus_WP::is_filter_called_by( 'wp_insert_post' ) ||
302
+ WPGlobus_WP::is_filter_called_by( 'wp_update_term' )
303
+ ) {
304
+ /**
305
+ * @internal_note: the DEFAULT language, not the current one
306
+ */
307
+ $title = WPGlobus_Core::text_filter(
308
+ $title, WPGlobus::Config()->default_language
309
+ );
310
+ }
311
+
312
+ return $title;
313
+ }
314
+
315
+ /**
316
+ * Filter @see get_term()
317
+ *
318
+ * @param string|object $term
319
+ *
320
+ * @return string|object
321
+ */
322
+ public static function filter__get_term( $term ) {
323
+
324
+ if ( WPGlobus_WP::is_http_post_action( 'inline-save-tax' ) ) {
325
+ /**
326
+ * Don't filter ajax action 'inline-save-tax' from edit-tags.php page.
327
+ * See quick_edit() in includes/js/wpglobus.admin.js
328
+ * for and example of working with taxonomy name and description
329
+ * wp_current_filter contains
330
+ * 0=wp_ajax_inline-save-tax
331
+ * 1=get_term
332
+ *
333
+ * @see wp_ajax_inline_save_tax()
334
+ */
335
+ // do nothing
336
+ } else {
337
+ WPGlobus_Core::translate_term( $term, WPGlobus::Config()->language );
338
+ }
339
+
340
+ return $term;
341
+
342
+ }
343
+
344
+ /**
345
+ * Filter @see get_terms_to_edit()
346
+ *
347
+ * @since 1.6.4
348
+ *
349
+ * @param string
350
+ *
351
+ * @return string
352
+ */
353
+ public static function filter__terms_to_edit( $terms_to_edit ) {
354
+
355
+ if ( ! WPGlobus_Core::has_translations( $terms_to_edit ) ) {
356
+ return $terms_to_edit;
357
+ }
358
+
359
+ $terms = explode( ',', $terms_to_edit );
360
+
361
+ foreach ( $terms as $k => $term ) {
362
+ $terms[ $k ] = WPGlobus_Core::text_filter( $term, WPGlobus::Config()->language );
363
+ }
364
+
365
+ return implode( ',', $terms );
366
+ }
367
+
368
+ /**
369
+ * Filter @see wp_insert_term().
370
+ *
371
+ * @since 1.6.6
372
+ *
373
+ * @param string $term The term to add or update.
374
+ * @param string $taxonomy Taxonomy slug.
375
+ *
376
+ * @return string
377
+ */
378
+ public static function filter__pre_insert_term( $term, $taxonomy ) {
379
+
380
+ $multilingual_term = esc_sql( $term );
381
+ if ( WPGlobus::Config()->language !== WPGlobus::Config()->default_language ) {
382
+ $multilingual_term = WPGlobus_Utils::build_multilingual_string( array( WPGlobus::Config()->language => $term ) );
383
+ }
384
+
385
+ global $wpdb;
386
+ $data = $wpdb->get_results( "SELECT * FROM $wpdb->terms AS terms WHERE terms.name LIKE '%{$multilingual_term}%'" );
387
+
388
+ if ( count( $data ) > 0 ) {
389
+ /**
390
+ * Return empty to prevent creating duplicate term.
391
+ *
392
+ * @see wp_insert_term() in wp-includes\taxonomy.php
393
+ */
394
+ return '';
395
+ }
396
+
397
+ return $term;
398
+ }
399
+
400
+ /**
401
+ * Localize home_url
402
+ * Should be processed on:
403
+ * - front
404
+ * - AJAX, except for several specific actions
405
+ *
406
+ * @param string $url
407
+ *
408
+ * @return string
409
+ */
410
+ public static function filter__home_url( $url ) {
411
+
412
+ /**
413
+ * @internal note
414
+ * Example of URL in admin:
415
+ * When admin interface is not in default language, we still should not see
416
+ * any permalinks with language prefixes.
417
+ * For that, we could check if we are at the 'post.php' screen:
418
+ * if ( 'post.php' == $pagenow ) ....
419
+ * However, we do not need it, because we disallowed almost any processing in admin.
420
+ */
421
+
422
+ /**
423
+ * 1. Do not work in admin
424
+ */
425
+ $need_to_process = ( ! is_admin() );
426
+
427
+ if ( WPGlobus_WP::is_pagenow( 'admin-ajax.php' ) ) {
428
+ /**
429
+ * 2. But work in AJAX, which is also admin
430
+ */
431
+ $need_to_process = true;
432
+
433
+ /**
434
+ * 3. However, don't convert url for these AJAX actions:
435
+ */
436
+ if ( WPGlobus_WP::is_http_post_action(
437
+ array(
438
+ 'heartbeat',
439
+ 'sample-permalink',
440
+ 'add-menu-item',
441
+ )
442
+ )
443
+ ) {
444
+ $need_to_process = false;
445
+ }
446
+ }
447
+
448
+ if ( $need_to_process ) {
449
+ $url = WPGlobus_Utils::localize_url( $url );
450
+ }
451
+
452
+ return $url;
453
+ }
454
+
455
+ /**
456
+ * Filter @see get_pages
457
+ *
458
+ * @qa See a list of available pages in the "Parent Page" metabox when editing a page.
459
+ *
460
+ * @param WP_Post[] $pages
461
+ *
462
+ * @return WP_Post[]
463
+ */
464
+ public static function filter__get_pages( $pages ) {
465
+
466
+ foreach ( $pages as &$_page ) {
467
+ WPGlobus_Core::translate_wp_post( $_page, WPGlobus::Config()->language );
468
+ }
469
+ unset( $_page );
470
+
471
+ reset( $pages );
472
+
473
+ return $pages;
474
+ }
475
+
476
+ /**
477
+ * Filter for @see get_locale
478
+ *
479
+ * @param string $locale
480
+ *
481
+ * @return string
482
+ * @todo Do we need to do setlocale(LC_???, $locale)? (*** NOT HERE )
483
+ * @see setlocale
484
+ * @link http://php.net/manual/en/function.setlocale.php
485
+ * @example echo setlocale(LC_ALL, 'Russian'); => Russian_Russia.1251
486
+ */
487
+ public static function filter__get_locale(
488
+ /** @noinspection PhpUnusedParameterInspection */
489
+ $locale
490
+ ) {
491
+
492
+ /**
493
+ * @todo This caching breaks the admin language switcher.
494
+ */
495
+ /* static $cached_locale = null;
496
+ if ( null !== $cached_locale ) {
497
+ return $cached_locale;
498
+ }*/
499
+
500
+ /**
501
+ * Special case: in admin area, show everything in the language of admin interface.
502
+ * (set in the General Settings in WP 4.1)
503
+ */
504
+ /**
505
+ * @internal
506
+ * We need to exclude is_admin when it's a front-originated AJAX,
507
+ * so we are doing a "hack" checking @see WPGlobus_WP::is_admin_doing_ajax.
508
+ */
509
+ if (
510
+ is_admin() &&
511
+ ( ! WPGlobus_WP::is_doing_ajax() || WPGlobus_WP::is_admin_doing_ajax() )
512
+ ) {
513
+ /**
514
+ * @todo is_multisite
515
+ * @todo Pre-WP4, WPLANG constant from wp-config
516
+ */
517
+ $WPLANG = get_option( 'WPLANG' );
518
+ if ( empty( $WPLANG ) ) {
519
+ $WPLANG = 'en_US';
520
+ }
521
+ WPGlobus::Config()->set_language( $WPLANG );
522
+
523
+ }
524
+
525
+ if ( is_admin() ) {
526
+ /**
527
+ * Checking case for set locale which does not set in WPGlobus
528
+ */
529
+ if ( WPGlobus::Config()->is_enabled_locale( $locale ) ) {
530
+ $locale = WPGlobus::Config()->locale[ WPGlobus::Config()->language ];
531
+ }
532
+ } else {
533
+ $locale = WPGlobus::Config()->locale[ WPGlobus::Config()->language ];
534
+ }
535
+
536
+ /* $cached_locale = $locale;*/
537
+
538
+ return $locale;
539
+
540
+ }
541
+
542
+ /**
543
+ * Filter @see wp_setup_nav_menu_item in wp-includes\nav-menu.php for more info
544
+ *
545
+ * @since 1.0.0
546
+ *
547
+ * @param WP_Post[] $object
548
+ *
549
+ * @return WP_Post[]
550
+ */
551
+ public static function filter__nav_menu_item( $object ) {
552
+ /**
553
+ * This filter is used at nav-menus.php page for .field-move elements
554
+ */
555
+ if ( is_object( $object ) && 'WP_Post' === get_class( $object ) ) {
556
+
557
+ if ( ! empty( $object->title ) ) {
558
+ $object->title = WPGlobus_Core::text_filter( $object->title, WPGlobus::Config()->language );
559
+ }
560
+ if ( ! empty( $object->description ) ) {
561
+ $object->description = WPGlobus_Core::text_filter( $object->description, WPGlobus::Config()->language );
562
+ }
563
+ }
564
+
565
+ return $object;
566
+ }
567
+
568
+ /**
569
+ * Filter @see nav_menu_description
570
+ *
571
+ * @since 1.0.0
572
+ *
573
+ * @param string $description
574
+ *
575
+ * @return string
576
+ */
577
+ public static function filter__nav_menu_description( $description ) {
578
+ /**
579
+ * This filter for translate menu item description
580
+ */
581
+ if ( ! empty( $description ) ) {
582
+ $description = WPGlobus_Core::text_filter( $description, WPGlobus::Config()->language );
583
+ }
584
+
585
+ return $description;
586
+ }
587
+
588
+ /**
589
+ * Filter @see heartbeat_received
590
+ *
591
+ * @since 1.0.1
592
+ *
593
+ * @param array $response
594
+ * @param array $data
595
+ * @param string $screen_id
596
+ *
597
+ * @return array
598
+ */
599
+ public static function filter__heartbeat_received(
600
+ $response, $data,
601
+ /** @noinspection PhpUnusedParameterInspection */
602
+ $screen_id
603
+ ) {
604
+
605
+ if ( false !== strpos( $_SERVER['HTTP_REFERER'], 'wpglobus=off' ) ) { // WPCS: input var ok, sanitization ok.
606
+ /**
607
+ * Check $_SERVER['HTTP_REFERER'] for wpglobus toggle is off because wpglobus-admin.js doesn't loaded in this mode
608
+ */
609
+ return $response;
610
+ }
611
+
612
+ if ( ! empty( $data['wp_autosave'] ) ) {
613
+
614
+ if ( empty( $data['wp_autosave']['post_id'] ) || 0 === (int) $data['wp_autosave']['post_id'] ) {
615
+ /**
616
+ * wp_autosave may come from edit.php page
617
+ */
618
+ return $response;
619
+ }
620
+
621
+ if ( empty( $data['wpglobus_heartbeat'] ) ) {
622
+ /**
623
+ * Check for wpglobus key
624
+ */
625
+ return $response;
626
+ }
627
+
628
+ $title_wrap = false;
629
+ $content_wrap = false;
630
+ $post_title_ext = '';
631
+ $content_ext = '';
632
+
633
+ foreach ( WPGlobus::Config()->enabled_languages as $language ) {
634
+ if ( $language === WPGlobus::Config()->default_language ) {
635
+
636
+ $post_title_ext .= WPGlobus::add_locale_marks( $data['wp_autosave']['post_title'], $language );
637
+ $content_ext .= WPGlobus::add_locale_marks( $data['wp_autosave']['content'], $language );
638
+
639
+ } else {
640
+
641
+ if ( ! empty( $data['wp_autosave'][ 'post_title_' . $language ] ) ) {
642
+ $title_wrap = true;
643
+
644
+ $post_title_ext .= WPGlobus::add_locale_marks( $data['wp_autosave'][ 'post_title_' . $language ], $language );
645
+ }
646
+
647
+ if ( ! empty( $data['wp_autosave'][ 'content_' . $language ] ) ) {
648
+ $content_wrap = true;
649
+
650
+ $content_ext .= WPGlobus::add_locale_marks( $data['wp_autosave'][ 'content_' . $language ], $language );
651
+ }
652
+ }
653
+ }
654
+
655
+ if ( $title_wrap ) {
656
+ $data['wp_autosave']['post_title'] = $post_title_ext;
657
+ }
658
+
659
+ if ( $content_wrap ) {
660
+ $data['wp_autosave']['content'] = $content_ext;
661
+ }
662
+
663
+ /**
664
+ * Filter before autosave
665
+ *
666
+ * @since 1.0.2
667
+ *
668
+ * @param array $data ['wp_autosave'] Array of post data.
669
+ */
670
+ $data['wp_autosave'] = apply_filters( 'wpglobus_autosave_post_data', $data['wp_autosave'] );
671
+
672
+ $saved = wp_autosave( $data['wp_autosave'] );
673
+
674
+ if ( is_wp_error( $saved ) ) {
675
+ $response['wp_autosave'] = array(
676
+ 'success' => false,
677
+ 'message' => $saved->get_error_message(),
678
+ );
679
+ } elseif ( empty( $saved ) ) {
680
+ $response['wp_autosave'] = array(
681
+ 'success' => false,
682
+ /// Do not translate
683
+ 'message' => __( 'Error while saving.' ),
684
+ );
685
+ } else {
686
+ /// Do not translate
687
+ $draft_saved_date_format = __( 'g:i:s a' );
688
+ $response['wp_autosave'] = array(
689
+ 'success' => true,
690
+ 'message' => sprintf(
691
+ /// Do not translate
692
+ __( 'Draft saved at %s.' ), date_i18n( $draft_saved_date_format ) ),
693
+ );
694
+ }
695
+ }
696
+
697
+ return $response;
698
+ }
699
+
700
+ /**
701
+ * Filter @see wp_nav_menu_objects
702
+ *
703
+ * @since 1.0.2
704
+ *
705
+ * @param array $object
706
+ *
707
+ * @return array
708
+ */
709
+ public static function filter__nav_menu_objects( $object ) {
710
+
711
+ if ( is_array( $object ) ) {
712
+ foreach ( $object as &$post ) {
713
+ if ( ! empty( $post->attr_title ) ) {
714
+ $post->attr_title = WPGlobus_Core::text_filter( $post->attr_title, WPGlobus::Config()->language );
715
+ }
716
+ }
717
+ }
718
+
719
+ return $object;
720
+
721
+ }
722
+
723
+ /**
724
+ * Translate widget strings (besides the title handled by the `widget_title` filter)
725
+ *
726
+ * @see WP_Widget::display_callback
727
+ * @scope front
728
+ *
729
+ * @param string[] $instance
730
+ *
731
+ * @return string[]
732
+ * @since 1.0.6
733
+ */
734
+ public static function filter__widget_display_callback( $instance ) {
735
+
736
+ foreach ( $instance as &$widget_setting ) {
737
+
738
+ /** @noinspection ReferenceMismatchInspection */
739
+ if ( ! empty( $widget_setting ) && is_string( $widget_setting ) ) {
740
+ $widget_setting =
741
+ WPGlobus_Core::text_filter( $widget_setting, WPGlobus::Config()->language );
742
+ }
743
+ }
744
+
745
+ return $instance;
746
+ }
747
+
748
+ /**
749
+ * Filter @see comment_moderation_text,
750
+ *
751
+ * @see comment_moderation_subject
752
+ * @since 1.0.6
753
+ *
754
+ * @param string $text
755
+ * @param int $comment_id
756
+ *
757
+ * @return string
758
+ */
759
+ public static function filter__comment_moderation( $text, $comment_id ) {
760
+
761
+ $comment = get_comment( $comment_id );
762
+ $post = get_post( $comment->comment_post_ID );
763
+ $title = WPGlobus_Core::text_filter( $post->post_title, WPGlobus::Config()->language );
764
+
765
+ return str_replace( $post->post_title, $title, $text );
766
+
767
+ }
768
+
769
+ /**
770
+ * Filter @see wp_trim_words
771
+ *
772
+ * @qa At the /wp-admin/index.php page is a Quick Draft metabox
773
+ * which shows 3 last post drafts. This filter lets post content in default language.
774
+ * @since 1.0.14
775
+ *
776
+ * @param string $text The trimmed text.
777
+ * @param int $num_words The number of words to trim the text to.
778
+ * @param string $more An optional string to append to the end of the trimmed text, e.g. &hellip;.
779
+ * @param string $original_text The text before it was trimmed.
780
+ *
781
+ * @return string
782
+ */
783
+ public static function filter__wp_trim_words(
784
+ /** @noinspection PhpUnusedParameterInspection */
785
+ $text, $num_words, $more, $original_text
786
+ ) {
787
+
788
+ // Method argument is ignored.
789
+ /* @noinspection SuspiciousAssignmentsInspection */
790
+ $text = WPGlobus_Core::text_filter( $original_text, WPGlobus::Config()->language );
791
+
792
+ if ( null === $more ) {
793
+ /// Do not translate
794
+ $more = __( '&hellip;' );
795
+ }
796
+
797
+ $text = wp_strip_all_tags( $text );
798
+ /// Do not translate
799
+ if ( 'characters' == _x( 'words', 'word count: words or characters?' ) && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) {
800
+ $text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' );
801
+ preg_match_all( '/./u', $text, $words_array );
802
+ $words_array = array_slice( $words_array[0], 0, $num_words + 1 );
803
+ $sep = '';
804
+ } else {
805
+ $words_array = preg_split( "/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY );
806
+ $sep = ' ';
807
+ }
808
+ if ( count( $words_array ) > $num_words ) {
809
+ array_pop( $words_array );
810
+ $text = implode( $sep, $words_array );
811
+ $text = $text . $more;
812
+ } else {
813
+ $text = implode( $sep, $words_array );
814
+ }
815
+
816
+ return $text;
817
+
818
+ }
819
+
820
+ /**
821
+ * Register the WPGlobus widgets
822
+ *
823
+ * @wp-hook widgets_init
824
+ * @since 1.0.7
825
+ */
826
+ public static function register_widgets() {
827
+ register_widget( 'WPGlobusWidget' );
828
+ }
829
+
830
+ /**
831
+ * Do something on admin_init hook.
832
+ *
833
+ * @todo Note: runs on admin-ajax and admin-post, too
834
+ */
835
+ public static function action__admin_init() {
836
+ /**
837
+ * Display blog name correctly on the WooThemes Helper page
838
+ * wp-admin/index.php?page=woothemes-helper
839
+ */
840
+ if ( WPGlobus_WP::is_plugin_page( 'woothemes-helper' ) ) {
841
+ add_filter( 'option_blogname', array( 'WPGlobus_Filters', 'filter__text' ), 0 );
842
+ }
843
+ }
844
+
845
+ /**
846
+ * Specify meta keys where the meta data can be multilingual
847
+ *
848
+ * @example
849
+ * <code>
850
+ * add_filter( 'wpglobus_multilingual_meta_keys',
851
+ * function ( $multilingual_meta_keys ) {
852
+ * $multilingual_meta_keys['slides'] = true;
853
+ * return $multilingual_meta_keys;
854
+ * }
855
+ * );
856
+ * </code>
857
+ * @since 1.2.1
858
+ */
859
+ public static function set_multilingual_meta_keys() {
860
+ self::$multilingual_meta_keys = apply_filters(
861
+ 'wpglobus_multilingual_meta_keys', self::$multilingual_meta_keys
862
+ );
863
+ }
864
+
865
+ /**
866
+ * Translate meta data
867
+ *
868
+ * @see \WPGlobus_Filters::set_multilingual_meta_keys
869
+ *
870
+ * @param string|array $value Null is passed. We set the value.
871
+ * @param int $object_id Post ID
872
+ * @param string $meta_key Passed by the filter. We need only one key.
873
+ * @param string|array $single Meta value, or an array of values.
874
+ *
875
+ * @return string|array
876
+ */
877
+ public static function filter__postmeta( $value, $object_id, $meta_key, $single ) {
878
+
879
+ /**
880
+ * @todo Currently, only single values are supported
881
+ */
882
+ if ( ! $single ) {
883
+ return $value;
884
+ }
885
+
886
+ /**
887
+ * Will process only if the `meta_key` is one of the explicitly set.
888
+ */
889
+ if ( ! isset( self::$multilingual_meta_keys[ $meta_key ] ) ) {
890
+ return $value;
891
+ }
892
+
893
+ /**
894
+ * May be called many times on one page. Let's cache.
895
+ */
896
+ static $_cache;
897
+ if ( isset( $_cache[ $meta_key ][ $object_id ] ) ) {
898
+ return $_cache[ $meta_key ][ $object_id ];
899
+ }
900
+
901
+ /** @global wpdb $wpdb */
902
+ global $wpdb;
903
+ $meta_value = $wpdb->get_var(
904
+ $wpdb->prepare(
905
+ "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = %s AND post_id = %d LIMIT 1;",
906
+ $meta_key, $object_id
907
+ )
908
+ );
909
+
910
+ if ( $meta_value ) {
911
+
912
+ if ( is_serialized( $meta_value ) ) {
913
+ /**
914
+ * @todo Refactor this. Write a `filter__array` method.
915
+ */
916
+ $_meta_array = unserialize( $meta_value );
917
+ foreach ( $_meta_array as &$_value ) {
918
+ if ( is_array( $_value ) ) {
919
+ foreach ( $_value as &$_deep_value ) {
920
+ /**
921
+ * @todo Assuming that the array had max. two levels, which is wrong.
922
+ */
923
+ $_deep_value = self::filter__text( $_deep_value );
924
+ }
925
+ unset( $_deep_value );
926
+ } else {
927
+ $_value = self::filter__text( $_value );
928
+ }
929
+ }
930
+ unset( $_value );
931
+ $value = $_meta_array;
932
+
933
+ /**
934
+ * If single is requested, the following code is executed by
935
+ *
936
+ * @see get_metadata
937
+ * <code>
938
+ * if ( $single && is_array( $check ) )
939
+ * return $check[0];
940
+ * </code>
941
+ * Therefore, we need to return the entire `$value` as the first element of
942
+ * an array.
943
+ */
944
+ if ( $single ) {
945
+ $value = array( $value );
946
+ }
947
+ } else {
948
+ $value = self::filter__text( $meta_value );
949
+ }
950
+ }
951
+
952
+ /**
953
+ * Save to cache, even if we did not do anything
954
+ */
955
+ $_cache[ $meta_key ][ $object_id ] = $value;
956
+
957
+ return $value;
958
+ }
959
+
960
+ /**
961
+ * Localize feed url
962
+ *
963
+ * @since 1.5.3
964
+ *
965
+ * @scope both (RSS are shown in admin dashboard "News" widgets).
966
+ *
967
+ * @param SimplePie $obj
968
+ */
969
+ public static function fetch_feed_options( $obj ) {
970
+
971
+ $need_to_localize = true;
972
+ /**
973
+ * Filter to disable localize feed url.
974
+ *
975
+ * @since 1.5.3
976
+ *
977
+ * @param bool $need_to_localize True is value by default.
978
+ * @param SimplePie $obj The feed object.
979
+ *
980
+ * @return bool
981
+ */
982
+ $need_to_localize = apply_filters( 'wpglobus_localize_feed_url', $need_to_localize, $obj );
983
+
984
+ if ( ! empty( $obj->feed_url ) && $need_to_localize ) {
985
+ $obj->feed_url = WPGlobus_Utils::localize_url( $obj->feed_url );
986
+ }
987
+
988
+ }
989
+
990
+ /**
991
+ * Filter CSS rules for frontend.
992
+ *
993
+ * @since 1.6.6
994
+ *
995
+ * @scope front
996
+ */
997
+ public static function filter__front_styles( $css, $css_editor ) {
998
+ if ( ! empty( $css_editor ) ) {
999
+ $css .= strip_tags( $css_editor );
1000
+ }
1001
+
1002
+ return $css;
1003
+ }
1004
+
1005
+ /**
1006
+ * De-localize URL to the default language so that @see url_to_postid() can
1007
+ * determine the post ID.
1008
+ *
1009
+ * @since 1.8.4
1010
+ *
1011
+ * @param string $url The URL to derive the post ID from.
1012
+ *
1013
+ * @return string
1014
+ */
1015
+ public static function filter__url_to_postid( $url ) {
1016
+ $url = WPGlobus_Utils::localize_url( $url, WPGlobus::Config()->default_language );
1017
+
1018
+ return $url;
1019
+ }
1020
+
1021
+ /**
1022
+ * The post ID has been changed already by the @see filter__url_to_postid,
1023
+ * so we do not need to modify it here.
1024
+ * However, oembed does not know which language to use to fill in its $data
1025
+ * from the post.
1026
+ * Therefore, we use a workaround: extract the language from the URL and
1027
+ * store it in a special variable, to use later in
1028
+ *
1029
+ * @see filter__oembed_response_data.
1030
+ *
1031
+ * @since 1.8.4
1032
+ *
1033
+ * @param int $post_id The post ID.
1034
+ * @param string $url The requested URL.
1035
+ *
1036
+ * @return int The post ID, unchanged.
1037
+ */
1038
+ public static function filter__oembed_request_post_id( $post_id, $url ) {
1039
+ $language = WPGlobus_Utils::extract_language_from_url( $url );
1040
+ if ( $language !== WPGlobus::Config()->default_language ) {
1041
+ WPGlobus::Config()->setLanguageForOembed( $language );
1042
+ }
1043
+
1044
+ return $post_id;
1045
+ }
1046
+
1047
+ /**
1048
+ * Filter the oembed data returned by the /wp-json/oembed/... calls.
1049
+ *
1050
+ * @param array $data The response data.
1051
+ *
1052
+ * @return array
1053
+ * @since 1.8.4
1054
+ */
1055
+ public static function filter__oembed_response_data( $data ) {
1056
+ // If $language_for_oembed is empty, text_filter will use the default language.
1057
+ $language_for_oembed = WPGlobus::Config()->getAndResetLanguageForOembed();
1058
+ foreach ( array( 'author_name', 'title' ) as $field ) {
1059
+ if ( ! empty( $data[ $field ] ) ) {
1060
+ $data[ $field ] = WPGlobus_Core::text_filter( $data[ $field ], $language_for_oembed );
1061
+ }
1062
+ }
1063
+
1064
+ return $data;
1065
+ }
1066
+
1067
+ /**
1068
+ * Filters the wp_mail() arguments.
1069
+ *
1070
+ * @see wp-includes\pluggable.php
1071
+ *
1072
+ * @param array $atts A compacted array of wp_mail() arguments.
1073
+ *
1074
+ * @return array
1075
+ * @since 1.9.5
1076
+ */
1077
+ public static function filter__wp_mail( $atts ) {
1078
+
1079
+ /**
1080
+ * May be called many times. Let's cache.
1081
+ */
1082
+ /*
1083
+ static $_cache;
1084
+ if ( isset( $_cache ) ) {
1085
+ return $_cache;
1086
+ } // */
1087
+
1088
+ /**
1089
+ * Array of enabled attributes to translate.
1090
+ * Full array is 'to', 'subject', 'message', 'headers', 'attachments';
1091
+ */
1092
+ $keys = array( 'subject', 'message', 'headers' );
1093
+
1094
+ foreach ( $keys as $key ) :
1095
+
1096
+ if ( empty( $atts[ $key ] ) ) {
1097
+ continue;
1098
+ }
1099
+
1100
+ if ( 'message' === $key ) {
1101
+ $atts[ $key ] = str_replace( "\n", '[[wpg-newline]]', $atts[ $key ] );
1102
+ }
1103
+
1104
+ $atts[ $key ] = WPGlobus_Core::extract_text( $atts[ $key ], WPGlobus::Config()->default_language );
1105
+
1106
+ if ( 'message' === $key ) {
1107
+ $atts[ $key ] = str_replace( '[[wpg-newline]]', "\n", $atts[ $key ] );
1108
+ }
1109
+
1110
+ endforeach;
1111
+
1112
+ /**
1113
+ * Save to cache.
1114
+ */
1115
+ // $_cache = $atts;
1116
+
1117
+ return $atts;
1118
+ }
1119
+
1120
+ /**
1121
+ * Filters oEmbed HTML.
1122
+ *
1123
+ * @param mixed $cache The cached HTML result, stored in post meta.
1124
+ * @param string $url The attempted embed URL.
1125
+ * @param array $attr An array of shortcode attributes.
1126
+ * @param int $post_ID Post ID.
1127
+ *
1128
+ * @return string
1129
+ * @since 1.9.8
1130
+ */
1131
+ public static function filter__embed_oembed_html( $cache, $url, $attr, $post_ID ) {
1132
+
1133
+ if ( ! is_string( $cache ) ) {
1134
+ /**
1135
+ * @since 1.9.8. We are working with string.
1136
+ */
1137
+ return $cache;
1138
+ }
1139
+
1140
+ $language = WPGlobus_Utils::extract_language_from_url( $url );
1141
+
1142
+ if ( empty( $language ) ) {
1143
+ /**
1144
+ * URL has no language code. So this is default language.
1145
+ */
1146
+ return $cache;
1147
+ }
1148
+
1149
+ $cache = str_replace( WPGlobus_Utils::localize_url( $url, WPGlobus::Config()->default_language ), $url, $cache );
1150
+
1151
+ return $cache;
1152
+ }
1153
+
1154
+ }
includes/class-wpglobus-plugin.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * File: class-wpglobus-plugin.php
4
+ *
5
+ * @package WPGlobus
6
+ * @since 1.6.1
7
+ */
8
+
9
+ /**
10
+ * Class WPGlobus_Plugin
11
+ */
12
+ abstract class WPGlobus_Plugin {
13
+
14
+ /**
15
+ * `__FILE__` from the loader.
16
+ *
17
+ * @var string
18
+ */
19
+ public $plugin_file = '';
20
+
21
+ /**
22
+ * Basename from `__FILE__`.
23
+ *
24
+ * @var string
25
+ */
26
+ public $plugin_basename = '';
27
+
28
+ /**
29
+ * Plugin directory URL. Initialized by the constructor.
30
+ *
31
+ * @var string
32
+ */
33
+ public $plugin_dir_url = '';
34
+
35
+ /**
36
+ * Parameter for the updater: slug of the product URL.
37
+ *
38
+ * @var string
39
+ */
40
+ protected $product_slug = '';
41
+
42
+ /**
43
+ * Parameter for the updater: product ID (name).
44
+ *
45
+ * @var string
46
+ */
47
+ protected $product_id = '';
48
+
49
+ /**
50
+ * Used in the `load_textdomain` call.
51
+ *
52
+ * @var string
53
+ */
54
+ protected $textdomain = '';
55
+
56
+ /**
57
+ * Constructor.
58
+ *
59
+ * @param string $the__file__ Pass `__FILE__` from the loader.
60
+ */
61
+ public function __construct( $the__file__ ) {
62
+ $this->plugin_file = $the__file__;
63
+ $this->plugin_basename = plugin_basename( $this->plugin_file );
64
+ $this->plugin_dir_url = plugin_dir_url( $this->plugin_file );
65
+ }
66
+
67
+ /**
68
+ * Setup updater.
69
+ * All parameters must be set by the child class' constructor.
70
+ */
71
+ public function setup_updater() {
72
+ if ( $this->plugin_file && $this->product_id && $this->product_slug ) {
73
+ /* @noinspection PhpUndefinedClassInspection */
74
+ new TIVWP_Updater( array(
75
+ 'plugin_file' => $this->plugin_file,
76
+ 'product_id' => $this->product_id,
77
+ 'url_product' => WPGlobus::URL_WPGLOBUS_SITE . 'product/' .
78
+ $this->product_slug . '/',
79
+ ) );
80
+ }
81
+ }
82
+
83
+ /**
84
+ * Load PO/MO.
85
+ * The parameter must be set by the child class' constructor.
86
+ */
87
+ public function load_translations() {
88
+ if ( $this->textdomain ) {
89
+ load_plugin_textdomain( $this->textdomain, false,
90
+ dirname( $this->plugin_basename ) . '/languages'
91
+ );
92
+ }
93
+ }
94
+ }
95
+
96
+ /* EOF */
includes/class-wpglobus-redirect.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package WPGlobus
4
+ * @since 1.8.0
5
+ */
6
+
7
+ /**
8
+ * Class WPGlobus_Redirect
9
+ */
10
+ class WPGlobus_Redirect {
11
+
12
+ /**
13
+ * Constructor.
14
+ */
15
+ public static function construct() {
16
+ add_action( 'wp', array( __CLASS__, 'on__init' ), 1 );
17
+ }
18
+
19
+ /**
20
+ * Init action.
21
+ */
22
+ public static function on__init() {
23
+
24
+ if ( empty( $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) ) { // WPCS: input var ok, sanitization ok.
25
+ // No language information in browser.
26
+ return;
27
+ }
28
+
29
+ $cookie_name = WPGlobus::_COOKIE;
30
+
31
+ if ( ! isset( $_COOKIE[ $cookie_name ] ) ) { // WPCS: input var ok, sanitization ok.
32
+ /**
33
+ * First visit.
34
+ */
35
+ $browser_language = substr( $_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2 ); // WPCS: input var ok, sanitization ok.
36
+ /* @noinspection SummerTimeUnsafeTimeManipulationInspection */
37
+ setcookie( $cookie_name, $browser_language, time() + 3600 * 24 * 365, '/' );
38
+ self::redirect( $browser_language );
39
+
40
+ return;
41
+ }
42
+
43
+ }
44
+
45
+ /**
46
+ * Redirect to specified language.
47
+ *
48
+ * @param string $language
49
+ */
50
+ public static function redirect( $language ) {
51
+
52
+ if ( $language === WPGlobus::Config()->language ) {
53
+ // Already in that language.
54
+ return;
55
+ }
56
+
57
+ if ( ! in_array( $language, WPGlobus::Config()->enabled_languages, true ) ) {
58
+ // No such language.
59
+ return;
60
+ }
61
+
62
+ // Convert the current URL to the requested language and redirect.
63
+ $current_url = WPGlobus_Utils::current_url();
64
+ $redirect_to = WPGlobus_Utils::localize_url( $current_url, $language );
65
+
66
+ /**
67
+ * Filter the `$redirect_to` URL.
68
+ * Returning a false value cancels redirect.
69
+ *
70
+ * @param string $redirect_to URL redirect to.
71
+ * @param string $language Language redirect to.
72
+ *
73
+ * @return string|false
74
+ */
75
+ $redirect_to = apply_filters( 'wpglobus_first_visit_redirect', $redirect_to, $language );
76
+
77
+ if ( ! $redirect_to ) {
78
+ return;
79
+ }
80
+
81
+ /**
82
+ * @todo This is for the old versions of WPGlobus Plus that do not have the above filter.
83
+ */
84
+ if ( class_exists( 'WPGlobusPlus_Publish' )
85
+ && version_compare( WPGLOBUS_PLUS_VERSION, '1.1.31', '<' )
86
+ && is_singular()
87
+ ) {
88
+ $post_status = get_post_meta( get_the_ID(), WPGlobusPlus_Publish::LANGUAGE_POST_STATUS, true );
89
+ if ( isset( $post_status[ $language ] ) && 'draft' === $post_status[ $language ] ) {
90
+ // This language is set to draft by WPGlobus Plus.
91
+ return;
92
+ }
93
+ }
94
+
95
+ wp_redirect( $redirect_to );
96
+ exit;
97
+
98
+ }
99
+ }
includes/class-wpglobus-utils.php ADDED
@@ -0,0 +1,457 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * File: class-wpglobus-utils.php
4
+ *
5
+ * @package WPGlobus
6
+ */
7
+
8
+ /**
9
+ * Class WPGlobus_Utils
10
+ */
11
+ class WPGlobus_Utils {
12
+
13
+ /**
14
+ * Localize URL by inserting language prefix
15
+ *
16
+ * @param string $url URL to localize
17
+ * @param string $language Language code
18
+ * @param WPGlobus_Config $config Alternative configuration (i.e. Unit Test mock object)
19
+ *
20
+ * @return string
21
+ */
22
+ public static function localize_url( $url = '', $language = '', WPGlobus_Config $config = null ) {
23
+ /**
24
+ * Use the global configuration if alternative not passed
25
+ */
26
+ if ( null === $config ) {
27
+ // @codeCoverageIgnoreStart
28
+ $config = WPGlobus::Config();
29
+ }
30
+ // @codeCoverageIgnoreEnd
31
+
32
+ /**
33
+ * Use the current language if not passed
34
+ */
35
+ $language = empty( $language ) ? $config->language : $language;
36
+
37
+ /**
38
+ * Local cache to speed-up processing on pages with multiple links.
39
+ */
40
+ static $cache = array();
41
+ if ( isset( $cache[ $language ][ $url ] ) ) {
42
+ return $cache[ $language ][ $url ];
43
+ }
44
+ if ( ! isset( $cache[ $language ] ) ) {
45
+ $cache[ $language ] = array();
46
+ }
47
+
48
+ /**
49
+ * In Admin-Settings-General:
50
+ * WordPress Address (URL) is site_url()
51
+ * Site Address (URL) is home_url
52
+ * We need home_url, and we cannot use the @home_url function,
53
+ * because it will filter back here causing endless loop.
54
+ *
55
+ * @todo Multisite?
56
+ */
57
+ $home_url = get_option( 'home' );
58
+
59
+ /**
60
+ * `hide_default_language` means "Do not use language code in the default URL"
61
+ * So, no /en/page/, just /page/
62
+ */
63
+ if ( $language === $config->default_language && $config->hide_default_language ) {
64
+ $language_url_prefix = '';
65
+ } else {
66
+ /**
67
+ * Language prefix looks like '/ru'
68
+ */
69
+ $language_url_prefix = '/' . $language;
70
+ }
71
+
72
+ /**
73
+ * For the following regex, we need home_url without prefix
74
+ * http://www.example.com becomes example.com
75
+ */
76
+ $home_domain_tld = self::domain_tld( $home_url );
77
+
78
+ /**
79
+ * Regex to replace current language prefix with the requested one.
80
+ *
81
+ * @example ^(https?:\/\/(?:.+\.)?example\.com)(?:\/?(?:en|ru|pt))?($|\/$|[\/#\?].*$)
82
+ */
83
+
84
+ /**
85
+ * The "host+path" part of the URL (captured)
86
+ * We ignore http(s) and domain prefix, but we must match the domain-tld, so any external URLs
87
+ * are not localized.
88
+ */
89
+ $re_host_part = '(https?:\/\/(?:.+\.)?' .
90
+ str_replace( '.', '\.', $home_domain_tld ) .
91
+ str_replace( '/', '\/', parse_url( $home_url, PHP_URL_PATH ) )
92
+ . ')';
93
+
94
+ /**
95
+ * The "language" part (optional, not captured, will be thrown away)
96
+ */
97
+ $re_language_part = '(?:\/?(?:' . implode( '|', $config->enabled_languages ) . '))?';
98
+
99
+ /**
100
+ * The rest of the URL. Can be:
101
+ * - Nothing or trailing slash, or
102
+ * - Slash, hash or question and optionally anything after
103
+ * *
104
+ * Using 'or' regex to capture things like '/rush' or '/designer/' correctly,
105
+ * and not extract '/ru' or '/de' from them,
106
+ */
107
+ $re_trailer = '(\/?|[\/#\?].*)';
108
+
109
+ $re = '!^' . $re_host_part . $re_language_part . $re_trailer . '$!';
110
+
111
+ /**
112
+ * Replace the existing (or empty) language prefix with the requested one
113
+ */
114
+ $localized_url = preg_replace( $re, '\1' . $language_url_prefix . '\2', $url );
115
+
116
+ /**
117
+ * Cache it.
118
+ */
119
+ $cache[ $language ][ $url ] = $localized_url;
120
+
121
+ return $localized_url;
122
+ }
123
+
124
+ /**
125
+ * Extract language from URL
126
+ * http://example.com/ru/page/ returns 'ru'
127
+ *
128
+ * @param string $url
129
+ * @param WPGlobus_Config $config Alternative configuration (i.e. Unit Test mock object)
130
+ *
131
+ * @return string
132
+ */
133
+ public static function extract_language_from_url( $url = '', WPGlobus_Config $config = null ) {
134
+
135
+ $language = '';
136
+
137
+ if ( ! is_string( $url ) ) {
138
+ return $language;
139
+ }
140
+
141
+ /**
142
+ * Use the global configuration is alternative not passed
143
+ */
144
+ if ( null === $config ) {
145
+ // @codeCoverageIgnoreStart
146
+ $config = WPGlobus::Config();
147
+ }
148
+ // @codeCoverageIgnoreEnd
149
+
150
+ $path = parse_url( $url, PHP_URL_PATH );
151
+
152
+ $path_home = untrailingslashit( parse_url( get_option( 'home' ), PHP_URL_PATH ) );
153
+
154
+ /**
155
+ * Regex to find the language prefix.
156
+ *
157
+ * @example !^/(en|ru|pt)/!
158
+ */
159
+ $re = '!^' . $path_home .
160
+ '/(' . implode( '|', $config->enabled_languages ) . ')(?:/|$)' . '!';
161
+
162
+ if ( preg_match( $re, $path, $match ) ) {
163
+ // Found language information
164
+ $language = $match[1];
165
+ }
166
+
167
+ return $language;
168
+
169
+ }
170
+
171
+ /**
172
+ * Check if was called by a specific function (could be any levels deep).
173
+ * @deprecated 1.7.7 Use WPGlobus_WP::is_function_in_backtrace()
174
+ * @see WPGlobus_WP::is_function_in_backtrace()
175
+ *
176
+ * @param string|callable $function_name Function name or array(class,function).
177
+ *
178
+ * @return bool True if Function is in backtrace.
179
+ */
180
+ public static function is_function_in_backtrace( $function_name ) {
181
+ _deprecated_function( __METHOD__, 'WPGlobus 1.7.7', 'WPGlobus_WP::is_function_in_backtrace()' );
182
+
183
+ return WPGlobus_WP::is_function_in_backtrace( $function_name );
184
+ }
185
+
186
+ /**
187
+ * Strip the prefix from the host name
188
+ * http://www.example.com becomes example.com
189
+ *
190
+ * @param string $url
191
+ *
192
+ * @return string
193
+ * @since 1.0.12
194
+ */
195
+ public static function domain_tld( $url ) {
196
+
197
+ $pre = '';
198
+ /**
199
+ * Short-circuit processing to provide own return for the cases not covered by the algorithm.
200
+ * Ex. www.example.carrara-massa.it (carrara-massa.it is a TLD)
201
+ *
202
+ * @param string $pre Empty string. Return your domain_tld instead.
203
+ * @param string $url The URL to extract domain_tld from.
204
+ */
205
+ $pre = apply_filters( 'wpglobus_pre_domain_tld', $pre, $url );
206
+ if ( $pre ) {
207
+ return $pre;
208
+ }
209
+
210
+ // URL passed with no scheme. parse_url will think it's a path only. Let's add a scheme.
211
+ if ( ! preg_match( '!^(?:https?:)?//!', $url ) ) {
212
+ $url = '//' . $url;
213
+ }
214
+
215
+ $host = parse_url( $url, PHP_URL_HOST );
216
+
217
+ if ( ! $host ) {
218
+ // parse_url failed. We cannot do much. Let's return the original url.
219
+ return $url;
220
+ }
221
+
222
+ /**
223
+ * Extract domain-tld from the host.
224
+ * Note: this does not cover all possible public suffixes.
225
+ * Using the proper algorithm based PublicList might be resource-consuming.
226
+ * We'll provide a filter for special cases instead.
227
+ *
228
+ * @link https://publicsuffix.org/list/
229
+ */
230
+ $re = '/([a-z0-9][a-z0-9\-]+\.[a-z\.]{2,6})$/';
231
+ $domain_tld = $host;
232
+ if ( preg_match( $re, $host, $matches ) ) {
233
+ $domain_tld = $matches[1];
234
+ }
235
+
236
+ return $domain_tld;
237
+ }
238
+
239
+ /**
240
+ * Convert array of local texts to multilingual string (with WPGlobus delimiters)
241
+ *
242
+ * @param string[] $translations
243
+ *
244
+ * @return string
245
+ */
246
+ public static function build_multilingual_string( $translations ) {
247
+ $sz = '';
248
+ $single = ( 1 === count( $translations ) );
249
+ foreach ( $translations as $language => $text ) {
250
+ if ( $single && $language === WPGlobus::Config()->default_language ) {
251
+ $sz = $text;
252
+ } else {
253
+ $sz .= WPGlobus::add_locale_marks( $text, $language );
254
+ }
255
+ }
256
+
257
+ return $sz;
258
+ }
259
+
260
+ /**
261
+ * Returns the current URL.
262
+ * There is no method of getting the current URL in WordPress.
263
+ * Various snippets published on the Web use a combination of home_url and add_query_arg.
264
+ * However, none of them work when WordPress is installed in a subfolder.
265
+ * The method below looks valid. There is a theoretical chance of HTTP_HOST tampered, etc.
266
+ * However, the same line of code is used by the WordPress core,
267
+ * for example in @see wp_admin_canonical_url, so we are going to use it, too
268
+ * *
269
+ * Note that #hash is always lost because it's a client-side parameter.
270
+ * We might add it using a JavaScript call.
271
+ *
272
+ * @since 1.1.1
273
+ */
274
+ public static function current_url() {
275
+ return set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); // WPCS: input var ok, sanitization ok.
276
+ }
277
+
278
+ /**
279
+ * Build hreflang metas
280
+ *
281
+ * @since 1.1.1
282
+ *
283
+ * @param WPGlobus_Config $config Alternative configuration (i.e. Unit Test mock object)
284
+ *
285
+ * @return string[] Array of rel-alternate link tags
286
+ */
287
+ public static function hreflangs( WPGlobus_Config $config = null ) {
288
+
289
+ /**
290
+ * Use the global configuration is alternative not passed
291
+ */
292
+ if ( null === $config ) {
293
+ // @codeCoverageIgnoreStart
294
+ $config = WPGlobus::Config();
295
+ }
296
+ // @codeCoverageIgnoreEnd
297
+
298
+ $hreflangs = array();
299
+
300
+ if ( is_404() ) {
301
+ return $hreflangs;
302
+ }
303
+
304
+ foreach ( $config->enabled_languages as $language ) {
305
+
306
+ $hreflangs[ $language ] = sprintf( '<link rel="alternate" hreflang="%s" href="%s"/>',
307
+ str_replace( '_', '-', $config->locale[ $language ] ),
308
+ esc_url( WPGlobus_Utils::localize_current_url( $language, $config ) )
309
+ );
310
+
311
+ }
312
+
313
+ return $hreflangs;
314
+ }
315
+
316
+ /**
317
+ * Localize the current URL.
318
+ * @since 1.2.3
319
+ *
320
+ * @param string $language Language to localize the URL to.
321
+ * @param WPGlobus_Config $config Alternative configuration (i.e. Unit Test mock object)
322
+ *
323
+ * @return string
324
+ */
325
+ public static function localize_current_url( $language = '', WPGlobus_Config $config = null ) {
326
+ /**
327
+ * Filter the current URL before it is localized (a short-circuit filter).
328
+ * If a non-empty string is returned by the filter, then the `localize_url()`
329
+ * won't be called.
330
+ *
331
+ * @param string $url Empty string is passed.
332
+ * @param string $language The language that the URL is going to be localized to.
333
+ *
334
+ * @return string
335
+ */
336
+ $url = apply_filters( 'wpglobus_pre_localize_current_url', '', $language );
337
+
338
+ if ( ! $url ) {
339
+ /**
340
+ * Use the global configuration if alternative not passed
341
+ */
342
+ if ( null === $config ) {
343
+ // @codeCoverageIgnoreStart
344
+ $config = WPGlobus::Config();
345
+ }
346
+ // @codeCoverageIgnoreEnd
347
+ $url = WPGlobus_Utils::localize_url( WPGlobus_Utils::current_url(), $language, $config );
348
+ }
349
+
350
+ /**
351
+ * Filter the current URL after it was localized.
352
+ *
353
+ * @since 1.8.1
354
+ *
355
+ * @param string $url The localized URL.
356
+ * @param string $language The language it was localized to.
357
+ *
358
+ * @return string
359
+ */
360
+ $url = apply_filters( 'wpglobus_after_localize_current_url', $url, $language );
361
+
362
+ return $url;
363
+ }
364
+
365
+ /**
366
+ * Localize wpglobus.com for use in outgoing links
367
+ *
368
+ * @param WPGlobus_Config $config
369
+ *
370
+ * @return string
371
+ * @since 1.2.6
372
+ */
373
+ public static function url_wpglobus_site( WPGlobus_Config $config = null ) {
374
+ if ( null === $config ) {
375
+ // @codeCoverageIgnoreStart
376
+ $config = WPGlobus::Config();
377
+ }
378
+ // @codeCoverageIgnoreEnd
379
+
380
+ $url = WPGlobus::URL_WPGLOBUS_SITE;
381
+ if ( 'ru' === $config->language ) {
382
+ $url .= 'ru' . '/';
383
+ }
384
+
385
+ return $url;
386
+ }
387
+
388
+ /**
389
+ * @codeCoverageIgnore
390
+ * Return true if language is in array of enabled languages, otherwise false
391
+ *
392
+ * @param string $language
393
+ *
394
+ * @return bool
395
+ */
396
+ public static function is_enabled( $language ) {
397
+ return in_array( $language, WPGlobus::Config()->enabled_languages, true );
398
+ }
399
+
400
+ /**
401
+ * Secure access to scalars in $_GET.
402
+ *
403
+ * @param string $key Index ($_GET[ $key ]).
404
+ *
405
+ * @return string The value or empty string if not exists or not scalar.
406
+ */
407
+ public static function safe_get( $key ) {
408
+ $value = '';
409
+
410
+ if ( isset( $_GET[ $key ] ) ) { // Input var okay.
411
+ $get_key = $_GET[ $key ]; // Input var okay; sanitization okay.
412
+
413
+ if ( is_scalar( $get_key ) ) {
414
+ $value = sanitize_text_field( $get_key );
415
+ }
416
+ }
417
+
418
+ return $value;
419
+ }
420
+
421
+ /**
422
+ * @todo The methods below are not used by the WPGlobus plugin.
423
+ * Need to check if they are used by any add-on.
424
+ * Marking them as deprecated so they will pop-up on code inspection.
425
+ */
426
+
427
+ /**
428
+ * @deprecated
429
+ * @codeCoverageIgnore
430
+ * Return true if language is in array of opened languages, otherwise false
431
+ *
432
+ * @param string $language
433
+ *
434
+ * @return bool
435
+ */
436
+ public static function is_open( $language ) {
437
+ return in_array( $language, WPGlobus::Config()->open_languages, true );
438
+ }
439
+
440
+ /**
441
+ * @deprecated
442
+ * @codeCoverageIgnore
443
+ *
444
+ * @param string $s
445
+ * @param string $n
446
+ *
447
+ * @return bool
448
+ */
449
+ public static function starts_with( $s, $n ) {
450
+ if ( strlen( $n ) > strlen( $s ) ) {
451
+ return false;
452
+ }
453
+
454
+ /* @noinspection SubStrUsedAsStrPosInspection */
455
+ return ( $n === substr( $s, 0, strlen( $n ) ) );
456
+ }
457
+ }
includes/class-wpglobus-widget.php ADDED
@@ -0,0 +1,278 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Widget
4
+ * @since 1.0.7
5
+ * @package WPGlobus
6
+ */
7
+
8
+ /**
9
+ * Class WPGlobusWidget
10
+ */
11
+ class WPGlobusWidget extends WP_Widget {
12
+
13
+ /**
14
+ * Array types of switcher
15
+ * @access private
16
+ * @since 1.0.7
17
+ * @var array
18
+ */
19
+ private $types = array();
20
+
21
+ /**
22
+ * Constructor
23
+ */
24
+ public function __construct() {
25
+ parent::__construct(
26
+ 'wpglobus',
27
+ esc_html__( 'WPGlobus widget', 'wpglobus' ),
28
+ array(
29
+ 'description' => esc_html__( 'Add language switcher', 'wpglobus' )
30
+ )
31
+ );
32
+ $this->types['flags'] = esc_html__( 'Flags', 'wpglobus' );
33
+ $this->types['list'] = esc_html__( 'List', 'wpglobus' );
34
+ $this->types['list_with_flags'] = esc_html__( 'List with flags', 'wpglobus' );
35
+ $this->types['select'] = esc_html__( 'Select', 'wpglobus' );
36
+ $this->types['select_with_code'] = esc_html__( 'Select with language code', 'wpglobus' );
37
+ $this->types['dropdown'] = esc_html__( 'Dropdown', 'wpglobus' );
38
+ $this->types['dropdown_with_flags'] = esc_html__( 'Dropdown with flags', 'wpglobus' );
39
+ }
40
+
41
+ /**
42
+ * Echo the widget content.
43
+ *
44
+ * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
45
+ * @param array $instance The settings for the particular instance of the widget
46
+ */
47
+ public function widget( $args, $instance ) {
48
+
49
+ if ( ! empty( $instance['type'] ) ) {
50
+ $type = $instance['type'];
51
+ } else {
52
+ $type = 'flags';
53
+ }
54
+
55
+ $inside = '';
56
+
57
+ $enabled_languages = WPGlobus::Config()->enabled_languages;
58
+
59
+ switch ( $type ) :
60
+ case 'list' :
61
+ $code = '<div class="list">{{inside}}</div>';
62
+ break;
63
+ case 'list_with_flags' :
64
+ $code = '<div class="list flags">{{inside}}</div>';
65
+ break;
66
+ case 'select' :
67
+ case 'select_with_code' :
68
+ $code =
69
+ '<div class="select-styled"><select onchange="document.location.href = this.value;">{{inside}}</select></div>';
70
+ break;
71
+ case 'dropdown' :
72
+ case 'dropdown_with_flags' :
73
+ /**
74
+ * @todo remove after testing.
75
+ * @since 1.6.9
76
+ */
77
+ //$sorted[] = WPGlobus::Config()->language;
78
+ //foreach ( $enabled_languages as $language ) {
79
+ //if ( $language != WPGlobus::Config()->language ) {
80
+ //$sorted[] = $language;
81
+ //}
82
+ //}
83
+ //$enabled_languages = $sorted;
84
+
85
+ $code = '<div class="dropdown-styled"> <ul>
86
+ <li>
87
+ {{language}}
88
+ <ul>
89
+ {{inside}}
90
+ </ul>
91
+ </li>
92
+ </ul></div>';
93
+ break;
94
+ default:
95
+ // This is case 'flags'. Having it as default makes $code always set.
96
+ $code = '<div class="flags-styled">{{inside}}</div>';
97
+ break;
98
+ endswitch;
99
+
100
+ $extra_languages = array_diff( $enabled_languages, (array) WPGlobus::Config()->language );
101
+
102
+ /**
103
+ * Filter extra languages.
104
+ *
105
+ * Returning array.
106
+ *
107
+ * @since 1.0.13
108
+ * @since 1.6.9
109
+ *
110
+ * @param array $extra_languages An array with extra languages to show off in menu.
111
+ * @param string WPGlobus::Config()->language The current language.
112
+ */
113
+ $extra_languages = apply_filters( 'wpglobus_extra_languages', $extra_languages, WPGlobus::Config()->language );
114
+
115
+ $enabled_languages = array_merge( (array)WPGlobus::Config()->language, $extra_languages );
116
+
117
+ /**
118
+ * Class for link in a and option tags. Used for adding hash.
119
+ * @see class wpglobus-selector-link
120
+ * @since 1.2.0
121
+ */
122
+ $link_classes['selector_link'] = 'wpglobus-selector-link';
123
+
124
+ /**
125
+ * Class for flag box
126
+ * @since 1.4.0
127
+ */
128
+ $flag_classes = array();
129
+
130
+ echo $args['before_widget']; // WPCS: XSS ok.
131
+ if ( ! empty( $instance['title'] ) ) {
132
+ echo $args['before_title'] . $instance['title'] . $args['after_title']; // WPCS: XSS ok.
133
+ }
134
+ foreach ( $enabled_languages as $language ) :
135
+
136
+ $selected = '';
137
+
138
+ /**
139
+ * Init current language class
140
+ */
141
+ $link_classes['current_language'] = '';
142
+
143
+ /**
144
+ * Init current language class for flag box
145
+ */
146
+ $flag_classes['current_language'] = '';
147
+
148
+ if ( $language == WPGlobus::Config()->language ) {
149
+ $selected = ' selected';
150
+ switch ( $type ) :
151
+ case 'flags' :
152
+ $flag_classes['current_language'] = 'wpglobus-current-language';
153
+ break;
154
+ case 'list' :
155
+ case 'list_with_flags' :
156
+ case 'dropdown' :
157
+ case 'dropdown_with_flags' :
158
+ $link_classes['current_language'] = 'wpglobus-current-language';
159
+ break;
160
+ endswitch;
161
+ }
162
+
163
+ $url = WPGlobus_Utils::localize_current_url( $language );
164
+
165
+ $flag = WPGlobus::Config()->flags_url . WPGlobus::Config()->flag[ $language ];
166
+
167
+ switch ( $type ) :
168
+ case 'flags' :
169
+ $inside .= '<span class="flag ' . implode( ' ', $flag_classes ) . '">';
170
+ $inside .= '<a href="' . $url . '" class="' . implode( ' ', $link_classes ) . '"><img src="' . $flag . '"/></a>';
171
+ $inside .= '</span>';
172
+ break;
173
+ case 'list' :
174
+ case 'list_with_flags' :
175
+ $inside .= '<a href="' . $url . '" class="' . implode( ' ', $link_classes ) . '">' .
176
+ '<img src="' . $flag . '" alt=""/>' .
177
+ ' ' .
178
+ '<span class="name">' .
179
+ WPGlobus::Config()->language_name[ $language ] .
180
+ '</span>' .
181
+ ' ' .
182
+ '<span class="code">' . strtoupper( $language ) . '</span>' .
183
+ '</a>';
184
+ break;
185
+ case 'select' :
186
+ $inside .= '<option class="' . implode( ' ', $link_classes ) . '" ' . $selected . ' value="' . $url . '">' . WPGlobus::Config()->language_name[ $language ] . '</option>';
187
+ break;
188
+ case 'select_with_code' :
189
+ $inside .= '<option class="' . implode( ' ', $link_classes ) . '" ' . $selected . ' value="' . $url . '">' . WPGlobus::Config()->language_name[ $language ] . '&nbsp;(' . strtoupper( $language ) . ')</option>';
190
+ break;
191
+ case 'dropdown' :
192
+ if ( '' != $selected ) {
193
+ $code =
194
+ str_replace( '{{language}}', '<a class="' . implode( ' ', $link_classes ) . '" href="' . $url . '">' . WPGlobus::Config()->language_name[ $language ] . '&nbsp;(' . strtoupper( $language ) . ')</a>', $code );
195
+ } else {
196
+ $inside .= '<li><a class="' . implode( ' ', $link_classes ) . '" href="' . $url . '">' . WPGlobus::Config()->language_name[ $language ] . '&nbsp;(' . strtoupper( $language ) . ')</a></li>';
197
+ }
198
+ break;
199
+ case 'dropdown_with_flags' :
200
+ if ( '' != $selected ) {
201
+ $code =
202
+ str_replace( '{{language}}', '<a class="' . implode( ' ', $link_classes ) . '" href="' . $url . '"><img src="' . $flag . '"/>&nbsp;&nbsp;' . WPGlobus::Config()->language_name[ $language ] . '</a>', $code );
203
+ } else {
204
+ $inside .= '<li><a class="' . implode( ' ', $link_classes ) . '" href="' . $url . '"><img src="' . $flag . '"/>&nbsp;&nbsp;' . WPGlobus::Config()->language_name[ $language ] . '</a></li>';
205
+ }
206
+ break;
207
+ endswitch;
208
+
209
+ endforeach;
210
+
211
+ echo str_replace( '{{inside}}', $inside, $code ); // WPCS: XSS ok.
212
+
213
+ echo $args['after_widget']; // WPCS: XSS ok.
214
+
215
+ }
216
+
217
+ /**
218
+ * Echo the settings update form.
219
+ *
220
+ * @param array $instance Current settings
221
+ *
222
+ * @return string
223
+ */
224
+ public function form( $instance ) {
225
+
226
+ if ( isset( $instance['type'] ) ) {
227
+ $selected_type = $instance['type'];
228
+ } else {
229
+ $selected_type = 'flags';
230
+ }
231
+ if ( empty( $instance['title'] ) ) {
232
+ $instance['title'] = '';
233
+ }
234
+ ?>
235
+ <p>
236
+ <label for="<?php echo esc_attr( $this->get_field_name( 'type' ) ); ?>"><?php echo esc_html__( 'Title' ); ?></label>
237
+ <input type="text" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"
238
+ name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" value="<?php echo esc_html( $instance['title'] ); ?>"/>
239
+ </p>
240
+ <p><?php esc_html_e( 'Selector type', 'wpglobus' ); ?></p>
241
+ <p><?php
242
+ foreach ( $this->types as $type => $caption ) :
243
+ $checked = '';
244
+ if ( $selected_type == $type ) {
245
+ $checked = ' checked';
246
+ } ?>
247
+ <input type="radio"
248
+ id="<?php echo esc_attr( $this->get_field_id( 'type' ) ); ?>"
249
+ name="<?php echo esc_attr( $this->get_field_name( 'type' ) ); ?>" <?php echo $checked; // WPCS: XSS ok. ?>
250
+ value="<?php echo esc_attr( $type ); ?>"/> <?php echo $caption . '<br />'; // WPCS: XSS ok.
251
+ endforeach;
252
+ ?></p> <?php
253
+
254
+ return '';
255
+
256
+ }
257
+
258
+ /**
259
+ * Update a particular instance.
260
+ * This function should check that $new_instance is set correctly.
261
+ * The newly calculated value of $instance should be returned.
262
+ * If "false" is returned, the instance won't be saved/updated.
263
+ *
264
+ * @param array $new_instance New settings for this instance as input by the user via form()
265
+ * @param array $old_instance Old settings for this instance
266
+ *
267
+ * @return array Settings to save or bool false to cancel saving
268
+ */
269
+ public function update( $new_instance, $old_instance ) {
270
+ $instance = array();
271
+ $instance['type'] = ( ! empty( $new_instance['type'] ) ) ? $new_instance['type'] : '';
272
+ $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? $new_instance['title'] : '';
273
+
274
+ return $instance;
275
+ }
276
+ }
277
+
278
+ # --- EOF
includes/class-wpglobus-wp.php ADDED
@@ -0,0 +1,254 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WordPress shortcuts
4
+ * @package WPGlobus
5
+ */
6
+
7
+ /**
8
+ * Class WPGlobus_WP
9
+ */
10
+ class WPGlobus_WP {
11
+
12
+ /**
13
+ * CSS classes for admin notices
14
+ * @example
15
+ * <code>
16
+ * echo '<div class="notice ' . WPGlobus_WP::ADMIN_NOTICE_WARNING . '">';
17
+ * </code>
18
+ */
19
+
20
+ const ADMIN_NOTICE_SUCCESS = 'notice-success';
21
+ const ADMIN_NOTICE_ERROR = 'notice-error';
22
+ const ADMIN_NOTICE_INFO = 'notice-info';
23
+ const ADMIN_NOTICE_WARNING = 'notice-warning';
24
+
25
+ /**
26
+ * @return bool
27
+ */
28
+ public static function is_doing_ajax() {
29
+ return ( defined( 'DOING_AJAX' ) && DOING_AJAX );
30
+ }
31
+
32
+ /**
33
+ * Attempt to check if an AJAX call was originated from admin screen.
34
+ * @todo There should be other actions. See $core_actions_get in admin-ajax.php
35
+ * Can also check $GLOBALS['_SERVER']['HTTP_REFERER']
36
+ * and $GLOBALS['current_screen']->in_admin()
37
+ *
38
+ * @todo add $action parameter for case to check for it only
39
+ * @return bool
40
+ */
41
+ public static function is_admin_doing_ajax() {
42
+ return (
43
+ self::is_doing_ajax() &&
44
+ (
45
+ self::is_http_post_action( 'inline-save' ) ||
46
+ self::is_http_post_action( 'save-widget' ) ||
47
+ self::is_http_post_action( 'customize_save' ) ||
48
+ self::is_http_get_action( 'ajax-tag-search' )
49
+ )
50
+ );
51
+ }
52
+
53
+
54
+ /**
55
+ * To get the current admin page
56
+ * (Set in wp-includes/vars.php)
57
+ * @return string $page
58
+ * @since 1.2.0
59
+ */
60
+ public static function pagenow() {
61
+ /**
62
+ * @global string $pagenow
63
+ */
64
+ global $pagenow;
65
+
66
+ return ( isset( $pagenow ) ? $pagenow : '' );
67
+ }
68
+
69
+ /**
70
+ * @param string|string[] $page
71
+ *
72
+ * @return bool
73
+ */
74
+ public static function is_pagenow( $page ) {
75
+ return in_array( self::pagenow(), (array) $page );
76
+ }
77
+
78
+ /**
79
+ * To get the plugin page ID
80
+ * @example On wp-admin/index.php?page=woothemes-helper, will return `woothemes-helper`.
81
+ * @return string
82
+ * @since 1.2.0
83
+ */
84
+ public static function plugin_page() {
85
+ /**
86
+ * Set in wp-admin/admin.php
87
+ * @global string $plugin_page
88
+ */
89
+ global $plugin_page;
90
+
91
+ return ( isset( $plugin_page ) ? $plugin_page : '' );
92
+ }
93
+
94
+ /**
95
+ * @param string|string[] $page
96
+ *
97
+ * @return bool
98
+ */
99
+ public static function is_plugin_page( $page ) {
100
+ return in_array( self::plugin_page(), (array) $page );
101
+ }
102
+
103
+ /**
104
+ * @param string|string[] $action
105
+ *
106
+ * @return bool
107
+ */
108
+ public static function is_http_post_action( $action ) {
109
+
110
+ $action = (array) $action;
111
+
112
+ return ( ! empty( $_POST['action'] ) && in_array( $_POST['action'], $action, true ) ); // WPCS: input var ok, sanitization ok.
113
+ }
114
+
115
+ /**
116
+ * @param string|string[] $action
117
+ *
118
+ * @return bool
119
+ */
120
+ public static function is_http_get_action( $action ) {
121
+
122
+ $action = (array) $action;
123
+
124
+ return ( ! empty( $_GET['action'] ) && in_array( $_GET['action'], $action, true ) ); // WPCS: input var ok, sanitization ok.
125
+ }
126
+
127
+ /**
128
+ * Check if a filter is called by a certain function / class
129
+ *
130
+ * @param string $function
131
+ * @param string $class
132
+ *
133
+ * @return bool
134
+ * @todo Unit test
135
+ * @todo What if we check class only?
136
+ * @todo Use the form class::method ?
137
+ * @todo Check multiple functions and classes (array)
138
+ */
139
+ public static function is_filter_called_by( $function, $class = '' ) {
140
+ if ( empty( $function ) ) {
141
+ return false;
142
+ }
143
+
144
+ /**
145
+ * WP calls filters at level 4. This function adds one more level.
146
+ */
147
+ $trace_level = 5;
148
+
149
+ if ( version_compare( $GLOBALS['wp_version'], '4.6.999', '>' ) ) {
150
+ /**
151
+ * Starting with WordPress 4.7, WP_Hook adds one more level.
152
+ * @since 1.7.0
153
+ */
154
+ $trace_level = 6;
155
+ }
156
+
157
+ if ( version_compare( PHP_VERSION, '7.0.0', '>=' ) ) {
158
+ /**
159
+ * In PHP 7, `call_user_func_array` no longer appears in the trace
160
+ * as a separate call.
161
+ * @since 1.5.4
162
+ */
163
+ $trace_level --;
164
+ }
165
+
166
+ $callers = debug_backtrace();
167
+ if ( empty( $callers[ $trace_level ] ) ) {
168
+ return false;
169
+ }
170
+
171
+ /**
172
+ * First check: if function name matches
173
+ */
174
+ $maybe = ( $callers[ $trace_level ]['function'] === $function );
175
+
176
+ if ( $maybe ) {
177
+ /**
178
+ * Now check if we also asked for a specific class, and it matches
179
+ */
180
+ if ( ! empty( $class ) &&
181
+ ! empty( $callers[ $trace_level ]['class'] ) &&
182
+ $callers[ $trace_level ]['class'] !== $class
183
+ ) {
184
+ $maybe = false;
185
+ }
186
+ }
187
+
188
+ return $maybe;
189
+ }
190
+
191
+ /**
192
+ * Check if was called by a specific function (could be any levels deep).
193
+ *
194
+ * @param callable|string $method Function name or array(class,function).
195
+ *
196
+ * @return bool True if Function is in backtrace.
197
+ */
198
+ public static function is_function_in_backtrace( $method ) {
199
+ $function_in_backtrace = false;
200
+
201
+ // Parse callable into class and function.
202
+ if ( is_string( $method ) ) {
203
+ $function_name = $method;
204
+ $class_name = '';
205
+ } elseif ( is_array( $method ) && isset( $method[0], $method[1] ) ) {
206
+ list( $class_name, $function_name ) = $method;
207
+ } else {
208
+ return false;
209
+ }
210
+
211
+ // Traverse backtrace and stop if the callable is found there.
212
+ foreach ( debug_backtrace() as $_ ) {
213
+ if ( isset( $_['function'] ) && $_['function'] === $function_name ) {
214
+ $function_in_backtrace = true;
215
+ if ( $class_name && isset( $_['class'] ) && $_['class'] !== $class_name ) {
216
+ $function_in_backtrace = false;
217
+ }
218
+ if ( $function_in_backtrace ) {
219
+ break;
220
+ }
221
+ }
222
+ }
223
+
224
+ return $function_in_backtrace;
225
+ }
226
+
227
+ /**
228
+ * To call @see is_function_in_backtrace with the array of parameters.
229
+ *
230
+ * @param callable[] $callables Array of callables.
231
+ *
232
+ * @return bool True if any of the pair is found in the backtrace.
233
+ */
234
+ public static function is_functions_in_backtrace( Array $callables ) {
235
+ foreach ( $callables as $callable ) {
236
+ if ( self::is_function_in_backtrace( $callable ) ) {
237
+ return true;
238
+ }
239
+ }
240
+
241
+ return false;
242
+ }
243
+
244
+ /**
245
+ * True if I am in the Admin Panel, not doing AJAX
246
+ * @return bool
247
+ */
248
+ public static function in_wp_admin() {
249
+ return ( is_admin() && ! self::is_doing_ajax() );
250
+ }
251
+
252
+ } // class
253
+
254
+ # --- EOF
includes/class-wpglobus.php ADDED
@@ -0,0 +1,3648 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package WPGlobus
4
+ */
5
+
6
+ /**
7
+ * Class WPGlobus
8
+ */
9
+ class WPGlobus {
10
+
11
+ const LOCALE_TAG = '{:%s}%s{:}';
12
+ const LOCALE_TAG_START = '{:%s}';
13
+ const LOCALE_TAG_END = '{:}';
14
+ const LOCALE_TAG_OPEN = '{:';
15
+ const LOCALE_TAG_CLOSE = '}';
16
+
17
+ const URL_WPGLOBUS_SITE = 'https://wpglobus.com/';
18
+
19
+ /**
20
+ * @var string
21
+ */
22
+ public static $minimalReduxFramework_version = '3.2.9.4';
23
+
24
+ /**
25
+ * Cookie name.
26
+ * @since 1.8
27
+ */
28
+ const _COOKIE = 'wpglobus-language';
29
+
30
+ /**
31
+ * Options page slug needed to get access to settings page
32
+ */
33
+ const OPTIONS_PAGE_SLUG = 'wpglobus_options';
34
+
35
+ /**
36
+ * Language edit page
37
+ */
38
+ const LANGUAGE_EDIT_PAGE = 'wpglobus_language_edit';
39
+
40
+ /**
41
+ * WPGlobus about page
42
+ */
43
+ const PAGE_WPGLOBUS_ABOUT = 'wpglobus-about';
44
+
45
+ /**
46
+ * WPGlobus clean page
47
+ */
48
+ const PAGE_WPGLOBUS_CLEAN = 'wpglobus-clean';
49
+
50
+ /**
51
+ * WPGlobus HelpDesk page
52
+ *
53
+ * @var string
54
+ * @since 1.6.5
55
+ */
56
+ const PAGE_WPGLOBUS_HELPDESK = 'wpglobus-helpdesk';
57
+
58
+ /**
59
+ * WPGlobus Admin Central page
60
+ *
61
+ * @var string
62
+ * @since 1.6.6
63
+ */
64
+ const PAGE_WPGLOBUS_ADMIN_CENTRAL = 'wpglobus-admin-central';
65
+
66
+ /**
67
+ * List navigation menus
68
+ * @var array
69
+ */
70
+ public $menus = array();
71
+
72
+ /**
73
+ * Initialized at plugin loader
74
+ * @var string
75
+ */
76
+ public static $PLUGIN_DIR_PATH = '';
77
+
78
+ /**
79
+ * Getter.
80
+ *
81
+ * @return string
82
+ */
83
+ public static function plugin_dir_path() {
84
+ return self::$PLUGIN_DIR_PATH;
85
+ }
86
+
87
+ /**
88
+ * Initialized at plugin loader
89
+ * @var string
90
+ */
91
+ public static $PLUGIN_DIR_URL = '';
92
+
93
+ /**
94
+ * Getter.
95
+ *
96
+ * @return string
97
+ */
98
+ public static function plugin_dir_url() {
99
+ return self::$PLUGIN_DIR_URL;
100
+ }
101
+
102
+ /**
103
+ * URL for internal images.
104
+ *
105
+ * @return string
106
+ */
107
+ public static function internal_images_url() {
108
+ return self::$PLUGIN_DIR_URL . 'includes/css/images';
109
+ }
110
+
111
+ /**
112
+ * Path to data folder.
113
+ *
114
+ * @return string
115
+ */
116
+ public static function data_path() {
117
+ return self::$PLUGIN_DIR_PATH . 'data';
118
+ }
119
+
120
+ /**
121
+ * Path to languages folder.
122
+ *
123
+ * @return string
124
+ * @since 1.9.6
125
+ */
126
+ public static function languages_path() {
127
+ return self::$PLUGIN_DIR_PATH . 'languages';
128
+ }
129
+
130
+ /**
131
+ * @var bool $_SCRIPT_DEBUG Internal representation of the define('SCRIPT_DEBUG')
132
+ */
133
+ protected static $_SCRIPT_DEBUG = false;
134
+
135
+ /**
136
+ * @var string $_SCRIPT_SUFFIX Whether to use minimized or full versions of JS and CSS.
137
+ */
138
+ protected static $_SCRIPT_SUFFIX = '.min';
139
+
140
+ /**
141
+ * @return string
142
+ */
143
+ public static function SCRIPT_SUFFIX() {
144
+ return self::$_SCRIPT_SUFFIX;
145
+ }
146
+
147
+ /**
148
+ * To use as the 'version' argument for JS/CSS enqueue.
149
+ *
150
+ * @since 1.2.2
151
+ * @return string
152
+ */
153
+ public static function SCRIPT_VER() {
154
+ return ( self::$_SCRIPT_DEBUG ? sprintf( 'debug-%d', time() ) : WPGLOBUS_VERSION );
155
+ }
156
+
157
+ /**
158
+ * Support third party plugin vendors
159
+ */
160
+ public $vendors_scripts = array();
161
+
162
+ const RETURN_IN_DEFAULT_LANGUAGE = 'in_default_language';
163
+ const RETURN_EMPTY = 'empty';
164
+
165
+ /**
166
+ * Don't make some updates at post screen and don't load scripts for this entities
167
+ */
168
+ public $disabled_entities = array();
169
+
170
+ /**
171
+ * Array of enabled pages for loading scripts, styles to achieve WPGlobusCore, WPGlobusDialogApp
172
+ * @since 1.2.0
173
+ */
174
+ public $enabled_pages = array();
175
+
176
+ /**
177
+ * Constructor
178
+ */
179
+ public function __construct() {
180
+
181
+ if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
182
+ self::$_SCRIPT_DEBUG = true;
183
+ self::$_SCRIPT_SUFFIX = '';
184
+ }
185
+
186
+ /** @todo maybe move this action to Class WPGlobus_Upgrade ? */
187
+ add_action( 'admin_init', array(
188
+ $this,
189
+ 'on_admin_init'
190
+ ) );
191
+
192
+ /**
193
+ * @todo $WPGlobus_Options is unused. Remove it.
194
+ */
195
+ global $WPGlobus_Options;
196
+
197
+ global $pagenow;
198
+
199
+ $config = WPGlobus::Config();
200
+
201
+ /**
202
+ * Init array of supported plugins
203
+ */
204
+ $this->vendors_scripts['ACF'] = false;
205
+ $this->vendors_scripts['ACFPRO'] = false;
206
+ /** Set to true in @see WPGlobus_WPSEO::controller or WPGlobus_YoastSEO::controller */
207
+ $this->vendors_scripts['WPSEO'] = false;
208
+ $this->vendors_scripts['WPSEO_PREMIUM'] = false;
209
+ $this->vendors_scripts['WOOCOMMERCE'] = false;
210
+ $this->vendors_scripts['AIOSEOP'] = false; // All In One SEO Pack
211
+ $this->vendors_scripts['WPCF7'] = false; // Contact Form 7
212
+
213
+ if ( function_exists( 'acf' ) ) {
214
+
215
+ /**
216
+ * @todo Work on the ACF compatibility is in progress
217
+ * Temporarily add CPT acf ( Advanced Custom Fields ) to the array of disabled_entities
218
+ * @see 'wpglobus_disabled_entities' filter for add/remove custom post types to array disabled_entities
219
+ * @since 1.0.4
220
+ */
221
+ global $acf;
222
+ if ( ! empty( $acf->settings['pro'] ) && $acf->settings['pro'] ) {
223
+ /**
224
+ * @since 1.2.6
225
+ */
226
+ $this->vendors_scripts['ACFPRO'] = true;
227
+ $this->disabled_entities[] = 'acf-field-group';
228
+ $this->disabled_entities[] = 'acf-field';
229
+
230
+ } else {
231
+
232
+ $this->vendors_scripts['ACF'] = true;
233
+ $this->disabled_entities[] = 'acf';
234
+
235
+ }
236
+
237
+ }
238
+
239
+ if ( defined( 'WC_VERSION' ) || defined( 'WOOCOMMERCE_VERSION' ) ) {
240
+
241
+ $this->vendors_scripts['WOOCOMMERCE'] = true;
242
+ $this->disabled_entities[] = 'product';
243
+ $this->disabled_entities[] = 'product_tag';
244
+ $this->disabled_entities[] = 'product_cat';
245
+ $this->disabled_entities[] = 'shop_order';
246
+ $this->disabled_entities[] = 'shop_coupon';
247
+
248
+ /**
249
+ * Gathering Woocommerce's post types in one place
250
+ * @since 1.4.3
251
+ */
252
+ $this->disabled_entities[] = 'product_variation';
253
+ $this->disabled_entities[] = 'shop_order_refund';
254
+ $this->disabled_entities[] = 'shop_webhook';
255
+
256
+ }
257
+
258
+ if ( defined( 'AIOSEOP_VERSION' ) ) {
259
+ $this->vendors_scripts['AIOSEOP'] = true;
260
+ }
261
+
262
+ if ( defined( 'WPCF7_VERSION' ) ) {
263
+ $this->vendors_scripts['WPCF7'] = true;
264
+ /**
265
+ * Disable cpt of plugin Contact Form 7 by default
266
+ *
267
+ * @since 1.4.6
268
+ */
269
+ $this->disabled_entities[] = 'wpcf7_contact_form';
270
+ }
271
+
272
+ /**
273
+ * If you need add new vendors script and disable cpt
274
+ * you must add it to customizer also
275
+ * @see class-wpglobus-customize-options.php:596
276
+ */
277
+
278
+ /**
279
+ * Add builtin post type
280
+ */
281
+ $this->disabled_entities[] = 'attachment';
282
+
283
+ /**
284
+ * @since 1.9.0
285
+ */
286
+ $this->disabled_entities[] = 'oembed_cache';
287
+
288
+ /**
289
+ * Add disabled post types from option
290
+ */
291
+ $option = get_option( 'wpglobus_option' );
292
+ $options_post_types = empty( $option['post_type'] ) ? array() : $option['post_type'];
293
+ foreach ( $options_post_types as $post_type => $value ) {
294
+ if ( $value != '1' ) {
295
+ $this->disabled_entities[] = $post_type;
296
+ }
297
+ }
298
+
299
+ /**
300
+ * Set disabled entities into config
301
+ * @todo maybe move code to Class WPGlobus_Config
302
+ */
303
+ WPGlobus::Config()->disabled_entities = $this->disabled_entities;
304
+
305
+ add_filter( 'wp_redirect', array(
306
+ $this,
307
+ 'on_wp_redirect'
308
+ ) );
309
+
310
+
311
+ /**
312
+ * NOTE: do not check for !DOING_AJAX here. Redux uses AJAX, for example, for disabling tracking.
313
+ * So, we need to load Redux on AJAX requests, too
314
+ */
315
+ if ( is_admin() ) {
316
+
317
+ /**
318
+ * Set values
319
+ * @since 1.2.0
320
+ */
321
+ $this->enabled_pages[] = self::LANGUAGE_EDIT_PAGE;
322
+ $this->enabled_pages[] = self::OPTIONS_PAGE_SLUG;
323
+ $this->enabled_pages[] = 'post.php';
324
+ $this->enabled_pages[] = 'post-new.php';
325
+ $this->enabled_pages[] = 'nav-menus.php';
326
+
327
+ /**
328
+ * @since 1.5.0
329
+ * edit-tags.php obsolete in WP 4.5
330
+ * term.php new in WP 4.5
331
+ */
332
+ $this->enabled_pages[] = 'edit-tags.php';
333
+ $this->enabled_pages[] = 'term.php';
334
+
335
+ $this->enabled_pages[] = 'edit.php';
336
+ $this->enabled_pages[] = 'options-general.php';
337
+ $this->enabled_pages[] = 'widgets.php';
338
+ $this->enabled_pages[] = 'customize.php';
339
+
340
+ /**
341
+ * WPGlobus clean page
342
+ * @since 1.4.3
343
+ */
344
+ $this->enabled_pages[] = self::PAGE_WPGLOBUS_CLEAN;
345
+
346
+ /**
347
+ * WPGlobus Admin Central page.
348
+ * @since 1.6.6
349
+ */
350
+ $this->enabled_pages[] = self::PAGE_WPGLOBUS_ADMIN_CENTRAL;
351
+
352
+ add_action( 'admin_body_class', array( $this, 'on_add_admin_body_class' ) );
353
+
354
+ add_action( 'wp_ajax_' . __CLASS__ . '_process_ajax', array( $this, 'on_process_ajax' ) );
355
+
356
+ require_once 'options/class-wpglobus-options.php';
357
+ new WPGlobus_Options();
358
+
359
+ if ( in_array( $pagenow, array( 'edit-tags.php', 'term.php' ), true ) ) {
360
+ /**
361
+ * Need to get taxonomy to use the correct filter.
362
+ */
363
+ $taxonomy_slug = WPGlobus_Utils::safe_get( 'taxonomy' );
364
+ if ( $taxonomy_slug ) {
365
+ add_action( "{$taxonomy_slug}_pre_edit_form",
366
+ array( $this, 'on_add_language_tabs_edit_taxonomy' ),
367
+ 10, 2
368
+ );
369
+
370
+ add_action( "{$taxonomy_slug}_edit_form",
371
+ array( $this, 'on_add_taxonomy_form_wrapper' ),
372
+ 10, 2
373
+ );
374
+ }
375
+ }
376
+
377
+ if ( self::Config()->toggle == 'on' || ! $this->user_can( 'wpglobus_toggle' ) ) {
378
+
379
+ /**
380
+ * Filters for adding language column to edit.php page
381
+ */
382
+ if ( WPGlobus_WP::is_pagenow( 'edit.php' ) && ! $this->disabled_entity() ) {
383
+
384
+ $post_type_filter = WPGlobus_Utils::safe_get( 'post_type' );
385
+ if ( $post_type_filter ) {
386
+ // This is a CPT.
387
+ // Add underscore to form the
388
+ // "manage_{$post->post_type}_posts_custom_column" filter.
389
+ $post_type_filter = '_' . $post_type_filter;
390
+ }
391
+
392
+ add_filter( "manage{$post_type_filter}_posts_columns",
393
+ array( $this, 'on_add_language_column' )
394
+ );
395
+
396
+ add_filter( "manage{$post_type_filter}_posts_custom_column",
397
+ array( $this, 'on_manage_language_column' )
398
+ );
399
+
400
+ }
401
+
402
+ /**
403
+ * Join post content and post title for enabled languages in func wp_insert_post
404
+ * @see action in wp-includes\post.php:3326
405
+ */
406
+ add_action( 'wp_insert_post_data', array(
407
+ $this,
408
+ 'on_save_post_data'
409
+ ), 10, 2 );
410
+
411
+ add_action( 'edit_form_after_editor', array(
412
+ $this,
413
+ 'on_add_wp_editors'
414
+ ), 10 );
415
+
416
+ add_action( 'edit_form_after_editor', array(
417
+ $this,
418
+ 'on_add_language_tabs'
419
+ ) );
420
+
421
+ add_action( 'edit_form_after_title', array(
422
+ $this,
423
+ 'on_add_title_fields'
424
+ ) );
425
+
426
+ add_action( 'admin_print_scripts', array(
427
+ $this,
428
+ 'on_admin_scripts'
429
+ ) );
430
+
431
+ add_action( 'admin_print_scripts', array(
432
+ $this,
433
+ 'on_admin_enqueue_scripts'
434
+ ), 99 );
435
+
436
+ add_action( 'admin_footer', array(
437
+ $this,
438
+ 'on_admin_footer'
439
+ ) );
440
+
441
+ add_filter( 'admin_title', array(
442
+ $this,
443
+ 'on_admin_title'
444
+ ), 10, 2 );
445
+
446
+ if ( $this->vendors_scripts['AIOSEOP'] && WPGlobus_WP::is_pagenow( array(
447
+ 'post.php',
448
+ 'post-new.php',
449
+ 'edit.php'
450
+ ) )
451
+ ) {
452
+
453
+ /** @global WP_Post $post */
454
+ global $post;
455
+
456
+ $type = empty( $post ) ? '' : $post->post_type;
457
+ if ( ! $this->disabled_entity( $type ) ) {
458
+
459
+ require_once 'vendor/class-wpglobus-aioseop.php';
460
+ if ( WPGlobus_WP::is_pagenow( array( 'post.php', 'post-new.php' ) ) ) {
461
+ /** @noinspection PhpUnusedLocalVariableInspection */
462
+ $WPGlobus_aioseop = new WPGlobus_aioseop();
463
+ }
464
+ }
465
+
466
+ }
467
+
468
+ /**
469
+ * Add multilingual Caption, Alternative Text, Description to media files.
470
+ * @since 1.7.3
471
+ */
472
+ if ( version_compare( $GLOBALS['wp_version'], '4.6.999', '>' ) ) :
473
+ if (
474
+ WPGlobus_WP::is_pagenow( 'post.php' ) ||
475
+ ( WPGlobus_WP::is_doing_ajax() && WPGlobus_WP::is_http_post_action('send-attachment-to-editor') )
476
+ ) {
477
+ require_once 'admin/media/class-wpglobus-media.php';
478
+ WPGlobus_Media::get_instance();
479
+ }
480
+ endif;
481
+
482
+ } // endif $devmode
483
+
484
+ if ( ( $this->vendors_scripts['ACF'] || $this->vendors_scripts['ACFPRO'] ) && WPGlobus_WP::is_pagenow( array(
485
+ 'post.php',
486
+ 'post-new.php'
487
+ ) )
488
+ ) {
489
+ require_once 'vendor/class-wpglobus-acf.php';
490
+ $WPGlobus_acf = new WPGlobus_Acf();
491
+ }
492
+
493
+ add_action( 'admin_print_styles', array(
494
+ $this,
495
+ 'on_admin_styles'
496
+ ) );
497
+
498
+ add_action( 'admin_menu', array(
499
+ $this,
500
+ 'on_admin_menu'
501
+ ), 10 );
502
+
503
+ add_action( 'post_submitbox_misc_actions', array(
504
+ $this,
505
+ 'on_add_devmode_switcher'
506
+ ) );
507
+
508
+ add_action( 'admin_bar_menu', array(
509
+ $this,
510
+ 'on_admin_bar_menu'
511
+ ) );
512
+
513
+ /**
514
+ * @scope admin
515
+ * @since 1.7.11
516
+ */
517
+ add_action( 'admin_enqueue_scripts', array(
518
+ $this,
519
+ 'enqueue_wpglobus_js'
520
+ ), 1000 );
521
+
522
+ if ( WPGlobus_WP::is_pagenow( 'plugin-install.php' ) ) {
523
+ require_once 'admin/class-wpglobus-plugin-install.php';
524
+ WPGlobus_Plugin_Install::controller();
525
+ }
526
+
527
+ } else {
528
+
529
+ /**
530
+ * @scope front
531
+ */
532
+
533
+ $this->menus = self::_get_nav_menus();
534
+
535
+ /**
536
+ * @todo This filter is currently disabled. Need to check if we need it.
537
+ * The on_wp_list_pages is called directly from on_wp_page_menu
538
+ */
539
+ 0 && add_filter( 'wp_list_pages', array(
540
+ $this,
541
+ 'on_wp_list_pages'
542
+ ), 99, 2 );
543
+
544
+ add_filter( 'wp_page_menu', array(
545
+ $this,
546
+ 'on_wp_page_menu'
547
+ ), 99, 2 );
548
+
549
+ /**
550
+ * Add language switcher to navigation menu
551
+ * @see on_add_item
552
+ */
553
+ add_filter( 'wp_nav_menu_objects', array(
554
+ $this,
555
+ 'on_add_item'
556
+ ), 99, 2 );
557
+
558
+ /**
559
+ * Convert url for menu items
560
+ */
561
+ add_filter( 'wp_nav_menu_objects', array(
562
+ $this,
563
+ 'on_get_convert_url_menu_items'
564
+ ), 10, 2 );
565
+
566
+ add_action( 'wp_head', array(
567
+ $this,
568
+ 'on_wp_head'
569
+ ), 11 );
570
+
571
+ add_action( 'wp_footer', array(
572
+ $this,
573
+ 'on__wp_footer'
574
+ ), 99 );
575
+
576
+ add_action( 'wp_head', array(
577
+ $this,
578
+ 'on_add_hreflang'
579
+ ), 11 );
580
+
581
+ add_action( 'wp_print_styles', array(
582
+ $this,
583
+ 'on_wp_styles'
584
+ ) );
585
+
586
+ add_action( 'wp_enqueue_scripts', array(
587
+ $this,
588
+ 'enqueue_wpglobus_js'
589
+ ),
590
+ /**
591
+ * Load this script as late as possible,
592
+ * because it triggers the `wpglobus_current_language_changed` event.
593
+ * @since 1.5.5
594
+ */
595
+ PHP_INT_MAX
596
+ );
597
+ }
598
+
599
+ }
600
+
601
+ /**
602
+ * Insert language title to edit.php page
603
+ *
604
+ * @param array $posts_columns
605
+ *
606
+ * @return array
607
+ */
608
+ public function on_add_language_column( $posts_columns ) {
609
+ /**
610
+ * Which column we insert after?
611
+ */
612
+ $insert_after = 'title';
613
+
614
+ $i = 0;
615
+ foreach ( $posts_columns as $key => $value ) {
616
+ if ( $key == $insert_after ) {
617
+ break;
618
+ }
619
+ $i ++;
620
+ }
621
+ $posts_columns =
622
+ array_slice( $posts_columns, 0, $i + 1 ) + array( 'wpglobus_languages' => 'Language' ) + array_slice( $posts_columns, $i + 1 );
623
+
624
+ /**
625
+ * Filter the columns displayed in the Posts list table.
626
+ * Returning array.
627
+ * @since 1.6.5
628
+ *
629
+ * @param array $posts_columns An array of column names.
630
+ */
631
+ return apply_filters( 'wpglobus_manage_posts_columns', $posts_columns );
632
+
633
+ }
634
+
635
+ /**
636
+ * Insert flags to every item at edit.php page
637
+ *
638
+ * @param string $column_name
639
+ */
640
+ public function on_manage_language_column( $column_name ) {
641
+
642
+ if ( 'wpglobus_languages' == $column_name ) {
643
+
644
+ /** @global WP_Post $post */
645
+ global $post;
646
+
647
+ $output = array();
648
+ $i = 0;
649
+ foreach ( WPGlobus::Config()->enabled_languages as $l ) {
650
+ if ( 1 == preg_match( "/(\{:|\[:|<!--:)[$l]{2}/", $post->post_title . $post->post_content ) ) {
651
+ $output[ $i ] =
652
+ '<img title="' . WPGlobus::Config()->en_language_name[ $l ] .
653
+ '" src="' . WPGlobus::Config()->flags_url . WPGlobus::Config()->flag[ $l ] . '" />';
654
+
655
+ /**
656
+ * Filter language item.
657
+ * Returning string.
658
+ * @since 1.0.14
659
+ *
660
+ * @param string $output Language item.
661
+ * @param array $post An object WP_Post.
662
+ * @param string $l The language.
663
+ */
664
+ $output[ $i ] = apply_filters( 'wpglobus_manage_language_item', $output[ $i ], $post, $l );
665
+ $i ++;
666
+ }
667
+ }
668
+
669
+ /**
670
+ * Filter language items before output.
671
+ * Returning array.
672
+ * @since 1.6.6
673
+ *
674
+ * @param string $output Array of language items.
675
+ * @param array $post An object WP_Post.
676
+ */
677
+ $output = apply_filters( 'wpglobus_manage_language_items', $output, $post );
678
+
679
+ if ( ! empty( $output ) ) {
680
+ echo implode( '<br />', $output ); // WPCS: XSS ok.
681
+ }
682
+
683
+ }
684
+
685
+ }
686
+
687
+
688
+ /**
689
+ * Handle ajax process
690
+ */
691
+ public function on_process_ajax() {
692
+
693
+ $ajax_return = array();
694
+
695
+ /**
696
+ * Sanitize
697
+ */
698
+
699
+ $order = wp_unslash( $_POST['order'] ); // WPCS: input var ok, sanitization ok.
700
+
701
+ $action = '';
702
+ if ( isset( $order['action'] ) && is_string( $order['action'] ) ) {
703
+ $action = sanitize_text_field( $order['action'] );
704
+ }
705
+ $post_type = '';
706
+ if ( isset( $order['post_type'] ) && is_string( $order['post_type'] ) ) {
707
+ $post_type = sanitize_text_field( $order['post_type'] );
708
+ }
709
+ $meta_key = '';
710
+ if ( isset( $order['meta_key'] ) && is_string( $order['meta_key'] ) ) {
711
+ $meta_key = sanitize_text_field( $order['meta_key'] );
712
+ }
713
+ $checked = '';
714
+ if ( isset( $order['checked'] ) && is_string( $order['checked'] ) ) {
715
+ $checked = sanitize_text_field( $order['checked'] );
716
+ }
717
+ $id = '';
718
+ if ( isset( $order['id'] ) && is_string( $order['id'] ) ) {
719
+ $id = sanitize_text_field( $order['id'] );
720
+ }
721
+ $locale = '';
722
+ if ( isset( $order['locale'] ) && is_string( $order['locale'] ) ) {
723
+ $locale = sanitize_text_field( $order['locale'] );
724
+ }
725
+ $type = '';
726
+ if ( isset( $order['type'] ) && is_string( $order['type'] ) ) {
727
+ $type = sanitize_text_field( $order['type'] );
728
+ }
729
+ $taxonomy = '';
730
+ if ( isset( $order['taxonomy'] ) && is_string( $order['taxonomy'] ) ) {
731
+ $taxonomy = sanitize_text_field( $order['taxonomy'] );
732
+ }
733
+ $titles = array();
734
+ if ( isset( $order['title'] ) && is_array( $order['title'] ) ) {
735
+ $titles = $order['title'];
736
+ }
737
+
738
+ switch ( $action ) {
739
+ case 'clean':
740
+ case 'wpglobus-reset':
741
+ require_once 'admin/class-wpglobus-clean.php';
742
+ WPGlobus_Clean::process_ajax( $order );
743
+
744
+ break;
745
+ case 'save_post_meta_settings':
746
+ /**
747
+ * This is the WPGlobus icon, wrench and checkbox on custom post meta fields.
748
+ */
749
+
750
+ $settings = (array) get_option( WPGlobus::Config()->option_post_meta_settings );
751
+
752
+ if ( empty( $settings[ $post_type ] ) ) {
753
+ $settings[ $post_type ] = array();
754
+ }
755
+ $settings[ $post_type ][ $meta_key ] = $checked;
756
+ if ( update_option( WPGlobus::Config()->option_post_meta_settings, $settings ) ) {
757
+ $ajax_return['result'] = 'ok';
758
+ } else {
759
+ $ajax_return['result'] = 'error';
760
+ }
761
+ $ajax_return['checked'] = $checked;
762
+ $ajax_return['id'] = $id;
763
+ $ajax_return['meta_key'] = $meta_key;
764
+ break;
765
+ case 'wpglobus_select_lang':
766
+ if ( 'en_US' === $locale ) {
767
+ update_option( 'WPLANG', '' );
768
+ } else {
769
+ update_option( 'WPLANG', $locale );
770
+ }
771
+ break;
772
+ case 'get_titles':
773
+ /**
774
+ * Prepare multilingual titles for Quick Edit.
775
+ */
776
+
777
+ if ( 'taxonomy' === $type ) {
778
+ /**
779
+ * Remove filter to get raw term description
780
+ */
781
+ remove_filter( 'get_term', array( 'WPGlobus_Filters', 'filter__get_term' ), 0 );
782
+ }
783
+
784
+ $config = WPGlobus::Config();
785
+
786
+ $result = array();
787
+ $bulkedit_post_titles = array();
788
+
789
+ /**
790
+ * Iterate through the Titles array.
791
+ *
792
+ * @var int $id Post or Term ID.
793
+ * @var string[] $data Post or Term Name is stored in the $data['source'].
794
+ */
795
+ foreach ( (array) $titles as $post_or_term_id => $data ) {
796
+ $title = '';
797
+ if ( ! empty( $data['source'] ) && is_string( $data['source'] ) ) {
798
+ $title = $data['source'];
799
+ }
800
+
801
+ if ( ! WPGlobus_Core::has_translations( $title ) ) {
802
+ /**
803
+ * In some cases, we've lost the raw data for post title on edit.php page
804
+ * for example product post type from Woo.
805
+ */
806
+ $_title_from_db = '';
807
+ if ( 'post' === $type ) {
808
+ $_title_from_db = get_post_field( 'post_title', $post_or_term_id );
809
+ } elseif ( 'taxonomy' === $type ) {
810
+ $_term_by_id = get_term_by( 'id', $post_or_term_id, $taxonomy );
811
+ if ( $_term_by_id ) {
812
+ $_title_from_db = $_term_by_id->name;
813
+ }
814
+ }
815
+
816
+ if ( $_title_from_db ) {
817
+ $title = $_title_from_db;
818
+ }
819
+
820
+ unset( $_term_by_id, $_title_from_db );
821
+ }
822
+
823
+ $result[ $post_or_term_id ]['source'] = $title;
824
+
825
+ $term = null; // Should initialize before if because used in the next foreach.
826
+
827
+ if ( 'taxonomy' === $type && $taxonomy ) {
828
+ $term = get_term( $post_or_term_id, $taxonomy );
829
+ if ( is_wp_error( $term ) ) {
830
+ $taxonomy = false;
831
+ }
832
+ }
833
+
834
+ foreach ( $config->enabled_languages as $language ) {
835
+ $return =
836
+ $language === $config->default_language ? WPGlobus::RETURN_IN_DEFAULT_LANGUAGE : WPGlobus::RETURN_EMPTY;
837
+
838
+ $result[ $post_or_term_id ][ $language ]['name'] =
839
+ WPGlobus_Core::text_filter( $title, $language, $return );
840
+ if ( $term && 'taxonomy' === $type && $taxonomy ) {
841
+ $result[ $post_or_term_id ][ $language ]['description'] =
842
+ WPGlobus_Core::text_filter( $term->description, $language, $return );
843
+ }
844
+
845
+ $bulkedit_post_titles[ $post_or_term_id ][ $language ]['name'] =
846
+ WPGlobus_Core::text_filter( $title, $language, WPGlobus::RETURN_IN_DEFAULT_LANGUAGE );
847
+ }
848
+ }
849
+ $ajax_return['qedit_titles'] = $result;
850
+ $ajax_return['bulkedit_post_titles'] = $bulkedit_post_titles;
851
+ break;
852
+ }
853
+
854
+ echo wp_json_encode( $ajax_return );
855
+ die();
856
+ }
857
+
858
+ /**
859
+ * Ugly hack.
860
+ * @see wp_page_menu
861
+ *
862
+ * @param string $html
863
+ *
864
+ * @return string
865
+ */
866
+ public function on_wp_page_menu( $html ) {
867
+ $switcher_html = $this->on_wp_list_pages( '' );
868
+ $html = str_replace( '</ul></div>', $switcher_html . '</ul></div>', $html );
869
+
870
+ return $html;
871
+ }
872
+
873
+ /**
874
+ * Start WPGlobus on "init" hook, so if there is another ReduxFramework, it will be loaded first. Hopefully :-)
875
+ * Note: "init" hook is not guaranteed to stay in the future versions.
876
+ */
877
+ public static function init() {
878
+ /** @global WPGlobus WPGlobus */
879
+ global $WPGlobus;
880
+ $WPGlobus = new self;
881
+ }
882
+
883
+ /**
884
+ * Set transient wpglobus_activated after activated plugin @see on_admin_init()
885
+ * @todo use $WPGlobus_Config to determine running this function?
886
+ *
887
+ * @param string $plugin
888
+ *
889
+ * @return void
890
+ */
891
+ public static function activated( $plugin ) {
892
+ if ( WPGLOBUS_PLUGIN_BASENAME == $plugin ) {
893
+ /**
894
+ * Run on_activate after plugin activated
895
+ */
896
+ $options['plugin'] = $plugin;
897
+ $options['action'] = 'update';
898
+ WPGlobus::Config()->on_activate( null, $options );
899
+
900
+ /** @noinspection SummerTimeUnsafeTimeManipulationInspection */
901
+ set_transient( 'wpglobus_activated', '', 60 * 60 * 24 );
902
+ }
903
+ }
904
+
905
+ /**
906
+ * WP redirect hook
907
+ *
908
+ * @param string $location
909
+ *
910
+ * @return string
911
+ */
912
+ public function on_wp_redirect( $location ) {
913
+ if ( is_admin() ) {
914
+ $_wp_http_referer = '';
915
+ if ( isset( $_POST['_wp_http_referer'] ) && is_string( $_POST['_wp_http_referer'] ) ) { // WPCS: input var ok, sanitization ok.
916
+ $_wp_http_referer = sanitize_text_field( wp_unslash( $_POST['_wp_http_referer'] ) ); // WPCS: input var ok.
917
+ }
918
+ if ( false !== strpos( $_wp_http_referer, 'wpglobus=off' ) ) {
919
+ $location .= '&wpglobus=off';
920
+ }
921
+ } else {
922
+ /**
923
+ * Get language code from cookie. Example: redirect $_SERVER[REQUEST_URI] = /wp-comments-post.php
924
+ */
925
+ $request_uri = '';
926
+ if ( isset( $_SERVER['REQUEST_URI'] ) && is_string( $_SERVER['REQUEST_URI'] ) ) { // WPCS: input var ok, sanitization ok.
927
+ $request_uri = sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ); // WPCS: input var ok.
928
+ }
929
+ if ( false !== strpos( $request_uri, 'wp-comments-post.php' ) ) {
930
+ if ( ! empty( $_COOKIE[ self::_COOKIE ] ) && is_string( $_COOKIE[ self::_COOKIE ] ) ) { // WPCS: input var ok, sanitization ok.
931
+ $wpglobus_language_cookie = sanitize_text_field( wp_unslash( $_COOKIE[ self::_COOKIE ] ) ); // WPCS: input var ok.
932
+ $location = WPGlobus_Utils::localize_url( $location, $wpglobus_language_cookie );
933
+ }
934
+ }
935
+ }
936
+
937
+ return $location;
938
+ }
939
+
940
+ /**
941
+ * Check if the current user has the $cap capability
942
+ *
943
+ * @param string $cap
944
+ *
945
+ * @return bool
946
+ */
947
+ public function user_can( $cap = '' ) {
948
+ global $current_user;
949
+ if ( empty( $current_user ) ) {
950
+ wp_get_current_user();
951
+ }
952
+ if ( 'wpglobus_toggle' == $cap ) {
953
+ if ( $this->user_has_role( 'administrator' ) || current_user_can( $cap ) ) {
954
+ return true;
955
+ }
956
+
957
+ return false;
958
+ }
959
+
960
+ return true;
961
+ }
962
+
963
+ /**
964
+ * Check current user has $role
965
+ *
966
+ * @param string $role
967
+ *
968
+ * @return boolean
969
+ */
970
+ public function user_has_role( $role = '' ) {
971
+ global $current_user;
972
+ if ( empty( $current_user ) ) {
973
+ wp_get_current_user();
974
+ }
975
+
976
+ return in_array( $role, $current_user->roles );
977
+ }
978
+
979
+ /**
980
+ * Add switcher to publish metabox.
981
+ */
982
+ public function on_add_devmode_switcher() {
983
+
984
+ if ( ! $this->user_can( 'wpglobus_toggle' ) ) {
985
+ return;
986
+ }
987
+
988
+ global $post, $pagenow;
989
+
990
+ if ( $pagenow != 'post.php' ) {
991
+ return;
992
+ }
993
+
994
+ if ( $this->disabled_entity( $post->post_type ) ) {
995
+ return;
996
+ }
997
+
998
+ // "Reverse" logic here. It's the mode to turn to, not the current one.
999
+ $mode = 'off';
1000
+ if ( isset( $_GET['wpglobus'] ) && 'off' === $_GET['wpglobus'] ) { // WPCS: input var ok, sanitization ok.
1001
+ $mode = 'on';
1002
+ }
1003
+
1004
+ $query_string = explode( '&', $_SERVER['QUERY_STRING'] );
1005
+
1006
+ foreach ( $query_string as $key => $_q ) {
1007
+ if ( false !== strpos( $_q, 'wpglobus=' ) ) {
1008
+ unset( $query_string[ $key ] );
1009
+ }
1010
+ }
1011
+
1012
+ $query = implode( '&', $query_string );
1013
+ $url = admin_url(
1014
+ add_query_arg( array(
1015
+ 'wpglobus' => $mode,
1016
+ ),
1017
+ 'post.php?' . $query
1018
+ )
1019
+ );
1020
+
1021
+ if ( 'on' === $mode ) {
1022
+ /// Translators: ON/OFF status of WPGlobus on the edit pages.
1023
+ $status_text = __( 'OFF', 'wpglobus' );
1024
+ $toggle_text = __( 'Turn on', 'wpglobus' );
1025
+ $highlight_class = 'wp-ui-text-notification';
1026
+ } else {
1027
+ /// Translators: ON/OFF status of WPGlobus on the edit pages.
1028
+ $status_text = __( 'ON', 'wpglobus' );
1029
+ $toggle_text = __( 'Turn off', 'wpglobus' );
1030
+ $highlight_class = 'wp-ui-text-highlight';
1031
+ }
1032
+ ?>
1033
+ <div class="misc-pub-section wpglobus-switch">
1034
+ <span id="wpglobus-raw" style="margin-right: 2px;"
1035
+ class="dashicons dashicons-admin-site <?php echo esc_attr( $highlight_class ); ?>"></span>
1036
+ <?php esc_html_e( 'WPGlobus', 'wpglobus' ); ?>:
1037
+ <strong class="<?php echo esc_attr( $highlight_class ); ?>"><?php echo esc_html( $status_text ); ?></strong>
1038
+ <a class="button button-small" style="margin:-3px 0 0 3px;"
1039
+ href="<?php echo esc_url( $url ); ?>"><?php echo esc_html( $toggle_text ); ?></a>
1040
+ </div>
1041
+ <?php
1042
+ }
1043
+
1044
+ public function on_admin_enqueue_scripts() {
1045
+ /**
1046
+ * @see on_admin_scripts()
1047
+ */
1048
+ if ( ! wp_script_is( 'autosave', 'enqueued' ) ) {
1049
+ wp_enqueue_script( 'autosave' );
1050
+ }
1051
+ }
1052
+
1053
+ /**
1054
+ * Enqueue admin scripts
1055
+ * @return void
1056
+ */
1057
+ public function on_admin_scripts() {
1058
+
1059
+ $post = get_post();
1060
+ $type = empty( $post->post_type ) ? '' : $post->post_type;
1061
+
1062
+ if ( $this->disabled_entity( $type ) ) {
1063
+ return;
1064
+ }
1065
+
1066
+ /**
1067
+ * Dequeue autosave for prevent alert from wp.autosave.server.postChanged() after run post_edit in wpglobus.admin.js
1068
+ * @see wp-includes\js\autosave.js
1069
+ */
1070
+ wp_dequeue_script( 'autosave' );
1071
+
1072
+ $pagenow = WPGlobus_WP::pagenow();
1073
+
1074
+ $config = WPGlobus::Config();
1075
+
1076
+ /**
1077
+ * Get array of enabled pages for loading js
1078
+ */
1079
+ $enabled_pages = $this->enabled_pages;
1080
+
1081
+ /**
1082
+ * Init $post_content
1083
+ */
1084
+ $post_content = '';
1085
+
1086
+ /**
1087
+ * Init $post_title
1088
+ */
1089
+ $post_title = '';
1090
+
1091
+ /**
1092
+ * Init $post_excerpt
1093
+ */
1094
+ $post_excerpt = '';
1095
+
1096
+ /**
1097
+ * Init $page_action
1098
+ */
1099
+ $page_action = '';
1100
+
1101
+ /**
1102
+ * Init $page
1103
+ */
1104
+ $page = '';
1105
+
1106
+ /**
1107
+ * Init array data depending on the context for localize script
1108
+ */
1109
+ $data = array(
1110
+ 'default_language' => $config->default_language,
1111
+ 'language' => $config->language,
1112
+ 'enabled_languages' => $config->enabled_languages,
1113
+ 'open_languages' => $config->open_languages,
1114
+ 'en_language_name' => $config->en_language_name,
1115
+ 'locale_tag_start' => self::LOCALE_TAG_START,
1116
+ 'locale_tag_end' => self::LOCALE_TAG_END
1117
+ );
1118
+
1119
+ if ( ! in_array( $pagenow, $enabled_pages ) ) {
1120
+ $page = WPGlobus_WP::plugin_page();
1121
+ }
1122
+
1123
+ if ( '' == $page ) {
1124
+ /**
1125
+ * Now get $pagenow
1126
+ */
1127
+ $page = isset( $pagenow ) ? $pagenow : '';
1128
+
1129
+ if ( 'post.php' == $page || 'post-new.php' == $page ) {
1130
+
1131
+ $page_action = 'post.php';
1132
+
1133
+ /**
1134
+ * We use $post_content, $post_title at edit post page
1135
+ */
1136
+
1137
+ /**
1138
+ * Set $post_content for default language
1139
+ * because we have text with all languages and delimiters in $post->post_content
1140
+ * next we send $post_content to js with localize script
1141
+ * @see post_edit() in admin.globus.js
1142
+ */
1143
+ $post_content = WPGlobus_Core::text_filter( $post->post_content, $config->default_language );
1144
+
1145
+ /**
1146
+ * Set $post_title for default language
1147
+ */
1148
+ $post_title = WPGlobus_Core::text_filter( $post->post_title, $config->default_language );
1149
+
1150
+ }
1151
+
1152
+ }
1153
+
1154
+ if ( self::LANGUAGE_EDIT_PAGE === $page ) {
1155
+
1156
+ /**
1157
+ * Using the same 'select2-js' ID as Redux Plugin does, to avoid duplicate enqueueing
1158
+ */
1159
+ if ( ! wp_script_is( 'select2-js' ) ) {
1160
+ wp_enqueue_script(
1161
+ 'select2-js',
1162
+ WPGlobus::$PLUGIN_DIR_URL . 'lib/select2.min.js',
1163
+ array( 'jquery' ),
1164
+ '3.5.2',
1165
+ true
1166
+ );
1167
+ }
1168
+
1169
+ }
1170
+
1171
+ if ( in_array( $page, $enabled_pages ) ) {
1172
+
1173
+ /**
1174
+ * Init $tabs_suffix
1175
+ */
1176
+ $tabs_suffix = array();
1177
+
1178
+ if ( in_array( $page, array( 'post.php', 'post-new.php', 'edit-tags.php', 'term.php' ) ) ) {
1179
+
1180
+ /**
1181
+ * Make suffixes for tabs
1182
+ */
1183
+ foreach ( $config->enabled_languages as $language ) {
1184
+ if ( $language == $config->default_language ) {
1185
+ $tabs_suffix[] = 'default';
1186
+ } else {
1187
+ $tabs_suffix[] = $language;
1188
+ }
1189
+ }
1190
+
1191
+ }
1192
+ $i18n = array();
1193
+ $i18n['cannot_disable_language'] = __( 'You cannot disable the main language.', 'wpglobus' );
1194
+
1195
+ if ( 'post.php' == $page || 'post-new.php' == $page ) {
1196
+
1197
+ /**
1198
+ * Add template for standard excerpt meta box
1199
+ */
1200
+ $data['template'] = '';
1201
+ foreach ( WPGlobus::Config()->enabled_languages as $language ) {
1202
+
1203
+ $return =
1204
+ $language == WPGlobus::Config()->default_language ? WPGlobus::RETURN_IN_DEFAULT_LANGUAGE : WPGlobus::RETURN_EMPTY;
1205
+
1206
+ $classes =
1207
+ in_array( $language, WPGlobus::Config()->open_languages ) ? 'wpglobus-excerpt wpglobus-translatable' : 'wpglobus-excerpt wpglobus-translatable hidden';
1208
+
1209
+ $data['template'] .= '<textarea data-language="' . $language . '" placeholder="' . WPGlobus::Config()->en_language_name[ $language ] . '" class="' . $classes . '" rows="1" cols="40" name="excerpt-' . $language . '" id="excerpt-' . $language . '">';
1210
+ $data['template'] .= WPGlobus_Core::text_filter( $post->post_excerpt, $language, $return );
1211
+ $data['template'] .= '</textarea>';
1212
+
1213
+ if ( defined( 'WPSEO_VERSION' ) ) {
1214
+ /**
1215
+ * @todo This is the only place with WPSEO not in its own class.
1216
+ */
1217
+ $blogname = get_option( 'blogname' );
1218
+ $blogdesc = get_option( 'blogdescription' );
1219
+ $data['blogname'][ $language ] =
1220
+ WPGlobus_Core::text_filter( $blogname, $language, WPGlobus::RETURN_IN_DEFAULT_LANGUAGE );
1221
+ $data['blogdescription'][ $language ] =
1222
+ WPGlobus_Core::text_filter( $blogdesc, $language, WPGlobus::RETURN_IN_DEFAULT_LANGUAGE );
1223
+ }
1224
+
1225
+ }
1226
+
1227
+ $data['modify_excerpt'] = true;
1228
+ if ( isset( $this->vendors_scripts['WOOCOMMERCE'] ) && $this->vendors_scripts['WOOCOMMERCE'] && 'product' == $post->post_type ) {
1229
+ $data['modify_excerpt'] = false;
1230
+ }
1231
+
1232
+ $data['tagsdiv'] = array();
1233
+ $data['tag'] = array();
1234
+ $tags = $this->_get_taxonomies( $post->post_type, 'non-hierarchical' );
1235
+
1236
+ if ( ! empty( $tags ) ) {
1237
+ foreach ( $tags as $tag ) {
1238
+ $data['tagsdiv'][] = 'tagsdiv-' . $tag;
1239
+ $data['tag'][ $tag ] = self::_get_terms( $tag );
1240
+ }
1241
+ }
1242
+
1243
+ /**
1244
+ * Check for support 'title'
1245
+ */
1246
+ $data['support']['title'] = true;
1247
+ if ( ! post_type_supports( $post->post_type, 'title' ) ) {
1248
+ $data['support']['title'] = false;
1249
+ }
1250
+
1251
+ /**
1252
+ * Check for support 'editor'
1253
+ */
1254
+ $data['support']['editor'] = true;
1255
+ if ( ! post_type_supports( $post->post_type, 'editor' ) ) {
1256
+ $data['support']['editor'] = false;
1257
+ }
1258
+
1259
+ if ( ! empty( $post ) ) {
1260
+ $data['post_type'] = $post->post_type;
1261
+ $opts = (array) get_option( WPGlobus::Config()->option_post_meta_settings );
1262
+ if ( empty( $opts ) ) {
1263
+ $data['post_meta_settings'] = '';
1264
+ } else {
1265
+ $data['post_meta_settings'] = $opts;
1266
+ }
1267
+ }
1268
+
1269
+ $data[ 'customFieldsEnabled' ] = true;
1270
+
1271
+ /**
1272
+ * Filter to enable/disable multilingual custom fields on post.php|post-new.php page.
1273
+ * Returning boolean.
1274
+ * @since 1.6.5
1275
+ *
1276
+ * @param boolean $data[ 'customFieldsEnabled' ] Enabled by default.
1277
+ * @param WP_Post Object $post Current post.
1278
+ */
1279
+ $data[ 'customFieldsEnabled' ] = apply_filters( 'wpglobus_custom_fields_enabled', $data[ 'customFieldsEnabled' ], $post );
1280
+
1281
+ if ( $data[ 'customFieldsEnabled' ] ) {
1282
+ $data[ 'customFieldsEnabled' ] = 'true';
1283
+ } else {
1284
+ $data[ 'customFieldsEnabled' ] = 'false';
1285
+ }
1286
+
1287
+ } else if ( 'nav-menus.php' === $page ) {
1288
+
1289
+ $page_action = 'menu-edit';
1290
+ $menu_items = array();
1291
+ $post_titles = array();
1292
+
1293
+ /** @global wpdb $wpdb */
1294
+ global $wpdb;
1295
+
1296
+ $_query = new WP_Query( array(
1297
+ 'post_type' => 'nav_menu_item',
1298
+ 'nopaging' => true,
1299
+ ) );
1300
+
1301
+ /**
1302
+ * Array of menu items.
1303
+ *
1304
+ * @var WP_Post[] $items
1305
+ */
1306
+ $items = $_query->posts;
1307
+ unset( $_query );
1308
+
1309
+ foreach ( $items as $item ) :
1310
+
1311
+ $item->post_title = trim( $item->post_title );
1312
+
1313
+ if ( empty( $item->post_title ) ) :
1314
+
1315
+ $item_type = get_post_meta( $item->ID, '_menu_item_type', true );
1316
+ $item_object = get_post_meta( $item->ID, '_menu_item_object', true );
1317
+ $item_object_id = get_post_meta( $item->ID, '_menu_item_object_id', true );
1318
+
1319
+ $_raw_title = '';
1320
+
1321
+ if ( 'post_type' === $item_type ) {
1322
+ $_raw_title = get_post_field( 'post_title', $item_object_id );
1323
+ } elseif ( 'taxonomy' === $item_type ) {
1324
+
1325
+ /**
1326
+ * Here we need the raw term. Temporary need to disable our filter.
1327
+ */
1328
+ remove_filter( 'get_term', array( 'WPGlobus_Filters', 'filter__get_term' ), 0 );
1329
+ $term = get_term_by( 'id', $item_object_id, $item_object );
1330
+ add_filter( 'get_term', array( 'WPGlobus_Filters', 'filter__get_term' ), 0 );
1331
+
1332
+ $_raw_title = $term->name;
1333
+ }
1334
+
1335
+ $_raw_title = trim( $_raw_title );
1336
+ if ( ! empty( $_raw_title ) ) {
1337
+ $item->post_title = $_raw_title;
1338
+ // Save the raw title in the menu.
1339
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_title = '%s' WHERE ID = %d", $_raw_title, $item->ID ) );
1340
+ }
1341
+
1342
+ endif; // Empty post_title.
1343
+
1344
+ /**
1345
+ * Add raw data for Navigation Label
1346
+ */
1347
+ $menu_items[ $item->ID ]['input.edit-menu-item-title']['source'] = $item->post_title;
1348
+
1349
+ /**
1350
+ * Add raw data for Title Attribute
1351
+ */
1352
+ $menu_items[ $item->ID ]['input.edit-menu-item-attr-title']['source'] = $item->post_excerpt;
1353
+
1354
+ $menu_items[ $item->ID ]['item-title'] =
1355
+ WPGlobus_Core::text_filter( $item->post_title, $config->default_language );
1356
+
1357
+ $post_titles[ $item->post_title ] = $menu_items[ $item->ID ]['item-title'];
1358
+
1359
+ foreach ( self::Config()->enabled_languages as $language ) {
1360
+
1361
+ $return =
1362
+ $language == self::Config()->default_language ? WPGlobus::RETURN_IN_DEFAULT_LANGUAGE : WPGlobus::RETURN_EMPTY;
1363
+
1364
+ /**
1365
+ * Navigation Label
1366
+ */
1367
+ $menu_items[ $item->ID ][ $language ]['input.edit-menu-item-title']['caption'] =
1368
+ WPGlobus_Core::text_filter( $item->post_title, $language, $return );
1369
+
1370
+ /**
1371
+ * Title Attribute
1372
+ */
1373
+ $menu_items[ $item->ID ][ $language ]['input.edit-menu-item-attr-title']['caption'] =
1374
+ WPGlobus_Core::text_filter( $item->post_excerpt, $language, $return );
1375
+
1376
+ /**
1377
+ * Navigation Label classes
1378
+ */
1379
+ $menu_items[ $item->ID ][ $language ]['input.edit-menu-item-title']['class'] =
1380
+ 'widefat wpglobus-menu-item wpglobus-item-title wpglobus-translatable';
1381
+
1382
+ /**
1383
+ * Title Attribute classes
1384
+ */
1385
+ $menu_items[ $item->ID ][ $language ]['input.edit-menu-item-attr-title']['class'] =
1386
+ 'widefat wpglobus-menu-item wpglobus-item-attr wpglobus-translatable';
1387
+
1388
+ }
1389
+
1390
+ endforeach;
1391
+
1392
+ $data['items'] = $menu_items;
1393
+ $data['post_titles'] = $post_titles;
1394
+
1395
+ $i18n['save_nav_menu'] = __( '*) Available after the menu is saved.', 'wpglobus' );
1396
+
1397
+ } else if ( 'edit-tags.php' == $page || 'term.php' == $page ) {
1398
+
1399
+ global $tag;
1400
+
1401
+ $data['taxonomy'] = empty( $_GET['taxonomy'] ) ? false : sanitize_text_field( wp_unslash( $_GET['taxonomy'] ) ); // WPCS: input var ok, sanitization ok.
1402
+ $data['tag_id'] = empty( $_GET['tag_ID'] ) ? false : sanitize_text_field( wp_unslash( $_GET['tag_ID'] ) ); // WPCS: input var ok, sanitization ok.
1403
+ $data['has_items'] = true;
1404
+ $data['multilingualSlug'] = array();
1405
+
1406
+ if ( $data['tag_id'] ) {
1407
+ /**
1408
+ * For example url: edit-tags.php?action=edit&taxonomy=category&tag_ID=4&post_type=post
1409
+ */
1410
+ $page_action = 'taxonomy-edit';
1411
+ $data['multilingualSlug']['title'] =
1412
+ '<div class=""><a href="' . WPGlobus_Utils::url_wpglobus_site() . 'product/wpglobus-plus/#taxonomies" target="_blank">' . esc_html__( 'Need a multilingual slug?', 'wpglobus' ) . '</a></div>';
1413
+ } else {
1414
+ /**
1415
+ * For example url: edit-tags.php?taxonomy=category
1416
+ * edit-tags.php?taxonomy=product_cat&post_type=product
1417
+ */
1418
+ if ( $data['taxonomy'] ) {
1419
+ $terms = get_terms( $data['taxonomy'] , array( 'hide_empty' => false ) );
1420
+ if ( is_wp_error( $terms ) or empty( $terms ) ) {
1421
+ $data['has_items'] = false;
1422
+ }
1423
+ }
1424
+ $page_action = 'taxonomy-quick-edit';
1425
+ }
1426
+
1427
+ if ( $data['tag_id'] ) {
1428
+ foreach ( $config->enabled_languages as $language ) {
1429
+ $lang = $language == $config->default_language ? 'default' : $language;
1430
+ if ( 'default' == $lang ) {
1431
+ $data['i18n'][ $lang ]['name'] =
1432
+ WPGlobus_Core::text_filter( $tag->name, $language, WPGlobus::RETURN_IN_DEFAULT_LANGUAGE );
1433
+ $data['i18n'][ $lang ]['description'] =
1434
+ WPGlobus_Core::text_filter( $tag->description, $language, WPGlobus::RETURN_IN_DEFAULT_LANGUAGE );
1435
+ } else {
1436
+ $data['i18n'][ $lang ]['name'] =
1437
+ WPGlobus_Core::text_filter( $tag->name, $language, WPGlobus::RETURN_EMPTY );
1438
+ $data['i18n'][ $lang ]['description'] =
1439
+ WPGlobus_Core::text_filter( $tag->description, $language, WPGlobus::RETURN_EMPTY );
1440
+ }
1441
+ }
1442
+ } else {
1443
+ /**
1444
+ * Get template for quick edit taxonomy name at edit-tags.php page
1445
+ */
1446
+ $data['template'] = $this->_get_quickedit_template();
1447
+
1448
+ }
1449
+
1450
+ } elseif ( $page == 'edit.php' ) {
1451
+
1452
+ $page_action = 'edit.php';
1453
+
1454
+ $post_type = empty( $_GET['post_type'] ) ? 'post' : sanitize_text_field( wp_unslash( $_GET['post_type'] ) ); // WPCS: input var ok, sanitization ok.
1455
+
1456
+ global $posts;
1457
+ $data['has_items'] = empty( $posts ) ? false : true;
1458
+ /**
1459
+ * Get template for quick edit post title at edit.php page
1460
+ */
1461
+ $data['template'] = $this->_get_quickedit_template();
1462
+
1463
+ $tags = $this->_get_taxonomies( $post_type, 'non-hierarchical' );
1464
+ if ( ! empty( $tags ) ) {
1465
+ foreach ( $tags as $tag ) {
1466
+ $terms = self::_get_terms( $tag );
1467
+ if ( ! empty( $terms ) ) {
1468
+ $data['tags'][] = $tag;
1469
+ $data['names'][ $tag ] = 'tax_input[' . $tag . ']';
1470
+ $data['tag'][ $tag ] = $terms;
1471
+ $data['value'][ $tag ] = array( 'post_id' => '' ); // just init
1472
+ }
1473
+ }
1474
+ }
1475
+
1476
+ } elseif ( 'options-general.php' === $page ) {
1477
+
1478
+ $page_action = 'options-general.php';
1479
+
1480
+ } elseif ( 'widgets.php' === $page ) {
1481
+
1482
+ $page_action = 'widgets.php';
1483
+
1484
+ } elseif ( 'customize.php' === $page ) {
1485
+
1486
+ if ( version_compare( WPGLOBUS_VERSION, '1.4.0-beta1', '<' ) ) {
1487
+ /// Do not translate
1488
+ $html = sprintf( __( 'You are customizing %s' ), '<strong class="theme-name site-title"><span id="wpglobus-customize-info">' . esc_html( WPGlobus_Core::text_filter( get_option( 'blogname' ), WPGlobus::Config()->default_language ) ) . '</span></strong>' );
1489
+ } else {
1490
+ // @since 1.4.0 class panel-title site-title
1491
+ /// Do not translate
1492
+ $html = sprintf( __( 'You are customizing %s' ), '<strong class="panel-title site-title"><span id="wpglobus-customize-info">' . esc_html( WPGlobus_Core::text_filter( get_option( 'blogname' ), WPGlobus::Config()->default_language ) ) . '</span></strong>' );
1493
+ }
1494
+
1495
+ $page_action = 'customize.php';
1496
+ $page_data_key = 'customize';
1497
+ $page_data_values = array(
1498
+ 'info' => array(
1499
+ 'element' => '#customize-info .preview-notice',
1500
+ 'html' => $html
1501
+ ),
1502
+ 'addElements' => array(
1503
+ 'wpglobus_blogname' => array(
1504
+ 'origin' => 'blogname',
1505
+ 'origin_element' => '#customize-control-blogname input',
1506
+ 'origin_parent' => '#customize-control-blogname',
1507
+ 'element' => '#customize-control-wpglobus_blogname input',
1508
+ 'value' => WPGlobus_Core::text_filter( get_option( 'blogname' ), WPGlobus::Config()->language, WPGlobus::RETURN_EMPTY )
1509
+ ),
1510
+ 'wpglobus_blogdescription' => array(
1511
+ 'origin' => 'blogdescription',
1512
+ 'origin_element' => '#customize-control-blogdescription input',
1513
+ 'origin_parent' => '#customize-control-blogdescription',
1514
+ 'element' => '#customize-control-wpglobus_blogdescription input',
1515
+ 'value' => WPGlobus_Core::text_filter( get_option( 'blogdescription' ), WPGlobus::Config()->language, WPGlobus::RETURN_EMPTY )
1516
+ )
1517
+ )
1518
+ );
1519
+
1520
+ } elseif ( in_array( $page, array( 'wpglobus_options', self::LANGUAGE_EDIT_PAGE ), true ) ) {
1521
+
1522
+ $page_action = 'wpglobus_options';
1523
+
1524
+ } elseif ( self::PAGE_WPGLOBUS_CLEAN === $page ) {
1525
+
1526
+ $page_action = 'wpglobus_clean';
1527
+
1528
+ } elseif (
1529
+ ( 'admin.php' === $pagenow && ! empty( $_GET['page'] ) // WPCS: input var ok, sanitization ok.
1530
+ && self::PAGE_WPGLOBUS_ADMIN_CENTRAL === $_GET['page'] ) // WPCS: input var ok, sanitization ok.
1531
+ || self::PAGE_WPGLOBUS_ADMIN_CENTRAL === $page
1532
+ ) {
1533
+
1534
+ /**
1535
+ * @since 1.6.6
1536
+ */
1537
+ $page_action = 'wpglobusAdminCentral';
1538
+ /**
1539
+ * @since 1.8
1540
+ */
1541
+ $data['pagenow'] = $pagenow;
1542
+ $data['page'] = self::PAGE_WPGLOBUS_ADMIN_CENTRAL;
1543
+ $data['pageAction'] = $page_action;
1544
+
1545
+ } else {
1546
+
1547
+ $page_action = $page;
1548
+
1549
+ }
1550
+
1551
+ /**
1552
+ * WordPress 4.7+ needs a new version of our admin JS.
1553
+ * @since 1.7.0
1554
+ */
1555
+ $version = '';
1556
+ if ( version_compare( $GLOBALS['wp_version'], '4.6.999', '>' ) ) {
1557
+ $version = '-47';
1558
+ }
1559
+
1560
+ /**
1561
+ * WordPress 4.9+ needs a new version of our admin JS.
1562
+ * @since 1.9.2
1563
+ */
1564
+ if ( version_compare( $GLOBALS['wp_version'], '4.8.999', '>' ) ) {
1565
+ $version = '-49';
1566
+ }
1567
+
1568
+ wp_register_script(
1569
+ 'wpglobus-admin',
1570
+ self::$PLUGIN_DIR_URL . "includes/js/wpglobus-admin$version" . self::$_SCRIPT_SUFFIX . ".js",
1571
+ array( 'jquery', 'jquery-ui-dialog', 'jquery-ui-tabs', 'jquery-ui-tooltip' ),
1572
+ WPGLOBUS_VERSION,
1573
+ true
1574
+ );
1575
+ wp_enqueue_script( 'wpglobus-admin' );
1576
+
1577
+ /**
1578
+ * We need to send the HTML breaks and not \r\n to the JS,
1579
+ * because we do element.text(...), and \r\n are being removed by TinyMCE
1580
+ * See other places with the same bookmark.
1581
+ * @bookmark EDITOR_LINE_BREAKS
1582
+ * added 24.05.2015
1583
+ * @todo what's next with wpautop? @see 'wpautop()' in https://make.wordpress.org/core/2015/05/14/dev-chat-summary-may-13/
1584
+ */
1585
+ if ( has_filter( 'the_content', 'wpautop' ) ) {
1586
+ $post_content_autop = wpautop( $post_content );
1587
+ } else {
1588
+ $post_content_autop = $post_content;
1589
+ }
1590
+
1591
+ /**
1592
+ * Filter for data to send to JS.
1593
+ * Returning array.
1594
+ * @since 1.5.5
1595
+ *
1596
+ * @param array $data An array with data.
1597
+ * @param string $page_action Page.
1598
+ */
1599
+ $data = apply_filters( 'wpglobus_localize_data', $data, $page_action );
1600
+
1601
+ wp_localize_script(
1602
+ 'wpglobus-admin',
1603
+ 'WPGlobusAdmin',
1604
+ array(
1605
+ 'version' => WPGLOBUS_VERSION,
1606
+ 'page' => $page_action,
1607
+ 'content' => $post_content_autop,
1608
+ 'title' => $post_title,
1609
+ 'excerpt' => $post_excerpt,
1610
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
1611
+ 'parentClass' => __CLASS__,
1612
+ 'process_ajax' => __CLASS__ . '_process_ajax',
1613
+ 'flag_url' => $config->flags_url,
1614
+ 'tabs' => $tabs_suffix,
1615
+ 'currentTab' => $config->default_language,
1616
+ 'i18n' => $i18n,
1617
+ 'data' => $data
1618
+ )
1619
+ );
1620
+
1621
+ if ( empty( $page_data_key ) ) {
1622
+ $page_data_key = 'page_custom_data';
1623
+ }
1624
+ if ( empty( $page_data_values ) ) {
1625
+ $page_data_values = null;
1626
+ }
1627
+
1628
+ /**
1629
+ * Add multisite property
1630
+ * @since 1.6.0
1631
+ */
1632
+ $is_multisite = 'false';
1633
+ if ( is_multisite() ) {
1634
+ $is_multisite = 'true';
1635
+ }
1636
+
1637
+ /**
1638
+ * Filter for custom data to send to JS.
1639
+ * Returning array or null.
1640
+ * @since 1.2.9
1641
+ *
1642
+ * @param array $page_data_values An array with custom data or null.
1643
+ * @param string $page_data_key Data key. @since 1.3.0
1644
+ * @param string $page_action Page. @since 1.5.0
1645
+ */
1646
+ $page_data_values = apply_filters( 'wpglobus_localize_custom_data', $page_data_values, $page_data_key, $page_action );
1647
+
1648
+ wp_localize_script(
1649
+ 'wpglobus-admin',
1650
+ 'WPGlobusCoreData',
1651
+ array_merge(
1652
+ array(
1653
+ 'version' => WPGLOBUS_VERSION,
1654
+ 'default_language' => $config->default_language,
1655
+ 'language' => $config->language,
1656
+ 'enabled_languages' => $config->enabled_languages,
1657
+ 'open_languages' => $config->open_languages,
1658
+ 'en_language_name' => $config->en_language_name,
1659
+ 'locale_tag_start' => self::LOCALE_TAG_START,
1660
+ 'locale_tag_end' => self::LOCALE_TAG_END,
1661
+ 'page' => $page_action,
1662
+ 'multisite' => $is_multisite,
1663
+ 'pluginInstallLocation' => array(
1664
+ 'single' => 'plugin-install.php?tab=search&s=WPGlobus&source=WPGlobus',
1665
+ 'multisite' => 'network/plugin-install.php?tab=search&s=WPGlobus&source=WPGlobus'
1666
+ )
1667
+ ), array(
1668
+ $page_data_key => $page_data_values
1669
+ )
1670
+ )
1671
+ );
1672
+
1673
+ /**
1674
+ * Enqueue js for ACF support
1675
+ */
1676
+ if (
1677
+ ( $this->vendors_scripts['ACF'] || $this->vendors_scripts['ACFPRO'] )
1678
+ && in_array( $page, array( 'post.php', 'post-new.php' )
1679
+ )
1680
+ ) {
1681
+
1682
+ /**
1683
+ * Filter to disable translation of selected ACF and ACF Pro fields.
1684
+ * @since 1.5.0
1685
+ *
1686
+ * To exclude field in ACF plugin you need to use the field name from Field Group ( usually wp-admin/edit.php?post_type=acf ).
1687
+ * To exclude field in ACF Pro plugin you need to use id, see Wrapper Attributes section on field's edit page.
1688
+ *
1689
+ * @param array $disabled_fields Default is empty array.
1690
+ * @param boolean $is_acf_pro Type of ACF plugin.
1691
+ *
1692
+ * @return array
1693
+ */
1694
+ $disabled_fields = apply_filters( 'wpglobus_disabled_acf_fields', array(), $this->vendors_scripts['ACFPRO'] );
1695
+
1696
+ wp_register_script(
1697
+ 'wpglobus-acf',
1698
+ self::$PLUGIN_DIR_URL . "includes/js/wpglobus-vendor-acf" . self::$_SCRIPT_SUFFIX . ".js",
1699
+ array( 'jquery', 'wpglobus-admin' ),
1700
+ WPGLOBUS_VERSION,
1701
+ true
1702
+ );
1703
+ wp_enqueue_script( 'wpglobus-acf' );
1704
+ wp_localize_script(
1705
+ 'wpglobus-acf',
1706
+ 'WPGlobusAcf',
1707
+ array(
1708
+ 'wpglobus_version' => WPGLOBUS_VERSION,
1709
+ 'pro' => $this->vendors_scripts['ACFPRO'] ? true : false,
1710
+ 'disabledFields' => $disabled_fields
1711
+ )
1712
+ );
1713
+
1714
+ }
1715
+
1716
+ if ( 'widgets.php' == $page ) {
1717
+
1718
+ $disabled_widgets_mask = array( 'rss-url' );
1719
+
1720
+ /**
1721
+ * Filter to disable making multilingual element on widgets.php page.
1722
+ * @since 1.5.3
1723
+ *
1724
+ * @param array $disabled_widgets_mask Array of disabled masks.
1725
+ *
1726
+ * @return array
1727
+ */
1728
+ $disabled_widgets_mask = apply_filters( 'wpglobus_disabled_widgets_mask', $disabled_widgets_mask );
1729
+
1730
+ wp_register_script(
1731
+ 'wpglobus-widgets',
1732
+ self::$PLUGIN_DIR_URL . "includes/js/wpglobus-widgets" . self::$_SCRIPT_SUFFIX . ".js",
1733
+ array( 'jquery', 'underscore', 'wpglobus-admin' ),
1734
+ WPGLOBUS_VERSION,
1735
+ true
1736
+ );
1737
+ wp_enqueue_script( 'wpglobus-widgets' );
1738
+ wp_localize_script(
1739
+ 'wpglobus-widgets',
1740
+ 'WPGlobusWidgets',
1741
+ array(
1742
+ 'wpglobus_version' => WPGLOBUS_VERSION,
1743
+ 'disabledMask' => $disabled_widgets_mask
1744
+ )
1745
+ );
1746
+
1747
+ }
1748
+
1749
+ } // endif $enabled_pages
1750
+ }
1751
+
1752
+ /**
1753
+ * Get taxonomies for post type
1754
+ *
1755
+ * @param string $post_type
1756
+ * @param string $type hierarchical, non-hierarchical or all taxonomies
1757
+ *
1758
+ * @return array
1759
+ */
1760
+ public function _get_taxonomies( $post_type, $type = 'all' ) {
1761
+ if ( empty( $post_type ) ) {
1762
+ return array();
1763
+ }
1764
+ $taxs = array();
1765
+ $taxonomies = get_object_taxonomies( $post_type );
1766
+ foreach ( $taxonomies as $taxonomy ) {
1767
+ $taxonomy_data = get_taxonomy( $taxonomy );
1768
+ if ( 'all' == $type ) {
1769
+ $taxs[] = $taxonomy_data->name;
1770
+ continue;
1771
+ }
1772
+ if ( 'non-hierarchical' == $type && ! $taxonomy_data->hierarchical ) {
1773
+ /**
1774
+ * This is tag
1775
+ * @todo Theoretically, it's not "tag". Can be any custom taxonomy. Need to check.
1776
+ * @todo
1777
+ * Practically in WP: all non-hierarchical taxonomy is tags.
1778
+ * In this context I use term $tags for saving non-hierarchical taxonomies only
1779
+ * for further work with them when editing posts
1780
+ */
1781
+ $taxs[] = $taxonomy_data->name;
1782
+ } elseif ( 'hierarchical' == $type && $taxonomy_data->hierarchical ) {
1783
+ $taxs[] = $taxonomy_data->name;
1784
+ }
1785
+ }
1786
+
1787
+ return $taxs;
1788
+ }
1789
+
1790
+ /**
1791
+ * Get template for quick edit at edit-tags.php, edit.php screens
1792
+ * @return string
1793
+ */
1794
+ public function _get_quickedit_template() {
1795
+ $t = '';
1796
+ foreach ( self::Config()->open_languages as $language ) {
1797
+ $t .= '<label>';
1798
+ $t .= '<span class="input-text-wrap">';
1799
+ $t .= '<input id="filled-in-js" data-language="' . $language . '" style="width:100%;" class="ptitle wpglobus-quick-edit-title wpglobus-translatable" type="text" value="" name="post_title-' . $language . '" placeholder="' . self::Config()->en_language_name[ $language ] . '">';
1800
+ $t .= '</span>';
1801
+ $t .= '</label>';
1802
+ }
1803
+
1804
+ return $t;
1805
+ }
1806
+
1807
+ /**
1808
+ * Enqueue admin styles
1809
+ * @return void
1810
+ */
1811
+ public function on_admin_styles() {
1812
+
1813
+ $page = '';
1814
+ if ( isset( $_GET['page'] ) && is_string( $_GET['page'] ) ) { // WPCS: input var ok, sanitization ok.
1815
+ $page = sanitize_text_field( wp_unslash( $_GET['page'] ) ); // WPCS: input var ok.
1816
+ }
1817
+
1818
+ wp_register_style(
1819
+ 'wpglobus-admin',
1820
+ self::$PLUGIN_DIR_URL . 'includes/css/wpglobus-admin' . WPGlobus::$_SCRIPT_SUFFIX . '.css',
1821
+ array(),
1822
+ WPGLOBUS_VERSION,
1823
+ 'all'
1824
+ );
1825
+ wp_enqueue_style( 'wpglobus-admin' );
1826
+
1827
+ if ( self::LANGUAGE_EDIT_PAGE === $page ) {
1828
+ /**
1829
+ * Using the same 'select2-css' ID as Redux Plugin does, to avoid duplicate enqueueing
1830
+ */
1831
+ if ( ! wp_style_is( 'select2-js' ) ) {
1832
+ wp_enqueue_style(
1833
+ 'select2-css',
1834
+ WPGlobus::$PLUGIN_DIR_URL . 'lib/select2.min.css',
1835
+ array(),
1836
+ '3.5.2'
1837
+ );
1838
+ }
1839
+ }
1840
+
1841
+ $post = get_post();
1842
+ $type = empty( $post ) ? '' : $post->post_type;
1843
+
1844
+ if ( ! $this->disabled_entity( $type ) ) {
1845
+
1846
+ /**
1847
+ * Loading CSS for enabled pages as for js
1848
+ * @since 1.2.0
1849
+ */
1850
+ /** @global string $pagenow */
1851
+ global $pagenow;
1852
+
1853
+ if ( in_array( $pagenow, $this->enabled_pages ) || in_array( $page, $this->enabled_pages ) ) {
1854
+
1855
+ wp_register_style(
1856
+ 'wpglobus-admin-tabs',
1857
+ self::$PLUGIN_DIR_URL . 'includes/css/wpglobus-admin-tabs' . WPGlobus::$_SCRIPT_SUFFIX . '.css',
1858
+ array(),
1859
+ WPGLOBUS_VERSION,
1860
+ 'all'
1861
+ );
1862
+ wp_enqueue_style( 'wpglobus-admin-tabs' );
1863
+
1864
+ wp_enqueue_style(
1865
+ 'dialog-ui',
1866
+ self::$PLUGIN_DIR_URL . 'includes/css/wpglobus-dialog-ui' . WPGlobus::$_SCRIPT_SUFFIX . '.css',
1867
+ array(),
1868
+ WPGLOBUS_VERSION,
1869
+ 'all'
1870
+ );
1871
+
1872
+ }
1873
+
1874
+ }
1875
+
1876
+ if ( self::PAGE_WPGLOBUS_ABOUT === $page ) {
1877
+ wp_register_style(
1878
+ 'wpglobus-special-pages',
1879
+ self::$PLUGIN_DIR_URL . 'includes/css/wpglobus-special-pages' . WPGlobus::$_SCRIPT_SUFFIX . '.css',
1880
+ array(),
1881
+ WPGLOBUS_VERSION,
1882
+ 'all'
1883
+ );
1884
+ wp_enqueue_style( 'wpglobus-special-pages' );
1885
+ }
1886
+
1887
+ }
1888
+
1889
+ /**
1890
+ * Add hidden submenu for Language edit page
1891
+ * @return void
1892
+ */
1893
+ public function on_admin_menu() {
1894
+
1895
+ /**
1896
+ * @todo Temporarily add main menu.
1897
+ */
1898
+ /**
1899
+ add_menu_page(
1900
+ 'WPGlobus',
1901
+ 'WPGlobus',
1902
+ 'administrator',
1903
+ 'wpglobus-main',
1904
+ array( $this, 'wpglobus_about' )
1905
+ ); **/
1906
+
1907
+ add_submenu_page(
1908
+ null,
1909
+ '',
1910
+ '',
1911
+ 'administrator',
1912
+ self::LANGUAGE_EDIT_PAGE,
1913
+ array(
1914
+ $this,
1915
+ 'on_language_edit'
1916
+ )
1917
+ );
1918
+
1919
+ add_submenu_page(
1920
+ null,
1921
+ '',
1922
+ '',
1923
+ 'administrator',
1924
+ self::PAGE_WPGLOBUS_ABOUT,
1925
+ array(
1926
+ $this,
1927
+ 'wpglobus_about'
1928
+ )
1929
+ );
1930
+
1931
+ add_submenu_page(
1932
+ null,
1933
+ '',
1934
+ '',
1935
+ 'administrator',
1936
+ self::PAGE_WPGLOBUS_CLEAN,
1937
+ array(
1938
+ $this,
1939
+ 'wpglobus_clean'
1940
+ )
1941
+ );
1942
+ }
1943
+
1944
+ /**
1945
+ * Include file for WPGlobus clean page
1946
+ * @since 1.4.3
1947
+ * @return void
1948
+ */
1949
+ public function wpglobus_clean() {
1950
+ require_once 'admin/class-wpglobus-clean.php';
1951
+ WPGlobus_Clean::controller();
1952
+ }
1953
+
1954
+ /**
1955
+ * Include file for WPGlobus about page
1956
+ * @return void
1957
+ */
1958
+ public function wpglobus_about() {
1959
+ require_once 'admin/class-wpglobus-about.php';
1960
+ WPGlobus_About::about_screen();
1961
+ }
1962
+
1963
+ /**
1964
+ * Include file for language edit page
1965
+ * @return void
1966
+ */
1967
+ public function on_language_edit() {
1968
+ require_once 'admin/class-wpglobus-language-edit.php';
1969
+ new WPGlobus_Language_Edit();
1970
+ }
1971
+
1972
+ /**
1973
+ * We must convert url for nav_menu_item with type == custom
1974
+ * For other types url has language shortcode already
1975
+ *
1976
+ * @param $sorted_menu_items
1977
+ *
1978
+ * @internal param $args
1979
+ * @return array
1980
+ */
1981
+ public function on_get_convert_url_menu_items( $sorted_menu_items ) {
1982
+
1983
+ foreach ( $sorted_menu_items as $key => $item ) {
1984
+
1985
+ /**
1986
+ * Ability to avoid the localize URL.
1987
+ * @since 1.8.6
1988
+ */
1989
+ $localize = true;
1990
+ if ( ! empty( $item->classes ) && in_array( 'wpglobus-menu-item-url-nolocalize', $item->classes ) ) {
1991
+ $localize = false;
1992
+ }
1993
+
1994
+ if ( 'custom' == $item->type ) {
1995
+ if ( $localize ) {
1996
+ $sorted_menu_items[ $key ]->url = WPGlobus_Utils::localize_url( $sorted_menu_items[ $key ]->url );
1997
+ }
1998
+ } else {
1999
+ if ( ! $localize ) {
2000
+ /**
2001
+ * URL was localized already.
2002
+ * @see wp_setup_nav_menu_item() in p-includes\nav-menu.php
2003
+ * @since 1.8.6
2004
+ */
2005
+ $sorted_menu_items[ $key ]->url = WPGlobus_Utils::localize_url( $sorted_menu_items[ $key ]->url, WPGlobus::Config()->default_language );
2006
+ }
2007
+
2008
+ }
2009
+ }
2010
+
2011
+ /**
2012
+ * Filter for menu objects
2013
+ * @since 1.5.1
2014
+ *
2015
+ * @param array $sorted_menu_items An array of sorted menu items.
2016
+ *
2017
+ * @return array
2018
+ */
2019
+ return apply_filters( 'wpglobus_nav_menu_objects', $sorted_menu_items );
2020
+
2021
+ }
2022
+
2023
+ /**
2024
+ * Enqueue styles
2025
+ * @return void
2026
+ */
2027
+ public function on_wp_styles() {
2028
+ wp_register_style(
2029
+ 'wpglobus',
2030
+ self::$PLUGIN_DIR_URL . "includes/css/wpglobus" . self::$_SCRIPT_SUFFIX . ".css",
2031
+ array(),
2032
+ WPGLOBUS_VERSION,
2033
+ 'all'
2034
+ );
2035
+ wp_enqueue_style( 'wpglobus' );
2036
+ }
2037
+
2038
+ /**
2039
+ * Enqueue the `wpglobus.js` script.
2040
+ * @since 1.0
2041
+ * @since 1.7.11 Added WPGlobus::Config()->enabled_languages.
2042
+ */
2043
+ public function enqueue_wpglobus_js() {
2044
+
2045
+ wp_enqueue_script(
2046
+ 'wpglobus',
2047
+ self::$PLUGIN_DIR_URL . "includes/js/wpglobus" . self::$_SCRIPT_SUFFIX . ".js",
2048
+ array( 'jquery', 'utils' ),
2049
+ WPGLOBUS_VERSION,
2050
+ true
2051
+ );
2052
+
2053
+ wp_localize_script(
2054
+ 'wpglobus',
2055
+ 'WPGlobus',
2056
+ array(
2057
+ 'version' => WPGLOBUS_VERSION,
2058
+ 'language' => WPGlobus::Config()->language,
2059
+ 'enabledLanguages' => WPGlobus::Config()->enabled_languages
2060
+ )
2061
+ );
2062
+ }
2063
+
2064
+ /**
2065
+ * Add rel="alternate" links to head section
2066
+ * @return void
2067
+ */
2068
+ public function on_add_hreflang() {
2069
+
2070
+ $hreflangs = WPGlobus_Utils::hreflangs();
2071
+
2072
+ /**
2073
+ * Filter hreflang.
2074
+ * Returning array.
2075
+ * @since 1.0.14
2076
+ *
2077
+ * @param string $hreflangs An array.
2078
+ */
2079
+ $hreflangs = apply_filters( 'wpglobus_hreflang_tag', $hreflangs );
2080
+
2081
+ if ( ! empty( $hreflangs ) ) {
2082
+ echo wp_kses( implode( '', $hreflangs ), array(
2083
+ 'link' => array(
2084
+ 'rel' => array(),
2085
+ 'hreflang' => array(),
2086
+ 'href' => array(),
2087
+ )
2088
+ ) );
2089
+ }
2090
+
2091
+ }
2092
+
2093
+ /**
2094
+ * Add css styles to head section
2095
+ * @return void
2096
+ */
2097
+ public function on_wp_head() {
2098
+
2099
+ $config = WPGlobus::Config();
2100
+
2101
+ $css = '';
2102
+
2103
+ /**
2104
+ * CSS rules for flags in the menu
2105
+ */
2106
+ foreach ( $config->enabled_languages as $language ) {
2107
+ $css .= '.wpglobus_flag_' . $language .
2108
+ '{background-image:url(' . $config->flags_url . $config->flag[ $language ] . ")}\n";
2109
+ }
2110
+
2111
+ /**
2112
+ * Swap flag and text for RTL
2113
+ * (See the LTR default rules in the wpglobus-flags.mixin.less)
2114
+ */
2115
+ if ( is_rtl() ) {
2116
+ $css .= '.wpglobus_flag{background-position:center right;}' .
2117
+ '.wpglobus_language_name{padding-right:22px;}';
2118
+ }
2119
+
2120
+ /**
2121
+ * Filter CSS rules for frontend.
2122
+ * @since 1.6.6
2123
+ *
2124
+ * @param string $css CSS rules for flags in the menu.
2125
+ * @param string $config->css_editor Custom CSS rules @see WPGlobus options.
2126
+ *
2127
+ * @return string
2128
+ */
2129
+ $css = apply_filters( 'wpglobus_styles', $css, $config->css_editor );
2130
+
2131
+ if ( ! empty( $css ) ) {
2132
+ ?>
2133
+ <style type="text/css" media="screen">
2134
+ <?php echo wp_kses( $css, array() ); ?>
2135
+ </style>
2136
+ <?php
2137
+ }
2138
+
2139
+ }
2140
+
2141
+ /**
2142
+ * Append language switcher dropdown or flat to a navigation menu, which was created with
2143
+ * @see wp_list_pages
2144
+ *
2145
+ * @since 1.5.8
2146
+ * @param string $output The menu HTML string
2147
+ * @return string HTML with appended switcher
2148
+ */
2149
+ public function filter__wp_list_pages( $output ) {
2150
+
2151
+ /**
2152
+ * WPGlobus Configuration setting in admin. Must be "ON" to process.
2153
+ */
2154
+ if ( ! WPGlobus::Config()->selector_wp_list_pages ) {
2155
+ return $output;
2156
+ }
2157
+
2158
+ $current_url = WPGlobus_Utils::current_url();
2159
+ $current_language = WPGlobus::Config()->language;
2160
+
2161
+ /**
2162
+ * List of the languages to show in the drop-down.
2163
+ * These are all enabled languages, except for the current one.
2164
+ * The current one will be shown at the top.
2165
+ */
2166
+ $extra_languages = array_diff(
2167
+ WPGlobus::Config()->enabled_languages, (array) $current_language );
2168
+
2169
+ /**
2170
+ * Filter extra languages.
2171
+ * Returning array.
2172
+ * @since 1.0.13
2173
+ *
2174
+ * @param array $extra_languages An array with languages to show in the dropdown.
2175
+ * @param string $current_language The current language.
2176
+ */
2177
+ $extra_languages = apply_filters(
2178
+ 'wpglobus_extra_languages', $extra_languages, $current_language );
2179
+
2180
+ /**
2181
+ * Filter to show dropdown menu or not.
2182
+ * Returning boolean.
2183
+ * @since 1.2.2
2184
+ *
2185
+ * @param bool
2186
+ * @param WPGlobus_Config
2187
+ */
2188
+ $dropdown_menu = apply_filters( 'wpglobus_dropdown_menu', true, WPGlobus::Config() );
2189
+
2190
+ /**
2191
+ * Array of menu items
2192
+ */
2193
+ $wpglobus_menu_items = array();
2194
+
2195
+ /**
2196
+ * Build the top-level menu link
2197
+ */
2198
+ //$language = $current_language;
2199
+ $url = WPGlobus_Utils::localize_url( $current_url, $current_language );
2200
+ $flag_name = $this->_get_flag_name( $current_language );
2201
+ $span_classes_lang = $this->_get_language_classes( $current_language );
2202
+
2203
+ $link_text = '<span class="' . implode( ' ', $span_classes_lang ) . '">' .
2204
+ esc_html( $flag_name ) . '</span>';
2205
+ $a_tag = '<a class="wpglobus-selector-link" href="' . esc_url( $url ) . '">' . $link_text . '</a>';
2206
+
2207
+ /**
2208
+ * Current language menu item classes
2209
+ */
2210
+ $menu_item_classes = array(
2211
+ 'page_item' => 'page_item',
2212
+ 'page_item_wpglobus_menu_switch' => 'page_item_wpglobus_menu_switch',
2213
+ 'page_item_has_children' => 'page_item_has_children',
2214
+ 'wpglobus-current-language' => 'wpglobus-current-language'
2215
+ );
2216
+
2217
+ /**
2218
+ * Submenu item classes for extra languages
2219
+ */
2220
+ $submenu_item_classes = array(
2221
+ 'page_item' => 'page_item',
2222
+ 'page_item_wpglobus_menu_switch' => 'page_item_wpglobus_menu_switch',
2223
+ 'sub_menu_item_wpglobus_menu_switch' => 'sub_menu_item_wpglobus_menu_switch'
2224
+ );
2225
+
2226
+ $item = new stdClass();
2227
+ $item->item_has_parent = false;
2228
+ $item->title = $a_tag;
2229
+ $item->url = $url;
2230
+ $item->language = $current_language;
2231
+
2232
+ if ( $dropdown_menu ) {
2233
+
2234
+ /**
2235
+ * Dropdown menu
2236
+ */
2237
+ $item->classes = $menu_item_classes;
2238
+ $item->classes[ 'page_item_wpglobus_menu_switch_' . $current_language ] = 'page_item_wpglobus_menu_switch_' . $current_language;
2239
+ $wpglobus_menu_items[] = $item;
2240
+
2241
+ $template = '<li {{parent}}<ul class="children">{{children}}</ul></li>';
2242
+
2243
+ foreach ( $extra_languages as $language ) :
2244
+ /**
2245
+ * Build the drop-down menu links for extra language
2246
+ */
2247
+ $url = WPGlobus_Utils::localize_current_url( $language );
2248
+ $flag_name = $this->_get_flag_name( $language );
2249
+ $span_classes_lang = $this->_get_language_classes( $language );
2250
+
2251
+ $link_text = '<span class="' . implode( ' ', $span_classes_lang ) . '">' .
2252
+ esc_html( $flag_name ) . '</span>';
2253
+ $a_tag = '<a class="wpglobus-selector-link" href="' . esc_url( $url ) . '">' . $link_text . '</a>';
2254
+
2255
+ $item = new stdClass();
2256
+ $item->item_has_parent = true;
2257
+ $item->title = $a_tag;
2258
+ $item->url = $url;
2259
+ $item->classes = $submenu_item_classes;
2260
+ $item->language = $language;
2261
+ $item->classes[ 'page_item_wpglobus_menu_switch_' . $language ] = 'page_item_wpglobus_menu_switch_' . $language;
2262
+
2263
+ // $item->object_id = $item->ID;
2264
+ $item->object = 'custom';
2265
+
2266
+ $wpglobus_menu_items[] = new WP_Post( $item );
2267
+
2268
+ endforeach;
2269
+
2270
+ } else {
2271
+
2272
+ /**
2273
+ * Flat menu
2274
+ */
2275
+ unset( $submenu_item_classes[ 'sub_menu_item_wpglobus_menu_switch' ] );
2276
+
2277
+ $item->classes = $submenu_item_classes;
2278
+ $item->classes[ 'wpglobus-current-language' ] = 'wpglobus-current-language';
2279
+ $item->classes[ 'page_item_wpglobus_menu_switch_' . $item->language ] = 'page_item_wpglobus_menu_switch_' . $item->language;
2280
+
2281
+ $wpglobus_menu_items[] = $item;
2282
+
2283
+ $template = '{{parent}}{{children}}';
2284
+
2285
+ foreach ( $extra_languages as $language ) :
2286
+ /**
2287
+ * Build the top-level menu link for extra language
2288
+ */
2289
+ $url = WPGlobus_Utils::localize_current_url( $language );
2290
+ $flag_name = $this->_get_flag_name( $language );
2291
+ $span_classes_lang = $this->_get_language_classes( $language );
2292
+
2293
+ $link_text = '<span class="' . implode( ' ', $span_classes_lang ) . '">' .
2294
+ esc_html( $flag_name ) . '</span>';
2295
+ $a_tag = '<a class="wpglobus-selector-link" href="' . esc_url( $url ) . '">' . $link_text . '</a>';
2296
+
2297
+
2298
+ $item = new stdClass();
2299
+ $item->item_has_parent = false;
2300
+ $item->title = $a_tag;
2301
+ $item->url = $url;
2302
+ $item->classes = $submenu_item_classes;
2303
+ $item->classes[] = 'page_item_wpglobus_menu_switch_' . $language;
2304
+ $item->language = $language;
2305
+
2306
+ $item->object = 'custom';
2307
+
2308
+ $wpglobus_menu_items[] = new WP_Post( $item );
2309
+
2310
+ endforeach;
2311
+
2312
+ } // $dropdown_menu
2313
+
2314
+ /**
2315
+ * Filter wpglobus selector items.
2316
+ * Returning array.
2317
+ * @since 1.5.8
2318
+ *
2319
+ * @param array $wpglobus_menu_items An array of selector items.
2320
+ * @param array $extra_languages An array of extra languages.
2321
+ */
2322
+ $wpglobus_menu_items = apply_filters( 'wpglobus_page_menu_items', $wpglobus_menu_items, $extra_languages );
2323
+
2324
+ $parent = '';
2325
+ $children = '';
2326
+
2327
+ foreach( $wpglobus_menu_items as $item ) :
2328
+
2329
+ if ( $dropdown_menu ) {
2330
+
2331
+ if ( ! $item->item_has_parent ) {
2332
+ $parent = 'class="' . implode( ' ', $item->classes ) . '">' . $item->title;
2333
+ continue;
2334
+ }
2335
+
2336
+ $children .= '<li class="' . implode( ' ', $item->classes ) . '">' . $item->title . '</li>';
2337
+
2338
+ } else {
2339
+
2340
+ $children .= '<li class="' . implode( ' ', $item->classes ) . '">' . $item->title . '</li>';
2341
+
2342
+ }
2343
+
2344
+ endforeach;
2345
+
2346
+ $selector_html = str_replace( '{{parent}}', $parent , $template );
2347
+ $selector_html = str_replace( '{{children}}', $children, $selector_html );
2348
+
2349
+ /**
2350
+ * Filter the HTML content for language selector.
2351
+ *
2352
+ * @param string $selector_html The HTML content for the navigation menu.
2353
+ * @param array $wpglobus_menu_items An array containing selector element.
2354
+ */
2355
+ return $output . apply_filters( 'wpglobus_page_menu_items_html', $selector_html, $wpglobus_menu_items );
2356
+
2357
+ }
2358
+
2359
+ /**
2360
+ * Append language switcher dropdown to a navigation menu, which was created with
2361
+ * @see wp_list_pages
2362
+ *
2363
+ * @deprecated from 1.5.8
2364
+ *
2365
+ * @param string $output The menu HTML string
2366
+ * @return string HTML with appended switcher
2367
+ */
2368
+ public function on_wp_list_pages( $output ) {
2369
+
2370
+ if (
2371
+ /**
2372
+ * Filter to use 'filter__wp_list_pages' instead of 'on_wp_list_pages'.
2373
+ *
2374
+ * @since 1.5.8
2375
+ * @param bool true If to use filter
2376
+ * @return bool
2377
+ */
2378
+ apply_filters( 'wpglobus_filter_wp_list_pages', true )
2379
+ ) {
2380
+ return $this->filter__wp_list_pages( $output );
2381
+ }
2382
+
2383
+ /**
2384
+ * WPGlobus Configuration setting in admin. Must be "ON" to process.
2385
+ */
2386
+ if ( ! WPGlobus::Config()->selector_wp_list_pages ) {
2387
+ return $output;
2388
+ }
2389
+
2390
+ $current_url = WPGlobus_Utils::current_url();
2391
+ $current_language = WPGlobus::Config()->language;
2392
+
2393
+ /**
2394
+ * List of the languages to show in the drop-down.
2395
+ * These are all enabled languages, except for the current one.
2396
+ * The current one will be shown at the top.
2397
+ */
2398
+ $extra_languages = array_diff(
2399
+ WPGlobus::Config()->enabled_languages, (array) $current_language );
2400
+
2401
+ /**
2402
+ * Filter extra languages.
2403
+ * Returning array.
2404
+ * @since 1.0.13
2405
+ *
2406
+ * @param array $extra_languages An array with languages to show in the dropdown.
2407
+ * @param string $current_language The current language.
2408
+ */
2409
+ $extra_languages = apply_filters(
2410
+ 'wpglobus_extra_languages', $extra_languages, $current_language );
2411
+
2412
+ /**
2413
+ * Filter to show dropdown menu or not.
2414
+ * Returning boolean.
2415
+ * @since 1.2.2
2416
+ *
2417
+ * @param bool
2418
+ * @param WPGlobus_Config
2419
+ */
2420
+ $dropdown_menu = apply_filters( 'wpglobus_dropdown_menu', true, WPGlobus::Config() );
2421
+
2422
+
2423
+ /**
2424
+ * Build the top-level menu link
2425
+ */
2426
+ $language = $current_language;
2427
+ $url = WPGlobus_Utils::localize_url( $current_url, $language );
2428
+ $flag_name = $this->_get_flag_name( $language );
2429
+ $span_classes_lang = $this->_get_language_classes( $language );
2430
+
2431
+ $link_text = '<span class="' . implode( ' ', $span_classes_lang ) . '">' .
2432
+ esc_html( $flag_name ) . '</span>';
2433
+ $a_tag = '<a class="wpglobus-selector-link" href="' . esc_url( $url ) . '">' . $link_text . '</a>';
2434
+
2435
+
2436
+ if ( $dropdown_menu ) {
2437
+
2438
+ $output .= '<li class="page_item page_item_wpglobus_menu_switch page_item_has_children wpglobus-current-language page_item_wpglobus_menu_switch_' . $language . '">' .
2439
+ $a_tag .
2440
+ '<ul class="children">';
2441
+
2442
+ foreach ( $extra_languages as $language ) :
2443
+ /**
2444
+ * Build the drop-down menu links for extra language
2445
+ */
2446
+ $url = WPGlobus_Utils::localize_current_url( $language );
2447
+ $flag_name = $this->_get_flag_name( $language );
2448
+ $span_classes_lang = $this->_get_language_classes( $language );
2449
+
2450
+ $link_text = '<span class="' . implode( ' ', $span_classes_lang ) . '">' .
2451
+ esc_html( $flag_name ) . '</span>';
2452
+ $a_tag = '<a class="wpglobus-selector-link" href="' . esc_url( $url ) . '">' . $link_text . '</a>';
2453
+
2454
+ $output .= '<li class="page_item page_item_wpglobus_menu_switch_' . $language . '">' .
2455
+ $a_tag .
2456
+ '</li>';
2457
+ endforeach;
2458
+
2459
+ $output .= '</ul>' .
2460
+ '</li>';
2461
+
2462
+ } else {
2463
+
2464
+ $output .= '<li class="page_item page_item_wpglobus_menu_switch wpglobus-current-language page_item_wpglobus_menu_switch_' . $language . '">' .
2465
+ $a_tag .
2466
+ '</li>';
2467
+
2468
+ foreach ( $extra_languages as $language ) :
2469
+ /**
2470
+ * Build the top-level menu link for extra language
2471
+ */
2472
+ // $url = WPGlobus_Utils::localize_url( $current_url, $language );
2473
+ $url = WPGlobus_Utils::localize_current_url( $language );
2474
+ $flag_name = $this->_get_flag_name( $language );
2475
+ $span_classes_lang = $this->_get_language_classes( $language );
2476
+
2477
+ $link_text = '<span class="' . implode( ' ', $span_classes_lang ) . '">' .
2478
+ esc_html( $flag_name ) . '</span>';
2479
+ $a_tag = '<a class="wpglobus-selector-link" href="' . esc_url( $url ) . '">' . $link_text . '</a>';
2480
+
2481
+ $output .= '<li class="page_item page_item_wpglobus_menu_switch page_item_wpglobus_menu_switch_' . $language . '">' .
2482
+ $a_tag .
2483
+ '</li>';
2484
+ endforeach;
2485
+
2486
+ } // $dropdown_menu
2487
+
2488
+ return $output;
2489
+ }
2490
+
2491
+ /**
2492
+ * Add language switcher to navigation menu
2493
+ *
2494
+ * @param array $sorted_menu_items
2495
+ * @param stdClass $args An object containing wp_nav_menu() arguments.
2496
+ *
2497
+ * @return array
2498
+ * @see wp_nav_menu()
2499
+ */
2500
+ public function on_add_item(
2501
+ $sorted_menu_items, /** @noinspection PhpUnusedParameterInspection */
2502
+ $args
2503
+ ) {
2504
+
2505
+ if ( empty( WPGlobus::Config()->nav_menu ) ) {
2506
+ /**
2507
+ * User can use WPGlobus widget
2508
+ * @since 1.0.7
2509
+ */
2510
+ $disable_add_selector = true;
2511
+
2512
+ } elseif ( 'all' === WPGlobus::Config()->nav_menu ) {
2513
+ /**
2514
+ * Attach to every nav menu
2515
+ * @since 1.0.7
2516
+ */
2517
+ $disable_add_selector = false;
2518
+
2519
+ } else {
2520
+
2521
+ $items = array();
2522
+ foreach ( $sorted_menu_items as $item ) {
2523
+ $items[] = $item->ID;
2524
+ }
2525
+
2526
+ $disable_add_selector = true;
2527
+ foreach ( $this->menus as $key => $menu ) {
2528
+ $diff = array_diff( $items, $menu->menu_items );
2529
+ if ( empty( $diff ) && WPGlobus::Config()->nav_menu === $menu->slug ) {
2530
+ $disable_add_selector = false;
2531
+ break;
2532
+ }
2533
+ }
2534
+
2535
+ }
2536
+
2537
+ /**
2538
+ * Filter to add or not language selector to the menu.
2539
+ * Returning boolean.
2540
+ * @since 1.5.8
2541
+ *
2542
+ * @param bool $disable_add_selector Disable or not to add language selector to the menu.
2543
+ * @param stdClass $args An object containing wp_nav_menu() arguments.
2544
+ */
2545
+ $disable_add_selector = apply_filters( 'wpglobus_menu_add_selector', $disable_add_selector, $args );
2546
+
2547
+ if ( $disable_add_selector ) {
2548
+ return $sorted_menu_items;
2549
+ }
2550
+
2551
+ /**
2552
+ * List of all languages, except the main one.
2553
+ *
2554
+ * @var string[] $extra_languages
2555
+ */
2556
+ $extra_languages = array();
2557
+ foreach ( WPGlobus::Config()->enabled_languages as $languages ) {
2558
+ if ( $languages !== WPGlobus::Config()->language ) {
2559
+ $extra_languages[] = $languages;
2560
+ }
2561
+ }
2562
+
2563
+ /**
2564
+ * Filter extra languages.
2565
+ * Returning array.
2566
+ * @since 1.0.13
2567
+ *
2568
+ * @param array $extra_languages An array of languages to show in the menu.
2569
+ * @param string WPGlobus::Config()->language The current language.
2570
+ */
2571
+ $extra_languages = apply_filters( 'wpglobus_extra_languages', $extra_languages, WPGlobus::Config()->language );
2572
+
2573
+ // Main menu item classes.
2574
+ $menu_item_classes = array(
2575
+ '',
2576
+ 'menu-item',
2577
+ 'menu-item-type-custom',
2578
+ 'menu-item-object-custom',
2579
+ 'menu_item_wpglobus_menu_switch',
2580
+ 'wpglobus-selector-link'
2581
+ );
2582
+
2583
+ // Submenu item classes.
2584
+ $submenu_item_classes = array(
2585
+ '',
2586
+ 'menu-item',
2587
+ 'menu-item-type-custom',
2588
+ 'menu-item-object-custom',
2589
+ 'sub_menu_item_wpglobus_menu_switch',
2590
+ 'wpglobus-selector-link'
2591
+ );
2592
+
2593
+ if (
2594
+ /**
2595
+ * Filter to show the language switcher as a dropdown (default) or plain menu.
2596
+ *
2597
+ * @since 1.2.2
2598
+ *
2599
+ * @param bool true If false then no dropdown
2600
+ * @param WPGlobus_Config
2601
+ *
2602
+ * @return bool Value of the first parameter, possibly updated by the filter
2603
+ */
2604
+ apply_filters( 'wpglobus_dropdown_menu', true, WPGlobus::Config() )
2605
+ ) {
2606
+ $parent_item_ID = 9999999999; # 9 999 999 999
2607
+ } else {
2608
+ $parent_item_ID = 0;
2609
+ }
2610
+
2611
+ $span_classes_lang = $this->_get_language_classes( WPGlobus::Config()->language );
2612
+
2613
+ $current_url = WPGlobus_Utils::current_url();
2614
+
2615
+ $item = new stdClass();
2616
+ $item->ID = 0 === $parent_item_ID ? 'wpglobus_menu_switch_' . WPGlobus::Config()->language : $parent_item_ID;
2617
+ $item->db_id = $item->ID;
2618
+ $item->object_id = $item->ID;
2619
+ $item->object = 'custom';
2620
+ $item->menu_item_parent = 0;
2621
+ $item->title =
2622
+ '<span class="' . implode( ' ', $span_classes_lang ) . '">' . $this->_get_flag_name( WPGlobus::Config()->language ) . '</span>';
2623
+ // The top menu level points to the current URL. Useless? Maybe good for refresh.
2624
+ $item->url = $current_url;
2625
+ $item->classes = $menu_item_classes;
2626
+ $item->classes[] = 'wpglobus-current-language';
2627
+ $item->description = '';
2628
+ $item->language = WPGlobus::Config()->language;
2629
+
2630
+ $wpglobus_menu_items[] = new WP_Post($item);
2631
+
2632
+ foreach ( $extra_languages as $language ) {
2633
+ $span_classes_lang = $this->_get_language_classes( $language );
2634
+ $item = new stdClass();
2635
+ $item->ID = 'wpglobus_menu_switch_' . $language;
2636
+ $item->db_id = $item->ID;
2637
+ $item->object_id = $item->ID;
2638
+ $item->object = 'custom';
2639
+ $item->menu_item_parent = $parent_item_ID;
2640
+ $item->title =
2641
+ '<span class="' . implode( ' ', $span_classes_lang ) . '">' . $this->_get_flag_name( $language ) . '</span>';
2642
+ // This points to the URL localized for the selected language.
2643
+ $item->url = WPGlobus_Utils::localize_current_url( $language );
2644
+ $item->classes = 0 === $parent_item_ID ? $menu_item_classes : $submenu_item_classes;
2645
+ $item->description = '';
2646
+ $item->language = $language;
2647
+
2648
+ $wpglobus_menu_items[] = new WP_Post( $item );
2649
+ }
2650
+
2651
+ $languages = $extra_languages;
2652
+ array_unshift( $languages, WPGlobus::Config()->language );
2653
+
2654
+ return array_merge(
2655
+ $sorted_menu_items,
2656
+
2657
+ /**
2658
+ * This filter can be used to change the order of languages.
2659
+ *
2660
+ * @since 1.2.2
2661
+ *
2662
+ * @param array $wpglobus_menu_items All WPGlobus menu items.
2663
+ * @param array $languages All languages, including current.
2664
+ * @return array The filtered list.
2665
+ */
2666
+ apply_filters( 'wpglobus_menu_items', $wpglobus_menu_items, $languages )
2667
+ );
2668
+ }
2669
+
2670
+ /**
2671
+ * Get flag name for navigation menu
2672
+ *
2673
+ * @param string $language
2674
+ *
2675
+ * @return string
2676
+ */
2677
+ public function _get_flag_name( $language ) {
2678
+
2679
+ switch ( WPGlobus::Config()->show_flag_name ) {
2680
+ case 'full_name' :
2681
+ $flag_name = WPGlobus::Config()->language_name[ $language ];
2682
+ break;
2683
+ case 'name' :
2684
+ $flag_name = WPGlobus::Config()->language_name[ $language ];
2685
+ break;
2686
+ case 'code' :
2687
+ $flag_name = $language;
2688
+ break;
2689
+ default:
2690
+ $flag_name = '';
2691
+ }
2692
+
2693
+ return $flag_name;
2694
+
2695
+ }
2696
+
2697
+ /**
2698
+ * Get language's classes
2699
+ * @since 1.2.1
2700
+ *
2701
+ * @param string $language
2702
+ *
2703
+ * @return array
2704
+ */
2705
+ public function _get_language_classes( $language = '' ) {
2706
+
2707
+ $class = array(
2708
+ 'wpglobus_flag',
2709
+ 'wpglobus_language_name'
2710
+ );
2711
+
2712
+ if ( ! empty( $language ) ) {
2713
+ $class[] = 'wpglobus_flag_' . $language;
2714
+ }
2715
+
2716
+ switch ( WPGlobus::Config()->show_flag_name ) {
2717
+ case 'full_name' :
2718
+ /* without flag */
2719
+ $class = array(
2720
+ 'wpglobus_language_full_name'
2721
+ );
2722
+ break;
2723
+ }
2724
+
2725
+ return $class;
2726
+ }
2727
+
2728
+ /**
2729
+ * Get navigation menus
2730
+ * @return array
2731
+ */
2732
+ public static function _get_nav_menus() {
2733
+ /** @global wpdb $wpdb */
2734
+ global $wpdb;
2735
+
2736
+ $query = "SELECT * FROM {$wpdb->prefix}terms AS t
2737
+ LEFT JOIN {$wpdb->prefix}term_taxonomy AS tt ON tt.term_id = t.term_id
2738
+ WHERE tt.taxonomy = 'nav_menu'";
2739
+
2740
+ $menus = $wpdb->get_results( $query );
2741
+
2742
+ foreach ( $menus as $key => $menu ) {
2743
+
2744
+ $result =
2745
+ $wpdb->get_results( $wpdb->prepare( "SELECT object_id FROM {$wpdb->prefix}term_relationships WHERE term_taxonomy_id = %d ORDER BY object_id ASC", $menu->term_id ), OBJECT_K );
2746
+
2747
+ $result = array_keys( $result );
2748
+
2749
+ $menus[ $key ]->menu_items = $result;
2750
+
2751
+ }
2752
+
2753
+ return $menus;
2754
+
2755
+ }
2756
+
2757
+ /**
2758
+ * Added wp_editor for enabled languages at post.php page
2759
+ * @see action edit_form_after_editor in wp-admin\edit-form-advanced.php:542
2760
+ *
2761
+ * @param WP_Post $post
2762
+ *
2763
+ * @return void
2764
+ */
2765
+ public function on_add_wp_editors( $post ) {
2766
+
2767
+ if ( $this->disabled_entity( $post->post_type ) ) {
2768
+ return;
2769
+ }
2770
+
2771
+ if ( ! post_type_supports( $post->post_type, 'editor' ) ) {
2772
+ return;
2773
+ }
2774
+
2775
+ foreach ( WPGlobus::Config()->open_languages as $language ) :
2776
+ if ( $language == WPGlobus::Config()->default_language ) {
2777
+
2778
+ continue;
2779
+
2780
+ } else {
2781
+
2782
+ $last_user = get_userdata( get_post_meta( $post->ID, '_edit_last', true ) );
2783
+ ?>
2784
+
2785
+ <div id="postdivrich-<?php echo esc_attr( $language ); ?>"
2786
+ class="postarea <?php echo esc_attr( apply_filters( 'wpglobus_postdivrich_class', 'postdivrich-wpglobus', $language ) ); ?>"
2787
+ style="<?php echo esc_attr( apply_filters( 'wpglobus_postdivrich_style', '', $language ) ); ?>"> <?php
2788
+ wp_editor( WPGlobus_Core::text_filter( $post->post_content, $language, WPGlobus::RETURN_EMPTY ), 'content_' . $language, array(
2789
+ '_content_editor_dfw' => true,
2790
+ #'dfw' => true,
2791
+ 'drag_drop_upload' => true,
2792
+ 'tabfocus_elements' => 'insert-media-button,save-post',
2793
+ 'editor_height' => 300,
2794
+ 'editor_class' => 'wpglobus-editor',
2795
+ 'tinymce' => array(
2796
+ 'resize' => true,
2797
+ 'wp_autoresize_on' => true,
2798
+ 'add_unload_trigger' => false,
2799
+ #'readonly' => true /* @todo for WPGlobus Authors */
2800
+ ),
2801
+ ) );
2802
+
2803
+ /**
2804
+ * Add post status info table
2805
+ * @since 1.0.13
2806
+ */
2807
+ ?>
2808
+ <table id="post-status-info-<?php echo esc_attr( $language ); ?>" class="wpglobus-post-status-info">
2809
+ <tbody>
2810
+ <tr>
2811
+ <td id="wp-word-count-<?php echo esc_attr( $language ); ?>"
2812
+ class="wpglobus-wp-word-count"><?php printf(
2813
+ /// Do not translate
2814
+ esc_html__( 'Word count: %s' ), '<span class="word-count-' . esc_attr( $language ) . '">0</span>' ); ?></td>
2815
+ <td class="autosave-info">
2816
+
2817
+ <span class="autosave-message">&nbsp;</span>
2818
+ <?php
2819
+ if ( 'auto-draft' != $post->post_status ) {
2820
+ echo '<span id="last-edit">';
2821
+ if ( $last_user ) {
2822
+ printf(
2823
+ /// Do not translate
2824
+ esc_html__( 'Last edited by %1$s on %2$s at %3$s' ),
2825
+ esc_html( $last_user->display_name ),
2826
+ esc_html( mysql2date( get_option( 'date_format' ), $post->post_modified ) ),
2827
+ esc_html( mysql2date( get_option( 'time_format' ), $post->post_modified ) )
2828
+ );
2829
+ } else {
2830
+ printf(
2831
+ /// Do not translate
2832
+ esc_html__( 'Last edited on %1$s at %2$s' ),
2833
+ esc_html( mysql2date( get_option( 'date_format' ), $post->post_modified ) ),
2834
+ esc_html( mysql2date( get_option( 'time_format' ), $post->post_modified ) )
2835
+ );
2836
+ }
2837
+ echo '</span>';
2838
+ } ?>
2839
+
2840
+ </td>
2841
+ <td id="content-resize-handle-<?php echo esc_attr( $language ); ?>"
2842
+ class="wpglobus-content-resize-handle hide-if-no-js"><br /></td>
2843
+ </tr>
2844
+ </tbody>
2845
+ </table>
2846
+
2847
+ </div> <?php // .postarea .postdivrich-wpglobus
2848
+
2849
+ }
2850
+ endforeach;
2851
+ }
2852
+
2853
+ /**
2854
+ * Surround text with language tags
2855
+ *
2856
+ * @param string $text
2857
+ * @param string $language
2858
+ *
2859
+ * @return string
2860
+ */
2861
+ public static function add_locale_marks( $text, $language ) {
2862
+ return sprintf( WPGlobus::LOCALE_TAG, $language, $text );
2863
+ }
2864
+
2865
+ /**
2866
+ * @param array $data
2867
+ * @param string[] $postarr
2868
+ *
2869
+ * @return array
2870
+ */
2871
+ public function on_save_post_data( $data, $postarr ) {
2872
+
2873
+ if ( 'revision' == $postarr['post_type'] ) {
2874
+ /**
2875
+ * Don't work with revisions
2876
+ * note: revision there are 2 types, its have some differences
2877
+ * - [post_name] => {post_id}-autosave-v1 and [post_name] => {post_id}-revision-v1
2878
+ * autosave : when [post_name] == {post_id}-autosave-v1 $postarr has [post_content] and [post_title] in default_language
2879
+ * regular revision : [post_name] == {post_id}-revision-v1 $postarr has [post_content] and [post_title] in all enabled languages with delimiters
2880
+ * @see https://codex.wordpress.org/Revision_Management
2881
+ * see $postarr for more info
2882
+ */
2883
+ return $data;
2884
+ }
2885
+
2886
+ if ( 'auto-draft' == $postarr['post_status'] ) {
2887
+ /**
2888
+ * Auto draft was automatically created with no data
2889
+ */
2890
+ return $data;
2891
+ }
2892
+
2893
+ if ( $this->disabled_entity( $data['post_type'] ) ) {
2894
+ return $data;
2895
+ }
2896
+
2897
+ /** @global string $pagenow */
2898
+ global $pagenow;
2899
+
2900
+ /**
2901
+ * Now we save post content and post title for all enabled languages for post.php, post-new.php
2902
+ * @todo Check also 'admin-ajax.php', 'nav-menus.php', etc.
2903
+ */
2904
+ $enabled_pages[] = 'post.php';
2905
+ $enabled_pages[] = 'post-new.php';
2906
+
2907
+ if ( ! in_array( $pagenow, $enabled_pages ) ) {
2908
+ /**
2909
+ * See other places with the same bookmark.
2910
+ * @bookmark EDITOR_LINE_BREAKS
2911
+ */
2912
+ // $data['post_content'] = trim( $data['post_content'], '</p><p>' );
2913
+
2914
+ return $data;
2915
+ }
2916
+
2917
+ if ( 'trash' === $postarr['post_status'] ) {
2918
+ /**
2919
+ * Don't work with move to trash
2920
+ */
2921
+ return $data;
2922
+ }
2923
+
2924
+ if ( isset( $_GET['action'] ) && 'untrash' === $_GET['action'] ) { // WPCS: input var ok, sanitization ok.
2925
+ /**
2926
+ * Don't work with untrash
2927
+ */
2928
+ return $data;
2929
+ }
2930
+
2931
+ $devmode = false;
2932
+ if ( 'off' == WPGlobus::Config()->toggle ) {
2933
+ $devmode = true;
2934
+ }
2935
+
2936
+ if ( ! $devmode ) :
2937
+
2938
+ $support_title = true;
2939
+ if ( ! post_type_supports( $data['post_type'], 'title' ) ) {
2940
+ $support_title = false;
2941
+ }
2942
+
2943
+ $support_editor = true;
2944
+ if ( ! post_type_supports( $data['post_type'], 'editor' ) ) {
2945
+ $support_editor = false;
2946
+ }
2947
+
2948
+ $data['post_title'] = $post_title = trim( $data['post_title'] );
2949
+ if ( ! empty( $data['post_title'] ) && $support_title ) {
2950
+ $data['post_title'] =
2951
+ WPGlobus::add_locale_marks( $data['post_title'], WPGlobus::Config()->default_language );
2952
+ }
2953
+
2954
+ $data['post_content'] = $post_content = trim( $data['post_content'] );
2955
+ if ( ! empty( $data['post_content'] ) && $support_editor ) {
2956
+ $data['post_content'] =
2957
+ WPGlobus::add_locale_marks( $data['post_content'], WPGlobus::Config()->default_language );
2958
+ }
2959
+
2960
+ /**
2961
+ * Add variables for check extra data
2962
+ * @since 1.2.2
2963
+ */
2964
+ $has_extra_post_title = false;
2965
+ $has_extra_post_content = false;
2966
+
2967
+ foreach ( WPGlobus::Config()->open_languages as $language ) :
2968
+ if ( $language == WPGlobus::Config()->default_language ) {
2969
+
2970
+ continue;
2971
+
2972
+ } else {
2973
+
2974
+ /**
2975
+ * Join post title for opened languages
2976
+ */
2977
+ $title =
2978
+ isset( $postarr[ 'post_title_' . $language ] ) ? trim( $postarr[ 'post_title_' . $language ] ) : '';
2979
+ if ( ! empty( $title ) ) {
2980
+ $data['post_title'] .= WPGlobus::add_locale_marks( $postarr[ 'post_title_' . $language ], $language );
2981
+ $has_extra_post_title = true;
2982
+ }
2983
+
2984
+ /**
2985
+ * Join post content for opened languages
2986
+ */
2987
+ $content =
2988
+ isset( $postarr[ 'content_' . $language ] ) ? trim( $postarr[ 'content_' . $language ] ) : '';
2989
+ if ( ! empty( $content ) ) {
2990
+ $data['post_content'] .= WPGlobus::add_locale_marks( $postarr[ 'content_' . $language ], $language );
2991
+ $has_extra_post_content = true;
2992
+ }
2993
+
2994
+ }
2995
+ endforeach;
2996
+
2997
+ endif; // $devmode
2998
+
2999
+ if ( ! $has_extra_post_title ) {
3000
+ $data['post_title'] = $post_title;
3001
+ }
3002
+
3003
+ if ( ! $has_extra_post_content ) {
3004
+ $data['post_content'] = $post_content;
3005
+ }
3006
+
3007
+ $data = apply_filters( 'wpglobus_save_post_data', $data, $postarr, $devmode );
3008
+
3009
+ return $data;
3010
+
3011
+ }
3012
+
3013
+ /**
3014
+ * Add wrapper for every table in enabled languages at edit-tags.php page
3015
+ * @return void
3016
+ */
3017
+ public function on_add_taxonomy_form_wrapper() {
3018
+ foreach ( WPGlobus::Config()->enabled_languages as $language ) {
3019
+ $classes = 'hidden'; ?>
3020
+ <div id="taxonomy-tab-<?php echo esc_attr( $language ); ?>" data-language="<?php echo esc_attr( $language ); ?>"
3021
+ class="<?php echo esc_attr( $classes ); ?>">
3022
+ </div>
3023
+ <?php
3024
+ }
3025
+
3026
+ }
3027
+
3028
+ /**
3029
+ * Add language tabs for edit taxonomy name at edit-tags.php page
3030
+ *
3031
+ * @param $object
3032
+ * @param $taxonomy
3033
+ */
3034
+ public function on_add_language_tabs_edit_taxonomy(
3035
+ $object, /** @noinspection PhpUnusedParameterInspection */
3036
+ $taxonomy
3037
+ ) {
3038
+
3039
+ if ( $this->disabled_entity() ) {
3040
+ return;
3041
+ } ?>
3042
+ <div class="wpglobus-taxonomy-tabs">
3043
+ <ul class="wpglobus-taxonomy-tabs-list"> <?php
3044
+ foreach ( self::Config()->open_languages as $language ) {
3045
+ $return =
3046
+ $language == WPGlobus::Config()->default_language ? WPGlobus::RETURN_IN_DEFAULT_LANGUAGE : WPGlobus::RETURN_EMPTY;
3047
+ ?>
3048
+ <li id="wpglobus-link-tab-<?php echo esc_attr( $language ); ?>" class=""
3049
+ data-language="<?php echo esc_attr( $language ); ?>"
3050
+ data-name="<?php echo esc_attr( WPGlobus_Core::text_filter( $object->name, $language, $return ) ); ?>"
3051
+ data-description="<?php echo esc_attr( WPGlobus_Core::text_filter( $object->description, $language, $return ) ); ?>">
3052
+ <a href="#taxonomy-tab-<?php echo esc_attr( $language ); ?>"><?php echo esc_html( self::Config()->en_language_name[ $language ] ); ?></a>
3053
+ </li> <?php
3054
+ } ?>
3055
+ </ul>
3056
+ </div><?php
3057
+ }
3058
+
3059
+ /**
3060
+ * Add language tabs for jQueryUI
3061
+ * @return void
3062
+ */
3063
+ public function on_add_language_tabs() {
3064
+
3065
+ /** @global WP_Post $post */
3066
+ global $post;
3067
+
3068
+ if ( $this->disabled_entity( $post->post_type ) ) {
3069
+ return;
3070
+ }
3071
+
3072
+ if (
3073
+ /**
3074
+ * Filter to show language tabs in post page.
3075
+ * @since 1.5.5
3076
+ *
3077
+ * @param bool
3078
+ * Returning boolean.
3079
+ */
3080
+ apply_filters( 'wpglobus_show_language_tabs', true )
3081
+ ) : ?>
3082
+
3083
+ <ul class="wpglobus-post-body-tabs-list"> <?php
3084
+ $order = 0;
3085
+ foreach ( self::Config()->open_languages as $language ) {
3086
+ $tab_suffix = $language == self::Config()->default_language ? 'default' : $language; ?>
3087
+ <li id="link-tab-<?php echo esc_attr( $tab_suffix ); ?>" data-language="<?php echo esc_attr( $language ); ?>"
3088
+ data-order="<?php echo esc_attr( $order ); ?>"
3089
+ class="wpglobus-post-tab">
3090
+ <a href="#tab-<?php echo esc_attr( $tab_suffix ); ?>"><?php echo esc_html( self::Config()->en_language_name[ $language ] ); ?></a>
3091
+ </li> <?php
3092
+ $order ++;
3093
+ } ?>
3094
+ </ul> <?php
3095
+
3096
+ endif;
3097
+
3098
+ }
3099
+
3100
+ /**
3101
+ * Add title fields for enabled languages at post.php, post-new.php page
3102
+ *
3103
+ * @param WP_Post $post
3104
+ *
3105
+ * @return void
3106
+ */
3107
+ public function on_add_title_fields( $post ) {
3108
+
3109
+ if ( $this->disabled_entity( $post->post_type ) ) {
3110
+ return;
3111
+ }
3112
+
3113
+ /**
3114
+ * Check for support 'title'
3115
+ */
3116
+ if ( ! post_type_supports( $post->post_type, 'title' ) ) {
3117
+ return;
3118
+ }
3119
+
3120
+ foreach ( self::Config()->open_languages as $language ) :
3121
+
3122
+ if ( $language == self::Config()->default_language ) {
3123
+
3124
+ continue;
3125
+
3126
+ } else { ?>
3127
+
3128
+ <div id="titlediv-<?php echo esc_attr( $language ); ?>" class="titlediv-wpglobus">
3129
+ <div id="titlewrap-<?php echo esc_attr( $language ); ?>" class="titlewrap-wpglobus">
3130
+ <label class="screen-reader-text" id="title-prompt-text-<?php echo esc_attr( $language ); ?>"
3131
+ for="title_<?php echo esc_attr( $language ); ?>"><?php echo esc_html( apply_filters( 'enter_title_here',
3132
+ /// Do not translate
3133
+ esc_html__( 'Enter title here' ), $post ) ); ?></label>
3134
+ <input type="text" name="post_title_<?php echo esc_attr( $language ); ?>" size="30"
3135
+ value="<?php echo esc_attr( WPGlobus_Core::text_filter( $post->post_title, $language, WPGlobus::RETURN_EMPTY ) ); ?>"
3136
+ id="title_<?php echo esc_attr( $language ); ?>"
3137
+ class="title_wpglobus"
3138
+ data-language="<?php echo esc_attr( $language ); ?>"
3139
+ autocomplete="off" />
3140
+ </div> <!-- #titlewrap -->
3141
+ <?php
3142
+ $slug_box = '<div class="inside">
3143
+ <div id="edit-slug-box-' . esc_attr( $language ) . '" class="wpglobus-edit-slug-box hide-if-no-js">
3144
+ <b></b>
3145
+ </div>
3146
+ </div><!-- .inside -->';
3147
+ // DO NOT ESCAPE THIS: it's HTML, already escaped above.
3148
+ echo apply_filters( 'wpglobus_edit_slug_box', $slug_box, $language ); // WPCS: XSS ok.
3149
+ ?>
3150
+ </div> <!-- #titlediv --> <?php
3151
+
3152
+ }
3153
+
3154
+ endforeach;
3155
+ }
3156
+
3157
+ /**
3158
+ * Check for disabled post_types, taxonomies
3159
+ *
3160
+ * @param string $entity
3161
+ *
3162
+ * @return boolean
3163
+ */
3164
+ public function disabled_entity( $entity = '' ) {
3165
+
3166
+ $entity_type = 'post';
3167
+
3168
+ if ( empty( $entity ) ) {
3169
+ /**
3170
+ * Try get entity from url. Ex. edit-tags.php?taxonomy=product_cat&post_type=product
3171
+ */
3172
+ if ( isset( $_GET['post_type'] ) && is_string( $_GET['post_type'] ) ) { // WPCS: input var ok, sanitization ok.
3173
+ $entity = sanitize_text_field( wp_unslash( $_GET['post_type'] ) ); // WPCS: input var ok.
3174
+ }
3175
+ if ( empty( $entity ) && isset( $_GET['taxonomy'] ) && is_string( $_GET['taxonomy'] ) ) { // WPCS: input var ok, sanitization ok.
3176
+ $entity = sanitize_text_field( wp_unslash( $_GET['taxonomy'] ) ); // WPCS: input var ok.
3177
+ $entity_type = 'taxonomy';
3178
+ }
3179
+ if ( empty( $entity ) && WPGlobus_WP::is_pagenow( 'edit.php' ) ) {
3180
+ $entity = 'post';
3181
+ }
3182
+ }
3183
+
3184
+ if ( 'post' === $entity_type ) {
3185
+ /**
3186
+ * Check for support 'title' and 'editor'
3187
+ */
3188
+ /** @global WP_Post $post */
3189
+ global $post;
3190
+
3191
+ $post_type = '';
3192
+
3193
+ if ( ! empty( $post ) && is_object( $post ) ) {
3194
+ $post_type = $post->post_type;
3195
+ }
3196
+
3197
+ /**
3198
+ * Filter to define post type.
3199
+ *
3200
+ * Some plugins may rewrite global $post, e.g. @see https://wordpress.org/plugins/geodirectory/
3201
+ * so user need to try define and return correct post type using filter to avoid PHP Notice: Trying to get property of non-object.
3202
+ *
3203
+ * @since 1.6.2
3204
+ *
3205
+ * @param string $post_type Post type.
3206
+ * @param array $post An object WP_Post.
3207
+ *
3208
+ * @return string.
3209
+ */
3210
+ $post_type = apply_filters( 'wpglobus_user_defined_post_type', $post_type, $post );
3211
+
3212
+ if ( ! empty( $post_type ) ) {
3213
+ if ( ! empty( $post ) && ! post_type_supports( $post_type, 'title' ) && ! post_type_supports( $post_type, 'editor' ) ) {
3214
+ return true;
3215
+ }
3216
+ }
3217
+ }
3218
+
3219
+ /**
3220
+ * Filter the array of disabled entities returned for load tabs, scripts, styles.
3221
+ * @since 1.7.6
3222
+ *
3223
+ * @see 'wpglobus_disabled_entities' filter in 'admin_init' action.
3224
+ *
3225
+ * @param array $disabled_entities Array of disabled entities.
3226
+ * @return boolean
3227
+ */
3228
+ $this->disabled_entities = apply_filters( 'wpglobus_disabled_entities', $this->disabled_entities );
3229
+
3230
+ if ( in_array( $entity, $this->disabled_entities ) ) {
3231
+ return true;
3232
+ }
3233
+
3234
+ return false;
3235
+
3236
+ }
3237
+
3238
+ /**
3239
+ * Get raw term names for $taxonomy
3240
+ * @todo This method should be somewhere else
3241
+ *
3242
+ * @param string $taxonomy
3243
+ *
3244
+ * @return array
3245
+ */
3246
+ public static function _get_terms( $taxonomy = '' ) {
3247
+
3248
+ if ( empty( $taxonomy ) ) {
3249
+ return array();
3250
+ }
3251
+
3252
+ if ( ! taxonomy_exists( $taxonomy ) ) {
3253
+ $error = new WP_Error( 'invalid_taxonomy',
3254
+ /// Do not translate
3255
+ __( 'Invalid taxonomy' ) );
3256
+
3257
+ return $error;
3258
+ }
3259
+
3260
+ remove_filter( 'get_terms', array( 'WPGlobus_Filters', 'filter__get_terms' ), 11 );
3261
+
3262
+ $terms = get_terms( $taxonomy, array( 'hide_empty' => false ) );
3263
+
3264
+ add_filter( 'get_terms', array( 'WPGlobus_Filters', 'filter__get_terms' ), 11 );
3265
+
3266
+ $term_names = array();
3267
+
3268
+ if ( ! empty( $terms ) ) {
3269
+ foreach ( $terms as $term ) {
3270
+ $term_names[ WPGlobus_Core::text_filter( $term->name, self::Config()->default_language ) ] =
3271
+ $term->name;
3272
+ /**
3273
+ * In admin self::Config()->language is the same as result get_locale()
3274
+ */
3275
+ $term_names[ WPGlobus_Core::text_filter( $term->name, self::Config()->language ) ] = $term->name;
3276
+ }
3277
+ }
3278
+
3279
+ return $term_names;
3280
+
3281
+ }
3282
+
3283
+ /**
3284
+ * Make correct title for admin pages
3285
+ *
3286
+ * @param string $admin_title Ignored
3287
+ * @param string $title
3288
+ *
3289
+ * @return string
3290
+ */
3291
+ public function on_admin_title(
3292
+ /** @noinspection PhpUnusedParameterInspection */
3293
+ $admin_title,
3294
+ $title
3295
+ ) {
3296
+ $blogname = get_option( 'blogname' );
3297
+
3298
+ return $title . ' &lsaquo; ' . WPGlobus_Core::text_filter( $blogname, WPGlobus::Config()->language, WPGlobus::RETURN_IN_DEFAULT_LANGUAGE ) . ' &#8212; WordPress';
3299
+ }
3300
+
3301
+ /**
3302
+ * Make correct Site Title in admin bar.
3303
+ * Make template for Site Title (option blogname)
3304
+ * a Tagline (option blogdescription) at options-general.php page.
3305
+ * @return void
3306
+ */
3307
+ public function on_admin_footer() {
3308
+
3309
+ $blogname = get_option( 'blogname' );
3310
+ $bn =
3311
+ WPGlobus_Core::text_filter( $blogname, WPGlobus::Config()->language, WPGlobus::RETURN_IN_DEFAULT_LANGUAGE );
3312
+
3313
+ ?>
3314
+ <script type='text/javascript'>
3315
+ /* <![CDATA[ */
3316
+ jQuery('#wp-admin-bar-site-name a').eq(0).text("<?php echo esc_js( $bn ); ?>");
3317
+ /* ]]> */
3318
+ </script>
3319
+ <?php
3320
+
3321
+
3322
+ /**
3323
+ * For dialog form
3324
+ * @since 1.2.0
3325
+ */
3326
+ /** @global string $pagenow */
3327
+ global $pagenow;
3328
+
3329
+ $page = '';
3330
+ if ( isset( $_GET['page'] ) && is_string( $_GET['page'] ) ) { // WPCS: input var ok, sanitization ok.
3331
+ $page = sanitize_text_field( wp_unslash( $_GET['page'] ) ); // WPCS: input var ok.
3332
+ }
3333
+
3334
+ // @todo remove after testing
3335
+ //if ( WPGlobus_WP::is_pagenow( array( 'post.php', 'widgets.php' ) ) ) {
3336
+
3337
+ if ( in_array( $pagenow, $this->enabled_pages ) || in_array( $page, $this->enabled_pages ) ) {
3338
+ /**
3339
+ * Output dialog form for window.WPGlobusDialogApp
3340
+ */
3341
+ ?>
3342
+ <div id="wpglobus-dialog-wrapper" class="hidden wpglobus-dialog-wrapper">
3343
+ <form id="wpglobus-dialog-form">
3344
+ <div id="wpglobus-dialog-tabs" class="wpglobus-dialog-tabs">
3345
+ <ul class="wpglobus-dialog-tabs-list"> <?php
3346
+ $order = 0;
3347
+ foreach ( WPGlobus::Config()->open_languages as $language ) { ?>
3348
+ <li id="dialog-link-tab-<?php echo esc_attr( $language ); ?>"
3349
+ data-language="<?php echo esc_attr( $language ); ?>"
3350
+ data-order="<?php echo esc_attr( $order ); ?>"
3351
+ class="wpglobus-dialog-tab"><a
3352
+ href="#dialog-tab-<?php echo esc_attr( $language ); ?>"><?php echo esc_html( WPGlobus::Config()->en_language_name[ $language ] ); ?></a>
3353
+ </li> <?php
3354
+ $order ++;
3355
+ } ?>
3356
+ </ul> <?php
3357
+
3358
+ foreach ( WPGlobus::Config()->open_languages as $language ) { ?>
3359
+ <div id="dialog-tab-<?php echo esc_attr( $language ); ?>" class="wpglobus-dialog-general">
3360
+ <textarea name="wpglobus-dialog-<?php echo esc_attr( $language ); ?>"
3361
+ id="wpglobus-dialog-<?php echo esc_attr( $language ); ?>"
3362
+ class="wpglobus_dialog_textarea textarea"
3363
+ data-language="<?php echo esc_attr( $language ); ?>"
3364
+ data-order="save_dialog"
3365
+ placeholder=""></textarea>
3366
+ </div> <?php
3367
+ } ?>
3368
+ </div>
3369
+ <div id="wpglobus-dialog-form-footer" style="width:100%;"></div>
3370
+ </form>
3371
+ </div> <?php
3372
+ }
3373
+
3374
+ if ( ! WPGlobus_WP::is_pagenow( 'options-general.php' ) ) {
3375
+ return;
3376
+ }
3377
+
3378
+ $blogdesc = get_option( 'blogdescription' );
3379
+ ?>
3380
+ <div id="wpglobus-blogname" class="hidden"> <?php
3381
+ foreach ( self::Config()->enabled_languages as $language ) :
3382
+ $return =
3383
+ $language == self::Config()->default_language ? WPGlobus::RETURN_IN_DEFAULT_LANGUAGE : WPGlobus::RETURN_EMPTY; ?>
3384
+
3385
+ <input type="text" class="regular-text wpglobus-blogname wpglobus-translatable"
3386
+ value="<?php echo esc_attr( WPGlobus_Core::text_filter( $blogname, $language, $return ) ); ?>"
3387
+ id="blogname-<?php echo esc_attr( $language ); ?>" name="blogname-<?php echo esc_attr( $language ); ?>"
3388
+ data-language="<?php echo esc_attr( $language ); ?>"
3389
+ placeholder="<?php echo esc_attr( self::Config()->en_language_name[ $language ] ); ?>"><br />
3390
+
3391
+ <?php
3392
+ endforeach; ?>
3393
+ </div>
3394
+
3395
+ <div id="wpglobus-blogdescription" class="hidden"> <?php
3396
+ foreach ( self::Config()->enabled_languages as $language ) :
3397
+ $return =
3398
+ $language == self::Config()->default_language ? WPGlobus::RETURN_IN_DEFAULT_LANGUAGE : WPGlobus::RETURN_EMPTY; ?>
3399
+
3400
+ <input type="text" class="regular-text wpglobus-blogdesc wpglobus-translatable"
3401
+ value="<?php echo esc_attr( WPGlobus_Core::text_filter( $blogdesc, $language, $return ) ); ?>"
3402
+ id="blogdescription-<?php echo esc_attr( $language ); ?>" name="blogdescription-<?php echo esc_attr( $language ); ?>"
3403
+ data-language="<?php echo esc_attr( $language ); ?>"
3404
+ placeholder="<?php echo esc_attr( self::Config()->en_language_name[ $language ] ); ?>"><br />
3405
+
3406
+ <?php
3407
+ endforeach; ?>
3408
+ </div>
3409
+ <?php
3410
+ }
3411
+
3412
+ /**
3413
+ * Shortcut to avoid globals
3414
+ * @return WPGlobus_Config
3415
+ */
3416
+ public static function Config() {
3417
+
3418
+ static $config = null;
3419
+
3420
+ if ( is_null( $config ) ) {
3421
+ $config = new WPGlobus_Config();
3422
+ }
3423
+
3424
+ return $config;
3425
+
3426
+ }
3427
+
3428
+ /**
3429
+ * Shortcut to avoid globals
3430
+ * @since 1.1.1
3431
+ * @return WPGlobus
3432
+ */
3433
+ public static function O() {
3434
+ /** @global WPGlobus $WPGlobus */
3435
+ global $WPGlobus;
3436
+
3437
+ return $WPGlobus;
3438
+ }
3439
+
3440
+ /**
3441
+ * Show notice to admin about permalinks settings
3442
+ * @since 1.0.13
3443
+ */
3444
+ public function admin_notice_permalink_structure() {
3445
+ ?>
3446
+ <div class="notice notice-error error">
3447
+ <p>
3448
+ <?php esc_html_e( 'You must enable Pretty Permalinks to use WPGlobus.', 'wpglobus' ); ?>
3449
+ <strong>
3450
+ <?php esc_html_e( 'Please go to Settings > Permalinks > Common Settings and choose a non-default option.', 'wpglobus' ); ?>
3451
+ </strong>
3452
+ </p>
3453
+ </div><?php
3454
+ }
3455
+
3456
+ /**
3457
+ * Various actions on admin_init hook
3458
+ */
3459
+ public function on_admin_init() {
3460
+
3461
+ if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
3462
+ // do nothing
3463
+ } else {
3464
+
3465
+ /**
3466
+ * For developers use only. Deletes settings with no warning! Irreversible!
3467
+ * @link wp-admin/admin.php?wpglobus-reset-all-options=1
3468
+ */
3469
+ if ( ! empty( $_GET['wpglobus-reset-all-options'] ) ) { // WPCS: input var ok, sanitization ok.
3470
+ /** @global wpdb $wpdb */
3471
+ global $wpdb;
3472
+ $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE 'wpglobus_option%';" );
3473
+ wp_safe_redirect( admin_url() );
3474
+ exit();
3475
+ }
3476
+
3477
+ /**
3478
+ * Check for transient wpglobus_activated
3479
+ */
3480
+ if ( false !== get_transient( 'wpglobus_activated' ) ) {
3481
+ delete_transient( 'wpglobus_activated' );
3482
+ wp_redirect( admin_url( add_query_arg( array( 'page' => WPGlobus::PAGE_WPGLOBUS_ABOUT ), 'admin.php' ) ) );
3483
+ exit;
3484
+ }
3485
+
3486
+ if ( ! get_option( 'permalink_structure' ) ) {
3487
+ add_action( 'admin_notices', array( $this, 'admin_notice_permalink_structure' ) );
3488
+ }
3489
+
3490
+ }
3491
+
3492
+ /**
3493
+ * Filter the array of disabled entities returned for load tabs, scripts, styles.
3494
+ * @since 1.0.0
3495
+ *
3496
+ * @todo may be remove this filter @see 'wpglobus_disabled_entities' in disabled_entity().
3497
+ *
3498
+ * @param array $disabled_entities Array of disabled entities.
3499
+ */
3500
+ $this->disabled_entities = apply_filters( 'wpglobus_disabled_entities', $this->disabled_entities );
3501
+
3502
+ /**
3503
+ * Filter the array of opened languages.
3504
+ * @since 1.0.0
3505
+ *
3506
+ * @param array $open_languages Array of opened languages.
3507
+ */
3508
+ WPGlobus::Config()->open_languages = apply_filters( 'wpglobus_open_languages', WPGlobus::Config()->open_languages );
3509
+
3510
+ /**
3511
+ * Filter the array of WPGlobus-enabled pages.
3512
+ * Used to load scripts and styles for WPGlobusCore, WPGlobusDialogApp (JS).
3513
+ * @since 1.2.0
3514
+ *
3515
+ * @param array $enabled_pages Array of enabled pages.
3516
+ */
3517
+ $this->enabled_pages = apply_filters( 'wpglobus_enabled_pages', $this->enabled_pages );
3518
+
3519
+ }
3520
+
3521
+ /**
3522
+ * Add class to body in admin
3523
+ * @since 1.0.10
3524
+ * @see admin_body_class filter
3525
+ *
3526
+ * @param string $classes
3527
+ *
3528
+ * @return string
3529
+ */
3530
+ public function on_add_admin_body_class( $classes ) {
3531
+ return $classes . ' wpglobus-wp-admin';
3532
+ }
3533
+
3534
+ /**
3535
+ * Add language selector to admin bar
3536
+ * @since 1.0.8
3537
+ *
3538
+ * @param WP_Admin_Bar $wp_admin_bar
3539
+ */
3540
+ public function on_admin_bar_menu( WP_Admin_Bar $wp_admin_bar ) {
3541
+
3542
+ $available_languages = get_available_languages();
3543
+
3544
+ $user_id = get_current_user_id();
3545
+
3546
+ if ( ! $user_id ) {
3547
+ return;
3548
+ }
3549
+
3550
+ $wp_admin_bar->add_menu( array(
3551
+ 'id' => 'wpglobus-language-select',
3552
+ 'parent' => 'top-secondary',
3553
+ 'title' => '<span class="ab-icon">' .
3554
+ '<img src="' . WPGlobus::Config()->flags_url .
3555
+ WPGlobus::Config()->flag[ WPGlobus::Config()->language ] . '"/>' .
3556
+ '</span><span class="ab-label">' .
3557
+ WPGlobus::Config()->language_name[ WPGlobus::Config()->language ] .
3558
+ '</span>',
3559
+ ) );
3560
+
3561
+ $add_more_languages = array();
3562
+ foreach ( WPGlobus::Config()->enabled_languages as $language ) :
3563
+
3564
+ if ( WPGlobus::Config()->language === $language ) {
3565
+ continue;
3566
+ }
3567
+
3568
+ $locale = WPGlobus::Config()->locale[ $language ];
3569
+
3570
+ if ( $locale != 'en_US' ) {
3571
+ if ( ! in_array( $locale, $available_languages ) ) {
3572
+ $add_more_languages[] = WPGlobus::Config()->language_name[ $language ];
3573
+ continue;
3574
+ }
3575
+ }
3576
+
3577
+ $wp_admin_bar->add_menu( array(
3578
+ 'parent' => 'wpglobus-language-select',
3579
+ 'id' => 'wpglobus-' . $language,
3580
+ 'title' => '<span><img src="' . WPGlobus::Config()->flags_url . WPGlobus::Config()->flag[ $language ] . '" /></span>&nbsp;&nbsp;' . WPGlobus::Config()->language_name[ $language ],
3581
+ 'href' => admin_url( 'options-general.php' ),
3582
+ 'meta' => array(
3583
+ 'tabindex' => - 1,
3584
+ 'onclick' => 'wpglobus_select_lang("' . $locale . '");return false;'
3585
+ ),
3586
+ ) );
3587
+
3588
+ endforeach;
3589
+
3590
+ if ( ! empty( $add_more_languages ) ) {
3591
+ $title = __( 'Add', 'wpglobus' ) . ' (' . implode( ', ', $add_more_languages ) . ')';
3592
+ $wp_admin_bar->add_menu( array(
3593
+ 'parent' => 'wpglobus-language-select',
3594
+ 'id' => 'wpglobus-add-languages',
3595
+ 'title' => $title,
3596
+ 'href' => admin_url( 'options-general.php' ),
3597
+ 'meta' => array(
3598
+ 'tabindex' => - 1,
3599
+ ),
3600
+ ) );
3601
+ }
3602
+ ?>
3603
+ <!--suppress AnonymousFunctionJS -->
3604
+ <script type="text/javascript">
3605
+ //<![CDATA[
3606
+ jQuery(document).ready(function ($) {
3607
+ $('#wpglobus-default-locale').on('click', function (e) {
3608
+ wpglobus_select_lang('<?php echo esc_js( WPGlobus::Config()->locale[ WPGlobus::Config()->language ] ); ?>');
3609
+ });
3610
+ wpglobus_select_lang = function (locale) {
3611
+ $.post(ajaxurl, {
3612
+ action: 'WPGlobus_process_ajax',
3613
+ order : {action: 'wpglobus_select_lang', locale: locale}
3614
+ }, function (d) {
3615
+ })
3616
+ .done(function () {
3617
+ window.location.reload();
3618
+ });
3619
+ }
3620
+ });
3621
+ //]]>
3622
+ </script>
3623
+ <?php
3624
+ }
3625
+
3626
+ /**
3627
+ * Add custom JS to footer section.
3628
+ *
3629
+ * @since 1.7.6
3630
+ * @return void
3631
+ */
3632
+ public function on__wp_footer() {
3633
+
3634
+ $js = trim( WPGlobus::Config()->js_editor );
3635
+
3636
+ if ( ! empty( $js ) ) {
3637
+ ?>
3638
+ <script type="text/javascript">
3639
+ <?php echo wp_kses( $js, array() ); ?>
3640
+ </script>
3641
+ <?php
3642
+ }
3643
+
3644
+ }
3645
+
3646
+ }
3647
+
3648
+ # --- EOF
includes/compat/mbstring.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * File: mbstring.php
4
+ * Implementation or stubs for PHP functions either missing from older PHP versions or not included by default.
5
+ *
6
+ * @package WPGlobus\Compat
7
+ */
8
+
9
+ if ( ! function_exists( 'mb_strtolower' ) ) :
10
+ /**
11
+ * @param string $str String to convert.
12
+ * @param string $encoding Encoding parameter is not used.
13
+ *
14
+ * @return string
15
+ */
16
+ function mb_strtolower(
17
+ $str,
18
+ // @formatter:off
19
+ /** @noinspection PhpUnusedParameterInspection */ $encoding = null
20
+ // @formatter:on
21
+ ) {
22
+ return strtolower( $str );
23
+ }
24
+ endif;
25
+
26
+ if ( ! function_exists( 'mb_stripos' ) ) :
27
+ /**
28
+ * Finds position of first occurrence of a string within another, case insensitive
29
+ * @link http://php.net/manual/en/function.mb-stripos.php
30
+ *
31
+ * @param string $haystack The string from which to get the position of the first occurrence of needle
32
+ * @param string $needle The string to find in haystack
33
+ * @param int $offset [optional] The position in haystack to start searching
34
+ * @param string $encoding [optional] Character encoding name to use. If it is omitted, internal character encoding is used.
35
+ *
36
+ * @return int Return the numeric position of the first occurrence of needle in the haystack string, or false if needle is not found.
37
+ */
38
+ function mb_stripos(
39
+ $haystack, $needle,
40
+ // @formatter:off
41
+ /** @noinspection PhpUnusedParameterInspection */ $offset = null,
42
+ /** @noinspection PhpUnusedParameterInspection */ $encoding = null
43
+ // @formatter:on
44
+ ) {
45
+ return stripos( $haystack, $needle );
46
+ }
47
+ endif;
48
+
49
+ /* EOF */
includes/css/images/btn_donateCC_LG_global.gif ADDED
Binary file
includes/css/images/checkbox-icon.png ADDED
Binary file
includes/css/images/edit.svg ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generated by IcoMoon.io -->
3
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="20" height="20" viewBox="0 0 20 20">
5
+ <g>
6
+ </g>
7
+ <path d="M13.89 3.39l2.71 2.72q0.34 0.35 0.335 0.84t-0.305 0.8l-8.010 8.020-5.56 1.16 1.16-5.58q7.6-7.63 7.99-8.030 0.29-0.3 0.815-0.285t0.865 0.355zM11.16 6.18l-5.59 5.61 1.11 1.11 5.54-5.65zM8.19 14.41l5.58-5.6-1.070-1.080-5.59 5.6z" fill="#000000"></path>
8
+ </svg>
includes/css/images/editicon.png ADDED
Binary file
includes/css/images/error.png ADDED
Binary file
includes/css/images/spinner.gif ADDED
Binary file
includes/css/images/success.png ADDED
Binary file
includes/css/images/ui-bg_flat40x100.png ADDED
Binary file
includes/css/images/woocommerce-wpglobus-logo-300x300.png ADDED
Binary file
includes/css/images/woocommerce-wpglobus-netaxeptcw-logo-300x300.jpg ADDED
Binary file
includes/css/images/wpglobus-for-bridge-theme-logo-400x400.png ADDED
Binary file
includes/css/images/wpglobus-hi-logo-400x400.png ADDED
Binary file
includes/css/images/wpglobus-logo-180x180.png ADDED
Binary file
includes/css/images/wpglobus-lw-logo-400x400.png ADDED
Binary file
includes/css/images/wpglobus-menu-visibility-logo.png ADDED
Binary file
includes/css/images/wpglobus-mobile-menu-logo-400x400.png ADDED
Binary file
includes/css/images/wpglobus-multi-currency-logo.jpg ADDED
Binary file
includes/css/images/wpglobus-plus-logo-150x150.png ADDED
Binary file
includes/css/images/wpglobus-plus-logo-300x300.png ADDED
Binary file
includes/css/images/wpglobus-revslider-logo-400x400.png ADDED
Binary file
includes/css/wpglobus-admin-debug.css ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #wpglobus-admin-debug-box {
2
+ clear: both;
3
+ background-color: #f1f1f1;
4
+ margin: 25px 0 0;
5
+ border-top: 1px solid #ccc;
6
+ padding: 0 0 35px;
7
+ min-width: 1000px;
8
+ padding-left: 190px;
9
+ position: absolute;
10
+ bottom: -100px;
11
+ }
12
+ #wpglobus-admin-debug-box pre {
13
+ white-space: pre-wrap;
14
+ word-wrap: break-word;
15
+ }
16
+ #wpglobus-admin-debug-box table {
17
+ position: absolute;
18
+ color: #333 !important;
19
+ border-collapse: collapse !important;
20
+ box-shadow: none !important;
21
+ width: 90% !important;
22
+ table-layout: auto !important;
23
+ margin: 0 0 30px;
24
+ }
25
+ #wpglobus-admin-debug-box td,
26
+ #wpglobus-admin-debug-box th,
27
+ #wpglobus-admin-debug-box caption {
28
+ background: #fff !important;
29
+ color: #333 !important;
30
+ box-sizing: border-box !important;
31
+ text-align: left !important;
32
+ font-style: normal !important;
33
+ font-weight: normal !important;
34
+ font-size: 11px !important;
35
+ line-height: 16px !important;
36
+ font-family: Menlo, Monaco, Consolas, monospace !important;
37
+ border: 1px solid #e8e8e8 !important;
38
+ padding: 4px 6px 3px !important;
39
+ vertical-align: top !important;
40
+ text-shadow: none !important;
41
+ text-transform: none !important;
42
+ -webkit-font-smoothing: auto !important;
43
+ letter-spacing: normal !important;
44
+ }
45
+ #wpglobus-admin-debug-box th {
46
+ font-weight: bold;
47
+ }
48
+ #wpglobus-admin-debug-box caption {
49
+ caption-side: top !important;
50
+ border-bottom-width: 0 !important;
51
+ }
52
+ #wpglobus-admin-debug-box tbody tr:hover td {
53
+ background: #f1f1f1 !important;
54
+ }
55
+ #wpglobus-admin-debug-box th[scope=col] {
56
+ border-bottom-width: 0 !important;
57
+ }
includes/css/wpglobus-admin-debug.less ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #wpglobus-admin-debug-box {
2
+ clear:both;
3
+ background-color:#f1f1f1;
4
+ margin:25px 0 0;
5
+ border-top:1px solid #ccc;
6
+ padding:0 0 35px;
7
+ min-width:1000px;
8
+ padding-left:190px;
9
+ position:absolute;
10
+ bottom:-100px;
11
+
12
+ pre {
13
+ white-space: pre-wrap;
14
+ word-wrap: break-word;
15
+ }
16
+
17
+ table {
18
+ position:absolute;
19
+ color: #333 !important;
20
+ border-collapse: collapse !important;
21
+ box-shadow: none !important;
22
+ width: 90% !important;
23
+ table-layout: auto !important;
24
+ margin: 0 0 30px;
25
+ }
26
+
27
+ td, th, caption {
28
+ background: #fff !important;
29
+ color: #333 !important;
30
+ box-sizing: border-box !important;
31
+ text-align: left !important;
32
+ font-style: normal !important;
33
+ font-weight: normal !important;
34
+ font-size: 11px !important;
35
+ line-height: 16px !important;
36
+ font-family: Menlo, Monaco, Consolas, monospace !important;
37
+ border: 1px solid #e8e8e8 !important;
38
+ padding: 4px 6px 3px !important;
39
+ vertical-align: top !important;
40
+ text-shadow: none !important;
41
+ text-transform: none !important;
42
+ -webkit-font-smoothing: auto !important;
43
+ letter-spacing: normal !important;
44
+ }
45
+
46
+ th {
47
+ font-weight:bold;
48
+ }
49
+
50
+ caption {
51
+ caption-side: top !important;
52
+ border-bottom-width: 0 !important;
53
+ }
54
+
55
+ tbody tr:hover td {
56
+ background: #f1f1f1 !important;
57
+ }
58
+
59
+ th[scope=col] {
60
+ border-bottom-width: 0 !important;
61
+ }
62
+
63
+ }
includes/css/wpglobus-admin-debug.min.css ADDED
@@ -0,0 +1 @@
 
1
+ #wpglobus-admin-debug-box{clear:both;background-color:#f1f1f1;margin:25px 0 0;border-top:1px solid #ccc;padding:0 0 35px;min-width:1000px;padding-left:190px;position:absolute;bottom:-100px}#wpglobus-admin-debug-box pre{white-space:pre-wrap;word-wrap:break-word}#wpglobus-admin-debug-box table{position:absolute;color:#333!important;border-collapse:collapse!important;box-shadow:none!important;width:90%!important;table-layout:auto!important;margin:0 0 30px}#wpglobus-admin-debug-box caption,#wpglobus-admin-debug-box td,#wpglobus-admin-debug-box th{background:#fff!important;color:#333!important;box-sizing:border-box!important;text-align:left!important;font-style:normal!important;font-weight:400!important;font-size:11px!important;line-height:16px!important;font-family:Menlo,Monaco,Consolas,monospace!important;border:1px solid #e8e8e8!important;padding:4px 6px 3px!important;vertical-align:top!important;text-shadow:none!important;text-transform:none!important;-webkit-font-smoothing:auto!important;letter-spacing:normal!important}#wpglobus-admin-debug-box th{font-weight:700}#wpglobus-admin-debug-box caption{caption-side:top!important;border-bottom-width:0!important}#wpglobus-admin-debug-box tbody tr:hover td{background:#f1f1f1!important}#wpglobus-admin-debug-box th[scope=col]{border-bottom-width:0!important}
includes/css/wpglobus-admin-tabs.css ADDED
@@ -0,0 +1,262 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Admin tabs styles
3
+ * @package WPGlobus
4
+ */
5
+ .wpglobus-wp-admin {
6
+ /* WPSEO metabox */
7
+ }
8
+ .wpglobus-wp-admin #post-body .wpglobus-post-body-tabs .ui-widget-content input.like-default-title {
9
+ padding: 3px 8px;
10
+ font-size: 1.7em;
11
+ line-height: 100%;
12
+ width: 100%;
13
+ outline: none;
14
+ }
15
+ .wpglobus-wp-admin .wpglobus-post-body-tabs .titlediv {
16
+ margin-bottom: 20px;
17
+ }
18
+ .wpglobus-wp-admin .wpglobus-post-body-tabs .mceIframeContainer iframe {
19
+ min-height: 150px !important;
20
+ }
21
+ .wpglobus-wp-admin .wpglobus-post-body-tabs .wp-editor-container {
22
+ border: 1px solid #ccc;
23
+ }
24
+ .wpglobus-wp-admin .wpglobus-post-body-tabs .titlediv-wpglobus {
25
+ position: relative;
26
+ }
27
+ .wpglobus-wp-admin .wpglobus-post-body-tabs .tabs-nav ul,
28
+ .wpglobus-wp-admin #wpglobus-aioseop-tabs .tabs-nav ul,
29
+ .wpglobus-wp-admin #wpglobus-wpseo-tabs .tabs-nav ul,
30
+ .wpglobus-wp-admin .wpglobus-wpseo-tabs .tabs-nav ul,
31
+ .wpglobus-wp-admin .wpglobus-taxonomy-tabs .tabs-nav ul {
32
+ list-style-type: none;
33
+ margin: 0 10px;
34
+ padding: 0;
35
+ }
36
+ .wpglobus-wp-admin .wpglobus-post-body-tabs li a,
37
+ .wpglobus-wp-admin #wpglobus-aioseop-tabs li a,
38
+ .wpglobus-wp-admin #wpglobus-wpseo-tabs li a,
39
+ .wpglobus-wp-admin .wpglobus-wpseo-tabs li a,
40
+ .wpglobus-wp-admin .wpglobus-taxonomy-tabs li a,
41
+ .wpglobus-wp-admin .wpglobus-post-body-tabs ul li,
42
+ .wpglobus-wp-admin #wpglobus-aioseop-tabs ul li,
43
+ .wpglobus-wp-admin #wpglobus-wpseo-tabs ul li,
44
+ .wpglobus-wp-admin .wpglobus-wpseo-tabs ul li,
45
+ .wpglobus-wp-admin .wpglobus-taxonomy-tabs ul li {
46
+ float: left;
47
+ margin: 0;
48
+ }
49
+ .wpglobus-wp-admin .wpglobus-post-body-tabs li.ui-state-default,
50
+ .wpglobus-wp-admin #wpglobus-aioseop-tabs li.ui-state-default,
51
+ .wpglobus-wp-admin #wpglobus-wpseo-tabs li.ui-state-default,
52
+ .wpglobus-wp-admin .wpglobus-wpseo-tabs li.ui-state-default,
53
+ .wpglobus-wp-admin .wpglobus-taxonomy-tabs li.ui-state-default {
54
+ border: 0;
55
+ background: transparent;
56
+ }
57
+ .wpglobus-wp-admin .wpglobus-post-body-tabs ul li.ui-state-default a,
58
+ .wpglobus-wp-admin #wpglobus-aioseop-tabs ul li.ui-state-default a,
59
+ .wpglobus-wp-admin #wpglobus-wpseo-tabs ul li.ui-state-default a,
60
+ .wpglobus-wp-admin .wpglobus-wpseo-tabs ul li.ui-state-default a,
61
+ .wpglobus-wp-admin .wpglobus-taxonomy-tabs ul li.ui-state-default a {
62
+ display: block;
63
+ color: #777;
64
+ background: #ebebeb;
65
+ border: 1px solid #e5e5e5;
66
+ border-bottom: 0;
67
+ font-weight: normal;
68
+ height: 2em;
69
+ line-height: 2em;
70
+ margin-right: 5px;
71
+ padding: 0 10px;
72
+ text-decoration: none;
73
+ }
74
+ .wpglobus-wp-admin .wpglobus-post-body-tabs ul li.ui-state-active a,
75
+ .wpglobus-wp-admin #wpglobus-aioseop-tabs ul li.ui-state-active a,
76
+ .wpglobus-wp-admin #wpglobus-wpseo-tabs ul li.ui-state-active a,
77
+ .wpglobus-wp-admin .wpglobus-wpseo-tabs ul li.ui-state-active a,
78
+ .wpglobus-wp-admin .wpglobus-taxonomy-tabs ul li.ui-state-active a {
79
+ background: #fff;
80
+ border: 1px solid #e5e5e5;
81
+ border-bottom-color: #fff;
82
+ color: #000;
83
+ margin-bottom: -1px;
84
+ font-weight: 700;
85
+ }
86
+ .wpglobus-wp-admin .wpglobus-post-body-tabs ul li a:hover,
87
+ .wpglobus-wp-admin #wpglobus-aioseop-tabs ul li a:hover,
88
+ .wpglobus-wp-admin #wpglobus-wpseo-tabs ul li a:hover,
89
+ .wpglobus-wp-admin .wpglobus-wpseo-tabs ul li a:hover,
90
+ .wpglobus-wp-admin .wpglobus-taxonomy-tabs ul li a:hover {
91
+ color: #000;
92
+ }
93
+ .wpglobus-wp-admin .wpglobus-post-body-tabs ul li a:focus,
94
+ .wpglobus-wp-admin #wpglobus-aioseop-tabs ul li a:focus,
95
+ .wpglobus-wp-admin #wpglobus-wpseo-tabs ul li a:focus,
96
+ .wpglobus-wp-admin .wpglobus-wpseo-tabs ul li a:focus,
97
+ .wpglobus-wp-admin .wpglobus-taxonomy-tabs ul li a:focus {
98
+ box-shadow: none;
99
+ }
100
+ .wpglobus-wp-admin .wpglobus-post-body-tabs .wpglobus-post-body-tabs-list,
101
+ .wpglobus-wp-admin #wpglobus-aioseop-tabs .wpglobus-post-body-tabs-list,
102
+ .wpglobus-wp-admin #wpglobus-wpseo-tabs .wpglobus-post-body-tabs-list,
103
+ .wpglobus-wp-admin .wpglobus-wpseo-tabs .wpglobus-post-body-tabs-list,
104
+ .wpglobus-wp-admin .wpglobus-taxonomy-tabs .wpglobus-post-body-tabs-list,
105
+ .wpglobus-wp-admin .wpglobus-post-body-tabs .wpglobus-wpseo-tabs-list,
106
+ .wpglobus-wp-admin #wpglobus-aioseop-tabs .wpglobus-wpseo-tabs-list,
107
+ .wpglobus-wp-admin #wpglobus-wpseo-tabs .wpglobus-wpseo-tabs-list,
108
+ .wpglobus-wp-admin .wpglobus-wpseo-tabs .wpglobus-wpseo-tabs-list,
109
+ .wpglobus-wp-admin .wpglobus-taxonomy-tabs .wpglobus-wpseo-tabs-list,
110
+ .wpglobus-wp-admin .wpglobus-post-body-tabs .wpglobus-aioseop-tabs-list,
111
+ .wpglobus-wp-admin #wpglobus-aioseop-tabs .wpglobus-aioseop-tabs-list,
112
+ .wpglobus-wp-admin #wpglobus-wpseo-tabs .wpglobus-aioseop-tabs-list,
113
+ .wpglobus-wp-admin .wpglobus-wpseo-tabs .wpglobus-aioseop-tabs-list,
114
+ .wpglobus-wp-admin .wpglobus-taxonomy-tabs .wpglobus-aioseop-tabs-list {
115
+ border: none;
116
+ border-bottom: 1px solid #dddddd;
117
+ background: transparent;
118
+ min-height: 3em;
119
+ }
120
+ .wpglobus-wp-admin .wpglobus-post-body-tabs .ui-corner-all,
121
+ .wpglobus-wp-admin #wpglobus-aioseop-tabs .ui-corner-all,
122
+ .wpglobus-wp-admin #wpglobus-wpseo-tabs .ui-corner-all,
123
+ .wpglobus-wp-admin .wpglobus-wpseo-tabs .ui-corner-all,
124
+ .wpglobus-wp-admin .wpglobus-taxonomy-tabs .ui-corner-all {
125
+ border-bottom-right-radius: 0;
126
+ border-bottom-left-radius: 0;
127
+ border-top-right-radius: 0;
128
+ border-top-left-radius: 0;
129
+ }
130
+ .wpglobus-wp-admin .wpglobus-post-body-tabs.ui-widget-content,
131
+ .wpglobus-wp-admin #wpglobus-aioseop-tabs.ui-widget-content,
132
+ .wpglobus-wp-admin #wpglobus-wpseo-tabs.ui-widget-content,
133
+ .wpglobus-wp-admin .wpglobus-wpseo-tabs.ui-widget-content,
134
+ .wpglobus-wp-admin .wpglobus-taxonomy-tabs.ui-widget-content {
135
+ border: none;
136
+ background: transparent;
137
+ color: inherit;
138
+ }
139
+ .wpglobus-wp-admin .wpglobus-post-body-tabs.ui-widget,
140
+ .wpglobus-wp-admin #wpglobus-aioseop-tabs.ui-widget,
141
+ .wpglobus-wp-admin #wpglobus-wpseo-tabs.ui-widget,
142
+ .wpglobus-wp-admin .wpglobus-wpseo-tabs.ui-widget,
143
+ .wpglobus-wp-admin .wpglobus-taxonomy-tabs.ui-widget {
144
+ font-family: inherit;
145
+ font-size: inherit;
146
+ }
147
+ .wpglobus-wp-admin .wpglobus-post-body-tabs.ui-tabs,
148
+ .wpglobus-wp-admin #wpglobus-aioseop-tabs.ui-tabs,
149
+ .wpglobus-wp-admin #wpglobus-wpseo-tabs.ui-tabs,
150
+ .wpglobus-wp-admin .wpglobus-wpseo-tabs.ui-tabs,
151
+ .wpglobus-wp-admin .wpglobus-taxonomy-tabs.ui-tabs {
152
+ padding: inherit;
153
+ }
154
+ .wpglobus-wp-admin .wpglobus-post-body-tabs.ui-tabs .ui-tabs-nav,
155
+ .wpglobus-wp-admin #wpglobus-aioseop-tabs.ui-tabs .ui-tabs-nav,
156
+ .wpglobus-wp-admin #wpglobus-wpseo-tabs.ui-tabs .ui-tabs-nav,
157
+ .wpglobus-wp-admin .wpglobus-wpseo-tabs.ui-tabs .ui-tabs-nav,
158
+ .wpglobus-wp-admin .wpglobus-taxonomy-tabs.ui-tabs .ui-tabs-nav {
159
+ margin: 0 0 1em 0;
160
+ padding: 0;
161
+ }
162
+ .wpglobus-wp-admin .wpglobus-post-body-tabs.ui-tabs .ui-tabs-panel,
163
+ .wpglobus-wp-admin #wpglobus-aioseop-tabs.ui-tabs .ui-tabs-panel,
164
+ .wpglobus-wp-admin #wpglobus-wpseo-tabs.ui-tabs .ui-tabs-panel,
165
+ .wpglobus-wp-admin .wpglobus-wpseo-tabs.ui-tabs .ui-tabs-panel,
166
+ .wpglobus-wp-admin .wpglobus-taxonomy-tabs.ui-tabs .ui-tabs-panel {
167
+ border-width: 0;
168
+ padding: inherit;
169
+ background: inherit;
170
+ }
171
+ .wpglobus-wp-admin #edittag #cat-tabs .form-field {
172
+ margin: 0 0 10px;
173
+ padding: 8px;
174
+ }
175
+ .wpglobus-wp-admin #edittag #cat-tabs .form-field p {
176
+ font-size: 12px;
177
+ font-style: italic;
178
+ font-family: sans-serif;
179
+ color: #666;
180
+ margin: 4px 0 5px;
181
+ }
182
+ .wpglobus-wp-admin #edittag #cat-tabs label {
183
+ display: block;
184
+ }
185
+ .wpglobus-wp-admin .post-excerpt {
186
+ margin: 0;
187
+ height: 4em;
188
+ width: 98%;
189
+ }
190
+ .wpglobus-wp-admin .titlediv-wpglobus .title_wpglobus {
191
+ background-color: #fff;
192
+ font-size: 1.7em;
193
+ height: 1.7em;
194
+ line-height: 100%;
195
+ margin: 0;
196
+ outline: -moz-use-text-color none 0;
197
+ padding: 3px 8px;
198
+ width: 100%;
199
+ }
200
+ .wpglobus-wp-admin .postdivrich-wpglobus .wp-editor-tools {
201
+ background-color: #f1f1f1;
202
+ padding-top: 20px;
203
+ }
204
+ .wpglobus-wp-admin .wpglobus-edit-slug-box {
205
+ height: 24px;
206
+ }
207
+ .wpglobus-wp-admin #wpglobus-wpseo-tabs {
208
+ /** @todo start from yoast seo 3.0.7
209
+ .wpglobus-snippet_preview .edit-icon {
210
+ position: absolute;
211
+ left: 0;
212
+ top: 0;
213
+ height: 100%;
214
+ width: 60px;
215
+ border-radius: 20px 0 0 20px;
216
+ border-right: 1px solid #eee;
217
+ text-align: center;
218
+ background: url(images/edit.svg) center no-repeat;
219
+ background-size: 40px;
220
+ } */
221
+ }
222
+ .wpglobus-wp-admin #wpglobus-wpseo-tabs .wpglobus-wpseosnippet {
223
+ font-family: Arial, Helvetica, sans-serif;
224
+ font-style: normal;
225
+ }
226
+ .wpglobus-wp-admin #wpglobus-wpseo-tabs .wpglobus-wpseosnippet .title {
227
+ color: #1e0fbe;
228
+ display: block;
229
+ font-size: 18px !important;
230
+ line-height: 1.2;
231
+ overflow-x: hidden;
232
+ overflow-y: hidden;
233
+ text-overflow: ellipsis;
234
+ white-space: nowrap;
235
+ width: 512px;
236
+ }
237
+ .wpglobus-wp-admin #wpglobus-wpseo-tabs .wpglobus-wpseosnippet .url {
238
+ color: #006621;
239
+ font-size: 13px;
240
+ line-height: 16px;
241
+ }
242
+ .wpglobus-wp-admin #wpglobus-wpseo-tabs .wpglobus-wpseosnippet .desc {
243
+ font-size: small;
244
+ line-height: 1.4;
245
+ word-wrap: break-word;
246
+ }
247
+ .wpglobus-wp-admin #wpglobus-wpseo-tabs .wpglobus-focuskwresults ul {
248
+ margin: 0;
249
+ }
250
+ .wpglobus-wp-admin #wpglobus-wpseo-tabs .wpglobus-focuskwresults li {
251
+ float: none !important;
252
+ list-style-type: disc;
253
+ margin: 0 0 0 20px !important;
254
+ }
255
+ .wpglobus-wp-admin #wpglobus-wpseo-tabs .wpglobus-focuskwresults li,
256
+ .wpglobus-wp-admin #wpglobus-wpseo-tabs .wpglobus-focuskwresults p {
257
+ font-size: 13px !important;
258
+ }
259
+ .wpglobus-wp-admin #wpglobus-wpseo-tabs .wpglobus-snippet_container [contenteditable=true]:hover {
260
+ background: url(images/edit.svg) right top no-repeat #bbdefb;
261
+ cursor: pointer;
262
+ }
includes/css/wpglobus-admin-tabs.less ADDED
@@ -0,0 +1,240 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Admin tabs styles
3
+ * @package WPGlobus
4
+ */
5
+
6
+ .wpglobus-wp-admin {
7
+
8
+ // TinyMCE
9
+ #post-body .wpglobus-post-body-tabs .ui-widget-content input.like-default-title {
10
+ padding: 3px 8px;
11
+ font-size: 1.7em;
12
+ line-height: 100%;
13
+ width: 100%;
14
+ outline: none;
15
+ }
16
+
17
+ .wpglobus-post-body-tabs {
18
+
19
+ .titlediv {
20
+ margin-bottom: 20px;
21
+ }
22
+
23
+ .mceIframeContainer iframe {
24
+ min-height: 150px !important;
25
+ }
26
+
27
+ .wp-editor-container {
28
+ border: 1px solid #ccc;
29
+ }
30
+
31
+ .titlediv-wpglobus {
32
+ position: relative;
33
+ }
34
+
35
+ }
36
+
37
+ // Post body Tabs, All in one SEO pack Tabs, WPSeo Tabs, Taxonomy Tabs
38
+ .wpglobus-post-body-tabs, #wpglobus-aioseop-tabs, #wpglobus-wpseo-tabs, .wpglobus-wpseo-tabs, .wpglobus-taxonomy-tabs {
39
+ .tabs-nav ul {
40
+ list-style-type: none;
41
+ margin: 0 10px;
42
+ padding: 0;
43
+ }
44
+
45
+ li a, ul li {
46
+ float: left;
47
+ margin: 0;
48
+ }
49
+
50
+ li.ui-state-default {
51
+ border: 0;
52
+ background: transparent;
53
+ }
54
+
55
+ ul li.ui-state-default a {
56
+ display: block;
57
+ color: #777;
58
+ background: #ebebeb;
59
+ border: 1px solid #e5e5e5;
60
+ border-bottom: 0;
61
+ font-weight: normal;
62
+ height: 2em;
63
+ line-height: 2em;
64
+ margin-right: 5px;
65
+ padding: 0 10px;
66
+ text-decoration: none;
67
+ }
68
+
69
+ ul li.ui-state-active a {
70
+ background: #fff;
71
+ border: 1px solid #e5e5e5;
72
+ border-bottom-color: #fff;
73
+ color: #000;
74
+ margin-bottom: -1px;
75
+ font-weight: 700;
76
+ }
77
+
78
+ ul li a {
79
+ &:hover {
80
+ color: #000;
81
+ }
82
+ &:focus{
83
+ box-shadow: none;
84
+ }
85
+ }
86
+
87
+ .wpglobus-post-body-tabs-list, .wpglobus-wpseo-tabs-list, .wpglobus-aioseop-tabs-list {
88
+ border: none;
89
+ border-bottom: 1px solid #dddddd;
90
+ background: transparent;
91
+
92
+ // To guarantee some space at the bottom
93
+ min-height: 3em;
94
+ }
95
+
96
+ .ui-corner-all {
97
+ border-bottom-right-radius: 0;
98
+ border-bottom-left-radius: 0;
99
+ border-top-right-radius: 0;
100
+ border-top-left-radius: 0;
101
+ }
102
+
103
+ &.ui-widget-content {
104
+ border: none;
105
+ background: transparent;
106
+ color: inherit;
107
+ }
108
+
109
+ &.ui-widget {
110
+ font-family: inherit;
111
+ font-size: inherit;
112
+ }
113
+
114
+ &.ui-tabs {
115
+ padding: inherit;
116
+ .ui-tabs-nav {
117
+ margin: 0 0 1em 0;
118
+ padding: 0;
119
+ }
120
+ .ui-tabs-panel {
121
+ border-width: 0;
122
+ padding: inherit;
123
+ background: inherit;
124
+ }
125
+ }
126
+
127
+ }
128
+
129
+ // form-field description
130
+ #edittag #cat-tabs .form-field {
131
+ margin: 0 0 10px;
132
+ padding: 8px;
133
+ }
134
+
135
+ #edittag #cat-tabs .form-field p {
136
+ font-size: 12px;
137
+ font-style: italic;
138
+ font-family: sans-serif;
139
+ color: #666;
140
+ margin: 4px 0 5px;
141
+ }
142
+
143
+ #edittag #cat-tabs label {
144
+ display: block;
145
+ }
146
+
147
+ .post-excerpt {
148
+ margin: 0;
149
+ height: 4em;
150
+ width: 98%;
151
+ }
152
+
153
+ .titlediv-wpglobus .title_wpglobus {
154
+ background-color: #fff;
155
+ font-size: 1.7em;
156
+ height: 1.7em;
157
+ line-height: 100%;
158
+ margin: 0;
159
+ outline: -moz-use-text-color none 0;
160
+ padding: 3px 8px;
161
+ width: 100%;
162
+ }
163
+
164
+ .postdivrich-wpglobus .wp-editor-tools {
165
+ background-color: #f1f1f1;
166
+ padding-top: 20px;
167
+ }
168
+
169
+ .wpglobus-edit-slug-box {
170
+ height: 24px;
171
+ }
172
+
173
+ /* WPSEO metabox */
174
+ #wpglobus-wpseo-tabs {
175
+
176
+ .wpglobus-wpseosnippet {
177
+ font-family: Arial, Helvetica, sans-serif;
178
+ font-style: normal;
179
+ }
180
+
181
+ .wpglobus-wpseosnippet .title {
182
+ color: #1e0fbe;
183
+ display: block;
184
+ font-size: 18px !important;
185
+ line-height: 1.2;
186
+ overflow-x: hidden;
187
+ overflow-y: hidden;
188
+ text-overflow: ellipsis;
189
+ white-space: nowrap;
190
+ width: 512px;
191
+ }
192
+
193
+ .wpglobus-wpseosnippet .url {
194
+ color: #006621;
195
+ font-size: 13px;
196
+ line-height: 16px;
197
+ }
198
+
199
+ .wpglobus-wpseosnippet .desc {
200
+ font-size: small;
201
+ line-height: 1.4;
202
+ word-wrap: break-word;
203
+ }
204
+
205
+ .wpglobus-focuskwresults ul {
206
+ margin: 0;
207
+ }
208
+
209
+ .wpglobus-focuskwresults li {
210
+ float: none !important;
211
+ list-style-type: disc;
212
+ margin: 0 0 0 20px !important;
213
+ }
214
+
215
+ .wpglobus-focuskwresults li, .wpglobus-focuskwresults p {
216
+ font-size: 13px !important;
217
+ }
218
+
219
+ .wpglobus-snippet_container [contenteditable=true]:hover {
220
+ background: url(images/edit.svg) right top no-repeat #bbdefb;
221
+ cursor: pointer;
222
+ }
223
+ /** @todo start from yoast seo 3.0.7
224
+ .wpglobus-snippet_preview .edit-icon {
225
+ position: absolute;
226
+ left: 0;
227
+ top: 0;
228
+ height: 100%;
229
+ width: 60px;
230
+ border-radius: 20px 0 0 20px;
231
+ border-right: 1px solid #eee;
232
+ text-align: center;
233
+ background: url(images/edit.svg) center no-repeat;
234
+ background-size: 40px;
235
+ } */
236
+ }
237
+
238
+ }
239
+
240
+ // --- EOF
includes/css/wpglobus-admin-tabs.min.css ADDED
@@ -0,0 +1 @@
 
1
+ .wpglobus-wp-admin #post-body .wpglobus-post-body-tabs .ui-widget-content input.like-default-title{padding:3px 8px;font-size:1.7em;line-height:100%;width:100%;outline:0}.wpglobus-wp-admin .wpglobus-post-body-tabs .titlediv{margin-bottom:20px}.wpglobus-wp-admin .wpglobus-post-body-tabs .mceIframeContainer iframe{min-height:150px!important}.wpglobus-wp-admin .wpglobus-post-body-tabs .wp-editor-container{border:1px solid #ccc}.wpglobus-wp-admin .wpglobus-post-body-tabs .titlediv-wpglobus{position:relative}.wpglobus-wp-admin #wpglobus-aioseop-tabs .tabs-nav ul,.wpglobus-wp-admin #wpglobus-wpseo-tabs .tabs-nav ul,.wpglobus-wp-admin .wpglobus-post-body-tabs .tabs-nav ul,.wpglobus-wp-admin .wpglobus-taxonomy-tabs .tabs-nav ul,.wpglobus-wp-admin .wpglobus-wpseo-tabs .tabs-nav ul{list-style-type:none;margin:0 10px;padding:0}.wpglobus-wp-admin #wpglobus-aioseop-tabs li a,.wpglobus-wp-admin #wpglobus-aioseop-tabs ul li,.wpglobus-wp-admin #wpglobus-wpseo-tabs li a,.wpglobus-wp-admin #wpglobus-wpseo-tabs ul li,.wpglobus-wp-admin .wpglobus-post-body-tabs li a,.wpglobus-wp-admin .wpglobus-post-body-tabs ul li,.wpglobus-wp-admin .wpglobus-taxonomy-tabs li a,.wpglobus-wp-admin .wpglobus-taxonomy-tabs ul li,.wpglobus-wp-admin .wpglobus-wpseo-tabs li a,.wpglobus-wp-admin .wpglobus-wpseo-tabs ul li{float:left;margin:0}.wpglobus-wp-admin #wpglobus-aioseop-tabs li.ui-state-default,.wpglobus-wp-admin #wpglobus-wpseo-tabs li.ui-state-default,.wpglobus-wp-admin .wpglobus-post-body-tabs li.ui-state-default,.wpglobus-wp-admin .wpglobus-taxonomy-tabs li.ui-state-default,.wpglobus-wp-admin .wpglobus-wpseo-tabs li.ui-state-default{border:0;background:0 0}.wpglobus-wp-admin #wpglobus-aioseop-tabs ul li.ui-state-default a,.wpglobus-wp-admin #wpglobus-wpseo-tabs ul li.ui-state-default a,.wpglobus-wp-admin .wpglobus-post-body-tabs ul li.ui-state-default a,.wpglobus-wp-admin .wpglobus-taxonomy-tabs ul li.ui-state-default a,.wpglobus-wp-admin .wpglobus-wpseo-tabs ul li.ui-state-default a{display:block;color:#777;background:#ebebeb;border:1px solid #e5e5e5;border-bottom:0;font-weight:400;height:2em;line-height:2em;margin-right:5px;padding:0 10px;text-decoration:none}.wpglobus-wp-admin #wpglobus-aioseop-tabs ul li.ui-state-active a,.wpglobus-wp-admin #wpglobus-wpseo-tabs ul li.ui-state-active a,.wpglobus-wp-admin .wpglobus-post-body-tabs ul li.ui-state-active a,.wpglobus-wp-admin .wpglobus-taxonomy-tabs ul li.ui-state-active a,.wpglobus-wp-admin .wpglobus-wpseo-tabs ul li.ui-state-active a{background:#fff;border:1px solid #e5e5e5;border-bottom-color:#fff;color:#000;margin-bottom:-1px;font-weight:700}.wpglobus-wp-admin #wpglobus-aioseop-tabs ul li a:hover,.wpglobus-wp-admin #wpglobus-wpseo-tabs ul li a:hover,.wpglobus-wp-admin .wpglobus-post-body-tabs ul li a:hover,.wpglobus-wp-admin .wpglobus-taxonomy-tabs ul li a:hover,.wpglobus-wp-admin .wpglobus-wpseo-tabs ul li a:hover{color:#000}.wpglobus-wp-admin #wpglobus-aioseop-tabs ul li a:focus,.wpglobus-wp-admin #wpglobus-wpseo-tabs ul li a:focus,.wpglobus-wp-admin .wpglobus-post-body-tabs ul li a:focus,.wpglobus-wp-admin .wpglobus-taxonomy-tabs ul li a:focus,.wpglobus-wp-admin .wpglobus-wpseo-tabs ul li a:focus{box-shadow:none}.wpglobus-wp-admin #wpglobus-aioseop-tabs .wpglobus-aioseop-tabs-list,.wpglobus-wp-admin #wpglobus-aioseop-tabs .wpglobus-post-body-tabs-list,.wpglobus-wp-admin #wpglobus-aioseop-tabs .wpglobus-wpseo-tabs-list,.wpglobus-wp-admin #wpglobus-wpseo-tabs .wpglobus-aioseop-tabs-list,.wpglobus-wp-admin #wpglobus-wpseo-tabs .wpglobus-post-body-tabs-list,.wpglobus-wp-admin #wpglobus-wpseo-tabs .wpglobus-wpseo-tabs-list,.wpglobus-wp-admin .wpglobus-post-body-tabs .wpglobus-aioseop-tabs-list,.wpglobus-wp-admin .wpglobus-post-body-tabs .wpglobus-post-body-tabs-list,.wpglobus-wp-admin .wpglobus-post-body-tabs .wpglobus-wpseo-tabs-list,.wpglobus-wp-admin .wpglobus-taxonomy-tabs .wpglobus-aioseop-tabs-list,.wpglobus-wp-admin .wpglobus-taxonomy-tabs .wpglobus-post-body-tabs-list,.wpglobus-wp-admin .wpglobus-taxonomy-tabs .wpglobus-wpseo-tabs-list,.wpglobus-wp-admin .wpglobus-wpseo-tabs .wpglobus-aioseop-tabs-list,.wpglobus-wp-admin .wpglobus-wpseo-tabs .wpglobus-post-body-tabs-list,.wpglobus-wp-admin .wpglobus-wpseo-tabs .wpglobus-wpseo-tabs-list{border:none;border-bottom:1px solid #ddd;background:0 0;min-height:3em}.wpglobus-wp-admin #wpglobus-aioseop-tabs .ui-corner-all,.wpglobus-wp-admin #wpglobus-wpseo-tabs .ui-corner-all,.wpglobus-wp-admin .wpglobus-post-body-tabs .ui-corner-all,.wpglobus-wp-admin .wpglobus-taxonomy-tabs .ui-corner-all,.wpglobus-wp-admin .wpglobus-wpseo-tabs .ui-corner-all{border-bottom-right-radius:0;border-bottom-left-radius:0;border-top-right-radius:0;border-top-left-radius:0}.wpglobus-wp-admin #wpglobus-aioseop-tabs.ui-widget-content,.wpglobus-wp-admin #wpglobus-wpseo-tabs.ui-widget-content,.wpglobus-wp-admin .wpglobus-post-body-tabs.ui-widget-content,.wpglobus-wp-admin .wpglobus-taxonomy-tabs.ui-widget-content,.wpglobus-wp-admin .wpglobus-wpseo-tabs.ui-widget-content{border:none;background:0 0;color:inherit}.wpglobus-wp-admin #wpglobus-aioseop-tabs.ui-widget,.wpglobus-wp-admin #wpglobus-wpseo-tabs.ui-widget,.wpglobus-wp-admin .wpglobus-post-body-tabs.ui-widget,.wpglobus-wp-admin .wpglobus-taxonomy-tabs.ui-widget,.wpglobus-wp-admin .wpglobus-wpseo-tabs.ui-widget{font-family:inherit;font-size:inherit}.wpglobus-wp-admin #wpglobus-aioseop-tabs.ui-tabs,.wpglobus-wp-admin #wpglobus-wpseo-tabs.ui-tabs,.wpglobus-wp-admin .wpglobus-post-body-tabs.ui-tabs,.wpglobus-wp-admin .wpglobus-taxonomy-tabs.ui-tabs,.wpglobus-wp-admin .wpglobus-wpseo-tabs.ui-tabs{padding:inherit}.wpglobus-wp-admin #wpglobus-aioseop-tabs.ui-tabs .ui-tabs-nav,.wpglobus-wp-admin #wpglobus-wpseo-tabs.ui-tabs .ui-tabs-nav,.wpglobus-wp-admin .wpglobus-post-body-tabs.ui-tabs .ui-tabs-nav,.wpglobus-wp-admin .wpglobus-taxonomy-tabs.ui-tabs .ui-tabs-nav,.wpglobus-wp-admin .wpglobus-wpseo-tabs.ui-tabs .ui-tabs-nav{margin:0 0 1em 0;padding:0}.wpglobus-wp-admin #wpglobus-aioseop-tabs.ui-tabs .ui-tabs-panel,.wpglobus-wp-admin #wpglobus-wpseo-tabs.ui-tabs .ui-tabs-panel,.wpglobus-wp-admin .wpglobus-post-body-tabs.ui-tabs .ui-tabs-panel,.wpglobus-wp-admin .wpglobus-taxonomy-tabs.ui-tabs .ui-tabs-panel,.wpglobus-wp-admin .wpglobus-wpseo-tabs.ui-tabs .ui-tabs-panel{border-width:0;padding:inherit;background:inherit}.wpglobus-wp-admin #edittag #cat-tabs .form-field{margin:0 0 10px;padding:8px}.wpglobus-wp-admin #edittag #cat-tabs .form-field p{font-size:12px;font-style:italic;font-family:sans-serif;color:#666;margin:4px 0 5px}.wpglobus-wp-admin #edittag #cat-tabs label{display:block}.wpglobus-wp-admin .post-excerpt{margin:0;height:4em;width:98%}.wpglobus-wp-admin .titlediv-wpglobus .title_wpglobus{background-color:#fff;font-size:1.7em;height:1.7em;line-height:100%;margin:0;outline:-moz-use-text-color none 0;padding:3px 8px;width:100%}.wpglobus-wp-admin .postdivrich-wpglobus .wp-editor-tools{background-color:#f1f1f1;padding-top:20px}.wpglobus-wp-admin .wpglobus-edit-slug-box{height:24px}.wpglobus-wp-admin #wpglobus-wpseo-tabs .wpglobus-wpseosnippet{font-family:Arial,Helvetica,sans-serif;font-style:normal}.wpglobus-wp-admin #wpglobus-wpseo-tabs .wpglobus-wpseosnippet .title{color:#1e0fbe;display:block;font-size:18px!important;line-height:1.2;overflow-x:hidden;overflow-y:hidden;text-overflow:ellipsis;white-space:nowrap;width:512px}.wpglobus-wp-admin #wpglobus-wpseo-tabs .wpglobus-wpseosnippet .url{color:#006621;font-size:13px;line-height:16px}.wpglobus-wp-admin #wpglobus-wpseo-tabs .wpglobus-wpseosnippet .desc{font-size:small;line-height:1.4;word-wrap:break-word}.wpglobus-wp-admin #wpglobus-wpseo-tabs .wpglobus-focuskwresults ul{margin:0}.wpglobus-wp-admin #wpglobus-wpseo-tabs .wpglobus-focuskwresults li{float:none!important;list-style-type:disc;margin:0 0 0 20px!important}.wpglobus-wp-admin #wpglobus-wpseo-tabs .wpglobus-focuskwresults li,.wpglobus-wp-admin #wpglobus-wpseo-tabs .wpglobus-focuskwresults p{font-size:13px!important}.wpglobus-wp-admin #wpglobus-wpseo-tabs .wpglobus-snippet_container [contenteditable=true]:hover{background:url(images/edit.svg) right top no-repeat #bbdefb;cursor:pointer}
includes/css/wpglobus-admin.css ADDED
@@ -0,0 +1,280 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Admin styles
3
+ * @package WPGlobus
4
+ */
5
+ #adminmenu li.toplevel_page_wpglobus_options div.wp-menu-image:before {
6
+ content: "\f319";
7
+ }
8
+ .wpglobus-menu-item-box {
9
+ background-color: #e0e0e0;
10
+ padding-bottom: 20px;
11
+ }
12
+ .wpglobus-excerpt {
13
+ width: 98%;
14
+ height: 4em;
15
+ }
16
+ .widefat thead tr th.column-wpglobus_languages {
17
+ width: 7%;
18
+ }
19
+ .wpglobus-switch .wpglobus-icon-globe:before {
20
+ display: inline-block;
21
+ -webkit-font-smoothing: antialiased;
22
+ font-family: 'dashicons';
23
+ font-weight: 400;
24
+ font-style: normal;
25
+ text-decoration: inherit;
26
+ content: "\f319";
27
+ font-size: 20px;
28
+ vertical-align: text-bottom;
29
+ opacity: 0.6;
30
+ }
31
+ ul.wpglobus-checkmarks li:before {
32
+ display: inline-block;
33
+ -webkit-font-smoothing: antialiased;
34
+ font-family: 'dashicons';
35
+ font-weight: 400;
36
+ font-style: normal;
37
+ text-decoration: inherit;
38
+ content: "\f147";
39
+ font-size: 2em;
40
+ vertical-align: top;
41
+ color: forestgreen;
42
+ }
43
+ ul.wpglobus-checkmarks li {
44
+ text-indent: -1em;
45
+ margin-left: 1.5em;
46
+ }
47
+ ul.wpglobus-important li:before {
48
+ display: inline-block;
49
+ -webkit-font-smoothing: antialiased;
50
+ font-family: 'dashicons';
51
+ font-weight: 400;
52
+ font-style: normal;
53
+ text-decoration: inherit;
54
+ content: "\f522";
55
+ font-size: 23px;
56
+ vertical-align: top;
57
+ color: darkred;
58
+ }
59
+ ul.wpglobus-important li {
60
+ text-indent: -14px;
61
+ margin-left: 24px;
62
+ }
63
+ .wpglobus-state-error {
64
+ border: 1px solid #f00 !important;
65
+ }
66
+ .wpglobus-post-status-info {
67
+ width: 100%;
68
+ border-spacing: 0;
69
+ border: 1px solid #e5e5e5;
70
+ border-top: none;
71
+ background-color: #f7f7f7;
72
+ -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
73
+ box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
74
+ z-index: 999;
75
+ }
76
+ .wpglobus-post-status-info td {
77
+ font-size: 12px;
78
+ }
79
+ .wpglobus-post-status-info .wpglobus-wp-word-count {
80
+ display: block;
81
+ padding: 2px 10px;
82
+ }
83
+ .wpglobus-wp-admin .wpglobus-translatable {
84
+ border-left: 3px solid blue !important;
85
+ }
86
+ .wpglobus-wp-admin .wpglobus-link-lock-icon {
87
+ cursor: not-allowed;
88
+ }
89
+ .wpglobus-wp-admin .wpglobus-link-trash-icon {
90
+ cursor: not-allowed;
91
+ }
92
+ .wpglobus-wp-admin .wpglobus-link-lock-icon:before {
93
+ font-family: 'dashicons';
94
+ font-weight: 400;
95
+ font-style: normal;
96
+ text-decoration: inherit;
97
+ content: "\f160";
98
+ font-size: 11px;
99
+ }
100
+ .wpglobus-wp-admin .wpglobus-link-open-icon:before {
101
+ font-family: 'dashicons';
102
+ font-weight: 400;
103
+ font-style: normal;
104
+ text-decoration: inherit;
105
+ content: "\f504";
106
+ font-size: 11px;
107
+ }
108
+ .wpglobus-wp-admin .wpglobus-link-trash-icon:before {
109
+ font-family: 'dashicons';
110
+ font-weight: 400;
111
+ font-style: normal;
112
+ text-decoration: inherit;
113
+ content: "\f182";
114
+ font-size: 11px;
115
+ }
116
+ .wpglobus-wp-admin .wpglobus-spinner {
117
+ background: url(images/spinner.gif) no-repeat;
118
+ -webkit-background-size: 20px 20px;
119
+ background-size: 20px 20px;
120
+ display: inline-block;
121
+ visibility: hidden;
122
+ float: right;
123
+ vertical-align: middle;
124
+ opacity: 0.7;
125
+ filter: alpha(opacity=70);
126
+ width: 20px;
127
+ height: 20px;
128
+ margin: 0;
129
+ }
130
+ /* @see #edit-slug-box */
131
+ .wpglobus-edit-slug-box {
132
+ line-height: 24px;
133
+ min-height: 25px;
134
+ margin-top: 5px;
135
+ padding: 0 10px;
136
+ color: #666;
137
+ /* @see #editable-post-name input */
138
+ }
139
+ .wpglobus-edit-slug-box .wpglobus-editable-post-name {
140
+ background-color: #fffbcc;
141
+ }
142
+ .wpglobus-edit-slug-box .wpglobus-editable-post-name-full {
143
+ display: none;
144
+ }
145
+ .wpglobus-edit-slug-box .wpglobus-editable-post-name input {
146
+ font-size: 13px;
147
+ height: 22px;
148
+ margin-bottom: 0;
149
+ margin-left: 0;
150
+ margin-right: 0;
151
+ margin-top: 0;
152
+ width: 20em;
153
+ }
154
+ .about-wrap.wpglobus-about-wrap .wpglobus-version {
155
+ color: #E38869;
156
+ font-size: 95%;
157
+ }
158
+ .about-wrap.wpglobus-about-wrap .wpglobus-motto {
159
+ font-style: italic;
160
+ }
161
+ .about-wrap.wpglobus-about-wrap .wpglobus-wp {
162
+ color: #23769C;
163
+ }
164
+ .about-wrap.wpglobus-about-wrap h1.wpglobus {
165
+ font-family: Georgia, serif;
166
+ font-variant: small-caps;
167
+ letter-spacing: 1.5px;
168
+ }
169
+ .about-wrap.wpglobus-about-wrap .wpglobus-stars {
170
+ color: #E38869;
171
+ }
172
+ .about-wrap.wpglobus-about-wrap .feature-section div {
173
+ text-align: left;
174
+ }
175
+ .toplevel_page_wpglobus_options #redux-header,
176
+ .toplevel_page_wpglobus_options .redux-timer {
177
+ display: none;
178
+ }
179
+ .toplevel_page_wpglobus_options .el-move::before {
180
+ display: inline-block;
181
+ -webkit-font-smoothing: antialiased;
182
+ font-family: 'dashicons';
183
+ font-weight: 400;
184
+ font-style: normal;
185
+ text-decoration: inherit;
186
+ content: "\f545";
187
+ border: 1px solid #2866a0;
188
+ color: #2866a0;
189
+ background-color: white;
190
+ margin: 0 3px 0 3px;
191
+ line-height: 1.2;
192
+ width: 1.5em;
193
+ text-align: center;
194
+ cursor: move;
195
+ }
196
+ .redux-container #redux-intro-text {
197
+ background-color: #d3e4f4;
198
+ color: black;
199
+ }
200
+ .redux-container #redux-intro-text h1 {
201
+ color: #2866a0;
202
+ float: left;
203
+ width: 204px;
204
+ margin: 0;
205
+ padding: 0;
206
+ }
207
+ .redux-container #redux-intro-text .wpg-bnr {
208
+ width: 400px;
209
+ }
210
+ .redux-container #redux-intro-text .wpg-bnr.wpg-bnr-left {
211
+ float: left;
212
+ }
213
+ .redux-container #redux-intro-text .wpg-bnr.wpg-bnr-right {
214
+ float: right;
215
+ }
216
+ .redux-container #redux-intro-text .wpg-a-img {
217
+ float: left;
218
+ display: block;
219
+ height: 100px;
220
+ border: 1px solid #5999d5;
221
+ background-color: white;
222
+ margin-right: 1em;
223
+ }
224
+ .redux-container #redux-intro-text .wpg-a-img img {
225
+ width: 100px;
226
+ }
227
+ .redux-container #redux-intro-text .wpg-text-block {
228
+ padding-top: 0.3em;
229
+ }
230
+ .redux-container #redux-intro-text .wpg-text-block .wpg-title {
231
+ font-weight: 700;
232
+ }
233
+ .redux-container #redux-intro-text .wpg-text-block .wpg-body {
234
+ margin: 0.3em 0;
235
+ }
236
+ .redux-container #redux-intro-text .wpg-text-block .wpg-footer {
237
+ font-style: italic;
238
+ }
239
+ .customize-controls-close.wpglobus-customize-selector:before {
240
+ content: "";
241
+ }
242
+ .customize-controls-close.wpglobus-customize-selector .wpglobus-icon-globe:before {
243
+ color: #00f;
244
+ display: inline-block;
245
+ font-family: 'dashicons';
246
+ content: "\f319";
247
+ font-size: 20px;
248
+ }
249
+ .wpglobus-customize-translatable-element,
250
+ .wpglobus-customize-control,
251
+ .wpglobus-customize-widget-control {
252
+ border-left: 3px solid blue !important;
253
+ }
254
+ @media screen and (max-width: 640px) {
255
+ .customize-controls-preview-toggle {
256
+ left: 88px;
257
+ }
258
+ }
259
+ .yoast_help.yoast-help-button.dashicons {
260
+ font-family: 'dashicons' !important;
261
+ font-size: 20px !important;
262
+ }
263
+ .wpglobus-mark {
264
+ font-weight: 700;
265
+ }
266
+ .wpglobus-mark.wpglobus-warning {
267
+ background-color: yellow;
268
+ color: black;
269
+ }
270
+ @media screen and (max-width: 782px) {
271
+ #wpadminbar li#wp-admin-bar-wpglobus-language-select {
272
+ display: block;
273
+ }
274
+ #wpadminbar li#wp-admin-bar-wpglobus-language-select .ab-icon {
275
+ margin-top: -3px;
276
+ }
277
+ #wpadminbar li#wp-admin-bar-wpglobus-language-select .ab-icon img {
278
+ height: 25px;
279
+ }
280
+ }
includes/css/wpglobus-admin.less ADDED
@@ -0,0 +1,347 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Admin styles
3
+ * @package WPGlobus
4
+ */
5
+
6
+ .dashicon-checkmark() {
7
+ content: "\f147";
8
+ }
9
+
10
+ .dashicon-triangle-right() {
11
+ content: "\f522";
12
+ }
13
+
14
+ .dashicon-globus() {
15
+ content: "\f319";
16
+ }
17
+
18
+ // To use in the Redux Sortable instead of elusive
19
+ .dashicons-image-flip-vertical() {
20
+ content: "\f168";
21
+ }
22
+
23
+ .dashicons-move() {
24
+ content: "\f545";
25
+ }
26
+
27
+ #adminmenu li.toplevel_page_wpglobus_options div.wp-menu-image:before {
28
+ .dashicon-globus();
29
+ }
30
+
31
+ .wpglobus-menu-item-box {
32
+ background-color: #e0e0e0;
33
+ padding-bottom: 20px;
34
+ }
35
+
36
+ .wpglobus-excerpt {
37
+ width: 98%;
38
+ height: 4em;
39
+ }
40
+
41
+ .widefat thead tr th.column-wpglobus_languages {
42
+ width: 7%;
43
+ }
44
+
45
+ //noinspection CssNoGenericFontName
46
+ .dashicon() {
47
+ display: inline-block;
48
+ -webkit-font-smoothing: antialiased;
49
+ font-family: 'dashicons';
50
+ font-weight: 400;
51
+ font-style: normal;
52
+ text-decoration: inherit;
53
+ }
54
+
55
+ .wpglobus-switch .wpglobus-icon-globe:before {
56
+ .dashicon();
57
+ .dashicon-globus();
58
+ font-size: 20px;
59
+ vertical-align: text-bottom;
60
+ opacity: 0.6;
61
+ }
62
+
63
+ ul.wpglobus-checkmarks {
64
+ li:before {
65
+ .dashicon();
66
+ .dashicon-checkmark();
67
+ font-size: 2em;
68
+ vertical-align: top;
69
+ color: forestgreen;
70
+ }
71
+ li {
72
+ text-indent: -1em;
73
+ margin-left: 1.5em;
74
+ }
75
+ }
76
+
77
+ ul.wpglobus-important {
78
+ li:before {
79
+ .dashicon();
80
+ .dashicon-triangle-right();
81
+ font-size: 23px;
82
+ vertical-align: top;
83
+ color: darkred;
84
+ }
85
+ li {
86
+ text-indent: -14px;
87
+ margin-left: 24px;
88
+ }
89
+ }
90
+
91
+ .wpglobus-state-error {
92
+ border: 1px solid #f00 !important;
93
+ }
94
+
95
+ .wpglobus-post-status-info {
96
+ width: 100%;
97
+ border-spacing: 0;
98
+ border: 1px solid #e5e5e5;
99
+ border-top: none;
100
+ background-color: #f7f7f7;
101
+ -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
102
+ box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
103
+ z-index: 999;
104
+ td {
105
+ font-size: 12px;
106
+ }
107
+ .wpglobus-wp-word-count {
108
+ display: block;
109
+ padding: 2px 10px;
110
+ }
111
+ }
112
+
113
+ .wpglobus-wp-admin {
114
+ .wpglobus-translatable {
115
+ border-left: 3px solid blue !important;
116
+ }
117
+ .wpglobus-link-lock-icon {
118
+ cursor: not-allowed;
119
+ }
120
+ .wpglobus-link-trash-icon {
121
+ cursor: not-allowed;
122
+ }
123
+ .wpglobus-link-lock-icon:before {
124
+ font-family: 'dashicons';
125
+ font-weight: 400;
126
+ font-style: normal;
127
+ text-decoration: inherit;
128
+ content: "\f160";
129
+ font-size: 11px;
130
+ }
131
+ .wpglobus-link-open-icon:before {
132
+ font-family: 'dashicons';
133
+ font-weight: 400;
134
+ font-style: normal;
135
+ text-decoration: inherit;
136
+ content: "\f504";
137
+ font-size: 11px;
138
+ }
139
+ .wpglobus-link-trash-icon:before {
140
+ font-family: 'dashicons';
141
+ font-weight: 400;
142
+ font-style: normal;
143
+ text-decoration: inherit;
144
+ content: "\f182";
145
+ font-size: 11px;
146
+ }
147
+ .wpglobus-spinner {
148
+ background: url(images/spinner.gif) no-repeat;
149
+ -webkit-background-size: 20px 20px;
150
+ background-size: 20px 20px;
151
+ display: inline-block;
152
+ visibility: hidden;
153
+ float: right;
154
+ vertical-align: middle;
155
+ opacity: 0.7;
156
+ filter: alpha(opacity=70);
157
+ width: 20px;
158
+ height: 20px;
159
+ margin: 0;
160
+ }
161
+
162
+ }
163
+
164
+ /* @see #edit-slug-box */
165
+ .wpglobus-edit-slug-box {
166
+ line-height: 24px;
167
+ min-height: 25px;
168
+ margin-top: 5px;
169
+ padding: 0 10px;
170
+ color: #666;
171
+ .wpglobus-editable-post-name {
172
+ background-color: #fffbcc;
173
+ }
174
+ .wpglobus-editable-post-name-full {
175
+ display: none;
176
+ }
177
+ /* @see #editable-post-name input */
178
+ .wpglobus-editable-post-name input {
179
+ font-size: 13px;
180
+ height: 22px;
181
+ margin-bottom: 0;
182
+ margin-left: 0;
183
+ margin-right: 0;
184
+ margin-top: 0;
185
+ width: 20em;
186
+ }
187
+
188
+ }
189
+
190
+ @color-wpglobus-logo-globe: #E38869;
191
+ @color-wpglobus-logo-wp: #23769C;
192
+
193
+ // @since 1.5.8 Use our styles only with our `wrap` class.
194
+ .about-wrap.wpglobus-about-wrap {
195
+ .wpglobus-version {
196
+ color: @color-wpglobus-logo-globe;
197
+ font-size: 95%;
198
+ }
199
+
200
+ .wpglobus-motto {
201
+ font-style: italic;
202
+ }
203
+
204
+ .wpglobus-wp {
205
+ color: @color-wpglobus-logo-wp;
206
+ }
207
+
208
+ h1.wpglobus {
209
+ font-family: Georgia, serif;
210
+ font-variant: small-caps;
211
+ letter-spacing: 1.5px;
212
+ }
213
+
214
+ .wpglobus-stars {
215
+ color: @color-wpglobus-logo-globe;
216
+ }
217
+
218
+ // The `Customizr` theme breaks this by setting to "center".
219
+ // @since 1.5.8
220
+ .feature-section {
221
+ div {
222
+ text-align: left;
223
+ }
224
+ }
225
+ }
226
+
227
+ // Hide Redux annoyances
228
+ .toplevel_page_wpglobus_options {
229
+ #redux-header, .redux-timer {
230
+ display: none;
231
+ }
232
+ }
233
+
234
+ // Use Dashicon instead of Elusive, because Elusive can be broken by a theme (ex. "Virtue")
235
+ @color-wpglobus-icon-sortable: #2866a0;
236
+ .toplevel_page_wpglobus_options {
237
+ .el-move::before {
238
+ .dashicon();
239
+ .dashicons-move();
240
+ border: 1px solid @color-wpglobus-icon-sortable;
241
+ color: @color-wpglobus-icon-sortable;
242
+ background-color: white;
243
+ margin: 0 3px 0 3px;
244
+ line-height: 1.2;
245
+ width: 1.5em;
246
+ text-align: center;
247
+ cursor: move;
248
+ }
249
+ }
250
+
251
+ // Options panel header
252
+ // @see includes/options/wpglobus-options-header.php
253
+ @bg-redux-info: #d3e4f4;
254
+ .redux-container #redux-intro-text {
255
+ background-color: @bg-redux-info;
256
+ color: black;
257
+ h1 {
258
+ color: darken(@bg-redux-info, 50%);
259
+ float: left;
260
+ width: 204px;
261
+ margin: 0;
262
+ padding: 0;
263
+ }
264
+ .wpg-bnr {
265
+ width: 400px;
266
+ &.wpg-bnr-left {
267
+ float: left;
268
+ }
269
+ &.wpg-bnr-right {
270
+ float: right;
271
+ }
272
+ }
273
+ .wpg-a-img {
274
+ float: left;
275
+ display: block;
276
+ height: 100px;
277
+ border: 1px solid darken(@bg-redux-info, 30%);
278
+ background-color: white;
279
+ margin-right: 1em;
280
+ img {
281
+ width: 100px;
282
+ }
283
+ }
284
+ .wpg-text-block {
285
+ padding-top: 0.3em;
286
+ .wpg-title {
287
+ font-weight: 700;
288
+ }
289
+ .wpg-body {
290
+ margin: 0.3em 0;
291
+ }
292
+ .wpg-footer {
293
+ font-style: italic;
294
+ }
295
+ }
296
+
297
+ }
298
+ // @see customize.php
299
+ .customize-controls-close.wpglobus-customize-selector:before {
300
+ content: "";
301
+ }
302
+ .customize-controls-close.wpglobus-customize-selector .wpglobus-icon-globe:before {
303
+ color: #00f;
304
+ display: inline-block;
305
+ font-family: 'dashicons';
306
+ content: "\f319";
307
+ font-size: 20px;
308
+ }
309
+ .wpglobus-customize-translatable-element, .wpglobus-customize-control, .wpglobus-customize-widget-control {
310
+ border-left: 3px solid blue !important;
311
+ }
312
+ @media screen and (max-width: 640px) {
313
+ .customize-controls-preview-toggle {
314
+ left: 88px;
315
+ }
316
+ }
317
+
318
+ // Fix Yoast help buttons. Because we wrap Yoast in jQ-UI tabs,
319
+ // the style might be broken. Specifically, the "Types" plugin breaks it.
320
+ .yoast_help.yoast-help-button.dashicons {
321
+ font-family: 'dashicons' !important;
322
+ font-size: 20px !important;
323
+ }
324
+
325
+ // To highlight texts in admin area.
326
+ .wpglobus-mark {
327
+ font-weight: 700;
328
+ &.wpglobus-warning {
329
+ background-color: yellow;
330
+ color: black;
331
+ }
332
+ }
333
+
334
+ // To display admin language selector on narrow screens.
335
+ @media screen and (max-width: 782px) {
336
+ #wpadminbar li#wp-admin-bar-wpglobus-language-select {
337
+ display: block;
338
+ .ab-icon {
339
+ margin-top: -3px;
340
+ img {
341
+ height: 25px;
342
+ }
343
+ }
344
+ }
345
+ }
346
+
347
+ // --- EOF
includes/css/wpglobus-admin.min.css ADDED
@@ -0,0 +1 @@
 
1
+ #adminmenu li.toplevel_page_wpglobus_options div.wp-menu-image:before{content:"\f319"}.wpglobus-menu-item-box{background-color:#e0e0e0;padding-bottom:20px}.wpglobus-excerpt{width:98%;height:4em}.widefat thead tr th.column-wpglobus_languages{width:7%}.wpglobus-switch .wpglobus-icon-globe:before{display:inline-block;-webkit-font-smoothing:antialiased;font-family:dashicons;font-weight:400;font-style:normal;text-decoration:inherit;content:"\f319";font-size:20px;vertical-align:text-bottom;opacity:.6}ul.wpglobus-checkmarks li:before{display:inline-block;-webkit-font-smoothing:antialiased;font-family:dashicons;font-weight:400;font-style:normal;text-decoration:inherit;content:"\f147";font-size:2em;vertical-align:top;color:#228b22}ul.wpglobus-checkmarks li{text-indent:-1em;margin-left:1.5em}ul.wpglobus-important li:before{display:inline-block;-webkit-font-smoothing:antialiased;font-family:dashicons;font-weight:400;font-style:normal;text-decoration:inherit;content:"\f522";font-size:23px;vertical-align:top;color:#8b0000}ul.wpglobus-important li{text-indent:-14px;margin-left:24px}.wpglobus-state-error{border:1px solid red!important}.wpglobus-post-status-info{width:100%;border-spacing:0;border:1px solid #e5e5e5;border-top:none;background-color:#f7f7f7;-webkit-box-shadow:0 1px 1px rgba(0,0,0,.04);box-shadow:0 1px 1px rgba(0,0,0,.04);z-index:999}.wpglobus-post-status-info td{font-size:12px}.wpglobus-post-status-info .wpglobus-wp-word-count{display:block;padding:2px 10px}.wpglobus-wp-admin .wpglobus-translatable{border-left:3px solid #00f!important}.wpglobus-wp-admin .wpglobus-link-lock-icon{cursor:not-allowed}.wpglobus-wp-admin .wpglobus-link-trash-icon{cursor:not-allowed}.wpglobus-wp-admin .wpglobus-link-lock-icon:before{font-family:dashicons;font-weight:400;font-style:normal;text-decoration:inherit;content:"\f160";font-size:11px}.wpglobus-wp-admin .wpglobus-link-open-icon:before{font-family:dashicons;font-weight:400;font-style:normal;text-decoration:inherit;content:"\f504";font-size:11px}.wpglobus-wp-admin .wpglobus-link-trash-icon:before{font-family:dashicons;font-weight:400;font-style:normal;text-decoration:inherit;content:"\f182";font-size:11px}.wpglobus-wp-admin .wpglobus-spinner{background:url(images/spinner.gif) no-repeat;-webkit-background-size:20px 20px;background-size:20px 20px;display:inline-block;visibility:hidden;float:right;vertical-align:middle;opacity:.7;width:20px;height:20px;margin:0}.wpglobus-edit-slug-box{line-height:24px;min-height:25px;margin-top:5px;padding:0 10px;color:#666}.wpglobus-edit-slug-box .wpglobus-editable-post-name{background-color:#fffbcc}.wpglobus-edit-slug-box .wpglobus-editable-post-name-full{display:none}.wpglobus-edit-slug-box .wpglobus-editable-post-name input{font-size:13px;height:22px;margin-bottom:0;margin-left:0;margin-right:0;margin-top:0;width:20em}.about-wrap.wpglobus-about-wrap .wpglobus-version{color:#e38869;font-size:95%}.about-wrap.wpglobus-about-wrap .wpglobus-motto{font-style:italic}.about-wrap.wpglobus-about-wrap .wpglobus-wp{color:#23769c}.about-wrap.wpglobus-about-wrap h1.wpglobus{font-family:Georgia,serif;font-variant:small-caps;letter-spacing:1.5px}.about-wrap.wpglobus-about-wrap .wpglobus-stars{color:#e38869}.about-wrap.wpglobus-about-wrap .feature-section div{text-align:left}.toplevel_page_wpglobus_options #redux-header,.toplevel_page_wpglobus_options .redux-timer{display:none}.toplevel_page_wpglobus_options .el-move::before{display:inline-block;-webkit-font-smoothing:antialiased;font-family:dashicons;font-weight:400;font-style:normal;text-decoration:inherit;content:"\f545";border:1px solid #2866a0;color:#2866a0;background-color:#fff;margin:0 3px 0 3px;line-height:1.2;width:1.5em;text-align:center;cursor:move}.redux-container #redux-intro-text{background-color:#d3e4f4;color:#000}.redux-container #redux-intro-text h1{color:#2866a0;float:left;width:204px;margin:0;padding:0}.redux-container #redux-intro-text .wpg-bnr{width:400px}.redux-container #redux-intro-text .wpg-bnr.wpg-bnr-left{float:left}.redux-container #redux-intro-text .wpg-bnr.wpg-bnr-right{float:right}.redux-container #redux-intro-text .wpg-a-img{float:left;display:block;height:100px;border:1px solid #5999d5;background-color:#fff;margin-right:1em}.redux-container #redux-intro-text .wpg-a-img img{width:100px}.redux-container #redux-intro-text .wpg-text-block{padding-top:.3em}.redux-container #redux-intro-text .wpg-text-block .wpg-title{font-weight:700}.redux-container #redux-intro-text .wpg-text-block .wpg-body{margin:.3em 0}.redux-container #redux-intro-text .wpg-text-block .wpg-footer{font-style:italic}.customize-controls-close.wpglobus-customize-selector:before{content:""}.customize-controls-close.wpglobus-customize-selector .wpglobus-icon-globe:before{color:#00f;display:inline-block;font-family:dashicons;content:"\f319";font-size:20px}.wpglobus-customize-control,.wpglobus-customize-translatable-element,.wpglobus-customize-widget-control{border-left:3px solid #00f!important}@media screen and (max-width:640px){.customize-controls-preview-toggle{left:88px}}.yoast_help.yoast-help-button.dashicons{font-family:dashicons!important;font-size:20px!important}.wpglobus-mark{font-weight:700}.wpglobus-mark.wpglobus-warning{background-color:#ff0;color:#000}@media screen and (max-width:782px){#wpadminbar li#wp-admin-bar-wpglobus-language-select{display:block}#wpadminbar li#wp-admin-bar-wpglobus-language-select .ab-icon{margin-top:-3px}#wpadminbar li#wp-admin-bar-wpglobus-language-select .ab-icon img{height:25px}}
includes/css/wpglobus-dialog-ui.css ADDED
@@ -0,0 +1,232 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Admin dialog styles
3
+ * @package WPGlobus
4
+ */
5
+ .wpglobus-wp-admin .wpglobus-icon-globe:before {
6
+ color: #00f;
7
+ display: inline-block;
8
+ font-family: 'dashicons';
9
+ content: "\f319";
10
+ font-size: 20px;
11
+ }
12
+ .wpglobus-wp-admin .wpglobus_dialog_icon {
13
+ margin-top: 10px;
14
+ cursor: pointer;
15
+ }
16
+ .wpglobus-wp-admin.widgets-php .wpglobus_dialog_icon {
17
+ margin-top: 0;
18
+ float: right;
19
+ cursor: pointer;
20
+ }
21
+ .wpglobus-wp-admin .wpglobus_dialog_settings {
22
+ margin-top: 0;
23
+ }
24
+ .wpglobus-wp-admin .wpglobus_dialog_settings:before {
25
+ color: #00f;
26
+ display: inline-block;
27
+ font-family: 'dashicons';
28
+ content: "\f107";
29
+ font-size: 20px;
30
+ }
31
+ .wpglobus-wp-admin .wpglobus_dialog_start:before {
32
+ color: #00f;
33
+ display: inline-block;
34
+ font-family: 'dashicons';
35
+ content: "\f319";
36
+ font-size: 20px;
37
+ }
38
+ .wpglobus-wp-admin .wpglobus_dialog_start_hidden {
39
+ visibility: hidden;
40
+ width: 0;
41
+ }
42
+ .wpglobus-wp-admin .wpglobus_dialog_error:before {
43
+ color: #f00;
44
+ }
45
+ .wpglobus-wp-admin .wpglobus-dialog-tabs-list {
46
+ min-height: 3em;
47
+ }
48
+ .wpglobus-wp-admin .wpglobus-dialog-tabs li a,
49
+ .wpglobus-wp-admin .wpglobus-dialog-tabs ul li {
50
+ float: left;
51
+ margin: 0;
52
+ }
53
+ .wpglobus-wp-admin .wpglobus-dialog-tabs li.ui-state-default {
54
+ border: 0;
55
+ background: transparent;
56
+ }
57
+ .wpglobus-wp-admin .wpglobus-dialog-tabs ul li a:hover {
58
+ color: #666;
59
+ }
60
+ .wpglobus-wp-admin .wpglobus-dialog-tabs ul li.ui-state-default a {
61
+ display: block;
62
+ color: #999;
63
+ background: #f9f9f9;
64
+ background: -moz-linear-gradient(left, #f9f9f9 0%, #ececec 100%);
65
+ background: -webkit-gradient(linear, left top, right top, color-stop(0%, #f9f9f9), color-stop(100%, #ececec));
66
+ background: -webkit-linear-gradient(left, #f9f9f9 0%, #ececec 100%);
67
+ background: -o-linear-gradient(left, #f9f9f9 0%, #ececec 100%);
68
+ background: -ms-linear-gradient(left, #f9f9f9 0%, #ececec 100%);
69
+ background: linear-gradient(to right, #f9f9f9 0%, #ececec 100%);
70
+ border: 1px solid #ddd;
71
+ border-bottom: 0;
72
+ font-weight: normal;
73
+ height: 2em;
74
+ line-height: 2em;
75
+ margin-right: 5px;
76
+ padding: 0 10px;
77
+ text-decoration: none;
78
+ text-shadow: #fff 0 1px 1px;
79
+ -moz-border-radius-topleft: 3px;
80
+ -webkit-border-top-left-radius: 3px;
81
+ border-top-left-radius: 3px;
82
+ -moz-border-radius-topright: 3px;
83
+ -webkit-border-top-right-radius: 3px;
84
+ border-top-right-radius: 3px;
85
+ }
86
+ .wpglobus-wp-admin .wpglobus-dialog-tabs ul li.ui-state-active a {
87
+ background: #fff;
88
+ border: 1px solid #ccc;
89
+ border-bottom-color: #fff;
90
+ color: #464646;
91
+ margin-bottom: -1px;
92
+ font-weight: normal;
93
+ }
94
+ .wpglobus-wp-admin .wpglobus-dialog {
95
+ z-index: 1000000;
96
+ }
97
+ .wpglobus-wp-admin .wpglobus-dialog .ui-dialog-title:before {
98
+ color: #00f;
99
+ display: inline-block;
100
+ font-family: 'dashicons';
101
+ content: "\f319";
102
+ font-size: 20px;
103
+ margin-right: 0.5em;
104
+ vertical-align: bottom;
105
+ }
106
+ .wpglobus-wp-admin .wpglobus-dialog .ui-dialog-title {
107
+ font-size: 20px;
108
+ }
109
+ .wpglobus-wp-admin .wpglobus-dialog .ui-dialog-buttonpane .ui-dialog-buttonset {
110
+ float: right;
111
+ margin-bottom: 10px;
112
+ }
113
+ .wpglobus-wp-admin .wpglobus-dialog .ui-dialog-buttonpane button {
114
+ cursor: pointer;
115
+ }
116
+ .wpglobus-wp-admin .wpglobus-dialog .ui-dialog-titlebar {
117
+ cursor: move;
118
+ }
119
+ .wpglobus-wp-admin .wpglobus-dialog .wpglobus-dialog-wrapper.ui-dialog-content.ui-widget-content {
120
+ position: relative;
121
+ border: 0;
122
+ padding: .5em 1em;
123
+ background: none;
124
+ overflow: auto;
125
+ }
126
+ .wpglobus-wp-admin .wpglobus-dialog .ui-tabs .ui-tabs-panel {
127
+ border-width: 0;
128
+ padding: 0;
129
+ background: transparent;
130
+ }
131
+ .wpglobus-wp-admin .wpglobus-dialog .ui-tabs .ui-tabs-nav {
132
+ margin: 0;
133
+ padding: 0;
134
+ }
135
+ .wpglobus-wp-admin .wpglobus-dialog .ui-corner-all {
136
+ border-radius: 0;
137
+ }
138
+ .wpglobus-wp-admin .wpglobus-dialog .ui-widget-header {
139
+ border: none;
140
+ background: transparent;
141
+ color: inherit;
142
+ font-weight: normal;
143
+ }
144
+ .wpglobus-wp-admin .wpglobus-dialog .ui-widget-content {
145
+ border: none;
146
+ background: transparent;
147
+ color: inherit;
148
+ }
149
+ .wpglobus-wp-admin .wpglobus-dialog .ui-widget {
150
+ font-family: inherit;
151
+ font-size: inherit;
152
+ }
153
+ .wpglobus-wp-admin .wpglobus-dialog .ui-widget textarea {
154
+ font-family: inherit;
155
+ font-size: inherit;
156
+ }
157
+ .wpglobus-wp-admin .wpglobus-dialog .ui-tabs {
158
+ padding: 0;
159
+ }
160
+ .wpglobus-wp-admin .wpglobus-dialog .wpglobus-button-cancel,
161
+ .wpglobus-wp-admin .wpglobus-dialog .wpglobus-button-save {
162
+ border-radius: 3px;
163
+ padding: .5em 1em;
164
+ border: none;
165
+ margin-right: 1em;
166
+ }
167
+ .wpglobus-wp-admin .wpglobus-dialog .wpglobus-button-save {
168
+ color: #ffffff;
169
+ background: #2ea2cc;
170
+ }
171
+ .wpglobus-wp-admin .wpglobus-dialog .wpglobus-button-cancel {
172
+ color: #000;
173
+ background: #eee;
174
+ }
175
+ .wpglobus-wp-admin .wpglobus-dialog .ui-button-text-only .ui-button-text {
176
+ padding: 0;
177
+ }
178
+ .wpglobus-wp-admin .ui-widget-overlay {
179
+ position: fixed;
180
+ top: 0;
181
+ left: 0;
182
+ width: 100%;
183
+ height: 100%;
184
+ }
185
+ .wpglobus-wp-admin .ui-widget-overlay {
186
+ background: #aaaaaa url("images/ui-bg_flat40x100.png") 50% 50% repeat-x;
187
+ opacity: .3;
188
+ }
189
+ .wpglobus-wp-admin .ui-widget-shadow {
190
+ margin: -8px 0 0 -8px;
191
+ padding: 8px;
192
+ opacity: .3;
193
+ border-radius: 8px;
194
+ }
195
+ .wpglobus-wp-admin .ui-dialog.wpglobus-dialog {
196
+ overflow: hidden;
197
+ position: absolute;
198
+ top: 0;
199
+ left: 0;
200
+ padding: .2em;
201
+ outline: 0;
202
+ background-color: #fff;
203
+ }
204
+ .wpglobus-wp-admin .ui-dialog.wpglobus-dialog .ui-dialog-titlebar {
205
+ padding: .4em 1em;
206
+ position: relative;
207
+ height: 25px !important;
208
+ margin-bottom: 0 !important;
209
+ background-color: #e1e1e1 !important;
210
+ }
211
+ .wpglobus-wp-admin .ui-dialog.wpglobus-dialog .ui-dialog-titlebar-close {
212
+ position: absolute;
213
+ right: .3em;
214
+ top: 50%;
215
+ width: 20px;
216
+ margin: -10px 0 0 0;
217
+ padding: 1px;
218
+ height: 20px;
219
+ display: none;
220
+ }
221
+ .wpglobus-wp-admin .ui-dialog.wpglobus-dialog .ui-dialog-content textarea {
222
+ width: 100%;
223
+ min-height: 8em !important;
224
+ margin-bottom: 1em;
225
+ }
226
+ .wpglobus-wp-admin .ui-dialog.wpglobus-dialog .ui-resizable-se {
227
+ width: 12px;
228
+ height: 12px;
229
+ right: -5px;
230
+ bottom: -5px;
231
+ background-position: 16px 16px;
232
+ }
includes/css/wpglobus-dialog-ui.less ADDED
@@ -0,0 +1,277 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Admin dialog styles
3
+ * @package WPGlobus
4
+ */
5
+
6
+ .wpglobus-wp-admin {
7
+
8
+ .wpglobus-icon-globe:before {
9
+ color: #00f;
10
+ display: inline-block;
11
+ font-family: 'dashicons';
12
+ content: "\f319";
13
+ font-size: 20px;
14
+ }
15
+
16
+ .wpglobus_dialog_icon{
17
+ margin-top: 10px;
18
+ cursor: pointer;
19
+ }
20
+ &.widgets-php .wpglobus_dialog_icon {
21
+ margin-top:0;
22
+ float: right;
23
+ cursor: pointer;
24
+ }
25
+ .wpglobus_dialog_settings {
26
+ margin-top: 0;
27
+ }
28
+ .wpglobus_dialog_settings:before {
29
+ color: #00f;
30
+ display: inline-block;
31
+ font-family: 'dashicons';
32
+ content: "\f107";
33
+ font-size: 20px;
34
+ }
35
+ .wpglobus_dialog_start:before {
36
+ color: #00f;
37
+ display: inline-block;
38
+ font-family: 'dashicons';
39
+ content: "\f319";
40
+ font-size: 20px;
41
+ }
42
+ .wpglobus_dialog_start_hidden {
43
+ visibility: hidden;
44
+ width: 0;
45
+ }
46
+ .wpglobus_dialog_error:before {
47
+ color: #f00;
48
+ }
49
+ .wpglobus-dialog-tabs-list {
50
+ min-height: 3em;
51
+ }
52
+
53
+ .wpglobus-dialog-tabs {
54
+
55
+ li a, ul li {
56
+ float: left;
57
+ margin: 0;
58
+ }
59
+
60
+ li.ui-state-default {
61
+ border: 0;
62
+ background: transparent;
63
+ }
64
+
65
+ ul li a:hover {
66
+ color: #666;
67
+ }
68
+
69
+ ul li.ui-state-default a {
70
+ display: block;
71
+ color: #999;
72
+
73
+ background: #f9f9f9;
74
+ background: -moz-linear-gradient(left, #f9f9f9 0%, #ececec 100%);
75
+ background: -webkit-gradient(linear, left top, right top, color-stop(0%, #f9f9f9), color-stop(100%, #ececec));
76
+ background: -webkit-linear-gradient(left, #f9f9f9 0%, #ececec 100%);
77
+ background: -o-linear-gradient(left, #f9f9f9 0%, #ececec 100%);
78
+ background: -ms-linear-gradient(left, #f9f9f9 0%, #ececec 100%);
79
+ background: linear-gradient(to right, #f9f9f9 0%, #ececec 100%);
80
+
81
+ border: 1px solid #ddd;
82
+ border-bottom: 0;
83
+ font-weight: normal;
84
+ height: 2em;
85
+ line-height: 2em;
86
+ margin-right: 5px;
87
+ padding: 0 10px;
88
+ text-decoration: none;
89
+ text-shadow: #fff 0 1px 1px;
90
+ -moz-border-radius-topleft: 3px;
91
+ -webkit-border-top-left-radius: 3px;
92
+ border-top-left-radius: 3px;
93
+ -moz-border-radius-topright: 3px;
94
+ -webkit-border-top-right-radius: 3px;
95
+ border-top-right-radius: 3px;
96
+ }
97
+
98
+ ul li.ui-state-active a {
99
+ background: #fff;
100
+ border: 1px solid #ccc;
101
+ border-bottom-color: #fff;
102
+ color: #464646;
103
+ margin-bottom: -1px;
104
+ font-weight: normal;
105
+ }
106
+
107
+ }
108
+
109
+ .wpglobus-dialog {
110
+
111
+ z-index: 1000000;
112
+
113
+ .ui-dialog-title:before {
114
+ color: #00f;
115
+ display: inline-block;
116
+ font-family: 'dashicons';
117
+ content: "\f319";
118
+ font-size: 20px;
119
+ margin-right: 0.5em;
120
+ vertical-align: bottom;
121
+ }
122
+ .ui-dialog-title {
123
+ font-size: 20px;
124
+ }
125
+ .ui-dialog-buttonpane .ui-dialog-buttonset {
126
+ float: right;
127
+ margin-bottom: 10px;
128
+ }
129
+
130
+ .ui-dialog-buttonpane button {
131
+ cursor: pointer;
132
+ }
133
+
134
+ .ui-dialog-titlebar {
135
+ cursor: move;
136
+ }
137
+
138
+ .wpglobus-dialog-wrapper.ui-dialog-content.ui-widget-content {
139
+ position: relative;
140
+ border: 0;
141
+ padding: .5em 1em;
142
+ background: none;
143
+ overflow: auto;
144
+ }
145
+
146
+ .ui-tabs .ui-tabs-panel {
147
+ border-width: 0;
148
+ padding: 0;
149
+ background: transparent;
150
+ }
151
+
152
+ .ui-tabs .ui-tabs-nav {
153
+ margin: 0;
154
+ padding: 0;
155
+ }
156
+
157
+ .ui-corner-all {
158
+ border-radius: 0;
159
+ }
160
+
161
+ .ui-widget-header {
162
+ border: none;
163
+ background: transparent;
164
+ color: inherit;
165
+ font-weight: normal;
166
+ }
167
+
168
+ .ui-widget-content {
169
+ border: none;
170
+ background: transparent;
171
+ color: inherit;
172
+ }
173
+
174
+ .ui-widget {
175
+ font-family: inherit;
176
+ font-size: inherit;
177
+ textarea {
178
+ font-family: inherit;
179
+ font-size: inherit;
180
+ }
181
+ }
182
+
183
+ .ui-tabs {
184
+ padding: 0;
185
+ }
186
+
187
+ //
188
+ // Button styles
189
+ //
190
+ .wpglobus-button-cancel,
191
+ .wpglobus-button-save {
192
+ border-radius: 3px;
193
+ padding: .5em 1em;
194
+ border: none;
195
+ margin-right: 1em;
196
+ }
197
+
198
+ .wpglobus-button-save {
199
+ color: #ffffff;
200
+ background: #2ea2cc;
201
+ }
202
+
203
+ .wpglobus-button-cancel {
204
+ color: #000;
205
+ background: #eee;
206
+ }
207
+
208
+ .ui-button-text-only .ui-button-text {
209
+ padding: 0;
210
+ }
211
+
212
+ }
213
+
214
+ // Overlays
215
+ .ui-widget-overlay {
216
+ position: fixed;
217
+ top: 0;
218
+ left: 0;
219
+ width: 100%;
220
+ height: 100%;
221
+ }
222
+ .ui-widget-overlay {
223
+ background: #aaaaaa url("images/ui-bg_flat40x100.png") 50% 50% repeat-x;
224
+ opacity: .3;
225
+ }
226
+ .ui-widget-shadow {
227
+ margin: -8px 0 0 -8px;
228
+ padding: 8px;
229
+ opacity: .3;
230
+ border-radius: 8px;
231
+ }
232
+
233
+ .ui-dialog.wpglobus-dialog {
234
+ overflow: hidden;
235
+ position: absolute;
236
+ top: 0;
237
+ left: 0;
238
+ padding: .2em;
239
+ outline: 0;
240
+ background-color: #fff;
241
+
242
+ .ui-dialog-titlebar {
243
+ padding: .4em 1em;
244
+ position: relative;
245
+ height: 25px !important;
246
+ margin-bottom: 0 !important;
247
+ background-color: #e1e1e1 !important;
248
+ }
249
+
250
+ .ui-dialog-titlebar-close {
251
+ position: absolute;
252
+ right: .3em;
253
+ top: 50%;
254
+ width: 20px;
255
+ margin: -10px 0 0 0;
256
+ padding: 1px;
257
+ height: 20px;
258
+ display: none;
259
+ }
260
+ .ui-dialog-content textarea {
261
+ width: 100%;
262
+ min-height: 8em !important;
263
+ margin-bottom: 1em;
264
+ }
265
+ .ui-resizable-se {
266
+ width: 12px;
267
+ height: 12px;
268
+ right: -5px;
269
+ bottom: -5px;
270
+ background-position: 16px 16px;
271
+ }
272
+
273
+ }
274
+
275
+ }
276
+
277
+ // --- EOF
includes/css/wpglobus-dialog-ui.min.css ADDED
@@ -0,0 +1 @@
 
1
+ .wpglobus-wp-admin .wpglobus-icon-globe:before{color:#00f;display:inline-block;font-family:dashicons;content:"\f319";font-size:20px}.wpglobus-wp-admin .wpglobus_dialog_icon{margin-top:10px;cursor:pointer}.wpglobus-wp-admin.widgets-php .wpglobus_dialog_icon{margin-top:0;float:right;cursor:pointer}.wpglobus-wp-admin .wpglobus_dialog_settings{margin-top:0}.wpglobus-wp-admin .wpglobus_dialog_settings:before{color:#00f;display:inline-block;font-family:dashicons;content:"\f107";font-size:20px}.wpglobus-wp-admin .wpglobus_dialog_start:before{color:#00f;display:inline-block;font-family:dashicons;content:"\f319";font-size:20px}.wpglobus-wp-admin .wpglobus_dialog_start_hidden{visibility:hidden;width:0}.wpglobus-wp-admin .wpglobus_dialog_error:before{color:red}.wpglobus-wp-admin .wpglobus-dialog-tabs-list{min-height:3em}.wpglobus-wp-admin .wpglobus-dialog-tabs li a,.wpglobus-wp-admin .wpglobus-dialog-tabs ul li{float:left;margin:0}.wpglobus-wp-admin .wpglobus-dialog-tabs li.ui-state-default{border:0;background:0 0}.wpglobus-wp-admin .wpglobus-dialog-tabs ul li a:hover{color:#666}.wpglobus-wp-admin .wpglobus-dialog-tabs ul li.ui-state-default a{display:block;color:#999;background:#f9f9f9;background:-moz-linear-gradient(left,#f9f9f9 0,#ececec 100%);background:-webkit-gradient(linear,left top,right top,color-stop(0,#f9f9f9),color-stop(100%,#ececec));background:-webkit-linear-gradient(left,#f9f9f9 0,#ececec 100%);background:-o-linear-gradient(left,#f9f9f9 0,#ececec 100%);background:-ms-linear-gradient(left,#f9f9f9 0,#ececec 100%);background:linear-gradient(to right,#f9f9f9 0,#ececec 100%);border:1px solid #ddd;border-bottom:0;font-weight:400;height:2em;line-height:2em;margin-right:5px;padding:0 10px;text-decoration:none;text-shadow:#fff 0 1px 1px;-moz-border-radius-topleft:3px;-webkit-border-top-left-radius:3px;border-top-left-radius:3px;-moz-border-radius-topright:3px;-webkit-border-top-right-radius:3px;border-top-right-radius:3px}.wpglobus-wp-admin .wpglobus-dialog-tabs ul li.ui-state-active a{background:#fff;border:1px solid #ccc;border-bottom-color:#fff;color:#464646;margin-bottom:-1px;font-weight:400}.wpglobus-wp-admin .wpglobus-dialog{z-index:1000000}.wpglobus-wp-admin .wpglobus-dialog .ui-dialog-title:before{color:#00f;display:inline-block;font-family:dashicons;content:"\f319";font-size:20px;margin-right:.5em;vertical-align:bottom}.wpglobus-wp-admin .wpglobus-dialog .ui-dialog-title{font-size:20px}.wpglobus-wp-admin .wpglobus-dialog .ui-dialog-buttonpane .ui-dialog-buttonset{float:right;margin-bottom:10px}.wpglobus-wp-admin .wpglobus-dialog .ui-dialog-buttonpane button{cursor:pointer}.wpglobus-wp-admin .wpglobus-dialog .ui-dialog-titlebar{cursor:move}.wpglobus-wp-admin .wpglobus-dialog .wpglobus-dialog-wrapper.ui-dialog-content.ui-widget-content{position:relative;border:0;padding:.5em 1em;background:0 0;overflow:auto}.wpglobus-wp-admin .wpglobus-dialog .ui-tabs .ui-tabs-panel{border-width:0;padding:0;background:0 0}.wpglobus-wp-admin .wpglobus-dialog .ui-tabs .ui-tabs-nav{margin:0;padding:0}.wpglobus-wp-admin .wpglobus-dialog .ui-corner-all{border-radius:0}.wpglobus-wp-admin .wpglobus-dialog .ui-widget-header{border:none;background:0 0;color:inherit;font-weight:400}.wpglobus-wp-admin .wpglobus-dialog .ui-widget-content{border:none;background:0 0;color:inherit}.wpglobus-wp-admin .wpglobus-dialog .ui-widget{font-family:inherit;font-size:inherit}.wpglobus-wp-admin .wpglobus-dialog .ui-widget textarea{font-family:inherit;font-size:inherit}.wpglobus-wp-admin .wpglobus-dialog .ui-tabs{padding:0}.wpglobus-wp-admin .wpglobus-dialog .wpglobus-button-cancel,.wpglobus-wp-admin .wpglobus-dialog .wpglobus-button-save{border-radius:3px;padding:.5em 1em;border:none;margin-right:1em}.wpglobus-wp-admin .wpglobus-dialog .wpglobus-button-save{color:#fff;background:#2ea2cc}.wpglobus-wp-admin .wpglobus-dialog .wpglobus-button-cancel{color:#000;background:#eee}.wpglobus-wp-admin .wpglobus-dialog .ui-button-text-only .ui-button-text{padding:0}.wpglobus-wp-admin .ui-widget-overlay{position:fixed;top:0;left:0;width:100%;height:100%}.wpglobus-wp-admin .ui-widget-overlay{background:#aaa url(images/ui-bg_flat40x100.png) 50% 50% repeat-x;opacity:.3}.wpglobus-wp-admin .ui-widget-shadow{margin:-8px 0 0 -8px;padding:8px;opacity:.3;border-radius:8px}.wpglobus-wp-admin .ui-dialog.wpglobus-dialog{overflow:hidden;position:absolute;top:0;left:0;padding:.2em;outline:0;background-color:#fff}.wpglobus-wp-admin .ui-dialog.wpglobus-dialog .ui-dialog-titlebar{padding:.4em 1em;position:relative;height:25px!important;margin-bottom:0!important;background-color:#e1e1e1!important}.wpglobus-wp-admin .ui-dialog.wpglobus-dialog .ui-dialog-titlebar-close{position:absolute;right:.3em;top:50%;width:20px;margin:-10px 0 0 0;padding:1px;height:20px;display:none}.wpglobus-wp-admin .ui-dialog.wpglobus-dialog .ui-dialog-content textarea{width:100%;min-height:8em!important;margin-bottom:1em}.wpglobus-wp-admin .ui-dialog.wpglobus-dialog .ui-resizable-se{width:12px;height:12px;right:-5px;bottom:-5px;background-position:16px 16px}
includes/css/wpglobus-flags.mixin.less ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * CSS for flags
3
+ * @package WPGlobus
4
+ */
5
+
6
+ .wpglobus_flag {
7
+ height: 12px;
8
+ width: 18px;
9
+ background-repeat: no-repeat;
10
+ background-position: center left;
11
+ }
12
+
13
+ .wpglobus_language_name {
14
+ padding-left: 22px;
15
+ }
16
+
17
+ // css rules for nav menu which was created from pages
18
+ // .page_item_wpglobus_menu_switch {width:80px;}
19
+ .page_item_wpglobus_menu_switch .children {
20
+ display: none;
21
+ }
22
+
23
+ .page_item_wpglobus_menu_switch:hover .children {
24
+ display: block;
25
+ }
26
+
27
+ // css rules for nav menu which was created in wp-admin/nav-menus.php
28
+ // .menu_item_wpglobus_menu_switch {width:80px;}
29
+ .menu_item_wpglobus_menu_switch .sub-menu {
30
+ display: none;
31
+ }
32
+
33
+ .menu_item_wpglobus_menu_switch:hover .sub-menu {
34
+ display: block;
35
+ }
36
+
37
+ // --- EOF
includes/css/wpglobus-special-pages.css ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* wpglobus-addons page */
2
+ .addons-wrap .products {
3
+ overflow: hidden;
4
+ }
5
+ .addons-wrap .products li {
6
+ float: left;
7
+ margin: 0 1em 1em 0 !important;
8
+ padding: 0;
9
+ vertical-align: top;
10
+ width: 300px;
11
+ }
12
+ .addons-wrap .products li a {
13
+ text-decoration: none;
14
+ color: inherit;
15
+ border: 1px solid #ddd;
16
+ display: block;
17
+ min-height: 220px;
18
+ overflow: hidden;
19
+ background: #f5f5f5;
20
+ -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), inset 0 -1px 0 rgba(0, 0, 0, 0.1);
21
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), inset 0 -1px 0 rgba(0, 0, 0, 0.1);
22
+ }
23
+ .addons-wrap .products li a img {
24
+ max-width: 258px;
25
+ max-height: 24px;
26
+ padding: 17px 20px;
27
+ display: block;
28
+ margin: 0;
29
+ background: #fff;
30
+ border-right: 260px solid #fff;
31
+ }
32
+ .addons-wrap .products li a img.own-thumb {
33
+ max-width: 300px;
34
+ max-height: 300px;
35
+ background: #f5f5f5;
36
+ padding: 0;
37
+ }
38
+ .addons-wrap .products li a img.extension-thumb + h3 {
39
+ display: none;
40
+ }
41
+ .addons-wrap .products li a .price {
42
+ display: none;
43
+ }
44
+ .addons-wrap .products li a h3 {
45
+ margin: 0 !important;
46
+ padding: 20px !important;
47
+ background: #fff;
48
+ }
49
+ .addons-wrap .products li a p {
50
+ padding: 20px !important;
51
+ margin: 0 !important;
52
+ border-top: 1px solid #f1f1f1;
53
+ }
54
+ .addons-wrap .products li a:hover,
55
+ .addons-wrap .products li a:focus {
56
+ background-color: #fff;
57
+ }
includes/css/wpglobus-special-pages.less ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* wpglobus-addons page */
2
+ .addons-wrap {
3
+ .products {
4
+ overflow: hidden;
5
+ li {
6
+ float: left;
7
+ margin: 0 1em 1em 0 !important;
8
+ padding: 0;
9
+ vertical-align: top;
10
+ width: 300px;
11
+
12
+ a {
13
+ text-decoration: none;
14
+ color: inherit;
15
+ border: 1px solid #ddd;
16
+ display: block;
17
+ min-height: 220px;
18
+ overflow: hidden;
19
+ background: #f5f5f5;
20
+ -webkit-box-shadow:
21
+ inset 0 1px 0 rgba(255,255,255,0.2),
22
+ inset 0 -1px 0 rgba(0,0,0,0.1);
23
+ box-shadow:
24
+ inset 0 1px 0 rgba(255,255,255,0.2),
25
+ inset 0 -1px 0 rgba(0,0,0,0.1);
26
+
27
+ img {
28
+ max-width: 258px;
29
+ max-height: 24px;
30
+ padding: 17px 20px;
31
+ display: block;
32
+ margin: 0;
33
+ background: #fff;
34
+ border-right: 260px solid #fff;
35
+ }
36
+ img.own-thumb {
37
+ max-width: 300px;
38
+ max-height: 300px;
39
+ background: #f5f5f5;
40
+ padding: 0;
41
+ }
42
+ img.extension-thumb+h3 {
43
+ display: none;
44
+ }
45
+ .price {
46
+ display: none;
47
+ }
48
+ h3 {
49
+ margin: 0 !important;
50
+ padding: 20px !important;
51
+ background: #fff;
52
+ }
53
+ p {
54
+ padding: 20px !important;
55
+ margin: 0 !important;
56
+ border-top: 1px solid #f1f1f1;
57
+ }
58
+ &:hover, &:focus {
59
+ background-color: #fff;
60
+ }
61
+ }
62
+ }
63
+ }
64
+ }
includes/css/wpglobus-special-pages.min.css ADDED
@@ -0,0 +1 @@
 
1
+ .addons-wrap .products{overflow:hidden}.addons-wrap .products li{float:left;margin:0 1em 1em 0!important;padding:0;vertical-align:top;width:300px}.addons-wrap .products li a{text-decoration:none;color:inherit;border:1px solid #ddd;display:block;min-height:220px;overflow:hidden;background:#f5f5f5;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),inset 0 -1px 0 rgba(0,0,0,.1);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),inset 0 -1px 0 rgba(0,0,0,.1)}.addons-wrap .products li a img{max-width:258px;max-height:24px;padding:17px 20px;display:block;margin:0;background:#fff;border-right:260px solid #fff}.addons-wrap .products li a img.own-thumb{max-width:300px;max-height:300px;background:#f5f5f5;padding:0}.addons-wrap .products li a img.extension-thumb+h3{display:none}.addons-wrap .products li a .price{display:none}.addons-wrap .products li a h3{margin:0!important;padding:20px!important;background:#fff}.addons-wrap .products li a p{padding:20px!important;margin:0!important;border-top:1px solid #f1f1f1}.addons-wrap .products li a:focus,.addons-wrap .products li a:hover{background-color:#fff}
includes/css/wpglobus-widget.mixin.less ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ///
2
+ // @see WPGlobusWidget::widget
3
+ //
4
+
5
+ //
6
+ // case 'flags' :
7
+ //
8
+ .widget_wpglobus {
9
+ .flags-styled {
10
+ // text-align: center;
11
+
12
+ .flag {
13
+ margin-right: 0.4em;
14
+ }
15
+ }
16
+
17
+ //
18
+ // class = "list"
19
+ //
20
+ .list {
21
+ a {
22
+ display: block;
23
+ img {
24
+ display: none;
25
+ }
26
+ span.name {
27
+ display: inline-block;
28
+ }
29
+ span.code {
30
+ display: inline-block;
31
+ margin: 0 0 0 4px;
32
+ &:before {
33
+ content: "(";
34
+ }
35
+ &:after {
36
+ content: ")";
37
+ }
38
+ }
39
+ }
40
+ //
41
+ // class = "list flags"
42
+ //
43
+ &.flags {
44
+ img {
45
+ margin: 0 4px 0 0;
46
+ display: inline-block;
47
+ }
48
+ }
49
+ }
50
+
51
+ //
52
+ // case 'select' :
53
+ // case 'select_with_code' :
54
+ //
55
+ .select-styled {
56
+ // width: 100%;
57
+ // width: 130px;
58
+ // height: 34px;
59
+ // border: 1px solid #111;
60
+ // border-radius: 5px;
61
+ overflow: hidden;
62
+ // margin: 0 auto;
63
+
64
+ // select {
65
+ // width: 100%;
66
+ // margin-top: 0;
67
+ // background: #eee;
68
+ // width: 150px;
69
+ // font-size: 16px;
70
+ // border: 1px solid #ccc;
71
+ // height: 34px;
72
+ // }
73
+ }
74
+
75
+ .dropdown-styled {
76
+ text-align: center;
77
+ display: inline;
78
+ list-style: none;
79
+
80
+ li {
81
+ text-align: left;
82
+ display: inline-block;
83
+ margin-right: -4px;
84
+ position: relative;
85
+ padding: 5px 10px;
86
+ background: #fff;
87
+ cursor: pointer;
88
+
89
+ &:hover {
90
+ background: #eee;
91
+ color: #fff;
92
+
93
+ ul {
94
+ display: block;
95
+ opacity: 1;
96
+ visibility: visible;
97
+ }
98
+ }
99
+
100
+ ul {
101
+ padding: 0;
102
+ position: absolute;
103
+ top: 28px;
104
+ left: -21px;
105
+ width: 150px;
106
+ display: none;
107
+ opacity: 0;
108
+ visibility: hidden;
109
+
110
+ li {
111
+ background: #eee;
112
+ display: block;
113
+ color: #fff;
114
+
115
+ &:hover {
116
+ background: #ddd;
117
+
118
+ }
119
+ }
120
+ }
121
+ }
122
+ }
123
+ }
124
+
includes/css/wpglobus.css ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * CSS for flags
3
+ * @package WPGlobus
4
+ */
5
+ .wpglobus_flag {
6
+ height: 12px;
7
+ width: 18px;
8
+ background-repeat: no-repeat;
9
+ background-position: center left;
10
+ }
11
+ .wpglobus_language_name {
12
+ padding-left: 22px;
13
+ }
14
+ .page_item_wpglobus_menu_switch .children {
15
+ display: none;
16
+ }
17
+ .page_item_wpglobus_menu_switch:hover .children {
18
+ display: block;
19
+ }
20
+ .menu_item_wpglobus_menu_switch .sub-menu {
21
+ display: none;
22
+ }
23
+ .menu_item_wpglobus_menu_switch:hover .sub-menu {
24
+ display: block;
25
+ }
26
+ .widget_wpglobus .flags-styled .flag {
27
+ margin-right: 0.4em;
28
+ }
29
+ .widget_wpglobus .list a {
30
+ display: block;
31
+ }
32
+ .widget_wpglobus .list a img {
33
+ display: none;
34
+ }
35
+ .widget_wpglobus .list a span.name {
36
+ display: inline-block;
37
+ }
38
+ .widget_wpglobus .list a span.code {
39
+ display: inline-block;
40
+ margin: 0 0 0 4px;
41
+ }
42
+ .widget_wpglobus .list a span.code:before {
43
+ content: "(";
44
+ }
45
+ .widget_wpglobus .list a span.code:after {
46
+ content: ")";
47
+ }
48
+ .widget_wpglobus .list.flags img {
49
+ margin: 0 4px 0 0;
50
+ display: inline-block;
51
+ }
52
+ .widget_wpglobus .select-styled {
53
+ overflow: hidden;
54
+ }
55
+ .widget_wpglobus .dropdown-styled {
56
+ text-align: center;
57
+ display: inline;
58
+ list-style: none;
59
+ }
60
+ .widget_wpglobus .dropdown-styled li {
61
+ text-align: left;
62
+ display: inline-block;
63
+ margin-right: -4px;
64
+ position: relative;
65
+ padding: 5px 10px;
66
+ background: #fff;
67
+ cursor: pointer;
68
+ }
69
+ .widget_wpglobus .dropdown-styled li:hover {
70
+ background: #eee;
71
+ color: #fff;
72
+ }
73
+ .widget_wpglobus .dropdown-styled li:hover ul {
74
+ display: block;
75
+ opacity: 1;
76
+ visibility: visible;
77
+ }
78
+ .widget_wpglobus .dropdown-styled li ul {
79
+ padding: 0;
80
+ position: absolute;
81
+ top: 28px;
82
+ left: -21px;
83
+ width: 150px;
84
+ display: none;
85
+ opacity: 0;
86
+ visibility: hidden;
87
+ }
88
+ .widget_wpglobus .dropdown-styled li ul li {
89
+ background: #eee;
90
+ display: block;
91
+ color: #fff;
92
+ }
93
+ .widget_wpglobus .dropdown-styled li ul li:hover {
94
+ background: #ddd;
95
+ }
includes/css/wpglobus.less ADDED
@@ -0,0 +1,2 @@
 
 
1
+ @import 'wpglobus-flags.mixin.less';
2
+ @import 'wpglobus-widget.mixin.less';
includes/css/wpglobus.min.css ADDED
@@ -0,0 +1 @@
 
1
+ .wpglobus_flag{height:12px;width:18px;background-repeat:no-repeat;background-position:center left}.wpglobus_language_name{padding-left:22px}.page_item_wpglobus_menu_switch .children{display:none}.page_item_wpglobus_menu_switch:hover .children{display:block}.menu_item_wpglobus_menu_switch .sub-menu{display:none}.menu_item_wpglobus_menu_switch:hover .sub-menu{display:block}.widget_wpglobus .flags-styled .flag{margin-right:.4em}.widget_wpglobus .list a{display:block}.widget_wpglobus .list a img{display:none}.widget_wpglobus .list a span.name{display:inline-block}.widget_wpglobus .list a span.code{display:inline-block;margin:0 0 0 4px}.widget_wpglobus .list a span.code:before{content:"("}.widget_wpglobus .list a span.code:after{content:")"}.widget_wpglobus .list.flags img{margin:0 4px 0 0;display:inline-block}.widget_wpglobus .select-styled{overflow:hidden}.widget_wpglobus .dropdown-styled{text-align:center;display:inline;list-style:none}.widget_wpglobus .dropdown-styled li{text-align:left;display:inline-block;margin-right:-4px;position:relative;padding:5px 10px;background:#fff;cursor:pointer}.widget_wpglobus .dropdown-styled li:hover{background:#eee;color:#fff}.widget_wpglobus .dropdown-styled li:hover ul{display:block;opacity:1;visibility:visible}.widget_wpglobus .dropdown-styled li ul{padding:0;position:absolute;top:28px;left:-21px;width:150px;display:none;opacity:0;visibility:hidden}.widget_wpglobus .dropdown-styled li ul li{background:#eee;display:block;color:#fff}.widget_wpglobus .dropdown-styled li ul li:hover{background:#ddd}
includes/js/wpglobus-admin-47.js ADDED
@@ -0,0 +1,1649 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * WPGlobus Administration Core, Dialog, Admin
3
+ * Interface JS functions
4
+ *
5
+ * @since 1.7.0
6
+ *
7
+ * @package WPGlobus
8
+ * @subpackage Administration
9
+ */
10
+ /*jslint browser: true*/
11
+ /*global jQuery, console, WPGlobusCore, WPGlobusDialogApp, WPGlobusAdmin, inlineEditPost */
12
+
13
+ var WPGlobusCore;
14
+
15
+ (function($) {
16
+ var api;
17
+ api = WPGlobusCore = {
18
+ strpos: function( haystack, needle, offset){
19
+ haystack = "" + haystack;
20
+ var i = haystack.indexOf( needle, offset );
21
+ return i >= 0 ? i : false;
22
+ },
23
+
24
+ TextFilter: function(text, language, return_in){
25
+ if ( typeof text == 'undefined' || '' === text ) { return text; }
26
+
27
+ var pos_start, pos_end, possible_delimiters = [], is_local_text_found = false;;
28
+
29
+ language = '' == language ? 'en' : language;
30
+ return_in = typeof return_in == 'undefined' || '' == return_in ? 'RETURN_IN_DEFAULT_LANGUAGE' : return_in;
31
+
32
+ possible_delimiters[0] = [];
33
+ possible_delimiters[0]['start'] = WPGlobusCoreData.locale_tag_start.replace('%s', language);
34
+ possible_delimiters[0]['end'] = WPGlobusCoreData.locale_tag_end;
35
+
36
+ possible_delimiters[1] = [];
37
+ possible_delimiters[1]['start'] = '<!--:'+language+'-->';
38
+ possible_delimiters[1]['end'] = '<!--:-->';
39
+
40
+ possible_delimiters[2] = [];
41
+ possible_delimiters[2]['start'] = '[:'+language+']';
42
+ possible_delimiters[2]['end'] = '[:';
43
+
44
+
45
+
46
+ for (var i = 0; i < 3; i++) {
47
+
48
+ pos_start = api.strpos( text, possible_delimiters[i]['start'] );
49
+ if ( pos_start === false ) {
50
+ continue;
51
+ }
52
+
53
+ pos_start = pos_start + possible_delimiters[i]['start'].length;
54
+
55
+ pos_end = api.strpos( text, possible_delimiters[i]['end'], pos_start );
56
+
57
+ if ( pos_end === false ) {
58
+ text = text.substr( pos_start );
59
+ } else {
60
+ text = text.substr( pos_start, pos_end - pos_start );
61
+ }
62
+
63
+ is_local_text_found = true;
64
+ break;
65
+
66
+ }
67
+
68
+ if ( ! is_local_text_found ) {
69
+ if ( return_in == 'RETURN_EMPTY' ) {
70
+ if ( language == WPGlobusCoreData.default_language && ! /(\{:|\[:|<!--:)[a-z]{2}/.test(text) ) {
71
+ /** do nothing */
72
+ } else {
73
+ text = '';
74
+ }
75
+ } else {
76
+ /**
77
+ * Try RETURN_IN_DEFAULT_LANGUAGE.
78
+ */
79
+ if ( language == WPGlobusCoreData.default_language ) {
80
+ if ( /(\{:|\[:|<!--:)[a-z]{2}/.test(text) ) {
81
+ text = '';
82
+ }
83
+ } else {
84
+ text = api.TextFilter( text, WPGlobusCoreData.default_language );
85
+ }
86
+ }
87
+ }
88
+ return text;
89
+ },
90
+ addLocaleMarks: function(text, language) {
91
+ return WPGlobusCoreData.locale_tag_start.replace('%s', language) + text + WPGlobusCoreData.locale_tag_end;
92
+ },
93
+ getTranslations: function(text) {
94
+ var t = {},
95
+ return_in;
96
+ $.each(WPGlobusCoreData.enabled_languages, function(i,l){
97
+ return_in = l == WPGlobusCoreData.default_language ? 'RETURN_IN_DEFAULT_LANGUAGE' : 'RETURN_EMPTY';
98
+ t[l] = api.TextFilter(text, l, return_in);
99
+ });
100
+ return t;
101
+ },
102
+ getString: function(s, newVal, l) {
103
+ if ( 'undefined' === typeof(s) ) {
104
+ return s;
105
+ }
106
+ if ( 'undefined' === typeof(newVal) ) {
107
+ newVal = '';
108
+ }
109
+ if ( 'undefined' === typeof(l) ) {
110
+ l = WPGlobusCoreData.language;
111
+ }
112
+
113
+ s = api.getTranslations(s);
114
+ s[l] = newVal;
115
+
116
+ var cS = '';
117
+
118
+ $.each(s, function(ln,val){
119
+ if ( '' != val && ln != WPGlobusCoreData.default_language) {
120
+ cS += api.addLocaleMarks(val, ln);
121
+ }
122
+ });
123
+
124
+ if ( '' != s[WPGlobusCoreData.default_language] ) {
125
+ if ( '' == cS ) {
126
+ cS = s[WPGlobusCoreData.default_language];
127
+ } else {
128
+ cS = api.addLocaleMarks(s[WPGlobusCoreData.default_language], WPGlobusCoreData.default_language) + cS;
129
+ }
130
+ }
131
+ return cS;
132
+ }
133
+ };
134
+ })(jQuery);
135
+
136
+ var WPGlobusDialogApp;
137
+
138
+ (function($) {
139
+
140
+ var api;
141
+ api = WPGlobusDialogApp = {
142
+ option : {
143
+ listenClass : '.wpglobus_dialog_start',
144
+ settingsClass : '.wpglobus_dialog_settings',
145
+ dialogTabs: '#wpglobus-dialog-tabs',
146
+ dialogTitle: '',
147
+ customData: null,
148
+ callback: function(){},
149
+ dialogOptions: {
150
+ title: '',
151
+ placeholder: '',
152
+ formFooter: '',
153
+ beforeOpen: function(){},
154
+ close: function(){},
155
+ },
156
+ dialog: {}
157
+ },
158
+ form : undefined,
159
+ element : undefined,
160
+ element_by : 'id',
161
+ id : '',
162
+ clone_id: '',
163
+ wpglobus_id : '',
164
+ type : 'textarea',
165
+ source : '',
166
+ order : {},
167
+ value : {},
168
+ request : 'core',
169
+ attrs: {},
170
+ dialogTitle: '',
171
+ trClass: 'wpglobus-translatable',
172
+ startButton: [
173
+ '<span id="wpglobus-dialog-start-{{clone_id}}" ',
174
+ 'style="{{style}}" ',
175
+ 'data-type="control" data-dialog-title="{{title}}" ',
176
+ 'data-source-type="" data-source-id="{{id}}" data-source-name="{{name}}" ',
177
+ 'data-nodename="{{nodename}}"',
178
+ '{{sbTitle}} ',
179
+ 'class="{{classes}}"></span>'
180
+ ].join(''),
181
+ startButtonClass : 'wpglobus_dialog_start wpglobus_dialog_icon',
182
+ clicks: 0,
183
+ init: function(args) {
184
+ api.option.dialog = api.option.dialogOptions;
185
+ api.option = $.extend(api.option, args);
186
+ $(api.option.dialogTabs).tabs();
187
+ api.dialogTitle = api.option.dialogTitle;
188
+ this.attachListener();
189
+ if ( api.option.customData != null && typeof api.option.customData.addElements != 'undefined' ) {
190
+ $.each(api.option.customData.addElements, function(i,e) {
191
+ api.addElement(e);
192
+ });
193
+ }
194
+ },
195
+ convertToId: function(s){
196
+ s = s.replace(/\]/g,'');
197
+ s = s.replace(/\[/g,'-');
198
+ return s;
199
+ },
200
+ addElement: function(elem) {
201
+ var option = {
202
+ id: null,
203
+ style: '',
204
+ styleTextareaWrapper: '',
205
+ sbTitle: '',
206
+ onChangeClass: '',
207
+ dialogTitle: '',
208
+ dialog: api.option.dialogOptions
209
+ }
210
+ if ( 'string' == typeof(elem) ) {
211
+ option.id = elem;
212
+ } else if ( 'object' == typeof(elem) ) {
213
+ option = $.extend(option, elem);
214
+ } else {
215
+ return;
216
+ }
217
+
218
+ var $element = null, id = null, name = null, node = null,
219
+ sb = api.startButton,
220
+ clone, v, style, nodeName = '';
221
+
222
+ api.element_by = 'name';
223
+ node = document.getElementsByName(option.id);
224
+
225
+ if ( 0 == node.length ) {
226
+ api.element_by = 'id';
227
+ node = document.getElementById(option.id);
228
+ }
229
+
230
+ if ( null === node ) {
231
+ return;
232
+ } else {
233
+ id = option.id;
234
+ if ( 'id' == api.element_by ) {
235
+ $element = $('#'+id);
236
+ } else {
237
+ nodeName = node[0].nodeName;
238
+ nodeName = nodeName.toLowerCase();
239
+ $element = $(nodeName+'[name="'+id+'"]');
240
+ }
241
+ }
242
+
243
+ if ( 'undefined' === typeof $element.attr('name') || '' == $element.attr('name') ) {
244
+ name = id;
245
+ } else {
246
+ name = $element.attr('name');
247
+ }
248
+ api.clone_id = api.convertToId(id);
249
+
250
+ if ( -1 != name.indexOf( 'wpglobus' ) || -1 != api.clone_id.indexOf( 'wpglobus' ) ) {
251
+ /**
252
+ * To prevent add element to itself.
253
+ */
254
+ return false;
255
+ }
256
+
257
+ if ( $( '#wpglobus-'+api.clone_id ).length > 0 ) {
258
+ /**
259
+ * WPGlobus element exists already.
260
+ */
261
+ return false;
262
+ }
263
+ if ( $( nodeName+'[name="wpglobus-'+name+'"]' ).length > 0 ) {
264
+ /**
265
+ * WPGlobus element exists already.
266
+ */
267
+ return false;
268
+ }
269
+
270
+ clone = $( $element.clone() );
271
+ //$element.addClass('hidden');
272
+ style = $element.attr('style') || '';
273
+ $element.attr( 'style', 'display:none;' );
274
+ clone.attr( 'id', 'wpglobus-'+api.clone_id ).attr( 'name', 'wpglobus-'+name );
275
+
276
+ /**
277
+ * Add WPGlobus translatable class.
278
+ */
279
+ clone.addClass( api.trClass );
280
+
281
+ if ( option.onChangeClass != '' ) {
282
+ /**
283
+ * add class to bind 'change' event
284
+ */
285
+ clone.addClass( option.onChangeClass );
286
+ }
287
+
288
+ if ( 'id' == api.element_by ) {
289
+ clone.attr('data-source-id', id).attr('data-source-name', '').attr('data-source-get-by',api.element_by);
290
+ } else {
291
+ clone.attr('data-source-id', '').attr('data-source-name', name).attr('data-source-get-by',api.element_by);
292
+ }
293
+
294
+ if ( 'textarea' == nodeName ) {
295
+ v = WPGlobusCore.getTranslations( $element.val() )[WPGlobusCoreData['language']];
296
+ clone.val( v );
297
+ clone.attr( 'data-nodename', 'textarea' );
298
+ if ( '' == option.style ) {
299
+ clone.attr( 'style', style + ';width:95%;float:left;' );
300
+ } else {
301
+ clone.attr( 'style', style + ';' + option.style );
302
+ }
303
+ } else {
304
+ v = WPGlobusCore.getTranslations( $element.val() )[WPGlobusCoreData['language']];
305
+ clone.attr( 'value', v );
306
+ clone.attr( 'data-nodename', 'input' );
307
+ if ( '' != option.style ) {
308
+ clone.attr( 'style', style + ';' + option.style );
309
+ }
310
+ }
311
+
312
+ /**
313
+ * Add dialog options.
314
+ * @since 1.7.12
315
+ */
316
+ if ( '' != option.dialog ) {
317
+ clone.attr( 'data-dialog', JSON.stringify(option.dialog) );
318
+ }
319
+
320
+ sb = sb.replace(/{{clone_id}}/g, api.clone_id);
321
+ if ( 'id' == api.element_by ) {
322
+ sb = sb.replace(/{{id}}/g, api.clone_id);
323
+ sb = sb.replace(/{{name}}/g, '');
324
+ sb = sb.replace(/{{nodename}}/g, '');
325
+ } else {
326
+ sb = sb.replace(/{{id}}/g, '');
327
+ sb = sb.replace(/{{name}}/g, name);
328
+ sb = sb.replace(/{{nodename}}/g, nodeName);
329
+ }
330
+ sb = 'textarea' == nodeName ? sb.replace( '{{style}}', 'float:left;margin-top:0;' ) : sb.replace( '{{style}}', '' );
331
+ var startButtonClasses = 'textarea' == nodeName ? api.startButtonClass + ' wpglobus-textarea wpglobus-textarea-'+api.clone_id : api.startButtonClass;
332
+ sb = sb.replace( '{{classes}}', startButtonClasses );
333
+ sb = option.dialogTitle == '' ? sb.replace('{{title}}', api.dialogTitle) : sb.replace('{{title}}', option.dialogTitle);
334
+ sb = option.sbTitle == '' ? sb.replace('{{sbTitle}}', option.sbTitle) : sb.replace('{{sbTitle}}', 'title="'+option.sbTitle+'"');
335
+
336
+ $(sb).insertAfter($element);
337
+ $(clone).insertAfter($element);
338
+
339
+ if ( 'textarea' == nodeName ) {
340
+ $('#wpglobus-'+api.clone_id).addClass( 'wpglobus-textarea-'+api.clone_id );
341
+ $('.wpglobus-textarea-'+api.clone_id).wrapAll( '<div class="wpglobus-textarea-wrapper" style="'+option.styleTextareaWrapper+'"></div>' );
342
+ }
343
+
344
+ /**
345
+ * Bind change event
346
+ */
347
+ var selector, ret = false;
348
+ if ( option.onChangeClass == '' ) {
349
+ selector = '#wpglobus-' + api.clone_id;
350
+ } else {
351
+ selector = '.' + option.onChangeClass;
352
+ var $events = $._data( $(document)[0], 'events' );
353
+ if( typeof $events === 'undefined' ){
354
+ ret = true;
355
+ } else {
356
+ if ( typeof $events.change !== 'undefined' ) {
357
+ $.each( $events.change, function(i, ev){
358
+ if ( ev.selector == selector ) {
359
+ ret = true;
360
+ return false;
361
+ }
362
+ });
363
+ }
364
+ }
365
+ }
366
+
367
+ if ( ret ) {
368
+ /**
369
+ * Return because we had bound 'change' event already.
370
+ */
371
+ return true;
372
+ }
373
+
374
+ $(document).on( 'change', selector, function() {
375
+ var $t = $(this),
376
+ sid = $t.data( 'source-id' );
377
+
378
+ if ( '' == sid ) {
379
+ sid = $t.data( 'nodename' ) + '[name="' + $t.data( 'source-name' ) + '"]';
380
+ } else {
381
+ sid = '#' + sid;
382
+ }
383
+ $(sid).val( WPGlobusCore.getString( $(sid).val(), $t.val() ) );
384
+ });
385
+ return true;
386
+ },
387
+ saveDialog: function() {
388
+ var s = '', sdl = '', scl = '', $e, val, l;
389
+ $('.wpglobus_dialog_textarea').each(function(indx,e){
390
+ $e = $(e);
391
+ val = $e.val();
392
+ l = $e.data('language');
393
+ if ( l == WPGlobusAdmin.data.language ) {
394
+ scl = val;
395
+ }
396
+ if ( val != '' ) {
397
+ s = s + WPGlobusCore.addLocaleMarks(val,l);
398
+ if ( l == WPGlobusCoreData.default_language ) {
399
+ sdl = val;
400
+ }
401
+ }
402
+ });
403
+ s = s.length == sdl.length + 8 ? sdl : s;
404
+ $(api.id).val(s);
405
+ s = scl == '' ? sdl : scl;
406
+ $(api.wpglobus_id).val(s);
407
+ },
408
+ dialog : $('#wpglobus-dialog-wrapper').dialog({
409
+ autoOpen: false,
410
+ //height: 250,
411
+ width: 650,
412
+ modal: true,
413
+ dialogClass: 'wpglobus-dialog',
414
+ buttons: [
415
+ {
416
+ text:'Save',
417
+ class: 'wpglobus-button-save',
418
+ click:function(){api.saveDialog(); api.dialog.dialog('close');}
419
+ },
420
+ {
421
+ text:'Cancel',
422
+ class: 'wpglobus-button-cancel',
423
+ click: function(){api.dialog.dialog('close');}
424
+ }
425
+ ],
426
+ open: function( event, ui ) {
427
+ var title = api.dialogTitle;
428
+ if ( typeof api.attrs.maxlength !== 'undefined' ) {
429
+ $('.wpglobus_dialog_textarea').attr('maxlength', api.attrs.maxlength);
430
+ title += ' | maxlength='+api.attrs.maxlength;
431
+ }
432
+ $('.wpglobus-dialog .ui-dialog-title').text(title);
433
+ },
434
+ close: function() {
435
+ /**
436
+ * Close callback.
437
+ */
438
+ api.runCallback( api.option.dialog.close );
439
+
440
+ api.form[0].reset();
441
+ //allFields.removeClass( "ui-state-error" );
442
+ }
443
+ }),
444
+ attachListener : function() {
445
+ $(document).on('click', api.option.settingsClass, function() {
446
+ if ( $('.wpglobus_dialog_options_wrapper').hasClass('hidden') ) {
447
+ $('.wpglobus_dialog_options_wrapper').removeClass('hidden');
448
+ } else {
449
+ $('.wpglobus_dialog_options_wrapper').addClass('hidden');
450
+ }
451
+ });
452
+ $(document).on('click', '.wpglobus_dialog_option', function(event) {
453
+ var $t = $(this), r;
454
+ var ob = $t.data('object');
455
+ api.order['action'] = 'save_post_meta_settings';
456
+ api.order['post_type'] = WPGlobusAdmin.data.post_type;
457
+ api.order['checked'] = $t.prop('checked');
458
+ api.order['id'] = $t.attr('id');
459
+ api.order['meta_key'] = $t.data('meta-key');
460
+ r = api.ajax(api.order);
461
+ r.done(function (result) {
462
+ if ( result.result == 'ok' ) {
463
+ if ( result.checked == 'true' ) {
464
+ $(ob).removeClass('wpglobus_dialog_start_hidden');
465
+ } else {
466
+ $(ob).addClass('wpglobus_dialog_start_hidden');
467
+ }
468
+ }
469
+ })
470
+ .fail(function (error) {})
471
+ .always(function (jqXHR, status){});
472
+ });
473
+ $(document).on('click', api.option.listenClass, function(e) {
474
+ api.element = $(this);
475
+ api.id = api.element.data('source-id');
476
+ if ( '' == api.id ) {
477
+ api.id = api.element.data('nodename') + '[name="'+api.element.data('source-name')+'"]';
478
+ api.wpglobus_id = '#wpglobus-'+api.convertToId( api.element.data('source-name') );
479
+ } else {
480
+ api.wpglobus_id = '#wpglobus-'+api.id;
481
+ api.id = '#'+api.id;
482
+ }
483
+
484
+ api.clicks++;
485
+ if ( api.clicks == 1 ) {
486
+ setTimeout(function () {
487
+ if (api.clicks == 1) {
488
+ api.onClick(e);
489
+ } else {
490
+ var s = $(api.id);
491
+ if ( s.hasClass('hidden') ) {
492
+ s.removeClass('hidden').attr('style', 'display:block;');
493
+ } else {
494
+ s.addClass('hidden').attr('style', 'display:none;');
495
+ }
496
+ }
497
+ api.clicks = 0;
498
+ }, 200);
499
+ }
500
+ });
501
+ api.form = api.dialog.find('form#wpglobus-dialog-form').on('submit', function( event ) {
502
+ event.preventDefault();
503
+ api.saveDialog();
504
+ });
505
+ },
506
+ ajax : function(order) {
507
+ return $.ajax({type:'POST', url:WPGlobusAdmin.ajaxurl, data:{action:WPGlobusAdmin.process_ajax, order:order}, dataType:'json', async:false});
508
+ },
509
+ onClick: function(ev) {
510
+ if ( typeof(api.element.data('dialog-title')) == 'undefined' || '' == api.element.data('dialog-title') ) {
511
+ api.dialogTitle = api.option.dialogTitle;
512
+ } else {
513
+ api.dialogTitle = api.element.data('dialog-title');
514
+ }
515
+ if ( typeof api.id !== 'undefined' ) {
516
+ api.attrs['maxlength'] = $(api.id).attr('maxlength');
517
+ }
518
+
519
+ api.source = api.element.data('source-value');
520
+ if ( typeof api.source === 'undefined' ) {
521
+ api.source = $(api.id).val();
522
+ if (api.request == 'ajax') {
523
+ // @todo revise ajax action
524
+ //api.order['action'] = 'get_translate';
525
+ //api.order['source'] = api.source;
526
+ //api.ajax(api.order);
527
+ } else {
528
+ api.value = WPGlobusCore.getTranslations(api.source);
529
+ }
530
+ }
531
+
532
+ /**
533
+ * Get dialog form options.
534
+ */
535
+ api.option.dialog = $.extend( {}, api.option.dialogOptions, $(api.wpglobus_id).data('dialog') );
536
+
537
+ if ( '' != api.option.dialog.title ) {
538
+ api.dialogTitle = api.option.dialog.title;
539
+ }
540
+
541
+ $.each(api.value, function(l,e){
542
+ var $d = $('#wpglobus-dialog-'+l);
543
+ /**
544
+ * Value.
545
+ */
546
+ $d.val(e);
547
+
548
+ /**
549
+ * Placeholder.
550
+ */
551
+ $d.attr(
552
+ 'placeholder',
553
+ WPGlobusCore.TextFilter( api.option.dialog.placeholder, l, 'RETURN_IN_DEFAULT_LANGUAGE' )
554
+ );
555
+ });
556
+
557
+ /**
558
+ * Dialog form footer.
559
+ */
560
+ $('#wpglobus-dialog-form-footer').html(api.option.dialog.formFooter);
561
+
562
+ /**
563
+ * Before open callback.
564
+ */
565
+ api.runCallback( api.option.dialog.beforeOpen );
566
+
567
+ api.dialog.dialog('open');
568
+ },
569
+ runCallback: function(callback) {
570
+
571
+ if ( 'object' === typeof callback ) {
572
+ var k = Object.keys(callback)[0];
573
+ var fn = callback[Object.keys(callback)[0]]
574
+ if ( 'window' === k ) {
575
+ if ( 'function' === typeof window[fn] ) {
576
+ window[fn]( callback[Object.keys(callback)[1]] );
577
+ }
578
+ } else if ( 'function' === typeof window[k][fn] ) {
579
+ window[k][fn]( callback[Object.keys(callback)[1]] );
580
+ }
581
+ } else if ( 'string' === typeof callback ) {
582
+ if ( 'function' === typeof window[callback] ) {
583
+ window[callback]();
584
+ }
585
+ }
586
+
587
+ }
588
+ };
589
+
590
+ })(jQuery);
591
+
592
+ jQuery(document).ready(function () {
593
+ "use strict";
594
+ window.WPGlobusAdminApp = (function (WPGlobusAdminApp, $) {
595
+ /* Object Constructor
596
+ ========================*/
597
+ WPGlobusAdminApp.App = function (config) {
598
+
599
+ if ( 'undefined' !== typeof window.WPGlobusAdminApp ) {
600
+ return;
601
+ }
602
+
603
+ this.config = {
604
+ debug: false,
605
+ version: WPGlobusAdmin.version
606
+ };
607
+
608
+ this.status = 'ok';
609
+
610
+ if ( 'undefined' === typeof WPGlobusAdmin ) {
611
+ this.status = 'error';
612
+ if (this.config.debug) {
613
+ console.log('WPGlobus: error options loading');
614
+ }
615
+ } else {
616
+ if (this.config.debug) {
617
+ console.dir(WPGlobusAdmin);
618
+ }
619
+ }
620
+
621
+ this.config.disable_first_language = [
622
+ '<div id="disable_first_language" style="display:block;" class="redux-field-errors notice-red">',
623
+ '<strong>',
624
+ '<span>&nbsp;</span>',
625
+ WPGlobusAdmin.i18n.cannot_disable_language,
626
+ '</strong>',
627
+ '</div>'
628
+ ].join('');
629
+
630
+ $.extend(this.config, config);
631
+
632
+ if ('ok' === this.status) {
633
+ this.init();
634
+ }
635
+ };
636
+
637
+ WPGlobusAdminApp.App.prototype = {
638
+ $document : $(document),
639
+ init: function () {
640
+ WPGlobusCoreData.multisite = this.parseBool(WPGlobusCoreData.multisite);
641
+ this.adminInit();
642
+ $('#content').addClass('wpglobus-editor').attr('data-language',WPGlobusAdmin.data.default_language);
643
+ $('textarea[id^=content_]').each(function(i,e){
644
+ var l=$(e).attr('id').replace('content_','');
645
+ $(e).attr('data-language',l);
646
+ });
647
+ if ('post.php' === WPGlobusAdmin.page) {
648
+ this.postEdit();
649
+ this.set_dialog();
650
+ if ( 'undefined' !== typeof WPGlobusAioseop ) {
651
+ WPGlobusAioseop.init();
652
+ }
653
+ } else if ('menu-edit' === WPGlobusAdmin.page) {
654
+ this.navMenus();
655
+ } else if ('taxonomy-edit' === WPGlobusAdmin.page) {
656
+ if (WPGlobusAdmin.data.tag_id) {
657
+ this.taxonomyEdit();
658
+ }
659
+ } else if ('taxonomy-quick-edit' === WPGlobusAdmin.page) {
660
+ this.quickEdit('taxonomy');
661
+ } else if ('edit.php' === WPGlobusAdmin.page) {
662
+ this.quickEdit('post');
663
+ } else if ('options-general.php' == WPGlobusAdmin.page) {
664
+ this.optionsGeneral();
665
+ } else if ('widgets.php' == WPGlobusAdmin.page) {
666
+ WPGlobusWidgets.init();
667
+ WPGlobusDialogApp.init({dialogTitle:'Edit text'});
668
+ } else if ('wpglobus_options' == WPGlobusAdmin.page) {
669
+ this.start();
670
+ } else if ('wpglobusAdminCentral' == WPGlobusAdmin.page) {
671
+ this.adminCentral();
672
+ } else {
673
+ /**
674
+ * Init WPGlobusDialogApp for using in a 3-party plugins.
675
+ */
676
+ WPGlobusDialogApp.init({customData:WPGlobusCoreData.page_custom_data});
677
+ }
678
+ },
679
+ parseBool: function(b) {
680
+ return !(/^(false|0)$/i).test(b) && !!b;
681
+ },
682
+ getCurrentTab: function() {
683
+ return $( '.wpglobus-post-body-tabs-list .ui-tabs-active' ).data( 'language' );
684
+ },
685
+ adminInit: function () {
686
+ var order = $('.wpglobus-addons-group a').data('key');
687
+ if ( 'undefined' !== typeof order ) {
688
+ if ( window.location.search.indexOf('page=wpglobus_options&tab='+order) >= 0 ) {
689
+ if ( WPGlobusCoreData.multisite ) {
690
+ window.location = WPGlobusCoreData.pluginInstallLocation.multisite;
691
+ } else {
692
+ window.location = WPGlobusCoreData.pluginInstallLocation.single;
693
+ }
694
+ } else {
695
+ var addon = $('#toplevel_page_wpglobus_options li').eq(order+1);
696
+ if ( WPGlobusCoreData.multisite ) {
697
+ $(addon).find('a').attr('href',WPGlobusCoreData.pluginInstallLocation.multisite).attr('onclick',"window.location=jQuery(this).attr('href');return false;");
698
+ } else {
699
+ $(addon).find('a').attr('href',WPGlobusCoreData.pluginInstallLocation.single).attr('onclick',"window.location=jQuery(this).attr('href');return false;");
700
+ }
701
+ }
702
+ }
703
+ },
704
+ optionsGeneral: function() {
705
+ var $bn = $('#blogname'),
706
+ $body = $('body');
707
+
708
+ $bn.addClass('hidden');
709
+ $('#wpglobus-blogname').insertAfter($bn).removeClass('hidden');
710
+
711
+ $body.on('blur', '.wpglobus-blogname', function () {
712
+ $('.wpglobus-blogname').each( function (i, e) {
713
+ var $e = $(e);
714
+ $bn.val( WPGlobusCore.getString( $bn.val(), $e.val(), $e.data('language') ) );
715
+ });
716
+ });
717
+
718
+ var $bd = $('#blogdescription');
719
+ $bd.addClass('hidden');
720
+ $('#wpglobus-blogdescription').insertAfter($bd).removeClass('hidden');
721
+ $body.on('blur', '.wpglobus-blogdesc', function () {
722
+ $('.wpglobus-blogdesc').each( function (i, e) {
723
+ var $e = $(e);
724
+ $bd.val( WPGlobusCore.getString( $bd.val(), $e.val(), $e.data('language') ) );
725
+ });
726
+ });
727
+ },
728
+ quickEdit: function(type) {
729
+ /**
730
+ * For more info @see ajax handler 'wp_ajax_inline_save'.
731
+ */
732
+ if ( 'undefined' === typeof WPGlobusAdmin.data.has_items ) {
733
+ return;
734
+ }
735
+ if (!WPGlobusAdmin.data.has_items) {
736
+ return;
737
+ }
738
+ var full_id = '', id = 0;
739
+
740
+ $(document).ajaxComplete(function(event, jqxhr, settings){
741
+ if (typeof settings.data === 'undefined') {
742
+ return;
743
+ }
744
+ if ( full_id == '' ) {
745
+ return;
746
+ }
747
+ if (settings.data.indexOf('action=inline-save-tax&') >= 0) {
748
+ $('#'+full_id+' a.row-title').text(WPGlobusAdmin.qedit_titles[id][WPGlobusAdmin.data.language]['name']);
749
+ $('#'+full_id+' .description').text(WPGlobusAdmin.qedit_titles[id][WPGlobusAdmin.data.language]['description']);
750
+ }
751
+ });
752
+
753
+ var title = {};
754
+ $('#the-list tr').each(function (i, e) {
755
+ var $e = $(e);
756
+ var k = ( type === 'post' ? 'post-' : 'tag-' );
757
+ id = $e.attr('id').replace(k, ''); /* don't need var with id, see line 109 */
758
+ title[id] = {};
759
+ if ('post' === type) {
760
+ title[id]['source'] = $e.find('.post_title').text();
761
+ } else if ('taxonomy' === type) {
762
+ title[id]['source'] = $('#inline_' + id + ' .name').text();
763
+ }
764
+ });
765
+
766
+ var order = {};
767
+ order['action'] = 'get_titles';
768
+ order['type'] = type;
769
+ order['taxonomy'] = typeof WPGlobusAdmin.data.taxonomy === 'undefined' ? false : WPGlobusAdmin.data.taxonomy;
770
+ order['title'] = title;
771
+ $.ajax({type:'POST', url:WPGlobusAdmin.ajaxurl, data:{action:WPGlobusAdmin.process_ajax, order:order}, dataType:'json'})
772
+ .done(function (result) {
773
+ WPGlobusAdmin.qedit_titles = result.qedit_titles;
774
+ $.each(result.bulkedit_post_titles, function(id, obj){
775
+ $('#inline_'+id+' .post_title').text(obj[WPGlobusAdmin.data.language]['name']);
776
+ });
777
+ })
778
+ .fail(function (error) {
779
+ })
780
+ .always(function (jqXHR, status) {
781
+ });
782
+
783
+ $('body').on('change', '.wpglobus-quick-edit-title', function () {
784
+ var s = '';
785
+ var lang = [];
786
+ $('.wpglobus-quick-edit-title').each(function (index, e) {
787
+ var $e = $(e);
788
+ var l = $e.data('language');
789
+ if ($e.val() !== '') {
790
+ s = WPGlobusCore.getString( s, $e.val(), l );
791
+ }
792
+ WPGlobusAdmin.qedit_titles[ id ][ l ][ 'name' ] = $e.val();
793
+ lang[ index ] = l;
794
+ });
795
+
796
+ var so = $(document).triggerHandler( 'wpglobus_get_translations', {string:s, lang:lang, id:id} );
797
+ if ( typeof so !== 'undefined' ) {
798
+ s = so;
799
+ }
800
+ $( 'input.ptitle' ).eq( 0 ).attr( 'value', s ) ;
801
+ WPGlobusAdmin.qedit_titles[ id ][ 'source' ] = s;
802
+ });
803
+
804
+ if ( typeof WPGlobusAdmin.data.tags !== 'undefined' ) {
805
+ $.each( WPGlobusAdmin.data.tags, function(i,tag){
806
+ WPGlobusAdmin.data.value[tag]['post_id'] = {};
807
+ });
808
+ }
809
+
810
+ $('button.save, input#bulk_edit').on('mouseenter', function (event) {
811
+ /**
812
+ * Quick edit action for the "Tags" box in edit.php page.
813
+ */
814
+ if ( typeof WPGlobusAdmin.data.tags === 'undefined' ) {
815
+ return;
816
+ }
817
+
818
+ if (event.currentTarget.id=='bulk_edit') {
819
+ $('input#bulk_edit').unbind('click');
820
+ } else {
821
+ $('button.save').unbind('click');
822
+ }
823
+
824
+ $( 'button.save, input#bulk_edit').on('click', function (event) {
825
+ //console.log( 'Start Updating' );
826
+ var promise = $.when();
827
+
828
+ var tagsHandler = function( $elem ) {
829
+ $elem.next('.spinner').css({'visibility':'visible'});
830
+ if (event.currentTarget.id != 'bulk_edit') {
831
+ $.ajaxSetup({async:false});
832
+ }
833
+ var p = $elem.parents('tr');
834
+ var id = p.attr('id').replace('edit-','');
835
+ var t,v,newTags;
836
+
837
+ $.each( WPGlobusAdmin.data.tags, function(index,tag){
838
+ t = p.find("textarea[name='" + WPGlobusAdmin.data.names[tag] + "']");
839
+ if ( t.length == 0 ) {
840
+ return true;
841
+ }
842
+ WPGlobusAdmin.data.value[tag]['post_id'][id] = t.val();
843
+ v = WPGlobusAdmin.data.value[tag]['post_id'][id].split(',');
844
+ newTags = [];
845
+ for(var i=0; i<v.length; i++) {
846
+ v[i] = v[i].trim(' ');
847
+ if ( v[i] != '' ) {
848
+ if ( typeof WPGlobusAdmin.data.tag[tag][v[i]] === 'undefined' ) {
849
+ newTags[i] = v[i];
850
+ } else {
851
+ newTags[i] = WPGlobusAdmin.data.tag[tag][v[i]];
852
+ }
853
+ }
854
+ }
855
+ t.val( newTags.join(', ') );
856
+ });
857
+ }
858
+
859
+ var $this = $(this);
860
+ var start = $.Deferred();
861
+ start.resolve( tagsHandler( $(this) ) );
862
+
863
+ promise = promise.then(function() {
864
+ return $.when(
865
+ start.done()
866
+ )
867
+ }).then( function() {
868
+ if (event.currentTarget.id != 'bulk_edit') {
869
+ setTimeout(
870
+ function() {
871
+ inlineEditPost.save(id);
872
+ $.ajaxSetup({async:true});
873
+ },
874
+ 50
875
+ );
876
+ }
877
+ });
878
+
879
+ });
880
+ });
881
+
882
+ $( '#the-list' ).on( 'click', 'a.editinline', function () {
883
+ var t = $(this);
884
+ full_id = t.parents('tr').attr('id');
885
+ if ('post' === type) {
886
+ id = full_id.replace('post-', '');
887
+ } else if ('taxonomy' === type) {
888
+ id = full_id.replace('tag-', '');
889
+ } else {
890
+ return;
891
+ }
892
+
893
+ if ( 'post' === type && 'undefined' !== typeof WPGlobusAdmin.data.tags ) {
894
+ /**
895
+ * @since 1.6.6
896
+ */
897
+ $.each( WPGlobusAdmin.data.tags, function(i,tag){
898
+ if ( WPGlobusAdmin.data.value[tag] != '' ) {
899
+ var val = $('#edit-' + id + ' textarea[name="' + WPGlobusAdmin.data.names[tag] + '"]').val(),
900
+ currentTags;
901
+ if ( 'undefined' !== typeof val ) {
902
+ currentTags = val.split(',');
903
+ $.each( currentTags, function(order,currentTag) {
904
+ val = val.replace(currentTag, WPGlobusCore.TextFilter(currentTag, WPGlobusCoreData.language));
905
+ });
906
+ $('#edit-' + id + ' textarea[name="' + WPGlobusAdmin.data.names[tag] + '"]').val(val);
907
+ }
908
+ }
909
+ });
910
+ }
911
+
912
+ var e = $('#edit-' + id + ' input.ptitle').eq(0);
913
+ var p = e.parents('label');
914
+ e.val(WPGlobusAdmin.qedit_titles[id].source);
915
+ e.addClass('hidden');
916
+ $(WPGlobusAdmin.data.template).insertAfter(p);
917
+
918
+ if ( typeof WPGlobusAdmin.qedit_titles[id] === 'undefined' ) {
919
+ WPGlobusAdmin.qedit_titles[id] = {};
920
+ WPGlobusAdmin.qedit_titles[id]['source'] = $('#'+full_id+' .name a.row-title').text();
921
+ $(WPGlobusAdmin.data.enabled_languages).each(function(i,l){
922
+ WPGlobusAdmin.qedit_titles[id][l] = {};
923
+ if ( l == WPGlobusAdmin.data.default_language ) {
924
+ WPGlobusAdmin.qedit_titles[id][l]['name'] = WPGlobusAdmin.qedit_titles[id]['source'];
925
+ } else {
926
+ WPGlobusAdmin.qedit_titles[id][l]['name'] = '';
927
+ }
928
+ WPGlobusAdmin.qedit_titles[id][l]['description'] = '';
929
+ });
930
+ }
931
+
932
+ $( '.wpglobus-quick-edit-title' ).each(function ( i, e ) {
933
+ var $e = $(e);
934
+ var l = $e.data( 'language' );
935
+ $e.attr( 'id', l + id );
936
+ if ( typeof WPGlobusAdmin.qedit_titles[id][l] !== 'undefined' ) {
937
+ WPGlobusAdmin.qedit_titles[id][l]['name'] = WPGlobusAdmin.qedit_titles[id][l]['name'].replace( /\\\'/g, "'" );
938
+ WPGlobusAdmin.qedit_titles[id][l]['name'] = WPGlobusAdmin.qedit_titles[id][l]['name'].replace( /\\\"/g, '"' );
939
+ $e.attr( 'value', WPGlobusAdmin.qedit_titles[id][l]['name'] );
940
+ WPGlobusAdmin.qedit_titles[id]['source'] =
941
+ WPGlobusCore.getString(
942
+ WPGlobusAdmin.qedit_titles[id]['source'],
943
+ WPGlobusAdmin.qedit_titles[id][l]['name'],
944
+ l
945
+ );
946
+ }
947
+ });
948
+ $( 'input.ptitle' ).eq( 0 ).attr( 'value', WPGlobusAdmin.qedit_titles[ id ][ 'source' ] );
949
+ });
950
+
951
+ },
952
+ taxonomyEdit: function () {
953
+
954
+ var elements = [];
955
+ elements[0] = 'name';
956
+ elements[1] = 'description';
957
+
958
+ var make_clone = function(id,language){
959
+ var $element = $('#'+id),
960
+ clone = $element.clone(),
961
+ name = $element.attr('name'),
962
+ classes = 'wpglobus-element wpglobus-element_'+id+' wpglobus-element_'+language+' wpglobus-translatable',
963
+ node;
964
+
965
+ node = document.getElementById(id);
966
+ node = node.nodeName;
967
+ $(clone).attr('id', id+'_'+language);
968
+ $(clone).attr('name', name+'_'+language);
969
+ if ( language !== WPGlobusCoreData.default_language ) {
970
+ classes += ' hidden';
971
+ }
972
+ $(clone).attr('class', classes);
973
+ $(clone).attr('data-save-to', id);
974
+ $(clone).attr('data-language', language);
975
+ if ( node == 'INPUT' ) {
976
+ $(clone).attr('value', $('#wpglobus-link-tab-'+language).data(id));
977
+ } else if ( node == 'TEXTAREA' ) {
978
+ $(clone).text($('#wpglobus-link-tab-'+language).data(id));
979
+ }
980
+ $element.addClass('hidden');
981
+ if ( $('.wpglobus-element_'+id).length == 0 ) {
982
+ $(clone).insertAfter($element);
983
+ } else {
984
+ $(clone).insertAfter($('.wpglobus-element_'+id).last());
985
+ }
986
+ };
987
+
988
+ $.each(WPGlobusCoreData.enabled_languages, function(i,l){
989
+ $.each(elements, function(i,e){
990
+ make_clone(e,l);
991
+ });
992
+ });
993
+
994
+ $('.wpglobus-taxonomy-tabs').insertAfter('#ajax-response');
995
+
996
+ /**
997
+ * Make class wrap as tabs container.
998
+ * Tabs on.
999
+ */
1000
+ $('.wrap').tabs();
1001
+
1002
+ $('body').on('click', '.wpglobus-taxonomy-tabs li', function(event){
1003
+ var $t = $(this);
1004
+ var language = $t.data('language');
1005
+ $('.wpglobus-element').addClass('hidden');
1006
+ $('.wpglobus-element_'+language).removeClass('hidden');
1007
+ });
1008
+
1009
+ $('.wpglobus-element').on('change', function () {
1010
+ var $this = $(this),
1011
+ save_to = $this.data('save-to'),
1012
+ s = '';
1013
+
1014
+ $('.wpglobus-element').each(function (index, element) {
1015
+ var $e = $(element),
1016
+ value = $e.val();
1017
+ if ( $e.data('save-to') == save_to && value !== '' ) {
1018
+ s = s + WPGlobusCore.addLocaleMarks(value, $e.data('language') )
1019
+ }
1020
+ });
1021
+ $('#' + save_to).val(s);
1022
+ });
1023
+
1024
+ /**
1025
+ * @since 1.8.1
1026
+ * $('<span class="wpglobus-multilingual-slug wpglobus_dialog_start wpglobus_dialog_icon" title="Title"></span>').insertBefore('#slug');
1027
+ * $('.term-slug-wrap th').css({'padding-right':'0'});
1028
+ * $('.term-slug-wrap td').css({'padding-left':'0'});
1029
+ */
1030
+ $(WPGlobusAdmin.data.multilingualSlug.title).insertAfter('.term-slug-wrap th label');
1031
+
1032
+ },
1033
+ navMenus: function () {
1034
+ var iID, menu_size,
1035
+ menu_item = '#menu-to-edit .menu-item';
1036
+
1037
+ var timer = function () {
1038
+ if ( menu_size !== $(menu_item).length ) {
1039
+ clearInterval(iID);
1040
+ $(menu_item).each(function (index, li) {
1041
+ var $li = $(li);
1042
+ if ($li.hasClass('wpglobus-menu-item')) {
1043
+ return; /** the same as continue */
1044
+ }
1045
+ var id = $(li).attr('id');
1046
+ $.each(['input.edit-menu-item-title', 'input.edit-menu-item-attr-title'], function (input_index, input) {
1047
+ var i = $('#' + id + ' ' + input);
1048
+ var $i = $(i);
1049
+ if (!$i.hasClass('wpglobus-hidden')) {
1050
+ $i.addClass('wpglobus-hidden');
1051
+ $i.css('display', 'none');
1052
+ var l = $i.parent('label');
1053
+ var p = $i.parents('p');
1054
+ $(p).css('height', '80px');
1055
+ $(l).append('<div style="color:#f00;">' + WPGlobusAdmin.i18n.save_nav_menu + '</div>');
1056
+ }
1057
+ });
1058
+ $li.addClass('wpglobus-menu-item');
1059
+ });
1060
+ }
1061
+ };
1062
+
1063
+ $.ajaxSetup({
1064
+ beforeSend: function (jqXHR, PlainObject) {
1065
+ if (typeof PlainObject.data === 'undefined') {
1066
+ return;
1067
+ }
1068
+ if (PlainObject.data.indexOf('action=add-menu-item') >= 0) {
1069
+ menu_size = $(menu_item).length;
1070
+ iID = setInterval(timer, 500);
1071
+ }
1072
+ }
1073
+ });
1074
+
1075
+ $(menu_item).each(function (index, li) {
1076
+
1077
+ var id = $(li).attr('id'),
1078
+ item_id = id.replace('menu-item-', '');
1079
+
1080
+ $.each(['input.edit-menu-item-title', 'input.edit-menu-item-attr-title'], function (input_index, input) {
1081
+ var $i = $('#' + id + ' ' + input);
1082
+ if ( $i.val() != WPGlobusAdmin.data.items[ item_id ][ input ][ 'source' ] ) {
1083
+ /**
1084
+ * fix for case when value resets by WP core
1085
+ */
1086
+ $i.val( WPGlobusAdmin.data.items[ item_id ][ input ][ 'source' ] );
1087
+ }
1088
+
1089
+ var p = $( '#' + id + ' ' + input ).parents('p');
1090
+ var height = 0;
1091
+
1092
+ $.each(WPGlobusAdmin.data.open_languages, function (index, language) {
1093
+ var new_element = $i.clone();
1094
+ new_element.attr('id', $i.attr('id') + '-' + language);
1095
+ new_element.attr('name', $i.attr('id') + '-' + language);
1096
+ new_element.attr('data-language', language);
1097
+ new_element.attr('data-item-id', item_id);
1098
+ new_element.attr('placeholder', WPGlobusAdmin.data.en_language_name[language]);
1099
+
1100
+ var classes = WPGlobusAdmin.data.items[item_id][language][input]['class'];
1101
+ if (input_index === 0 && language === WPGlobusAdmin.data.default_language) {
1102
+ new_element.attr('class', classes + ' edit-menu-item-title');
1103
+ } else {
1104
+ new_element.attr('class', classes);
1105
+ }
1106
+
1107
+ if ( WPGlobusAdmin.data.items[ item_id ][ language ][ input ][ 'caption' ] != '' ) {
1108
+ new_element.attr('value', WPGlobusAdmin.data.items[item_id][language][input]['caption']);
1109
+ } else {
1110
+ new_element.attr('value', '');
1111
+ }
1112
+ new_element.css('margin-bottom', '0.6em');
1113
+ $(p).append( new_element );
1114
+ height = index;
1115
+ });
1116
+ height = (height + 1) * 40;
1117
+ $i.css('display', 'none').attr('class', '').addClass('widefat wpglobus-hidden');
1118
+ $(p).css('height', height + 'px').addClass('wpglobus-menu-item-box');
1119
+
1120
+ });
1121
+ $(li).addClass('wpglobus-menu-item');
1122
+ });
1123
+
1124
+ $('.menus-move-left, .menus-move-right').each(function(index,e) {
1125
+ var $e = $(e), new_title;
1126
+ var item_id = $e.parents('li').attr('id').replace('menu-item-', '');
1127
+ var title = $e.attr('title');
1128
+ if ( typeof title !== 'undefined' ) {
1129
+ $.each(WPGlobusAdmin.data.post_titles, function(post_title, item_title) {
1130
+ if ( title.indexOf(post_title) >= 0 ) {
1131
+ new_title = title.replace(post_title, item_title);
1132
+ $e.attr('title', new_title);
1133
+ $e.text(new_title);
1134
+ }
1135
+ });
1136
+ }
1137
+ });
1138
+
1139
+ /**
1140
+ * Run the item handle title when the navigation label was loaded.
1141
+ * @see wp-admin\js\nav-menu.js
1142
+ */
1143
+ $('.edit-menu-item-title').trigger('change');
1144
+ wpNavMenu.refreshAdvancedAccessibility();
1145
+ wpNavMenu.menusChanged = false;
1146
+
1147
+ $('.wpglobus-menu-item').on('change', function () {
1148
+ var $this = $(this),
1149
+ item_id = $this.data('item-id'),
1150
+ s, so;
1151
+ if ($this.hasClass('wpglobus-item-title')) {
1152
+ s = WPGlobusCore.getString( $('input#edit-menu-item-title-' + item_id).val(), $this.val(), $this.data('language') );
1153
+ so = $(document).triggerHandler('wpglobus_get_menu_translations', {string:s, lang:WPGlobusCoreData.open_languages, id:item_id, type:'input.edit-menu-item-title'});
1154
+ if ( typeof so !== 'undefined' ) {
1155
+ s = so;
1156
+ }
1157
+ $('input#edit-menu-item-title-' + item_id).val(s);
1158
+ }
1159
+ if ($this.hasClass('wpglobus-item-attr')) {
1160
+ s = WPGlobusCore.getString( $('input#edit-menu-item-attr-title-' + item_id).val(), $this.val(), $this.data('language') );
1161
+ so = $(document).triggerHandler('wpglobus_get_menu_translations', {string:s, lang:WPGlobusCoreData.open_languages, id:item_id, type:'input.edit-menu-item-attr-title'});
1162
+ if ( typeof so !== 'undefined' ) {
1163
+ s = so;
1164
+ }
1165
+ $('input#edit-menu-item-attr-title-' + item_id).val(s);
1166
+ }
1167
+
1168
+ });
1169
+ },
1170
+ postEdit: function () {
1171
+ /**
1172
+ * Hook into the heartbeat-send.
1173
+ */
1174
+ $(document).on('heartbeat-send', function(e, data) {
1175
+ if ( typeof data['wp_autosave'] !== 'undefined' ) {
1176
+ data['wpglobus_heartbeat'] = 'wpglobus';
1177
+ $.each(WPGlobusAdmin.data.open_languages, function(i,l){
1178
+ var v = $('#title_'+l).val() || '';
1179
+ v = $.trim(v);
1180
+ if ( v != '' ) {
1181
+ data['wp_autosave']['post_title_'+l] = v;
1182
+ }
1183
+ v = $('#content_'+l).val() || '';
1184
+ v = $.trim(v);
1185
+ if ( v != '' ) {
1186
+ data['wp_autosave']['content_'+l] = v;
1187
+ }
1188
+ });
1189
+ }
1190
+ });
1191
+
1192
+ var wrap_at = '#postdivrich',
1193
+ set_title = true,
1194
+ content_tabs_id = '#post-body-content';
1195
+ if ( WPGlobusAdmin.data.support['editor'] === false ) {
1196
+ wrap_at = '#titlediv';
1197
+ set_title = false;
1198
+ }
1199
+ if ( WPGlobusAdmin.data.support['title'] === false ) {
1200
+ set_title = false;
1201
+ }
1202
+ /**
1203
+ * Make post-body-content as tabs container.
1204
+ */
1205
+ $(content_tabs_id).prepend($('.wpglobus-post-body-tabs-list'));
1206
+ $.each(WPGlobusAdmin.tabs, function (index, suffix) {
1207
+ if ('default' === suffix) {
1208
+ $(wrap_at).wrap('<div id="tab-default"></div>');
1209
+ if ( set_title ) {
1210
+ $($('#titlediv')).insertBefore(wrap_at);
1211
+ }
1212
+ } else {
1213
+ $(wrap_at+'-' + suffix).wrap('<div id="tab-' + suffix + '"></div>');
1214
+ if ( set_title ) {
1215
+ $($('#titlediv-' + suffix)).insertBefore(wrap_at+'-' + suffix);
1216
+ }
1217
+ }
1218
+ });
1219
+
1220
+ /**
1221
+ * Tabs on.
1222
+ */
1223
+ $(content_tabs_id).addClass('wpglobus-post-body-tabs').tabs({
1224
+ beforeActivate: function( event, ui ){
1225
+ var otab = ui.oldTab[0].id.replace('link-tab-','');
1226
+ var ntab = ui.newTab[0].id.replace('link-tab-','');
1227
+ if ( 'default' == otab ) {
1228
+ otab = WPGlobusCoreData.default_language;
1229
+ }
1230
+ if ( 'default' == ntab ) {
1231
+ ntab = WPGlobusCoreData.default_language;
1232
+ }
1233
+ var a = $(document).triggerHandler('wpglobus_post_body_tabs', [ otab, ntab ]);
1234
+ if ( a || typeof a === 'undefined' ) {
1235
+ return true;
1236
+ }
1237
+ return false;
1238
+ }
1239
+ }); /** #post-body-content */
1240
+
1241
+ /**
1242
+ * Setup for default language.
1243
+ */
1244
+ $('#title').val(WPGlobusAdmin.title);
1245
+
1246
+ /**
1247
+ * See other places with the same bookmark.
1248
+ * @bookmark EDITOR_LINE_BREAKS
1249
+ */
1250
+ //$('#content').text(WPGlobusAdmin.content.replace(/\n/g, "<p>"));
1251
+
1252
+ $('#content').text(WPGlobusAdmin.content);
1253
+
1254
+ if (typeof WPGlobusVendor !== "undefined" && WPGlobusVendor.vendor.WPSEO ) {
1255
+ if ( typeof wpglobus_wpseo !== "undefined" ) {
1256
+ wpglobus_wpseo();
1257
+ } else if ( 'undefined' !== typeof WPGlobusYoastSeo ) {
1258
+ if ( 'undefined' !== typeof WPGlobusYoastSeoPremium ) {
1259
+ /**
1260
+ * @since WPGlobus 1.7.2
1261
+ */
1262
+ if ( WPGlobusYoastSeoPremium ) {
1263
+ WPGlobusYoastSeoPremium.init();
1264
+ }
1265
+ }
1266
+ /**
1267
+ * @since Yoast SEO 3.0
1268
+ */
1269
+ WPGlobusYoastSeo.init();
1270
+ }
1271
+ }
1272
+
1273
+ if ( WPGlobusAdmin.data.modify_excerpt ) {
1274
+ /**
1275
+ * Add excerpt fields from template.
1276
+ */
1277
+ var $excerpt = $( '#excerpt' );
1278
+ $excerpt.addClass( 'hidden' ).css( {'display':'none'} );
1279
+ $( WPGlobusAdmin.data.template ).insertAfter( $excerpt );
1280
+ $( 'body' ).on( 'change', '.wpglobus-excerpt', function () {
1281
+ var $t = $( this );
1282
+ $excerpt.val( WPGlobusCore.getString( $excerpt.val(), $t.val(), $t.data('language') ) );
1283
+ });
1284
+ }
1285
+
1286
+ /**
1287
+ * wp_editor word count.
1288
+ * from WordPress 4.3 @see \wp-admin\js\post.js
1289
+ */
1290
+ if ( typeof wp.utils !== 'undefined' && typeof wp.utils.WordCounter !== 'undefined' ) {
1291
+ WPGlobusCoreData.wordCounter = {};
1292
+
1293
+ var self = this, wpglobusEditors = {};
1294
+
1295
+ $.each( WPGlobusCoreData.enabled_languages, function( i, l ){
1296
+ if ( l == WPGlobusCoreData.default_language ) {
1297
+ return true;
1298
+ }
1299
+ wpglobusEditors[i] = 'content_'+l;
1300
+
1301
+ ( function( $, counter, l ) {
1302
+ WPGlobusCoreData.wordCounter[ l ] = {};
1303
+ WPGlobusCoreData.wordCounter[ l ][ 'counter' ] = counter;
1304
+
1305
+ $( function() {
1306
+
1307
+ WPGlobusCoreData.wordCounter[ l ][ 'content' ] = $( '#content_'+l );
1308
+ WPGlobusCoreData.wordCounter[ l ][ 'count' ] = $( '#wp-word-count-'+l ).find( '.word-count-'+l );
1309
+
1310
+ WPGlobusCoreData.wordCounter[ l ][ 'prevCount' ] = 0;
1311
+
1312
+ function update( l ) {
1313
+ var text, count;
1314
+
1315
+ if ( typeof l === 'object' ) {
1316
+
1317
+ if ( l == 'tinymce' ) {
1318
+ /** wysiwyg editor */
1319
+ l = self.getCurrentTab();
1320
+ } else {
1321
+ /** textarea */
1322
+ l = l.target.id.replace( 'content_', '' );
1323
+ }
1324
+
1325
+ }
1326
+
1327
+ if ( typeof WPGlobusCoreData.wordCounter[ l ] === 'undefined' ) {
1328
+ return;
1329
+ }
1330
+
1331
+ if ( ! WPGlobusCoreData.wordCounter[ l ][ 'contentEditor' ] ||
1332
+ WPGlobusCoreData.wordCounter[ l ][ 'contentEditor' ].isHidden() ) {
1333
+
1334
+ text = WPGlobusCoreData.wordCounter[ l ][ 'content' ].val();
1335
+
1336
+ } else {
1337
+ text = WPGlobusCoreData.wordCounter[ l ][ 'contentEditor' ].getContent( { format: 'raw' } );
1338
+ }
1339
+
1340
+ count = WPGlobusCoreData.wordCounter[ l ][ 'counter' ].count( text );
1341
+
1342
+ if ( count !== WPGlobusCoreData.wordCounter[ l ][ 'prevCount' ] ) {
1343
+ WPGlobusCoreData.wordCounter[ l ][ 'count' ].text( count );
1344
+ }
1345
+
1346
+ WPGlobusCoreData.wordCounter[ l ][ 'prevCount' ] = count;
1347
+ }
1348
+
1349
+ $(document).on( 'tinymce-editor-init', function( event, editor ) {
1350
+
1351
+ if ( -1 == $.inArray(editor.id, wpglobusEditors) ) {
1352
+ /**
1353
+ * Init WPGlobus editor only.
1354
+ */
1355
+ return;
1356
+ }
1357
+ var l = editor.id.replace( 'content_', '' );
1358
+
1359
+ WPGlobusCoreData.wordCounter[ l ][ 'contentEditor' ] = editor;
1360
+
1361
+ editor.on( 'nodechange keyup', _.debounce( update, 1000 ) );
1362
+ } );
1363
+
1364
+ WPGlobusCoreData.wordCounter[l]['content'].on( 'input keyup', _.debounce( update, 1000 ) );
1365
+
1366
+ update( l );
1367
+
1368
+ } );
1369
+ } )( jQuery, new wp.utils.WordCounter(), l );
1370
+ });
1371
+
1372
+ }
1373
+
1374
+ $(document).on('click', '#publish, #save-post', function() {
1375
+ if ( WPGlobusAdmin.data.open_languages.length > 1 ) {
1376
+ $(document).triggerHandler('wpglobus_before_save_post', {content_tabs_id:content_tabs_id});
1377
+ /**
1378
+ * If empty title in default language make it from another titles.
1379
+ */
1380
+ var t = $('#title').val(),
1381
+ index, title = '', delimiter = '';
1382
+
1383
+ if ( t.length == 0 ) {
1384
+ index = WPGlobusAdmin.data.open_languages.indexOf(WPGlobusAdmin.data.default_language);
1385
+ WPGlobusAdmin.data.open_languages.splice(index, 1);
1386
+ $(WPGlobusAdmin.data.open_languages).each(function(i,l){
1387
+ delimiter = i == 0 ? '' : '-';
1388
+ t = $('#title_'+l).val();
1389
+ if ( t.length > 0 ) {
1390
+ if ( title.length == 0 ) { delimiter = '';}
1391
+ title = title + delimiter + t;
1392
+ }
1393
+ });
1394
+ }
1395
+ if ( title.length > 0 ) {
1396
+ $('#title').val(title);
1397
+ }
1398
+ }
1399
+
1400
+ /**
1401
+ * To handle taxonomy tags.
1402
+ */
1403
+ if ( 'undefined' === typeof WPGlobusAdmin.data.tagsdiv || WPGlobusAdmin.data.tagsdiv.length < 1 ) {
1404
+ return;
1405
+ }
1406
+ $(WPGlobusAdmin.data.tagsdiv).each(function(i,tagsdiv){
1407
+ if ($('#' + tagsdiv).length == 0) {
1408
+ /**
1409
+ * Next iteration.
1410
+ */
1411
+ return true;
1412
+ }
1413
+
1414
+ var id = tagsdiv.replace('tagsdiv-', '');
1415
+ if ( 'undefined' === id ) {
1416
+ return true;
1417
+ }
1418
+ if ( $('#tax-input-'+id).length == 0 ) {
1419
+ return true;
1420
+ }
1421
+
1422
+ var name, tags = [];
1423
+
1424
+ $('#tagsdiv-'+id+' .tagchecklist > span').each(function(i,e){
1425
+ name = $(e).html();
1426
+ name = name.replace( /<button.*<\/button>&nbsp;/, '' );
1427
+ if ( 'undefined' === typeof WPGlobusAdmin.data.tag[id][name] ) {
1428
+ tags[i] = name;
1429
+ } else {
1430
+ tags[i] = WPGlobusAdmin.data.tag[id][name];
1431
+ }
1432
+ });
1433
+
1434
+ $('#tax-input-'+id).val(tags.join(', '));
1435
+ });
1436
+ /**
1437
+ * The end to handle taxonomy tags.
1438
+ */
1439
+ });
1440
+
1441
+ /**
1442
+ * The alignment when default tab was clicked.
1443
+ */
1444
+ $('.ui-state-default').on('click', function () {
1445
+ if ('link-tab-default' === $(this).attr('id')) {
1446
+ $(window).scrollTop($(window).scrollTop() + 1);
1447
+ $(window).scrollTop($(window).scrollTop() - 1);
1448
+ }
1449
+ });
1450
+
1451
+ /**
1452
+ * Set current value after language tab of content was changed.
1453
+ */
1454
+ $(document).on( 'tabsactivate', content_tabs_id, function( event, ui ) {
1455
+ WPGlobusAdmin.currentTab = ui.newTab[0].dataset.language;
1456
+ });
1457
+
1458
+ $(document).triggerHandler('wpglobus_after_post_edit');
1459
+
1460
+ },
1461
+ adminCentral: function () {
1462
+ $( '.wpglobus-admin-central-tab' ).css({ 'display':'none' });
1463
+
1464
+ if ( $( '.nav-tab-active' ).length > 1 ) {
1465
+ $( '.wpglobus-about-wrap .nav-tab-wrapper a' ).removeClass( 'nav-tab-active' );
1466
+ }
1467
+
1468
+ var setFirstElement = true;
1469
+ if ( 0 == location.hash.indexOf( '#' ) ) {
1470
+ $( '.wpglobus-about-wrap .nav-tab-wrapper a').each( function( i, e ) {
1471
+ if ( $(e).attr( 'href' ) == location.hash ) {
1472
+ setFirstElement = false;
1473
+ $(e).addClass( 'nav-tab-active' );
1474
+ }
1475
+ });
1476
+ }
1477
+ if ( setFirstElement ) {
1478
+ $( '.wpglobus-about-wrap .nav-tab-wrapper a' ).eq(0).addClass( 'nav-tab-active' );
1479
+ }
1480
+
1481
+ var activePanel = $( '.wpglobus-about-wrap .nav-tab-active' ).data( 'tab-id' );
1482
+ if ( '' != activePanel ) {
1483
+ $( '#'+activePanel ).css({'display':'block'});
1484
+ }
1485
+
1486
+ $(document).on( 'click', '.wpglobus-about-wrap .nav-tab', function(event){
1487
+ var $t = $( this );
1488
+ if ( $t.hasClass( 'nav-tab-active' ) ) {
1489
+ return;
1490
+ }
1491
+ $( '.wpglobus-admin-central-tab' ).css({ 'display':'none' });
1492
+ $( '.wpglobus-about-wrap .nav-tab' ).removeClass( 'nav-tab-active' );
1493
+ $t.addClass( 'nav-tab-active' );
1494
+ if ( '' != $t.data( 'tab-id' ) ) {
1495
+ $( '#' + $t.data( 'tab-id' ) ).css({ 'display':'block' });
1496
+ }
1497
+ });
1498
+ },
1499
+ start: function () {
1500
+ var t = this;
1501
+ $('#wpglobus_flags').select2({
1502
+ formatResult: this.format,
1503
+ formatSelection: this.format,
1504
+ minimumResultsForSearch: -1,
1505
+ escapeMarkup: function (m) {
1506
+ return m;
1507
+ }
1508
+ });
1509
+
1510
+ /** disable checked off first language */
1511
+ $('body').on('click', '#enabled_languages-list li:first input', function (event) {
1512
+ event.preventDefault();
1513
+ $('.redux-save-warn').css({'display': 'none'});
1514
+ $('#enabled_languages-list').find('li:first > input').val('1');
1515
+ if ($('#disable_first_language').length === 0) {
1516
+ $(t.config.disable_first_language).insertAfter('#info_bar');
1517
+ }
1518
+ return false;
1519
+ });
1520
+
1521
+ },
1522
+ format: function (language) {
1523
+ return '<img class="wpglobus_flag" src="' + WPGlobusAdmin.flag_url + language.text + '"/>&nbsp;&nbsp;' + language.text;
1524
+ },
1525
+ set_dialog: function() {
1526
+
1527
+ if ( 'undefined' !== typeof WPGlobusAdmin.data.customFieldsEnabled ) {
1528
+ WPGlobusAdmin.data.customFieldsEnabled = this.parseBool( WPGlobusAdmin.data.customFieldsEnabled );
1529
+ if ( ! WPGlobusAdmin.data.customFieldsEnabled ) {
1530
+ return;
1531
+ }
1532
+ }
1533
+
1534
+ var ajaxify_row_id, added_control = false;
1535
+ var add_elements = function(post_id) {
1536
+
1537
+ var id, rows, cb, _cb,
1538
+ _classes = 'wpglobus_dialog_start wpglobus_dialog_icon';
1539
+
1540
+ _cb = [
1541
+ '<div class="wpglobus_dialog_options_wrapper hidden">',
1542
+ '<input style="width:initial;" id="wpglobus-cb-{{id}}" data-object="#wpglobus-dialog-start-{{id}}" data-meta-key="{{meta-key}}" class="wpglobus_dialog_option wpglobus_dialog_cb" type="checkbox" {{checked}} />',
1543
+ '</div>'
1544
+ ].join('');
1545
+
1546
+ if (typeof post_id == 'undefined') {
1547
+ rows = '#the-list tr';
1548
+ } else {
1549
+ rows = '#the-list tr#'+post_id;
1550
+ }
1551
+ $(rows).each(function(){
1552
+ var $t = $(this),
1553
+ tid = $t.attr('id'),
1554
+ element = $t.find('textarea'),
1555
+ clone, name, meta_key,
1556
+ classes = _classes;
1557
+
1558
+ id = element.attr('id');
1559
+ if ( undefined === id ) {
1560
+ return true;
1561
+ }
1562
+ meta_key = $('#'+tid+'-key').val();
1563
+ clone = $('#'+id).clone();
1564
+ $(element).addClass('wpglobus-dialog-field-source hidden');
1565
+ name = element.attr('name');
1566
+ $(clone).attr('id', 'wpglobus-'+id);
1567
+ $(clone).attr('name', 'wpglobus-'+name);
1568
+ $(clone).attr('data-source-id', id);
1569
+ $(clone).attr('class', 'wpglobus-dialog-field');
1570
+ $(clone).val( WPGlobusCore.TextFilter($(element).val(), WPGlobusCoreData.language) );
1571
+ $(clone).insertAfter(element);
1572
+ cb = _cb.replace(/{{id}}/g, id);
1573
+ cb = cb.replace(/{{meta-key}}/g, meta_key);
1574
+ if ( undefined === WPGlobusAdmin.data.post_meta_settings[WPGlobusAdmin.data.post_type] ) {
1575
+ cb = cb.replace(/{{checked}}/, 'checked');
1576
+ } else {
1577
+ if ( undefined !== WPGlobusAdmin.data.post_meta_settings[WPGlobusAdmin.data.post_type][meta_key] && WPGlobusAdmin.data.post_meta_settings[WPGlobusAdmin.data.post_type][meta_key] == 'false' ) {
1578
+ cb = cb.replace(/{{checked}}/, '');
1579
+ classes = _classes+' wpglobus_dialog_start_hidden';
1580
+ } else {
1581
+ cb = cb.replace(/{{checked}}/, 'checked');
1582
+ classes = _classes;
1583
+ }
1584
+ }
1585
+ $t.append('<td style="width:20px;"><div id="wpglobus-dialog-start-'+id+'" data-type="control" data-source-type="textarea" data-source-id="'+id+'" class="'+classes+'"></div>'+cb+'</td>');
1586
+ });
1587
+ if ( ! added_control && $('#list-table .wpglobus_dialog_start').length > 0 ) {
1588
+ $('#list-table thead tr').append('<th class="wpglobus-control-head"><div class="wpglobus_dialog_settings wpglobus_dialog_icon"></div></th>');
1589
+ added_control = true;
1590
+ }
1591
+ }
1592
+
1593
+ add_elements();
1594
+
1595
+ $('body').on('change', '.wpglobus-dialog-field', function(){
1596
+ var $t = $(this),
1597
+ source_id = '#'+$t.data('source-id'),
1598
+ source = '', s = '', new_value;
1599
+
1600
+ if ( typeof source_id == 'undefined' ) {
1601
+ return;
1602
+ }
1603
+ source = $(source_id).val();
1604
+
1605
+ if ( ! /(\{:|\[:|<!--:)[a-z]{2}/.test(source) ) {
1606
+ $(source_id).val($t.val());
1607
+ } else {
1608
+ $.each(WPGlobusCoreData.enabled_languages, function(i,l){
1609
+ if ( l == WPGlobusCoreData.language ) {
1610
+ new_value = $t.val();
1611
+ } else {
1612
+ new_value = WPGlobusCore.TextFilter(source,l,'RETURN_EMPTY');
1613
+ }
1614
+ if ( '' != new_value ) {
1615
+ s = s + WPGlobusCore.addLocaleMarks(new_value,l);
1616
+ }
1617
+ });
1618
+ $(source_id).val(s);
1619
+ }
1620
+
1621
+ });
1622
+
1623
+ $(document).ajaxSend(function(event, jqxhr, settings){
1624
+ if ( 'add-meta' == settings.action ) {
1625
+ ajaxify_row_id = settings.element;
1626
+ }
1627
+ });
1628
+ $(document).ajaxComplete(function(event, jqxhr, settings){
1629
+ if ( 'add-meta' == settings.action && undefined !== jqxhr.responseXML ) {
1630
+ if ( 'newmeta' == ajaxify_row_id ) {
1631
+ add_elements('meta-'+$(jqxhr.responseXML.documentElement.outerHTML).find('meta').attr('id'));
1632
+ } else {
1633
+ add_elements(ajaxify_row_id);
1634
+ }
1635
+ }
1636
+ });
1637
+
1638
+ WPGlobusDialogApp.init({dialogTitle:'Edit meta'});
1639
+
1640
+ }
1641
+ };
1642
+
1643
+ new WPGlobusAdminApp.App();
1644
+
1645
+ return WPGlobusAdminApp;
1646
+
1647
+ }(window.WPGlobusAdminApp || {}, jQuery));
1648
+
1649
+ });
includes/js/wpglobus-admin-47.min.js ADDED
@@ -0,0 +1 @@
 
1
+ var WPGlobusCore;!function(t){var a;a=WPGlobusCore={strpos:function(t,a,e){var o=(t=""+t).indexOf(a,e);return o>=0&&o},TextFilter:function(t,e,o){if(void 0===t||""===t)return t;var n,i,l=[],s=!1;e=""==e?"en":e,o=void 0===o||""==o?"RETURN_IN_DEFAULT_LANGUAGE":o,l[0]=[],l[0].start=WPGlobusCoreData.locale_tag_start.replace("%s",e),l[0].end=WPGlobusCoreData.locale_tag_end,l[1]=[],l[1].start="\x3c!--:"+e+"--\x3e",l[1].end="\x3c!--:--\x3e",l[2]=[],l[2].start="[:"+e+"]",l[2].end="[:";for(var d=0;d<3;d++)if(!1!==(n=a.strpos(t,l[d].start))){n+=l[d].start.length,t=!1===(i=a.strpos(t,l[d].end,n))?t.substr(n):t.substr(n,i-n),s=!0;break}return s||("RETURN_EMPTY"==o?(e!=WPGlobusCoreData.default_language||/(\{:|\[:|<!--:)[a-z]{2}/.test(t))&&(t=""):e==WPGlobusCoreData.default_language?/(\{:|\[:|<!--:)[a-z]{2}/.test(t)&&(t=""):t=a.TextFilter(t,WPGlobusCoreData.default_language)),t},addLocaleMarks:function(t,a){return WPGlobusCoreData.locale_tag_start.replace("%s",a)+t+WPGlobusCoreData.locale_tag_end},getTranslations:function(e){var o,n={};return t.each(WPGlobusCoreData.enabled_languages,function(t,i){o=i==WPGlobusCoreData.default_language?"RETURN_IN_DEFAULT_LANGUAGE":"RETURN_EMPTY",n[i]=a.TextFilter(e,i,o)}),n},getString:function(e,o,n){if(void 0===e)return e;void 0===o&&(o=""),void 0===n&&(n=WPGlobusCoreData.language),(e=a.getTranslations(e))[n]=o;var i="";return t.each(e,function(t,e){""!=e&&t!=WPGlobusCoreData.default_language&&(i+=a.addLocaleMarks(e,t))}),""!=e[WPGlobusCoreData.default_language]&&(i=""==i?e[WPGlobusCoreData.default_language]:a.addLocaleMarks(e[WPGlobusCoreData.default_language],WPGlobusCoreData.default_language)+i),i}}}(jQuery);var WPGlobusDialogApp;!function(t){var a;a=WPGlobusDialogApp={option:{listenClass:".wpglobus_dialog_start",settingsClass:".wpglobus_dialog_settings",dialogTabs:"#wpglobus-dialog-tabs",dialogTitle:"",customData:null,callback:function(){},dialogOptions:{title:"",placeholder:"",formFooter:"",beforeOpen:function(){},close:function(){}},dialog:{}},form:void 0,element:void 0,element_by:"id",id:"",clone_id:"",wpglobus_id:"",type:"textarea",source:"",order:{},value:{},request:"core",attrs:{},dialogTitle:"",trClass:"wpglobus-translatable",startButton:['<span id="wpglobus-dialog-start-{{clone_id}}" ','style="{{style}}" ','data-type="control" data-dialog-title="{{title}}" ','data-source-type="" data-source-id="{{id}}" data-source-name="{{name}}" ','data-nodename="{{nodename}}"',"{{sbTitle}} ",'class="{{classes}}"></span>'].join(""),startButtonClass:"wpglobus_dialog_start wpglobus_dialog_icon",clicks:0,init:function(e){a.option.dialog=a.option.dialogOptions,a.option=t.extend(a.option,e),t(a.option.dialogTabs).tabs(),a.dialogTitle=a.option.dialogTitle,this.attachListener(),null!=a.option.customData&&void 0!==a.option.customData.addElements&&t.each(a.option.customData.addElements,function(t,e){a.addElement(e)})},convertToId:function(t){return t=(t=t.replace(/\]/g,"")).replace(/\[/g,"-")},addElement:function(e){var o={id:null,style:"",styleTextareaWrapper:"",sbTitle:"",onChangeClass:"",dialogTitle:"",dialog:a.option.dialogOptions};if("string"==typeof e)o.id=e;else{if("object"!=typeof e)return;o=t.extend(o,e)}var n,i,l,s=null,d=null,u=null,r=null,c=a.startButton,g="";if(a.element_by="name",0==(r=document.getElementsByName(o.id)).length&&(a.element_by="id",r=document.getElementById(o.id)),null!==r){if(d=o.id,"id"==a.element_by?s=t("#"+d):(g=(g=r[0].nodeName).toLowerCase(),s=t(g+'[name="'+d+'"]')),u=void 0===s.attr("name")||""==s.attr("name")?d:s.attr("name"),a.clone_id=a.convertToId(d),-1!=u.indexOf("wpglobus")||-1!=a.clone_id.indexOf("wpglobus"))return!1;if(t("#wpglobus-"+a.clone_id).length>0)return!1;if(t(g+'[name="wpglobus-'+u+'"]').length>0)return!1;n=t(s.clone()),l=s.attr("style")||"",s.attr("style","display:none;"),n.attr("id","wpglobus-"+a.clone_id).attr("name","wpglobus-"+u),n.addClass(a.trClass),""!=o.onChangeClass&&n.addClass(o.onChangeClass),"id"==a.element_by?n.attr("data-source-id",d).attr("data-source-name","").attr("data-source-get-by",a.element_by):n.attr("data-source-id","").attr("data-source-name",u).attr("data-source-get-by",a.element_by),"textarea"==g?(i=WPGlobusCore.getTranslations(s.val())[WPGlobusCoreData.language],n.val(i),n.attr("data-nodename","textarea"),""==o.style?n.attr("style",l+";width:95%;float:left;"):n.attr("style",l+";"+o.style)):(i=WPGlobusCore.getTranslations(s.val())[WPGlobusCoreData.language],n.attr("value",i),n.attr("data-nodename","input"),""!=o.style&&n.attr("style",l+";"+o.style)),""!=o.dialog&&n.attr("data-dialog",JSON.stringify(o.dialog)),c=c.replace(/{{clone_id}}/g,a.clone_id),c="id"==a.element_by?(c=(c=c.replace(/{{id}}/g,a.clone_id)).replace(/{{name}}/g,"")).replace(/{{nodename}}/g,""):(c=(c=c.replace(/{{id}}/g,"")).replace(/{{name}}/g,u)).replace(/{{nodename}}/g,g),c="textarea"==g?c.replace("{{style}}","float:left;margin-top:0;"):c.replace("{{style}}","");var b="textarea"==g?a.startButtonClass+" wpglobus-textarea wpglobus-textarea-"+a.clone_id:a.startButtonClass;c=c.replace("{{classes}}",b),c=""==o.dialogTitle?c.replace("{{title}}",a.dialogTitle):c.replace("{{title}}",o.dialogTitle),c=""==o.sbTitle?c.replace("{{sbTitle}}",o.sbTitle):c.replace("{{sbTitle}}",'title="'+o.sbTitle+'"'),t(c).insertAfter(s),t(n).insertAfter(s),"textarea"==g&&(t("#wpglobus-"+a.clone_id).addClass("wpglobus-textarea-"+a.clone_id),t(".wpglobus-textarea-"+a.clone_id).wrapAll('<div class="wpglobus-textarea-wrapper" style="'+o.styleTextareaWrapper+'"></div>'));var p,m=!1;if(""==o.onChangeClass)p="#wpglobus-"+a.clone_id;else{p="."+o.onChangeClass;var v=t._data(t(document)[0],"events");void 0===v?m=!0:void 0!==v.change&&t.each(v.change,function(t,a){if(a.selector==p)return m=!0,!1})}return!!m||(t(document).on("change",p,function(){var a=t(this),e=a.data("source-id");e=""==e?a.data("nodename")+'[name="'+a.data("source-name")+'"]':"#"+e,t(e).val(WPGlobusCore.getString(t(e).val(),a.val()))}),!0)}},saveDialog:function(){var e,o,n,i="",l="",s="";t(".wpglobus_dialog_textarea").each(function(a,d){e=t(d),o=e.val(),(n=e.data("language"))==WPGlobusAdmin.data.language&&(s=o),""!=o&&(i+=WPGlobusCore.addLocaleMarks(o,n),n==WPGlobusCoreData.default_language&&(l=o))}),i=i.length==l.length+8?l:i,t(a.id).val(i),i=""==s?l:s,t(a.wpglobus_id).val(i)},dialog:t("#wpglobus-dialog-wrapper").dialog({autoOpen:!1,width:650,modal:!0,dialogClass:"wpglobus-dialog",buttons:[{text:"Save",class:"wpglobus-button-save",click:function(){a.saveDialog(),a.dialog.dialog("close")}},{text:"Cancel",class:"wpglobus-button-cancel",click:function(){a.dialog.dialog("close")}}],open:function(e,o){var n=a.dialogTitle;void 0!==a.attrs.maxlength&&(t(".wpglobus_dialog_textarea").attr("maxlength",a.attrs.maxlength),n+=" | maxlength="+a.attrs.maxlength),t(".wpglobus-dialog .ui-dialog-title").text(n)},close:function(){a.runCallback(a.option.dialog.close),a.form[0].reset()}}),attachListener:function(){t(document).on("click",a.option.settingsClass,function(){t(".wpglobus_dialog_options_wrapper").hasClass("hidden")?t(".wpglobus_dialog_options_wrapper").removeClass("hidden"):t(".wpglobus_dialog_options_wrapper").addClass("hidden")}),t(document).on("click",".wpglobus_dialog_option",function(e){var o=t(this),n=o.data("object");a.order.action="save_post_meta_settings",a.order.post_type=WPGlobusAdmin.data.post_type,a.order.checked=o.prop("checked"),a.order.id=o.attr("id"),a.order.meta_key=o.data("meta-key"),a.ajax(a.order).done(function(a){"ok"==a.result&&("true"==a.checked?t(n).removeClass("wpglobus_dialog_start_hidden"):t(n).addClass("wpglobus_dialog_start_hidden"))}).fail(function(t){}).always(function(t,a){})}),t(document).on("click",a.option.listenClass,function(e){a.element=t(this),a.id=a.element.data("source-id"),""==a.id?(a.id=a.element.data("nodename")+'[name="'+a.element.data("source-name")+'"]',a.wpglobus_id="#wpglobus-"+a.convertToId(a.element.data("source-name"))):(a.wpglobus_id="#wpglobus-"+a.id,a.id="#"+a.id),a.clicks++,1==a.clicks&&setTimeout(function(){if(1==a.clicks)a.onClick(e);else{var o=t(a.id);o.hasClass("hidden")?o.removeClass("hidden").attr("style","display:block;"):o.addClass("hidden").attr("style","display:none;")}a.clicks=0},200)}),a.form=a.dialog.find("form#wpglobus-dialog-form").on("submit",function(t){t.preventDefault(),a.saveDialog()})},ajax:function(a){return t.ajax({type:"POST",url:WPGlobusAdmin.ajaxurl,data:{action:WPGlobusAdmin.process_ajax,order:a},dataType:"json",async:!1})},onClick:function(e){void 0===a.element.data("dialog-title")||""==a.element.data("dialog-title")?a.dialogTitle=a.option.dialogTitle:a.dialogTitle=a.element.data("dialog-title"),void 0!==a.id&&(a.attrs.maxlength=t(a.id).attr("maxlength")),a.source=a.element.data("source-value"),void 0===a.source&&(a.source=t(a.id).val(),"ajax"==a.request||(a.value=WPGlobusCore.getTranslations(a.source))),a.option.dialog=t.extend({},a.option.dialogOptions,t(a.wpglobus_id).data("dialog")),""!=a.option.dialog.title&&(a.dialogTitle=a.option.dialog.title),t.each(a.value,function(e,o){var n=t("#wpglobus-dialog-"+e);n.val(o),n.attr("placeholder",WPGlobusCore.TextFilter(a.option.dialog.placeholder,e,"RETURN_IN_DEFAULT_LANGUAGE"))}),t("#wpglobus-dialog-form-footer").html(a.option.dialog.formFooter),a.runCallback(a.option.dialog.beforeOpen),a.dialog.dialog("open")},runCallback:function(t){if("object"==typeof t){var a=Object.keys(t)[0],e=t[Object.keys(t)[0]];"window"===a?"function"==typeof window[e]&&window[e](t[Object.keys(t)[1]]):"function"==typeof window[a][e]&&window[a][e](t[Object.keys(t)[1]])}else"string"==typeof t&&"function"==typeof window[t]&&window[t]()}}}(jQuery),jQuery(document).ready(function(){"use strict";window.WPGlobusAdminApp=(t=window.WPGlobusAdminApp||{},a=jQuery,t.App=function(t){void 0===window.WPGlobusAdminApp&&(this.config={debug:!1,version:WPGlobusAdmin.version},this.status="ok","undefined"==typeof WPGlobusAdmin?(this.status="error",this.config.debug&&console.log("WPGlobus: error options loading")):this.config.debug&&console.dir(WPGlobusAdmin),this.config.disable_first_language=['<div id="disable_first_language" style="display:block;" class="redux-field-errors notice-red">',"<strong>","<span>&nbsp;</span>",WPGlobusAdmin.i18n.cannot_disable_language,"</strong>","</div>"].join(""),a.extend(this.config,t),"ok"===this.status&&this.init())},t.App.prototype={$document:a(document),init:function(){WPGlobusCoreData.multisite=this.parseBool(WPGlobusCoreData.multisite),this.adminInit(),a("#content").addClass("wpglobus-editor").attr("data-language",WPGlobusAdmin.data.default_language),a("textarea[id^=content_]").each(function(t,e){var o=a(e).attr("id").replace("content_","");a(e).attr("data-language",o)}),"post.php"===WPGlobusAdmin.page?(this.postEdit(),this.set_dialog(),"undefined"!=typeof WPGlobusAioseop&&WPGlobusAioseop.init()):"menu-edit"===WPGlobusAdmin.page?this.navMenus():"taxonomy-edit"===WPGlobusAdmin.page?WPGlobusAdmin.data.tag_id&&this.taxonomyEdit():"taxonomy-quick-edit"===WPGlobusAdmin.page?this.quickEdit("taxonomy"):"edit.php"===WPGlobusAdmin.page?this.quickEdit("post"):"options-general.php"==WPGlobusAdmin.page?this.optionsGeneral():"widgets.php"==WPGlobusAdmin.page?(WPGlobusWidgets.init(),WPGlobusDialogApp.init({dialogTitle:"Edit text"})):"wpglobus_options"==WPGlobusAdmin.page?this.start():"wpglobusAdminCentral"==WPGlobusAdmin.page?this.adminCentral():WPGlobusDialogApp.init({customData:WPGlobusCoreData.page_custom_data})},parseBool:function(t){return!/^(false|0)$/i.test(t)&&!!t},getCurrentTab:function(){return a(".wpglobus-post-body-tabs-list .ui-tabs-active").data("language")},adminInit:function(){var t=a(".wpglobus-addons-group a").data("key");if(void 0!==t)if(window.location.search.indexOf("page=wpglobus_options&tab="+t)>=0)WPGlobusCoreData.multisite?window.location=WPGlobusCoreData.pluginInstallLocation.multisite:window.location=WPGlobusCoreData.pluginInstallLocation.single;else{var e=a("#toplevel_page_wpglobus_options li").eq(t+1);WPGlobusCoreData.multisite?a(e).find("a").attr("href",WPGlobusCoreData.pluginInstallLocation.multisite).attr("onclick","window.location=jQuery(this).attr('href');return false;"):a(e).find("a").attr("href",WPGlobusCoreData.pluginInstallLocation.single).attr("onclick","window.location=jQuery(this).attr('href');return false;")}},optionsGeneral:function(){var t=a("#blogname"),e=a("body");t.addClass("hidden"),a("#wpglobus-blogname").insertAfter(t).removeClass("hidden"),e.on("blur",".wpglobus-blogname",function(){a(".wpglobus-blogname").each(function(e,o){var n=a(o);t.val(WPGlobusCore.getString(t.val(),n.val(),n.data("language")))})});var o=a("#blogdescription");o.addClass("hidden"),a("#wpglobus-blogdescription").insertAfter(o).removeClass("hidden"),e.on("blur",".wpglobus-blogdesc",function(){a(".wpglobus-blogdesc").each(function(t,e){var n=a(e);o.val(WPGlobusCore.getString(o.val(),n.val(),n.data("language")))})})},quickEdit:function(t){if(void 0!==WPGlobusAdmin.data.has_items&&WPGlobusAdmin.data.has_items){var e="",o=0;a(document).ajaxComplete(function(t,n,i){void 0!==i.data&&""!=e&&i.data.indexOf("action=inline-save-tax&")>=0&&(a("#"+e+" a.row-title").text(WPGlobusAdmin.qedit_titles[o][WPGlobusAdmin.data.language].name),a("#"+e+" .description").text(WPGlobusAdmin.qedit_titles[o][WPGlobusAdmin.data.language].description))});var n={};a("#the-list tr").each(function(e,i){var l=a(i),s="post"===t?"post-":"tag-";o=l.attr("id").replace(s,""),n[o]={},"post"===t?n[o].source=l.find(".post_title").text():"taxonomy"===t&&(n[o].source=a("#inline_"+o+" .name").text())});var i={};i.action="get_titles",i.type=t,i.taxonomy=void 0!==WPGlobusAdmin.data.taxonomy&&WPGlobusAdmin.data.taxonomy,i.title=n,a.ajax({type:"POST",url:WPGlobusAdmin.ajaxurl,data:{action:WPGlobusAdmin.process_ajax,order:i},dataType:"json"}).done(function(t){WPGlobusAdmin.qedit_titles=t.qedit_titles,a.each(t.bulkedit_post_titles,function(t,e){a("#inline_"+t+" .post_title").text(e[WPGlobusAdmin.data.language].name)})}).fail(function(t){}).always(function(t,a){}),a("body").on("change",".wpglobus-quick-edit-title",function(){var t="",e=[];a(".wpglobus-quick-edit-title").each(function(n,i){var l=a(i),s=l.data("language");""!==l.val()&&(t=WPGlobusCore.getString(t,l.val(),s)),WPGlobusAdmin.qedit_titles[o][s].name=l.val(),e[n]=s});var n=a(document).triggerHandler("wpglobus_get_translations",{string:t,lang:e,id:o});void 0!==n&&(t=n),a("input.ptitle").eq(0).attr("value",t),WPGlobusAdmin.qedit_titles[o].source=t}),void 0!==WPGlobusAdmin.data.tags&&a.each(WPGlobusAdmin.data.tags,function(t,a){WPGlobusAdmin.data.value[a].post_id={}}),a("button.save, input#bulk_edit").on("mouseenter",function(t){void 0!==WPGlobusAdmin.data.tags&&("bulk_edit"==t.currentTarget.id?a("input#bulk_edit").unbind("click"):a("button.save").unbind("click"),a("button.save, input#bulk_edit").on("click",function(t){var e=a.when(),n=(a(this),a.Deferred());n.resolve(function(e){e.next(".spinner").css({visibility:"visible"}),"bulk_edit"!=t.currentTarget.id&&a.ajaxSetup({async:!1});var o,n,i,l=e.parents("tr"),s=l.attr("id").replace("edit-","");a.each(WPGlobusAdmin.data.tags,function(t,a){if(0==(o=l.find("textarea[name='"+WPGlobusAdmin.data.names[a]+"']")).length)return!0;WPGlobusAdmin.data.value[a].post_id[s]=o.val(),n=WPGlobusAdmin.data.value[a].post_id[s].split(","),i=[];for(var e=0;e<n.length;e++)n[e]=n[e].trim(" "),""!=n[e]&&(void 0===WPGlobusAdmin.data.tag[a][n[e]]?i[e]=n[e]:i[e]=WPGlobusAdmin.data.tag[a][n[e]]);o.val(i.join(", "))})}(a(this))),e=e.then(function(){return a.when(n.done())}).then(function(){"bulk_edit"!=t.currentTarget.id&&setTimeout(function(){inlineEditPost.save(o),a.ajaxSetup({async:!0})},50)})}))}),a("#the-list").on("click","a.editinline",function(){var n=a(this);if(e=n.parents("tr").attr("id"),"post"===t)o=e.replace("post-","");else{if("taxonomy"!==t)return;o=e.replace("tag-","")}"post"===t&&void 0!==WPGlobusAdmin.data.tags&&a.each(WPGlobusAdmin.data.tags,function(t,e){if(""!=WPGlobusAdmin.data.value[e]){var n,i=a("#edit-"+o+' textarea[name="'+WPGlobusAdmin.data.names[e]+'"]').val();void 0!==i&&(n=i.split(","),a.each(n,function(t,a){i=i.replace(a,WPGlobusCore.TextFilter(a,WPGlobusCoreData.language))}),a("#edit-"+o+' textarea[name="'+WPGlobusAdmin.data.names[e]+'"]').val(i))}});var i=a("#edit-"+o+" input.ptitle").eq(0),l=i.parents("label");i.val(WPGlobusAdmin.qedit_titles[o].source),i.addClass("hidden"),a(WPGlobusAdmin.data.template).insertAfter(l),void 0===WPGlobusAdmin.qedit_titles[o]&&(WPGlobusAdmin.qedit_titles[o]={},WPGlobusAdmin.qedit_titles[o].source=a("#"+e+" .name a.row-title").text(),a(WPGlobusAdmin.data.enabled_languages).each(function(t,a){WPGlobusAdmin.qedit_titles[o][a]={},a==WPGlobusAdmin.data.default_language?WPGlobusAdmin.qedit_titles[o][a].name=WPGlobusAdmin.qedit_titles[o].source:WPGlobusAdmin.qedit_titles[o][a].name="",WPGlobusAdmin.qedit_titles[o][a].description=""})),a(".wpglobus-quick-edit-title").each(function(t,e){var n=a(e),i=n.data("language");n.attr("id",i+o),void 0!==WPGlobusAdmin.qedit_titles[o][i]&&(WPGlobusAdmin.qedit_titles[o][i].name=WPGlobusAdmin.qedit_titles[o][i].name.replace(/\\\'/g,"'"),WPGlobusAdmin.qedit_titles[o][i].name=WPGlobusAdmin.qedit_titles[o][i].name.replace(/\\\"/g,'"'),n.attr("value",WPGlobusAdmin.qedit_titles[o][i].name),WPGlobusAdmin.qedit_titles[o].source=WPGlobusCore.getString(WPGlobusAdmin.qedit_titles[o].source,WPGlobusAdmin.qedit_titles[o][i].name,i))}),a("input.ptitle").eq(0).attr("value",WPGlobusAdmin.qedit_titles[o].source)})}},taxonomyEdit:function(){var t=[];t[0]="name",t[1]="description",a.each(WPGlobusCoreData.enabled_languages,function(e,o){a.each(t,function(t,e){!function(t,e){var o,n=a("#"+t),i=n.clone(),l=n.attr("name"),s="wpglobus-element wpglobus-element_"+t+" wpglobus-element_"+e+" wpglobus-translatable";o=(o=document.getElementById(t)).nodeName,a(i).attr("id",t+"_"+e),a(i).attr("name",l+"_"+e),e!==WPGlobusCoreData.default_language&&(s+=" hidden"),a(i).attr("class",s),a(i).attr("data-save-to",t),a(i).attr("data-language",e),"INPUT"==o?a(i).attr("value",a("#wpglobus-link-tab-"+e).data(t)):"TEXTAREA"==o&&a(i).text(a("#wpglobus-link-tab-"+e).data(t)),n.addClass("hidden"),0==a(".wpglobus-element_"+t).length?a(i).insertAfter(n):a(i).insertAfter(a(".wpglobus-element_"+t).last())}(e,o)})}),a(".wpglobus-taxonomy-tabs").insertAfter("#ajax-response"),a(".wrap").tabs(),a("body").on("click",".wpglobus-taxonomy-tabs li",function(t){var e=a(this).data("language");a(".wpglobus-element").addClass("hidden"),a(".wpglobus-element_"+e).removeClass("hidden")}),a(".wpglobus-element").on("change",function(){var t=a(this).data("save-to"),e="";a(".wpglobus-element").each(function(o,n){var i=a(n),l=i.val();i.data("save-to")==t&&""!==l&&(e+=WPGlobusCore.addLocaleMarks(l,i.data("language")))}),a("#"+t).val(e)}),a(WPGlobusAdmin.data.multilingualSlug.title).insertAfter(".term-slug-wrap th label")},navMenus:function(){var t,e,o="#menu-to-edit .menu-item",n=function(){e!==a(o).length&&(clearInterval(t),a(o).each(function(t,e){var o=a(e);if(!o.hasClass("wpglobus-menu-item")){var n=a(e).attr("id");a.each(["input.edit-menu-item-title","input.edit-menu-item-attr-title"],function(t,e){var o=a("#"+n+" "+e),i=a(o);if(!i.hasClass("wpglobus-hidden")){i.addClass("wpglobus-hidden"),i.css("display","none");var l=i.parent("label"),s=i.parents("p");a(s).css("height","80px"),a(l).append('<div style="color:#f00;">'+WPGlobusAdmin.i18n.save_nav_menu+"</div>")}}),o.addClass("wpglobus-menu-item")}}))};a.ajaxSetup({beforeSend:function(i,l){void 0!==l.data&&l.data.indexOf("action=add-menu-item")>=0&&(e=a(o).length,t=setInterval(n,500))}}),a(o).each(function(t,e){var o=a(e).attr("id"),n=o.replace("menu-item-","");a.each(["input.edit-menu-item-title","input.edit-menu-item-attr-title"],function(t,e){var i=a("#"+o+" "+e);i.val()!=WPGlobusAdmin.data.items[n][e].source&&i.val(WPGlobusAdmin.data.items[n][e].source);var l=a("#"+o+" "+e).parents("p"),s=0;a.each(WPGlobusAdmin.data.open_languages,function(o,d){var u=i.clone();u.attr("id",i.attr("id")+"-"+d),u.attr("name",i.attr("id")+"-"+d),u.attr("data-language",d),u.attr("data-item-id",n),u.attr("placeholder",WPGlobusAdmin.data.en_language_name[d]);var r=WPGlobusAdmin.data.items[n][d][e].class;0===t&&d===WPGlobusAdmin.data.default_language?u.attr("class",r+" edit-menu-item-title"):u.attr("class",r),""!=WPGlobusAdmin.data.items[n][d][e].caption?u.attr("value",WPGlobusAdmin.data.items[n][d][e].caption):u.attr("value",""),u.css("margin-bottom","0.6em"),a(l).append(u),s=o}),s=40*(s+1),i.css("display","none").attr("class","").addClass("widefat wpglobus-hidden"),a(l).css("height",s+"px").addClass("wpglobus-menu-item-box")}),a(e).addClass("wpglobus-menu-item")}),a(".menus-move-left, .menus-move-right").each(function(t,e){var o,n=a(e),i=(n.parents("li").attr("id").replace("menu-item-",""),n.attr("title"));void 0!==i&&a.each(WPGlobusAdmin.data.post_titles,function(t,a){i.indexOf(t)>=0&&(o=i.replace(t,a),n.attr("title",o),n.text(o))})}),a(".edit-menu-item-title").trigger("change"),wpNavMenu.refreshAdvancedAccessibility(),wpNavMenu.menusChanged=!1,a(".wpglobus-menu-item").on("change",function(){var t,e,o=a(this),n=o.data("item-id");o.hasClass("wpglobus-item-title")&&(t=WPGlobusCore.getString(a("input#edit-menu-item-title-"+n).val(),o.val(),o.data("language")),void 0!==(e=a(document).triggerHandler("wpglobus_get_menu_translations",{string:t,lang:WPGlobusCoreData.open_languages,id:n,type:"input.edit-menu-item-title"}))&&(t=e),a("input#edit-menu-item-title-"+n).val(t)),o.hasClass("wpglobus-item-attr")&&(t=WPGlobusCore.getString(a("input#edit-menu-item-attr-title-"+n).val(),o.val(),o.data("language")),void 0!==(e=a(document).triggerHandler("wpglobus_get_menu_translations",{string:t,lang:WPGlobusCoreData.open_languages,id:n,type:"input.edit-menu-item-attr-title"}))&&(t=e),a("input#edit-menu-item-attr-title-"+n).val(t))})},postEdit:function(){a(document).on("heartbeat-send",function(t,e){void 0!==e.wp_autosave&&(e.wpglobus_heartbeat="wpglobus",a.each(WPGlobusAdmin.data.open_languages,function(t,o){var n=a("#title_"+o).val()||"";""!=(n=a.trim(n))&&(e.wp_autosave["post_title_"+o]=n),n=a("#content_"+o).val()||"",""!=(n=a.trim(n))&&(e.wp_autosave["content_"+o]=n)}))});var t="#postdivrich",e=!0,o="#post-body-content";if(!1===WPGlobusAdmin.data.support.editor&&(t="#titlediv",e=!1),!1===WPGlobusAdmin.data.support.title&&(e=!1),a(o).prepend(a(".wpglobus-post-body-tabs-list")),a.each(WPGlobusAdmin.tabs,function(o,n){"default"===n?(a(t).wrap('<div id="tab-default"></div>'),e&&a(a("#titlediv")).insertBefore(t)):(a(t+"-"+n).wrap('<div id="tab-'+n+'"></div>'),e&&a(a("#titlediv-"+n)).insertBefore(t+"-"+n))}),a(o).addClass("wpglobus-post-body-tabs").tabs({beforeActivate:function(t,e){var o=e.oldTab[0].id.replace("link-tab-",""),n=e.newTab[0].id.replace("link-tab-","");"default"==o&&(o=WPGlobusCoreData.default_language),"default"==n&&(n=WPGlobusCoreData.default_language);var i=a(document).triggerHandler("wpglobus_post_body_tabs",[o,n]);return!(!i&&void 0!==i)}}),a("#title").val(WPGlobusAdmin.title),a("#content").text(WPGlobusAdmin.content),"undefined"!=typeof WPGlobusVendor&&WPGlobusVendor.vendor.WPSEO&&("undefined"!=typeof wpglobus_wpseo?wpglobus_wpseo():"undefined"!=typeof WPGlobusYoastSeo&&("undefined"!=typeof WPGlobusYoastSeoPremium&&WPGlobusYoastSeoPremium&&WPGlobusYoastSeoPremium.init(),WPGlobusYoastSeo.init())),WPGlobusAdmin.data.modify_excerpt){var n=a("#excerpt");n.addClass("hidden").css({display:"none"}),a(WPGlobusAdmin.data.template).insertAfter(n),a("body").on("change",".wpglobus-excerpt",function(){var t=a(this);n.val(WPGlobusCore.getString(n.val(),t.val(),t.data("language")))})}if(void 0!==wp.utils&&void 0!==wp.utils.WordCounter){WPGlobusCoreData.wordCounter={};var i=this,l={};a.each(WPGlobusCoreData.enabled_languages,function(t,a){if(a==WPGlobusCoreData.default_language)return!0;l[t]="content_"+a,e=jQuery,o=new wp.utils.WordCounter,n=a,WPGlobusCoreData.wordCounter[n]={},WPGlobusCoreData.wordCounter[n].counter=o,e(function(){WPGlobusCoreData.wordCounter[n].content=e("#content_"+n),WPGlobusCoreData.wordCounter[n].count=e("#wp-word-count-"+n).find(".word-count-"+n),WPGlobusCoreData.wordCounter[n].prevCount=0;function t(t){var a,e;"object"==typeof t&&(t="tinymce"==t?i.getCurrentTab():t.target.id.replace("content_","")),void 0!==WPGlobusCoreData.wordCounter[t]&&(a=!WPGlobusCoreData.wordCounter[t].contentEditor||WPGlobusCoreData.wordCounter[t].contentEditor.isHidden()?WPGlobusCoreData.wordCounter[t].content.val():WPGlobusCoreData.wordCounter[t].contentEditor.getContent({format:"raw"}),(e=WPGlobusCoreData.wordCounter[t].counter.count(a))!==WPGlobusCoreData.wordCounter[t].prevCount&&WPGlobusCoreData.wordCounter[t].count.text(e),WPGlobusCoreData.wordCounter[t].prevCount=e)}e(document).on("tinymce-editor-init",function(a,o){if(-1!=e.inArray(o.id,l)){var n=o.id.replace("content_","");WPGlobusCoreData.wordCounter[n].contentEditor=o,o.on("nodechange keyup",_.debounce(t,1e3))}}),WPGlobusCoreData.wordCounter[n].content.on("input keyup",_.debounce(t,1e3)),t(n)});var e,o,n})}a(document).on("click","#publish, #save-post",function(){if(WPGlobusAdmin.data.open_languages.length>1){a(document).triggerHandler("wpglobus_before_save_post",{content_tabs_id:o});var t,e=a("#title").val(),n="",i="";0==e.length&&(t=WPGlobusAdmin.data.open_languages.indexOf(WPGlobusAdmin.data.default_language),WPGlobusAdmin.data.open_languages.splice(t,1),a(WPGlobusAdmin.data.open_languages).each(function(t,o){i=0==t?"":"-",(e=a("#title_"+o).val()).length>0&&(0==n.length&&(i=""),n=n+i+e)})),n.length>0&&a("#title").val(n)}void 0===WPGlobusAdmin.data.tagsdiv||WPGlobusAdmin.data.tagsdiv.length<1||a(WPGlobusAdmin.data.tagsdiv).each(function(t,e){if(0==a("#"+e).length)return!0;var o=e.replace("tagsdiv-","");if("undefined"===o)return!0;if(0==a("#tax-input-"+o).length)return!0;var n,i=[];a("#tagsdiv-"+o+" .tagchecklist > span").each(function(t,e){n=(n=a(e).html()).replace(/<button.*<\/button>&nbsp;/,""),void 0===WPGlobusAdmin.data.tag[o][n]?i[t]=n:i[t]=WPGlobusAdmin.data.tag[o][n]}),a("#tax-input-"+o).val(i.join(", "))})}),a(".ui-state-default").on("click",function(){"link-tab-default"===a(this).attr("id")&&(a(window).scrollTop(a(window).scrollTop()+1),a(window).scrollTop(a(window).scrollTop()-1))}),a(document).on("tabsactivate",o,function(t,a){WPGlobusAdmin.currentTab=a.newTab[0].dataset.language}),a(document).triggerHandler("wpglobus_after_post_edit")},adminCentral:function(){a(".wpglobus-admin-central-tab").css({display:"none"}),a(".nav-tab-active").length>1&&a(".wpglobus-about-wrap .nav-tab-wrapper a").removeClass("nav-tab-active");var t=!0;0==location.hash.indexOf("#")&&a(".wpglobus-about-wrap .nav-tab-wrapper a").each(function(e,o){a(o).attr("href")==location.hash&&(t=!1,a(o).addClass("nav-tab-active"))}),t&&a(".wpglobus-about-wrap .nav-tab-wrapper a").eq(0).addClass("nav-tab-active");var e=a(".wpglobus-about-wrap .nav-tab-active").data("tab-id");""!=e&&a("#"+e).css({display:"block"}),a(document).on("click",".wpglobus-about-wrap .nav-tab",function(t){var e=a(this);e.hasClass("nav-tab-active")||(a(".wpglobus-admin-central-tab").css({display:"none"}),a(".wpglobus-about-wrap .nav-tab").removeClass("nav-tab-active"),e.addClass("nav-tab-active"),""!=e.data("tab-id")&&a("#"+e.data("tab-id")).css({display:"block"}))})},start:function(){var t=this;a("#wpglobus_flags").select2({formatResult:this.format,formatSelection:this.format,minimumResultsForSearch:-1,escapeMarkup:function(t){return t}}),a("body").on("click","#enabled_languages-list li:first input",function(e){return e.preventDefault(),a(".redux-save-warn").css({display:"none"}),a("#enabled_languages-list").find("li:first > input").val("1"),0===a("#disable_first_language").length&&a(t.config.disable_first_language).insertAfter("#info_bar"),!1})},format:function(t){return'<img class="wpglobus_flag" src="'+WPGlobusAdmin.flag_url+t.text+'"/>&nbsp;&nbsp;'+t.text},set_dialog:function(){if(void 0===WPGlobusAdmin.data.customFieldsEnabled||(WPGlobusAdmin.data.customFieldsEnabled=this.parseBool(WPGlobusAdmin.data.customFieldsEnabled),WPGlobusAdmin.data.customFieldsEnabled)){var t,e=!1,o=function(t){var o,n,i,l="wpglobus_dialog_start wpglobus_dialog_icon";i=['<div class="wpglobus_dialog_options_wrapper hidden">','<input style="width:initial;" id="wpglobus-cb-{{id}}" data-object="#wpglobus-dialog-start-{{id}}" data-meta-key="{{meta-key}}" class="wpglobus_dialog_option wpglobus_dialog_cb" type="checkbox" {{checked}} />',"</div>"].join(""),a(void 0===t?"#the-list tr":"#the-list tr#"+t).each(function(){var t,e,s,d=a(this),u=d.attr("id"),r=d.find("textarea"),c=l;if(void 0===(o=r.attr("id")))return!0;s=a("#"+u+"-key").val(),t=a("#"+o).clone(),a(r).addClass("wpglobus-dialog-field-source hidden"),e=r.attr("name"),a(t).attr("id","wpglobus-"+o),a(t).attr("name","wpglobus-"+e),a(t).attr("data-source-id",o),a(t).attr("class","wpglobus-dialog-field"),a(t).val(WPGlobusCore.TextFilter(a(r).val(),WPGlobusCoreData.language)),a(t).insertAfter(r),n=(n=i.replace(/{{id}}/g,o)).replace(/{{meta-key}}/g,s),void 0===WPGlobusAdmin.data.post_meta_settings[WPGlobusAdmin.data.post_type]?n=n.replace(/{{checked}}/,"checked"):void 0!==WPGlobusAdmin.data.post_meta_settings[WPGlobusAdmin.data.post_type][s]&&"false"==WPGlobusAdmin.data.post_meta_settings[WPGlobusAdmin.data.post_type][s]?(n=n.replace(/{{checked}}/,""),c=l+" wpglobus_dialog_start_hidden"):(n=n.replace(/{{checked}}/,"checked"),c=l),d.append('<td style="width:20px;"><div id="wpglobus-dialog-start-'+o+'" data-type="control" data-source-type="textarea" data-source-id="'+o+'" class="'+c+'"></div>'+n+"</td>")}),!e&&a("#list-table .wpglobus_dialog_start").length>0&&(a("#list-table thead tr").append('<th class="wpglobus-control-head"><div class="wpglobus_dialog_settings wpglobus_dialog_icon"></div></th>'),e=!0)};o(),a("body").on("change",".wpglobus-dialog-field",function(){var t,e=a(this),o="#"+e.data("source-id"),n="",i="";void 0!==o&&(n=a(o).val(),/(\{:|\[:|<!--:)[a-z]{2}/.test(n)?(a.each(WPGlobusCoreData.enabled_languages,function(a,o){""!=(t=o==WPGlobusCoreData.language?e.val():WPGlobusCore.TextFilter(n,o,"RETURN_EMPTY"))&&(i+=WPGlobusCore.addLocaleMarks(t,o))}),a(o).val(i)):a(o).val(e.val()))}),a(document).ajaxSend(function(a,e,o){"add-meta"==o.action&&(t=o.element)}),a(document).ajaxComplete(function(e,n,i){"add-meta"==i.action&&void 0!==n.responseXML&&o("newmeta"==t?"meta-"+a(n.responseXML.documentElement.outerHTML).find("meta").attr("id"):t)}),WPGlobusDialogApp.init({dialogTitle:"Edit meta"})}}},new t.App,t);var t,a});
includes/js/wpglobus-admin-49.js ADDED
@@ -0,0 +1,1654 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * WPGlobus Administration Core, Dialog, Admin
3
+ * Interface JS functions
4
+ *
5
+ * @since 1.9.0
6
+ *
7
+ * @package WPGlobus
8
+ * @subpackage Administration
9
+ */
10
+ /*jslint browser: true*/
11
+ /*global jQuery, console, WPGlobusCore, WPGlobusDialogApp, WPGlobusAdmin, inlineEditPost */
12
+
13
+ var WPGlobusCore;
14
+
15
+ (function($) {
16
+ var api;
17
+ api = WPGlobusCore = {
18
+ strpos: function( haystack, needle, offset){
19
+ haystack = "" + haystack;
20
+ var i = haystack.indexOf( needle, offset );
21
+ return i >= 0 ? i : false;
22
+ },
23
+
24
+ TextFilter: function(text, language, return_in){
25
+ if ( typeof text == 'undefined' || '' === text ) { return text; }
26
+
27
+ var pos_start, pos_end, possible_delimiters = [], is_local_text_found = false;;
28
+
29
+ language = '' == language ? 'en' : language;
30
+ return_in = typeof return_in == 'undefined' || '' == return_in ? 'RETURN_IN_DEFAULT_LANGUAGE' : return_in;
31
+
32
+ possible_delimiters[0] = [];
33
+ possible_delimiters[0]['start'] = WPGlobusCoreData.locale_tag_start.replace('%s', language);
34
+ possible_delimiters[0]['end'] = WPGlobusCoreData.locale_tag_end;
35
+
36
+ possible_delimiters[1] = [];
37
+ possible_delimiters[1]['start'] = '<!--:'+language+'-->';
38
+ possible_delimiters[1]['end'] = '<!--:-->';
39
+
40
+ possible_delimiters[2] = [];
41
+ possible_delimiters[2]['start'] = '[:'+language+']';
42
+ possible_delimiters[2]['end'] = '[:';
43
+
44
+
45
+
46
+ for (var i = 0; i < 3; i++) {
47
+
48
+ pos_start = api.strpos( text, possible_delimiters[i]['start'] );
49
+ if ( pos_start === false ) {
50
+ continue;
51
+ }
52
+
53
+ pos_start = pos_start + possible_delimiters[i]['start'].length;
54
+
55
+ pos_end = api.strpos( text, possible_delimiters[i]['end'], pos_start );
56
+
57
+ if ( pos_end === false ) {
58
+ text = text.substr( pos_start );
59
+ } else {
60
+ text = text.substr( pos_start, pos_end - pos_start );
61
+ }
62
+
63
+ is_local_text_found = true;
64
+ break;
65
+
66
+ }
67
+
68
+ if ( ! is_local_text_found ) {
69
+ if ( return_in == 'RETURN_EMPTY' ) {
70
+ if ( language == WPGlobusCoreData.default_language && ! /(\{:|\[:|<!--:)[a-z]{2}/.test(text) ) {
71
+ /** do nothing */
72
+ } else {
73
+ text = '';
74
+ }
75
+ } else {
76
+ /**
77
+ * Try RETURN_IN_DEFAULT_LANGUAGE.
78
+ */
79
+ if ( language == WPGlobusCoreData.default_language ) {
80
+ if ( /(\{:|\[:|<!--:)[a-z]{2}/.test(text) ) {
81
+ text = '';
82
+ }
83
+ } else {
84
+ text = api.TextFilter( text, WPGlobusCoreData.default_language );
85
+ }
86
+ }
87
+ }
88
+ return text;
89
+ },
90
+ addLocaleMarks: function(text, language) {
91
+ return WPGlobusCoreData.locale_tag_start.replace('%s', language) + text + WPGlobusCoreData.locale_tag_end;
92
+ },
93
+ getTranslations: function(text) {
94
+ var t = {},
95
+ return_in;
96
+ $.each(WPGlobusCoreData.enabled_languages, function(i,l){
97
+ return_in = l == WPGlobusCoreData.default_language ? 'RETURN_IN_DEFAULT_LANGUAGE' : 'RETURN_EMPTY';
98
+ t[l] = api.TextFilter(text, l, return_in);
99
+ });
100
+ return t;
101
+ },
102
+ getString: function(s, newVal, l) {
103
+ if ( 'undefined' === typeof(s) ) {
104
+ return s;
105
+ }
106
+ if ( 'undefined' === typeof(newVal) ) {
107
+ newVal = '';
108
+ }
109
+ if ( 'undefined' === typeof(l) ) {
110
+ l = WPGlobusCoreData.language;
111
+ }
112
+
113
+ s = api.getTranslations(s);
114
+ s[l] = newVal;
115
+
116
+ var cS = '';
117
+
118
+ $.each(s, function(ln,val){
119
+ if ( '' != val && ln != WPGlobusCoreData.default_language) {
120
+ cS += api.addLocaleMarks(val, ln);
121
+ }
122
+ });
123
+
124
+ if ( '' != s[WPGlobusCoreData.default_language] ) {
125
+ if ( '' == cS ) {
126
+ cS = s[WPGlobusCoreData.default_language];
127
+ } else {
128
+ cS = api.addLocaleMarks(s[WPGlobusCoreData.default_language], WPGlobusCoreData.default_language) + cS;
129
+ }
130
+ }
131
+ return cS;
132
+ }
133
+ };
134
+ })(jQuery);
135
+
136
+ var WPGlobusDialogApp;
137
+
138
+ (function($) {
139
+
140
+ var api;
141
+ api = WPGlobusDialogApp = {
142
+ option : {
143
+ listenClass : '.wpglobus_dialog_start',
144
+ settingsClass : '.wpglobus_dialog_settings',
145
+ dialogTabs: '#wpglobus-dialog-tabs',
146
+ dialogTitle: '',
147
+ customData: null,
148
+ callback: function(){},
149
+ dialogOptions: {
150
+ title: '',
151
+ placeholder: '',
152
+ formFooter: '',
153
+ beforeOpen: function(){},
154
+ close: function(){},
155
+ },
156
+ dialog: {}
157
+ },
158
+ form : undefined,
159
+ element : undefined,
160
+ element_by : 'id',
161
+ id : '',
162
+ clone_id: '',
163
+ wpglobus_id : '',
164
+ type : 'textarea',
165
+ source : '',
166
+ order : {},
167
+ value : {},
168
+ request : 'core',
169
+ attrs: {},
170
+ dialogTitle: '',
171
+ trClass: 'wpglobus-translatable',
172
+ startButton: [
173
+ '<span id="wpglobus-dialog-start-{{clone_id}}" ',
174
+ 'style="{{style}}" ',
175
+ 'data-type="control" data-dialog-title="{{title}}" ',
176
+ 'data-source-type="" data-source-id="{{id}}" data-source-name="{{name}}" ',
177
+ 'data-nodename="{{nodename}}"',
178
+ '{{sbTitle}} ',
179
+ 'class="{{classes}}"></span>'
180
+ ].join(''),
181
+ startButtonClass : 'wpglobus_dialog_start wpglobus_dialog_icon',
182
+ clicks: 0,
183
+ init: function(args) {
184
+ api.option.dialog = api.option.dialogOptions;
185
+ api.option = $.extend(api.option, args);
186
+ $(api.option.dialogTabs).tabs();
187
+ api.dialogTitle = api.option.dialogTitle;
188
+ this.attachListener();
189
+ if ( api.option.customData != null && typeof api.option.customData.addElements != 'undefined' ) {
190
+ $.each(api.option.customData.addElements, function(i,e) {
191
+ api.addElement(e);
192
+ });
193
+ }
194
+ },
195
+ convertToId: function(s){
196
+ s = s.replace(/\]/g,'');
197
+ s = s.replace(/\[/g,'-');
198
+ return s;
199
+ },
200
+ addElement: function(elem) {
201
+ var option = {
202
+ id: null,
203
+ style: '',
204
+ styleTextareaWrapper: '',
205
+ sbTitle: '',
206
+ onChangeClass: '',
207
+ dialogTitle: '',
208
+ dialog: api.option.dialogOptions
209
+ }
210
+ if ( 'string' == typeof(elem) ) {
211
+ option.id = elem;
212
+ } else if ( 'object' == typeof(elem) ) {
213
+ option = $.extend(option, elem);
214
+ } else {
215
+ return;
216
+ }
217
+
218
+ var $element = null, id = null, name = null, node = null,
219
+ sb = api.startButton,
220
+ clone, v, style, nodeName = '';
221
+
222
+ api.element_by = 'name';
223
+ node = document.getElementsByName(option.id);
224
+
225
+ if ( 0 == node.length ) {
226
+ api.element_by = 'id';
227
+ node = document.getElementById(option.id);
228
+ }
229
+
230
+ if ( null === node ) {
231
+ return;
232
+ } else {
233
+ id = option.id;
234
+ if ( 'id' == api.element_by ) {
235
+ $element = $('#'+id);
236
+ } else {
237
+ nodeName = node[0].nodeName;
238
+ nodeName = nodeName.toLowerCase();
239
+ $element = $(nodeName+'[name="'+id+'"]');
240
+ }
241
+ }
242
+
243
+ if ( 'undefined' === typeof $element.attr('name') || '' == $element.attr('name') ) {
244
+ name = id;
245
+ } else {
246
+ name = $element.attr('name');
247
+ }
248
+ api.clone_id = api.convertToId(id);
249
+
250
+ if ( -1 != name.indexOf( 'wpglobus' ) || -1 != api.clone_id.indexOf( 'wpglobus' ) ) {
251
+ /**
252
+ * To prevent add element to itself.
253
+ */
254
+ return false;
255
+ }
256
+
257
+ if ( $( '#wpglobus-'+api.clone_id ).length > 0 ) {
258
+ /**
259
+ * WPGlobus element exists already.
260
+ */
261
+ return false;
262
+ }
263
+ if ( $( nodeName+'[name="wpglobus-'+name+'"]' ).length > 0 ) {
264
+ /**
265
+ * WPGlobus element exists already.
266
+ */
267
+ return false;
268
+ }
269
+
270
+ clone = $( $element.clone() );
271
+ //$element.addClass('hidden');
272
+ style = $element.attr('style') || '';
273
+ $element.attr( 'style', 'display:none;' );
274
+ clone.attr( 'id', 'wpglobus-'+api.clone_id ).attr( 'name', 'wpglobus-'+name );
275
+
276
+ /**
277
+ * Add WPGlobus translatable class.
278
+ */
279
+ clone.addClass( api.trClass );
280
+
281
+ if ( option.onChangeClass != '' ) {
282
+ /**
283
+ * add class to bind 'change' event
284
+ */
285
+ clone.addClass( option.onChangeClass );
286
+ }
287
+
288
+ if ( 'id' == api.element_by ) {
289
+ clone.attr('data-source-id', id).attr('data-source-name', '').attr('data-source-get-by',api.element_by);
290
+ } else {
291
+ clone.attr('data-source-id', '').attr('data-source-name', name).attr('data-source-get-by',api.element_by);
292
+ }
293
+
294
+ if ( 'textarea' == nodeName ) {
295
+ v = WPGlobusCore.getTranslations( $element.val() )[WPGlobusCoreData['language']];
296
+ clone.val( v );
297
+ clone.attr( 'data-nodename', 'textarea' );
298
+ if ( '' == option.style ) {
299
+ clone.attr( 'style', style + ';width:95%;float:left;' );
300
+ } else {
301
+ clone.attr( 'style', style + ';' + option.style );
302
+ }
303
+ } else {
304
+ v = WPGlobusCore.getTranslations( $element.val() )[WPGlobusCoreData['language']];
305
+ clone.attr( 'value', v );
306
+ clone.attr( 'data-nodename', 'input' );
307
+ if ( '' != option.style ) {
308
+ clone.attr( 'style', style + ';' + option.style );
309
+ }
310
+ }
311
+
312
+ /**
313
+ * Add dialog options.
314
+ * @since 1.7.12
315
+ */
316
+ if ( '' != option.dialog ) {
317
+ clone.attr( 'data-dialog', JSON.stringify(option.dialog) );
318
+ }
319
+
320
+ sb = sb.replace(/{{clone_id}}/g, api.clone_id);
321
+ if ( 'id' == api.element_by ) {
322
+ sb = sb.replace(/{{id}}/g, api.clone_id);
323
+ sb = sb.replace(/{{name}}/g, '');
324
+ sb = sb.replace(/{{nodename}}/g, '');
325
+ } else {
326
+ sb = sb.replace(/{{id}}/g, '');
327
+ sb = sb.replace(/{{name}}/g, name);
328
+ sb = sb.replace(/{{nodename}}/g, nodeName);
329
+ }
330
+ sb = 'textarea' == nodeName ? sb.replace( '{{style}}', 'float:left;margin-top:0;' ) : sb.replace( '{{style}}', '' );
331
+ var startButtonClasses = 'textarea' == nodeName ? api.startButtonClass + ' wpglobus-textarea wpglobus-textarea-'+api.clone_id : api.startButtonClass;
332
+ sb = sb.replace( '{{classes}}', startButtonClasses );
333
+ sb = option.dialogTitle == '' ? sb.replace('{{title}}', api.dialogTitle) : sb.replace('{{title}}', option.dialogTitle);
334
+ sb = option.sbTitle == '' ? sb.replace('{{sbTitle}}', option.sbTitle) : sb.replace('{{sbTitle}}', 'title="'+option.sbTitle+'"');
335
+
336
+ $(sb).insertAfter($element);
337
+ $(clone).insertAfter($element);
338
+
339
+ if ( 'textarea' == nodeName ) {
340
+ $('#wpglobus-'+api.clone_id).addClass( 'wpglobus-textarea-'+api.clone_id );
341
+ $('.wpglobus-textarea-'+api.clone_id).wrapAll( '<div class="wpglobus-textarea-wrapper" style="'+option.styleTextareaWrapper+'"></div>' );
342
+ }
343
+
344
+ /**
345
+ * Bind change event
346
+ */
347
+ var selector, ret = false;
348
+ if ( option.onChangeClass == '' ) {
349
+ selector = '#wpglobus-' + api.clone_id;
350
+ } else {
351
+ selector = '.' + option.onChangeClass;
352
+ var $events = $._data( $(document)[0], 'events' );
353
+ if( typeof $events === 'undefined' ){
354
+ ret = true;
355
+ } else {
356
+ if ( typeof $events.change !== 'undefined' ) {
357
+ $.each( $events.change, function(i, ev){
358
+ if ( ev.selector == selector ) {
359
+ ret = true;
360
+ return false;
361
+ }
362
+ });
363
+ }
364
+ }
365
+ }
366
+
367
+ if ( ret ) {
368
+ /**
369
+ * Return because we had bound 'change' event already.
370
+ */
371
+ return true;
372
+ }
373
+
374
+ $(document).on( 'change', selector, function() {
375
+ var $t = $(this),
376
+ sid = $t.data( 'source-id' );
377
+
378
+ if ( '' == sid ) {
379
+ sid = $t.data( 'nodename' ) + '[name="' + $t.data( 'source-name' ) + '"]';
380
+ } else {
381
+ sid = '#' + sid;
382
+ }
383
+ $(sid).val( WPGlobusCore.getString( $(sid).val(), $t.val() ) );
384
+ });
385
+ return true;
386
+ },
387
+ saveDialog: function() {
388
+ var s = '', sdl = '', scl = '', $e, val, l;
389
+ $('.wpglobus_dialog_textarea').each(function(indx,e){
390
+ $e = $(e);
391
+ val = $e.val();
392
+ l = $e.data('language');
393
+ if ( l == WPGlobusAdmin.data.language ) {
394
+ scl = val;
395
+ }
396
+ if ( val != '' ) {
397
+ s = s + WPGlobusCore.addLocaleMarks(val,l);
398
+ if ( l == WPGlobusCoreData.default_language ) {
399
+ sdl = val;
400
+ }
401
+ }
402
+ });
403
+ s = s.length == sdl.length + 8 ? sdl : s;
404
+ $(api.id).val(s);
405
+ s = scl == '' ? sdl : scl;
406
+ $(api.wpglobus_id).val(s);
407
+ },
408
+ dialog : $('#wpglobus-dialog-wrapper').dialog({
409
+ autoOpen: false,
410
+ //height: 250,
411
+ width: 650,
412
+ modal: true,
413
+ dialogClass: 'wpglobus-dialog',
414
+ buttons: [
415
+ {
416
+ text:'Save',
417
+ class: 'wpglobus-button-save',
418
+ click:function(){api.saveDialog(); api.dialog.dialog('close');}
419
+ },
420
+ {
421
+ text:'Cancel',
422
+ class: 'wpglobus-button-cancel',
423
+ click: function(){api.dialog.dialog('close');}
424
+ }
425
+ ],
426
+ open: function( event, ui ) {
427
+ var title = api.dialogTitle;
428
+ if ( typeof api.attrs.maxlength !== 'undefined' ) {
429
+ $('.wpglobus_dialog_textarea').attr('maxlength', api.attrs.maxlength);
430
+ title += ' | maxlength='+api.attrs.maxlength;
431
+ }
432
+ $('.wpglobus-dialog .ui-dialog-title').text(title);
433
+ },
434
+ close: function() {
435
+ /**
436
+ * Close callback.
437
+ */
438
+ api.runCallback( api.option.dialog.close );
439
+
440
+ api.form[0].reset();
441
+ //allFields.removeClass( "ui-state-error" );
442
+ }
443
+ }),
444
+ attachListener : function() {
445
+ $(document).on('click', api.option.settingsClass, function() {
446
+ if ( $('.wpglobus_dialog_options_wrapper').hasClass('hidden') ) {
447
+ $('.wpglobus_dialog_options_wrapper').removeClass('hidden');
448
+ } else {
449
+ $('.wpglobus_dialog_options_wrapper').addClass('hidden');
450
+ }
451
+ });
452
+ $(document).on('click', '.wpglobus_dialog_option', function(event) {
453
+ var $t = $(this), r;
454
+ var ob = $t.data('object');
455
+ api.order['action'] = 'save_post_meta_settings';
456
+ api.order['post_type'] = WPGlobusAdmin.data.post_type;
457
+ api.order['checked'] = $t.prop('checked');
458
+ api.order['id'] = $t.attr('id');
459
+ api.order['meta_key'] = $t.data('meta-key');
460
+ r = api.ajax(api.order);
461
+ r.done(function (result) {
462
+ if ( result.result == 'ok' ) {
463
+ if ( result.checked == 'true' ) {
464
+ $(ob).removeClass('wpglobus_dialog_start_hidden');
465
+ } else {
466
+ $(ob).addClass('wpglobus_dialog_start_hidden');
467
+ }
468
+ }
469
+ })
470
+ .fail(function (error) {})
471
+ .always(function (jqXHR, status){});
472
+ });
473
+ $(document).on('click', api.option.listenClass, function(e) {
474
+ api.element = $(this);
475
+ api.id = api.element.data('source-id');
476
+ if ( '' == api.id ) {
477
+ api.id = api.element.data('nodename') + '[name="'+api.element.data('source-name')+'"]';
478
+ api.wpglobus_id = '#wpglobus-'+api.convertToId( api.element.data('source-name') );
479
+ } else {
480
+ api.wpglobus_id = '#wpglobus-'+api.id;
481
+ api.id = '#'+api.id;
482
+ }
483
+
484
+ api.clicks++;
485
+ if ( api.clicks == 1 ) {
486
+ setTimeout(function () {
487
+ if (api.clicks == 1) {
488
+ api.onClick(e);
489
+ } else {
490
+ var s = $(api.id);
491
+ if ( s.hasClass('hidden') ) {
492
+ s.removeClass('hidden').attr('style', 'display:block;');
493
+ } else {
494
+ s.addClass('hidden').attr('style', 'display:none;');
495
+ }
496
+ }
497
+ api.clicks = 0;
498
+ }, 200);
499
+ }
500
+ });
501
+ api.form = api.dialog.find('form#wpglobus-dialog-form').on('submit', function( event ) {
502
+ event.preventDefault();
503
+ api.saveDialog();
504
+ });
505
+ },
506
+ ajax : function(order) {
507
+ return $.ajax({type:'POST', url:WPGlobusAdmin.ajaxurl, data:{action:WPGlobusAdmin.process_ajax, order:order}, dataType:'json', async:false});
508
+ },
509
+ onClick: function(ev) {
510
+ if ( typeof(api.element.data('dialog-title')) == 'undefined' || '' == api.element.data('dialog-title') ) {
511
+ api.dialogTitle = api.option.dialogTitle;
512
+ } else {
513
+ api.dialogTitle = api.element.data('dialog-title');
514
+ }
515
+ if ( typeof api.id !== 'undefined' ) {
516
+ api.attrs['maxlength'] = $(api.id).attr('maxlength');
517
+ }
518
+
519
+ api.source = api.element.data('source-value');
520
+ if ( typeof api.source === 'undefined' ) {
521
+ api.source = $(api.id).val();
522
+ if (api.request == 'ajax') {
523
+ // @todo revise ajax action
524
+ //api.order['action'] = 'get_translate';
525
+ //api.order['source'] = api.source;
526
+ //api.ajax(api.order);
527
+ } else {
528
+ api.value = WPGlobusCore.getTranslations(api.source);
529
+ }
530
+ }
531
+
532
+ /**
533
+ * Get dialog form options.
534
+ */
535
+ api.option.dialog = $.extend( {}, api.option.dialogOptions, $(api.wpglobus_id).data('dialog') );
536
+
537
+ if ( '' != api.option.dialog.title ) {
538
+ api.dialogTitle = api.option.dialog.title;
539
+ }
540
+
541
+ $.each(api.value, function(l,e){
542
+ var $d = $('#wpglobus-dialog-'+l);
543
+ /**
544
+ * Value.
545
+ */
546
+ $d.val(e);
547
+
548
+ /**
549
+ * Placeholder.
550
+ */
551
+ $d.attr(
552
+ 'placeholder',
553
+ WPGlobusCore.TextFilter( api.option.dialog.placeholder, l, 'RETURN_IN_DEFAULT_LANGUAGE' )
554
+ );
555
+ });
556
+
557
+ /**
558
+ * Dialog form footer.
559
+ */
560
+ $('#wpglobus-dialog-form-footer').html(api.option.dialog.formFooter);
561
+
562
+ /**
563
+ * Before open callback.
564
+ */
565
+ api.runCallback( api.option.dialog.beforeOpen );
566
+
567
+ api.dialog.dialog('open');
568
+ },
569
+ runCallback: function(callback) {
570
+
571
+ if ( 'object' === typeof callback ) {
572
+ var k = Object.keys(callback)[0];
573
+ var fn = callback[Object.keys(callback)[0]]
574
+ if ( 'window' === k ) {
575
+ if ( 'function' === typeof window[fn] ) {
576
+ window[fn]( callback[Object.keys(callback)[1]] );
577
+ }
578
+ } else if ( 'function' === typeof window[k][fn] ) {
579
+ window[k][fn]( callback[Object.keys(callback)[1]] );
580
+ }
581
+ } else if ( 'string' === typeof callback ) {
582
+ if ( 'function' === typeof window[callback] ) {
583
+ window[callback]();
584
+ }
585
+ }
586
+
587
+ }
588
+ };
589
+
590
+ })(jQuery);
591
+
592
+ jQuery(document).ready(function () {
593
+ "use strict";
594
+ window.WPGlobusAdminApp = (function (WPGlobusAdminApp, $) {
595
+ /* Object Constructor
596
+ ========================*/
597
+ WPGlobusAdminApp.App = function (config) {
598
+
599
+ if ( 'undefined' !== typeof window.WPGlobusAdminApp ) {
600
+ return;
601
+ }
602
+
603
+ this.config = {
604
+ debug: false,
605
+ version: WPGlobusAdmin.version
606
+ };
607
+
608
+ this.status = 'ok';
609
+
610
+ if ( 'undefined' === typeof WPGlobusAdmin ) {
611
+ this.status = 'error';
612
+ if (this.config.debug) {
613
+ console.log('WPGlobus: error options loading');
614
+ }
615
+ } else {
616
+ if (this.config.debug) {
617
+ console.dir(WPGlobusAdmin);
618
+ }
619
+ }
620
+
621
+ this.config.disable_first_language = [
622
+ '<div id="disable_first_language" style="display:block;" class="redux-field-errors notice-red">',
623
+ '<strong>',
624
+ '<span>&nbsp;</span>',
625
+ WPGlobusAdmin.i18n.cannot_disable_language,
626
+ '</strong>',
627
+ '</div>'
628
+ ].join('');
629
+
630
+ $.extend(this.config, config);
631
+
632
+ if ('ok' === this.status) {
633
+ this.init();
634
+ }
635
+ };
636
+
637
+ WPGlobusAdminApp.App.prototype = {
638
+ $document : $(document),
639
+ init: function () {
640
+ WPGlobusCoreData.multisite = this.parseBool(WPGlobusCoreData.multisite);
641
+ this.adminInit();
642
+ $('#content').addClass('wpglobus-editor').attr('data-language',WPGlobusAdmin.data.default_language);
643
+ $('textarea[id^=content_]').each(function(i,e){
644
+ var l=$(e).attr('id').replace('content_','');
645
+ $(e).attr('data-language',l);
646
+ });
647
+ if ('post.php' === WPGlobusAdmin.page) {
648
+ this.postEdit();
649
+ this.set_dialog();
650
+ if ( 'undefined' !== typeof WPGlobusAioseop ) {
651
+ WPGlobusAioseop.init();
652
+ }
653
+ } else if ('menu-edit' === WPGlobusAdmin.page) {
654
+ this.navMenus();
655
+ } else if ('taxonomy-edit' === WPGlobusAdmin.page) {
656
+ if (WPGlobusAdmin.data.tag_id) {
657
+ this.taxonomyEdit();
658
+ }
659
+ } else if ('taxonomy-quick-edit' === WPGlobusAdmin.page) {
660
+ this.quickEdit('taxonomy');
661
+ } else if ('edit.php' === WPGlobusAdmin.page) {
662
+ this.quickEdit('post');
663
+ } else if ('options-general.php' == WPGlobusAdmin.page) {
664
+ this.optionsGeneral();
665
+ WPGlobusDialogApp.init({customData:WPGlobusCoreData.page_custom_data});
666
+ } else if ('widgets.php' == WPGlobusAdmin.page) {
667
+ WPGlobusWidgets.init();
668
+ WPGlobusDialogApp.init({dialogTitle:'Edit text'});
669
+ } else if ('wpglobus_options' == WPGlobusAdmin.page) {
670
+ this.start();
671
+ } else if ('wpglobusAdminCentral' == WPGlobusAdmin.page) {
672
+ this.adminCentral();
673
+ } else {
674
+ /**
675
+ * Init WPGlobusDialogApp for using in a 3-party plugins.
676
+ */
677
+ WPGlobusDialogApp.init({customData:WPGlobusCoreData.page_custom_data});
678
+ }
679
+ },
680
+ parseBool: function(b) {
681
+ return !(/^(false|0)$/i).test(b) && !!b;
682
+ },
683
+ getCurrentTab: function() {
684
+ return $( '.wpglobus-post-body-tabs-list .ui-tabs-active' ).data( 'language' );
685
+ },
686
+ adminInit: function () {
687
+ var order = $('.wpglobus-addons-group a').data('key');
688
+ if ( 'undefined' !== typeof order ) {
689
+ if ( window.location.search.indexOf('page=wpglobus_options&tab='+order) >= 0 ) {
690
+ if ( WPGlobusCoreData.multisite ) {
691
+ window.location = WPGlobusCoreData.pluginInstallLocation.multisite;
692
+ } else {
693
+ window.location = WPGlobusCoreData.pluginInstallLocation.single;
694
+ }
695
+ } else {
696
+ var addon = $('#toplevel_page_wpglobus_options li').eq(order+1);
697
+ if ( WPGlobusCoreData.multisite ) {
698
+ $(addon).find('a').attr('href',WPGlobusCoreData.pluginInstallLocation.multisite).attr('onclick',"window.location=jQuery(this).attr('href');return false;");
699
+ } else {
700
+ $(addon).find('a').attr('href',WPGlobusCoreData.pluginInstallLocation.single).attr('onclick',"window.location=jQuery(this).attr('href');return false;");
701
+ }
702
+ }
703
+ }
704
+ },
705
+ optionsGeneral: function() {
706
+ var $bn = $('#blogname'),
707
+ $body = $('body');
708
+
709
+ $bn.addClass('hidden');
710
+ $('#wpglobus-blogname').insertAfter($bn).removeClass('hidden');
711
+
712
+ $body.on('blur', '.wpglobus-blogname', function () {
713
+ $('.wpglobus-blogname').each( function (i, e) {
714
+ var $e = $(e);
715
+ $bn.val( WPGlobusCore.getString( $bn.val(), $e.val(), $e.data('language') ) );
716
+ });
717
+ });
718
+
719
+ var $bd = $('#blogdescription');
720
+ $bd.addClass('hidden');
721
+ $('#wpglobus-blogdescription').insertAfter($bd).removeClass('hidden');
722
+ $body.on('blur', '.wpglobus-blogdesc', function () {
723
+ $('.wpglobus-blogdesc').each( function (i, e) {
724
+ var $e = $(e);
725
+ $bd.val( WPGlobusCore.getString( $bd.val(), $e.val(), $e.data('language') ) );
726
+ });
727
+ });
728
+ },
729
+ quickEdit: function(type) {
730
+ /**
731
+ * For more info @see ajax handler 'wp_ajax_inline_save'.
732
+ */
733
+ if ( 'undefined' === typeof WPGlobusAdmin.data.has_items ) {
734
+ return;
735
+ }
736
+ if (!WPGlobusAdmin.data.has_items) {
737
+ return;
738
+ }
739
+ var full_id = '', id = 0;
740
+
741
+ $(document).ajaxComplete(function(event, jqxhr, settings){
742
+ if (typeof settings.data === 'undefined') {
743
+ return;
744
+ }
745
+ if ( full_id == '' ) {
746
+ return;
747
+ }
748
+ if (settings.data.indexOf('action=inline-save-tax&') >= 0) {
749
+ $('#'+full_id+' a.row-title').text(WPGlobusAdmin.qedit_titles[id][WPGlobusAdmin.data.language]['name']);
750
+ $('#'+full_id+' .description').text(WPGlobusAdmin.qedit_titles[id][WPGlobusAdmin.data.language]['description']);
751
+ }
752
+ });
753
+
754
+ var title = {};
755
+ $('#the-list tr').each(function (i, e) {
756
+ var $e = $(e);
757
+ var k = ( type === 'post' ? 'post-' : 'tag-' );
758
+ id = $e.attr('id').replace(k, ''); /* don't need var with id, see line 109 */
759
+ title[id] = {};
760
+ if ('post' === type) {
761
+ title[id]['source'] = $e.find('.post_title').text();
762
+ } else if ('taxonomy' === type) {
763
+ title[id]['source'] = $('#inline_' + id + ' .name').text();
764
+ }
765
+ });
766
+
767
+ var order = {};
768
+ order['action'] = 'get_titles';
769
+ order['type'] = type;
770
+ order['taxonomy'] = typeof WPGlobusAdmin.data.taxonomy === 'undefined' ? false : WPGlobusAdmin.data.taxonomy;
771
+ order['title'] = title;
772
+ $.ajax({type:'POST', url:WPGlobusAdmin.ajaxurl, data:{action:WPGlobusAdmin.process_ajax, order:order}, dataType:'json'})
773
+ .done(function (result) {
774
+ WPGlobusAdmin.qedit_titles = result.qedit_titles;
775
+ $.each(result.bulkedit_post_titles, function(id, obj){
776
+ $('#inline_'+id+' .post_title').text(obj[WPGlobusAdmin.data.language]['name']);
777
+ });
778
+ })
779
+ .fail(function (error) {
780
+ })
781
+ .always(function (jqXHR, status) {
782
+ });
783
+
784
+ $('body').on('change', '.wpglobus-quick-edit-title', function () {
785
+ var s = '';
786
+ var lang = [];
787
+ $('.wpglobus-quick-edit-title').each(function (index, e) {
788
+ var $e = $(e);
789
+ var l = $e.data('language');
790
+ if ($e.val() !== '') {
791
+ s = WPGlobusCore.getString( s, $e.val(), l );
792
+ }
793
+ WPGlobusAdmin.qedit_titles[ id ][ l ][ 'name' ] = $e.val();
794
+ lang[ index ] = l;
795
+ });
796
+
797
+ var so = $(document).triggerHandler( 'wpglobus_get_translations', {string:s, lang:lang, id:id} );
798
+ if ( typeof so !== 'undefined' ) {
799
+ s = so;
800
+ }
801
+ $( 'input.ptitle' ).eq( 0 ).attr( 'value', s ) ;
802
+ WPGlobusAdmin.qedit_titles[ id ][ 'source' ] = s;
803
+ });
804
+
805
+ if ( typeof WPGlobusAdmin.data.tags !== 'undefined' ) {
806
+ $.each( WPGlobusAdmin.data.tags, function(i,tag){
807
+ WPGlobusAdmin.data.value[tag]['post_id'] = {};
808
+ });
809
+ }
810
+
811
+ $('button.save, input#bulk_edit').on('mouseenter', function (event) {
812
+ /**
813
+ * Quick edit action for the "Tags" box in edit.php page.
814
+ */
815
+ if ( typeof WPGlobusAdmin.data.tags === 'undefined' ) {
816
+ return;
817
+ }
818
+
819
+ if (event.currentTarget.id=='bulk_edit') {
820
+ $('input#bulk_edit').unbind('click');
821
+ } else {
822
+ $('button.save').unbind('click');
823
+ }
824
+
825
+ $( 'button.save, input#bulk_edit').on('click', function (event) {
826
+ //console.log( 'Start Updating' );
827
+ var promise = $.when();
828
+
829
+ var tagsHandler = function( $elem ) {
830
+ $elem.next('.spinner').css({'visibility':'visible'});
831
+ if (event.currentTarget.id != 'bulk_edit') {
832
+ $.ajaxSetup({async:false});
833
+ }
834
+ var p = $elem.parents('tr');
835
+ var id = p.attr('id').replace('edit-','');
836
+ var t,v,newTags;
837
+
838
+ $.each( WPGlobusAdmin.data.tags, function(index,tag){
839
+ t = p.find("textarea[name='" + WPGlobusAdmin.data.names[tag] + "']");
840
+ if ( t.length == 0 ) {
841
+ return true;
842
+ }
843
+ WPGlobusAdmin.data.value[tag]['post_id'][id] = t.val();
844
+ v = WPGlobusAdmin.data.value[tag]['post_id'][id].split(',');
845
+ newTags = [];
846
+ for(var i=0; i<v.length; i++) {
847
+ v[i] = v[i].trim(' ');
848
+ if ( v[i] != '' ) {
849
+ if ( typeof WPGlobusAdmin.data.tag[tag][v[i]] === 'undefined' ) {
850
+ newTags[i] = v[i];
851
+ } else {
852
+ newTags[i] = WPGlobusAdmin.data.tag[tag][v[i]];
853
+ }
854
+ }
855
+ }
856
+ t.val( newTags.join(', ') );
857
+ });
858
+ }
859
+
860
+ var $this = $(this);
861
+ var start = $.Deferred();
862
+ start.resolve( tagsHandler( $(this) ) );
863
+
864
+ promise = promise.then(function() {
865
+ return $.when(
866
+ start.done()
867
+ )
868
+ }).then( function() {
869
+ if (event.currentTarget.id != 'bulk_edit') {
870
+ setTimeout(
871
+ function() {
872
+ inlineEditPost.save(id);
873
+ $.ajaxSetup({async:true});
874
+ },
875
+ 50
876
+ );
877
+ }
878
+ });
879
+
880
+ });
881
+ });
882
+
883
+ $( '#the-list' ).on( 'click', 'a.editinline', function () {
884
+ var t = $(this);
885
+ full_id = t.parents('tr').attr('id');
886
+ if ('post' === type) {
887
+ id = full_id.replace('post-', '');
888
+ } else if ('taxonomy' === type) {
889
+ id = full_id.replace('tag-', '');
890
+ } else {
891
+ return;
892
+ }
893
+
894
+ if ( 'post' === type && 'undefined' !== typeof WPGlobusAdmin.data.tags ) {
895
+ /**
896
+ * @since 1.6.6
897
+ */
898
+ $.each( WPGlobusAdmin.data.tags, function(i,tag){
899
+ if ( WPGlobusAdmin.data.value[tag] != '' ) {
900
+ var val = $('#edit-' + id + ' textarea[name="' + WPGlobusAdmin.data.names[tag] + '"]').val(),
901
+ currentTags;
902
+ if ( 'undefined' !== typeof val ) {
903
+ currentTags = val.split(',');
904
+ $.each( currentTags, function(order,currentTag) {
905
+ val = val.replace(currentTag, WPGlobusCore.TextFilter(currentTag, WPGlobusCoreData.language));
906
+ });
907
+ $('#edit-' + id + ' textarea[name="' + WPGlobusAdmin.data.names[tag] + '"]').val(val);
908
+ }
909
+ }
910
+ });
911
+ }
912
+
913
+ var e = $('#edit-' + id + ' input.ptitle').eq(0);
914
+ var p = e.parents('label');
915
+ e.val(WPGlobusAdmin.qedit_titles[id].source);
916
+ e.addClass('hidden');
917
+ $(WPGlobusAdmin.data.template).insertAfter(p);
918
+
919
+ if ( typeof WPGlobusAdmin.qedit_titles[id] === 'undefined' ) {
920
+ WPGlobusAdmin.qedit_titles[id] = {};
921
+ WPGlobusAdmin.qedit_titles[id]['source'] = $('#'+full_id+' .name a.row-title').text();
922
+ $(WPGlobusAdmin.data.enabled_languages).each(function(i,l){
923
+ WPGlobusAdmin.qedit_titles[id][l] = {};
924
+ if ( l == WPGlobusAdmin.data.default_language ) {
925
+ WPGlobusAdmin.qedit_titles[id][l]['name'] = WPGlobusAdmin.qedit_titles[id]['source'];
926
+ } else {
927
+ WPGlobusAdmin.qedit_titles[id][l]['name'] = '';
928
+ }
929
+ WPGlobusAdmin.qedit_titles[id][l]['description'] = '';
930
+ });
931
+ }
932
+
933
+ $( '.wpglobus-quick-edit-title' ).each(function ( i, e ) {
934
+ var $e = $(e);
935
+ var l = $e.data( 'language' );
936
+ $e.attr( 'id', l + id );
937
+ if ( typeof WPGlobusAdmin.qedit_titles[id][l] !== 'undefined' ) {
938
+ WPGlobusAdmin.qedit_titles[id][l]['name'] = WPGlobusAdmin.qedit_titles[id][l]['name'].replace( /\\\'/g, "'" );
939
+ WPGlobusAdmin.qedit_titles[id][l]['name'] = WPGlobusAdmin.qedit_titles[id][l]['name'].replace( /\\\"/g, '"' );
940
+ $e.attr( 'value', WPGlobusAdmin.qedit_titles[id][l]['name'] );
941
+ WPGlobusAdmin.qedit_titles[id]['source'] =
942
+ WPGlobusCore.getString(
943
+ WPGlobusAdmin.qedit_titles[id]['source'],
944
+ WPGlobusAdmin.qedit_titles[id][l]['name'],
945
+ l
946
+ );
947
+ }
948
+ });
949
+ $( 'input.ptitle' ).eq( 0 ).attr( 'value', WPGlobusAdmin.qedit_titles[ id ][ 'source' ] );
950
+ });
951
+
952
+ },
953
+ taxonomyEdit: function () {
954
+
955
+ var elements = [];
956
+ elements[0] = 'name';
957
+ elements[1] = 'description';
958
+
959
+ var make_clone = function(id,language){
960
+ var $element = $('#'+id),
961
+ clone = $element.clone(),
962
+ name = $element.attr('name'),
963
+ classes = 'wpglobus-element wpglobus-element_'+id+' wpglobus-element_'+language+' wpglobus-translatable',
964
+ node;
965
+
966
+ node = document.getElementById(id);
967
+ node = node.nodeName;
968
+ $(clone).attr('id', id+'_'+language);
969
+ $(clone).attr('name', name+'_'+language);
970
+ if ( language !== WPGlobusCoreData.default_language ) {
971
+ classes += ' hidden';
972
+ }
973
+ $(clone).attr('class', classes);
974
+ $(clone).attr('data-save-to', id);
975
+ $(clone).attr('data-language', language);
976
+ if ( node == 'INPUT' ) {
977
+ $(clone).attr('value', $('#wpglobus-link-tab-'+language).data(id));
978
+ } else if ( node == 'TEXTAREA' ) {
979
+ $(clone).text($('#wpglobus-link-tab-'+language).data(id));
980
+ }
981
+ $element.addClass('hidden');
982
+ if ( $('.wpglobus-element_'+id).length == 0 ) {
983
+ $(clone).insertAfter($element);
984
+ } else {
985
+ $(clone).insertAfter($('.wpglobus-element_'+id).last());
986
+ }
987
+ };
988
+
989
+ $.each(WPGlobusCoreData.enabled_languages, function(i,l){
990
+ $.each(elements, function(i,e){
991
+ make_clone(e,l);
992
+ });
993
+ });
994
+
995
+ $('.wpglobus-taxonomy-tabs').insertAfter('#ajax-response');
996
+
997
+ /**
998
+ * Make class wrap as tabs container.
999
+ * Tabs on.
1000
+ */
1001
+ $('.wrap').tabs();
1002
+
1003
+ $('body').on('click', '.wpglobus-taxonomy-tabs li', function(event){
1004
+ var $t = $(this);
1005
+ var language = $t.data('language');
1006
+ $('.wpglobus-element').addClass('hidden');
1007
+ $('.wpglobus-element_'+language).removeClass('hidden');
1008
+ });
1009
+
1010
+ $('.wpglobus-element').on('change', function () {
1011
+ var $this = $(this),
1012
+ save_to = $this.data('save-to'),
1013
+ s = '';
1014
+
1015
+ $('.wpglobus-element').each(function (index, element) {
1016
+ var $e = $(element),
1017
+ value = $e.val();
1018
+ if ( $e.data('save-to') == save_to && value !== '' ) {
1019
+ s = s + WPGlobusCore.addLocaleMarks(value, $e.data('language') )
1020
+ }
1021
+ });
1022
+ $('#' + save_to).val(s);
1023
+ });
1024
+
1025
+ /**
1026
+ * @since 1.8.1
1027
+ * $('<span class="wpglobus-multilingual-slug wpglobus_dialog_start wpglobus_dialog_icon" title="Title"></span>').insertBefore('#slug');
1028
+ * $('.term-slug-wrap th').css({'padding-right':'0'});
1029
+ * $('.term-slug-wrap td').css({'padding-left':'0'});
1030
+ */
1031
+ $(WPGlobusAdmin.data.multilingualSlug.title).insertAfter('.term-slug-wrap th label');
1032
+
1033
+ },
1034
+ navMenus: function () {
1035
+ var iID, menu_size,
1036
+ menu_item = '#menu-to-edit .menu-item';
1037
+
1038
+ var timer = function () {
1039
+ if ( menu_size !== $(menu_item).length ) {
1040
+ clearInterval(iID);
1041
+ $(menu_item).each(function (index, li) {
1042
+ var $li = $(li);
1043
+ if ($li.hasClass('wpglobus-menu-item')) {
1044
+ return; /** the same as continue */
1045
+ }
1046
+ var id = $(li).attr('id');
1047
+ $.each(['input.edit-menu-item-title', 'input.edit-menu-item-attr-title'], function (input_index, input) {
1048
+ var i = $('#' + id + ' ' + input);
1049
+ var $i = $(i);
1050
+ if (!$i.hasClass('wpglobus-hidden')) {
1051
+ $i.addClass('wpglobus-hidden');
1052
+ $i.css('display', 'none');
1053
+ var l = $i.parent('label');
1054
+ var p = $i.parents('p');
1055
+ $(p).css('height', '80px');
1056
+ $(l).append('<div style="color:#f00;">' + WPGlobusAdmin.i18n.save_nav_menu + '</div>');
1057
+ }
1058
+ });
1059
+ $li.addClass('wpglobus-menu-item');
1060
+ });
1061
+ }
1062
+ };
1063
+
1064
+ $.ajaxSetup({
1065
+ beforeSend: function (jqXHR, PlainObject) {
1066
+ if (typeof PlainObject.data === 'undefined') {
1067
+ return;
1068
+ }
1069
+ if (PlainObject.data.indexOf('action=add-menu-item') >= 0) {
1070
+ menu_size = $(menu_item).length;
1071
+ iID = setInterval(timer, 500);
1072
+ }
1073
+ }
1074
+ });
1075
+
1076
+ $(menu_item).each(function (index, li) {
1077
+
1078
+ var id = $(li).attr('id'),
1079
+ item_id = id.replace('menu-item-', '');
1080
+
1081
+ $.each(['input.edit-menu-item-title', 'input.edit-menu-item-attr-title'], function (input_index, input) {
1082
+ var $i = $('#' + id + ' ' + input);
1083
+ if ( $i.val() != WPGlobusAdmin.data.items[ item_id ][ input ][ 'source' ] ) {
1084
+ /**
1085
+ * fix for case when value resets by WP core
1086
+ */
1087
+ $i.val( WPGlobusAdmin.data.items[ item_id ][ input ][ 'source' ] );
1088
+ }
1089
+
1090
+ var p = $( '#' + id + ' ' + input ).parents('p');
1091
+ var height = 0;
1092
+
1093
+ $.each(WPGlobusAdmin.data.open_languages, function (index, language) {
1094
+ var new_element = $i.clone();
1095
+ new_element.attr('id', $i.attr('id') + '-' + language);
1096
+ new_element.attr('name', $i.attr('id') + '-' + language);
1097
+ new_element.attr('data-language', language);
1098
+ new_element.attr('data-item-id', item_id);
1099
+ new_element.attr('placeholder', WPGlobusAdmin.data.en_language_name[language]);
1100
+
1101
+ var classes = WPGlobusAdmin.data.items[item_id][language][input]['class'];
1102
+ if (input_index === 0 && language === WPGlobusAdmin.data.default_language) {
1103
+ new_element.attr('class', classes + ' edit-menu-item-title');
1104
+ } else {
1105
+ new_element.attr('class', classes);
1106
+ }
1107
+
1108
+ if ( WPGlobusAdmin.data.items[ item_id ][ language ][ input ][ 'caption' ] != '' ) {
1109
+ new_element.attr('value', WPGlobusAdmin.data.items[item_id][language][input]['caption']);
1110
+ } else {
1111
+ new_element.attr('value', '');
1112
+ }
1113
+ new_element.css('margin-bottom', '0.6em');
1114
+ $(p).append( new_element );
1115
+ height = index;
1116
+ });
1117
+ height = (height + 1) * 40;
1118
+ $i.css('display', 'none').attr('class', '').addClass('widefat wpglobus-hidden');
1119
+ $(p).css('height', height + 'px').addClass('wpglobus-menu-item-box');
1120
+
1121
+ });
1122
+ $(li).addClass('wpglobus-menu-item');
1123
+ });
1124
+
1125
+ $('.menus-move-left, .menus-move-right').each(function(index,e) {
1126
+ var $e = $(e), new_title;
1127
+ var item_id = $e.parents('li').attr('id').replace('menu-item-', '');
1128
+ var title = $e.attr('title');
1129
+ if ( typeof title !== 'undefined' ) {
1130
+ $.each(WPGlobusAdmin.data.post_titles, function(post_title, item_title) {
1131
+ if ( title.indexOf(post_title) >= 0 ) {
1132
+ new_title = title.replace(post_title, item_title);
1133
+ $e.attr('title', new_title);
1134
+ $e.text(new_title);
1135
+ }
1136
+ });
1137
+ }
1138
+ });
1139
+
1140
+ /**
1141
+ * Run the item handle title when the navigation label was loaded.
1142
+ * @see wp-admin\js\nav-menu.js
1143
+ */
1144
+ $('.edit-menu-item-title').trigger('change');
1145
+ wpNavMenu.refreshAdvancedAccessibility();
1146
+ wpNavMenu.menusChanged = false;
1147
+
1148
+ $('.wpglobus-menu-item').on('change', function () {
1149
+ var $this = $(this),
1150
+ item_id = $this.data('item-id'),
1151
+ s, so;
1152
+ if ($this.hasClass('wpglobus-item-title')) {
1153
+ s = WPGlobusCore.getString( $('input#edit-menu-item-title-' + item_id).val(), $this.val(), $this.data('language') );
1154
+ so = $(document).triggerHandler('wpglobus_get_menu_translations', {string:s, lang:WPGlobusCoreData.open_languages, id:item_id, type:'input.edit-menu-item-title'});
1155
+ if ( typeof so !== 'undefined' ) {
1156
+ s = so;
1157
+ }
1158
+ $('input#edit-menu-item-title-' + item_id).val(s);
1159
+ }
1160
+ if ($this.hasClass('wpglobus-item-attr')) {
1161
+ s = WPGlobusCore.getString( $('input#edit-menu-item-attr-title-' + item_id).val(), $this.val(), $this.data('language') );
1162
+ so = $(document).triggerHandler('wpglobus_get_menu_translations', {string:s, lang:WPGlobusCoreData.open_languages, id:item_id, type:'input.edit-menu-item-attr-title'});
1163
+ if ( typeof so !== 'undefined' ) {
1164
+ s = so;
1165
+ }
1166
+ $('input#edit-menu-item-attr-title-' + item_id).val(s);
1167
+ }
1168
+
1169
+ });
1170
+ },
1171
+ postEdit: function () {
1172
+ /**
1173
+ * Hook into the heartbeat-send.
1174
+ */
1175
+ $(document).on('heartbeat-send', function(e, data) {
1176
+ if ( typeof data['wp_autosave'] !== 'undefined' ) {
1177
+ data['wpglobus_heartbeat'] = 'wpglobus';
1178
+ $.each(WPGlobusAdmin.data.open_languages, function(i,l){
1179
+ var v = $('#title_'+l).val() || '';
1180
+ v = $.trim(v);
1181
+ if ( v != '' ) {
1182
+ data['wp_autosave']['post_title_'+l] = v;
1183
+ }
1184
+ v = $('#content_'+l).val() || '';
1185
+ v = $.trim(v);
1186
+ if ( v != '' ) {
1187
+ data['wp_autosave']['content_'+l] = v;
1188
+ }
1189
+ });
1190
+ }
1191
+ });
1192
+
1193
+ var wrap_at = '#postdivrich',
1194
+ set_title = true,
1195
+ content_tabs_id = '#post-body-content';
1196
+ if ( WPGlobusAdmin.data.support['editor'] === false ) {
1197
+ wrap_at = '#titlediv';
1198
+ set_title = false;
1199
+ }
1200
+ if ( WPGlobusAdmin.data.support['title'] === false ) {
1201
+ set_title = false;
1202
+ }
1203
+ /**
1204
+ * Make post-body-content as tabs container.
1205
+ */
1206
+ $(content_tabs_id).prepend($('.wpglobus-post-body-tabs-list'));
1207
+ $.each(WPGlobusAdmin.tabs, function (index, suffix) {
1208
+ if ('default' === suffix) {
1209
+ $(wrap_at).wrap('<div id="tab-default"></div>');
1210
+ if ( set_title ) {
1211
+ $($('#titlediv')).insertBefore(wrap_at);
1212
+ }
1213
+ } else {
1214
+ $(wrap_at+'-' + suffix).wrap('<div id="tab-' + suffix + '"></div>');
1215
+ if ( set_title ) {
1216
+ $($('#titlediv-' + suffix)).insertBefore(wrap_at+'-' + suffix);
1217
+ }
1218
+ }
1219
+ });
1220
+
1221
+ /**
1222
+ * Tabs on.
1223
+ */
1224
+ $(content_tabs_id).addClass('wpglobus-post-body-tabs').tabs({
1225
+ beforeActivate: function( event, ui ){
1226
+ var otab = ui.oldTab[0].id.replace('link-tab-','');
1227
+ var ntab = ui.newTab[0].id.replace('link-tab-','');
1228
+ if ( 'default' == otab ) {
1229
+ otab = WPGlobusCoreData.default_language;
1230
+ }
1231
+ if ( 'default' == ntab ) {
1232
+ ntab = WPGlobusCoreData.default_language;
1233
+ }
1234
+ var a = $(document).triggerHandler('wpglobus_post_body_tabs', [ otab, ntab ]);
1235
+ if ( a || typeof a === 'undefined' ) {
1236
+ return true;
1237
+ }
1238
+ return false;
1239
+ }
1240
+ }); /** #post-body-content */
1241
+
1242
+ /**
1243
+ * Setup for default language.
1244
+ */
1245
+ $('#title').val(WPGlobusAdmin.title);
1246
+
1247
+ /**
1248
+ * See other places with the same bookmark.
1249
+ * @bookmark EDITOR_LINE_BREAKS
1250
+ */
1251
+ //$('#content').text(WPGlobusAdmin.content.replace(/\n/g, "<p>"));
1252
+
1253
+ $('#content').text(WPGlobusAdmin.content);
1254
+
1255
+ if (typeof WPGlobusVendor !== "undefined" && WPGlobusVendor.vendor.WPSEO ) {
1256
+ if ( typeof wpglobus_wpseo !== "undefined" ) {
1257
+ wpglobus_wpseo();
1258
+ } else if ( 'undefined' !== typeof WPGlobusYoastSeo ) {
1259
+ if ( 'undefined' !== typeof WPGlobusYoastSeoPremium ) {
1260
+ /**
1261
+ * @since WPGlobus 1.7.2
1262
+ */
1263
+ if ( WPGlobusYoastSeoPremium ) {
1264
+ WPGlobusYoastSeoPremium.init();
1265
+ }
1266
+ }
1267
+ /**
1268
+ * @since Yoast SEO 3.0
1269
+ */
1270
+ WPGlobusYoastSeo.init();
1271
+ }
1272
+ }
1273
+
1274
+ if ( WPGlobusAdmin.data.modify_excerpt ) {
1275
+ /**
1276
+ * Add excerpt fields from template.
1277
+ */
1278
+ var $excerpt = $( '#excerpt' );
1279
+ $excerpt.addClass( 'hidden' ).css( {'display':'none'} );
1280
+ $( WPGlobusAdmin.data.template ).insertAfter( $excerpt );
1281
+ $( 'body' ).on( 'change', '.wpglobus-excerpt', function () {
1282
+ var $t = $( this );
1283
+ $excerpt.val( WPGlobusCore.getString( $excerpt.val(), $t.val(), $t.data('language') ) );
1284
+ });
1285
+ }
1286
+
1287
+ /**
1288
+ * wp_editor word count.
1289
+ * from WordPress 4.3 @see \wp-admin\js\post.js
1290
+ */
1291
+ if ( typeof wp.utils !== 'undefined' && typeof wp.utils.WordCounter !== 'undefined' ) {
1292
+ WPGlobusCoreData.wordCounter = {};
1293
+
1294
+ var self = this, wpglobusEditors = {};
1295
+
1296
+ $.each( WPGlobusCoreData.enabled_languages, function( i, l ){
1297
+ if ( l == WPGlobusCoreData.default_language ) {
1298
+ return true;
1299
+ }
1300
+ wpglobusEditors[i] = 'content_'+l;
1301
+
1302
+ ( function( $, counter, l ) {
1303
+ WPGlobusCoreData.wordCounter[ l ] = {};
1304
+ WPGlobusCoreData.wordCounter[ l ][ 'counter' ] = counter;
1305
+
1306
+ $( function() {
1307
+
1308
+ WPGlobusCoreData.wordCounter[ l ][ 'content' ] = $( '#content_'+l );
1309
+ WPGlobusCoreData.wordCounter[ l ][ 'count' ] = $( '#wp-word-count-'+l ).find( '.word-count-'+l );
1310
+
1311
+ WPGlobusCoreData.wordCounter[ l ][ 'prevCount' ] = 0;
1312
+
1313
+ function update( l ) {
1314
+ var text, count;
1315
+
1316
+ if ( typeof l === 'object' ) {
1317
+
1318
+ if ( l == 'tinymce' ) {
1319
+ /** wysiwyg editor */
1320
+ l = self.getCurrentTab();
1321
+ } else {
1322
+ /** textarea */
1323
+ l = l.target.id.replace( 'content_', '' );
1324
+ }
1325
+
1326
+ }
1327
+
1328
+ if ( typeof WPGlobusCoreData.wordCounter[ l ] === 'undefined' ) {
1329
+ return;
1330
+ }
1331
+
1332
+ if ( ! WPGlobusCoreData.wordCounter[ l ][ 'contentEditor' ] ||
1333
+ WPGlobusCoreData.wordCounter[ l ][ 'contentEditor' ].isHidden() ) {
1334
+
1335
+ text = WPGlobusCoreData.wordCounter[ l ][ 'content' ].val();
1336
+
1337
+ } else {
1338
+ text = WPGlobusCoreData.wordCounter[ l ][ 'contentEditor' ].getContent( { format: 'raw' } );
1339
+ }
1340
+
1341
+ count = WPGlobusCoreData.wordCounter[ l ][ 'counter' ].count( text );
1342
+
1343
+ if ( count !== WPGlobusCoreData.wordCounter[ l ][ 'prevCount' ] ) {
1344
+ WPGlobusCoreData.wordCounter[ l ][ 'count' ].text( count );
1345
+ }
1346
+
1347
+ WPGlobusCoreData.wordCounter[ l ][ 'prevCount' ] = count;
1348
+ }
1349
+
1350
+ $(document).on( 'tinymce-editor-init', function( event, editor ) {
1351
+
1352
+ if ( -1 == $.inArray(editor.id, wpglobusEditors) ) {
1353
+ /**
1354
+ * Init WPGlobus editor only.
1355
+ */
1356
+ return;
1357
+ }
1358
+ var l = editor.id.replace( 'content_', '' );
1359
+
1360
+ WPGlobusCoreData.wordCounter[ l ][ 'contentEditor' ] = editor;
1361
+
1362
+ editor.on( 'nodechange keyup', _.debounce( update, 1000 ) );
1363
+ } );
1364
+
1365
+ WPGlobusCoreData.wordCounter[l]['content'].on( 'input keyup', _.debounce( update, 1000 ) );
1366
+
1367
+ update( l );
1368
+
1369
+ } );
1370
+ } )( jQuery, new wp.utils.WordCounter(), l );
1371
+ });
1372
+
1373
+ }
1374
+
1375
+ $(document).on('click', '#publish, #save-post', function() {
1376
+ if ( WPGlobusAdmin.data.open_languages.length > 1 ) {
1377
+ $(document).triggerHandler('wpglobus_before_save_post', {content_tabs_id:content_tabs_id});
1378
+ /**
1379
+ * If empty title in default language make it from another titles.
1380
+ */
1381
+ var t = $('#title').val(),
1382
+ index, title = '', delimiter = '';
1383
+
1384
+ if ( t.length == 0 ) {
1385
+ index = WPGlobusAdmin.data.open_languages.indexOf(WPGlobusAdmin.data.default_language);
1386
+ WPGlobusAdmin.data.open_languages.splice(index, 1);
1387
+ $(WPGlobusAdmin.data.open_languages).each(function(i,l){
1388
+ delimiter = i == 0 ? '' : '-';
1389
+ t = $('#title_'+l).val();
1390
+ if ( t.length > 0 ) {
1391
+ if ( title.length == 0 ) { delimiter = '';}
1392
+ title = title + delimiter + t;
1393
+ }
1394
+ });
1395
+ }
1396
+ if ( title.length > 0 ) {
1397
+ $('#title').val(title);
1398
+ }
1399
+ }
1400
+
1401
+ /**
1402
+ * To handle taxonomy tags.
1403
+ */
1404
+ if ( 'undefined' === typeof WPGlobusAdmin.data.tagsdiv || WPGlobusAdmin.data.tagsdiv.length < 1 ) {
1405
+ return;
1406
+ }
1407
+ $(WPGlobusAdmin.data.tagsdiv).each(function(i,tagsdiv){
1408
+ if ($('#' + tagsdiv).length == 0) {
1409
+ /**
1410
+ * Next iteration.
1411
+ */
1412
+ return true;
1413
+ }
1414
+
1415
+ var id = tagsdiv.replace('tagsdiv-', '');
1416
+ if ( 'undefined' === id ) {
1417
+ return true;
1418
+ }
1419
+ if ( $('#tax-input-'+id).length == 0 ) {
1420
+ return true;
1421
+ }
1422
+
1423
+ var name, tags = [];
1424
+
1425
+ /**
1426
+ * Obsolete from WP 4.9
1427
+ * $('#tagsdiv-'+id+' .tagchecklist > span').each(function(i,e){
1428
+ */
1429
+ $('#tagsdiv-'+id+' .tagchecklist li').each(function(i,e){
1430
+ name = $(e).html();
1431
+ name = name.replace( /<button.*<\/button>&nbsp;/, '' );
1432
+ if ( 'undefined' === typeof WPGlobusAdmin.data.tag[id][name] ) {
1433
+ tags[i] = name;
1434
+ } else {
1435
+ tags[i] = WPGlobusAdmin.data.tag[id][name];
1436
+ }
1437
+ });
1438
+
1439
+ $('#tax-input-'+id).val(tags.join(', '));
1440
+ });
1441
+ /**
1442
+ * The end to handle taxonomy tags.
1443
+ */
1444
+ });
1445
+
1446
+ /**
1447
+ * The alignment when default tab was clicked.
1448
+ */
1449
+ $('.ui-state-default').on('click', function () {
1450
+ if ('link-tab-default' === $(this).attr('id')) {
1451
+ $(window).scrollTop($(window).scrollTop() + 1);
1452
+ $(window).scrollTop($(window).scrollTop() - 1);
1453
+ }
1454
+ });
1455
+
1456
+ /**
1457
+ * Set current value after language tab of content was changed.
1458
+ */
1459
+ $(document).on( 'tabsactivate', content_tabs_id, function( event, ui ) {
1460
+ WPGlobusAdmin.currentTab = ui.newTab[0].dataset.language;
1461
+ });
1462
+
1463
+ $(document).triggerHandler('wpglobus_after_post_edit');
1464
+
1465
+ },
1466
+ adminCentral: function () {
1467
+ $( '.wpglobus-admin-central-tab' ).css({ 'display':'none' });
1468
+
1469
+ if ( $( '.nav-tab-active' ).length > 1 ) {
1470
+ $( '.wpglobus-about-wrap .nav-tab-wrapper a' ).removeClass( 'nav-tab-active' );
1471
+ }
1472
+
1473
+ var setFirstElement = true;
1474
+ if ( 0 == location.hash.indexOf( '#' ) ) {
1475
+ $( '.wpglobus-about-wrap .nav-tab-wrapper a').each( function( i, e ) {
1476
+ if ( $(e).attr( 'href' ) == location.hash ) {
1477
+ setFirstElement = false;
1478
+ $(e).addClass( 'nav-tab-active' );
1479
+ }
1480
+ });
1481
+ }
1482
+ if ( setFirstElement ) {
1483
+ $( '.wpglobus-about-wrap .nav-tab-wrapper a' ).eq(0).addClass( 'nav-tab-active' );
1484
+ }
1485
+
1486
+ var activePanel = $( '.wpglobus-about-wrap .nav-tab-active' ).data( 'tab-id' );
1487
+ if ( '' != activePanel ) {
1488
+ $( '#'+activePanel ).css({'display':'block'});
1489
+ }
1490
+
1491
+ $(document).on( 'click', '.wpglobus-about-wrap .nav-tab', function(event){
1492
+ var $t = $( this );
1493
+ if ( $t.hasClass( 'nav-tab-active' ) ) {
1494
+ return;
1495
+ }
1496
+ $( '.wpglobus-admin-central-tab' ).css({ 'display':'none' });
1497
+ $( '.wpglobus-about-wrap .nav-tab' ).removeClass( 'nav-tab-active' );
1498
+ $t.addClass( 'nav-tab-active' );
1499
+ if ( '' != $t.data( 'tab-id' ) ) {
1500
+ $( '#' + $t.data( 'tab-id' ) ).css({ 'display':'block' });
1501
+ }
1502
+ });
1503
+ },
1504
+ start: function () {
1505
+ var t = this;
1506
+ $('#wpglobus_flags').select2({
1507
+ formatResult: this.format,
1508
+ formatSelection: this.format,
1509
+ minimumResultsForSearch: -1,
1510
+ escapeMarkup: function (m) {
1511
+ return m;
1512
+ }
1513
+ });
1514
+
1515
+ /** disable checked off first language */
1516
+ $('body').on('click', '#enabled_languages-list li:first input', function (event) {
1517
+ event.preventDefault();
1518
+ $('.redux-save-warn').css({'display': 'none'});
1519
+ $('#enabled_languages-list').find('li:first > input').val('1');
1520
+ if ($('#disable_first_language').length === 0) {
1521
+ $(t.config.disable_first_language).insertAfter('#info_bar');
1522
+ }
1523
+ return false;
1524
+ });
1525
+
1526
+ },
1527
+ format: function (language) {
1528
+ return '<img class="wpglobus_flag" src="' + WPGlobusAdmin.flag_url + language.text + '"/>&nbsp;&nbsp;' + language.text;
1529
+ },
1530
+ set_dialog: function() {
1531
+
1532
+ if ( 'undefined' !== typeof WPGlobusAdmin.data.customFieldsEnabled ) {
1533
+ WPGlobusAdmin.data.customFieldsEnabled = this.parseBool( WPGlobusAdmin.data.customFieldsEnabled );
1534
+ if ( ! WPGlobusAdmin.data.customFieldsEnabled ) {
1535
+ return;
1536
+ }
1537
+ }
1538
+
1539
+ var ajaxify_row_id, added_control = false;
1540
+ var add_elements = function(post_id) {
1541
+
1542
+ var id, rows, cb, _cb,
1543
+ _classes = 'wpglobus_dialog_start wpglobus_dialog_icon';
1544
+
1545
+ _cb = [
1546
+ '<div class="wpglobus_dialog_options_wrapper hidden">',
1547
+ '<input style="width:initial;" id="wpglobus-cb-{{id}}" data-object="#wpglobus-dialog-start-{{id}}" data-meta-key="{{meta-key}}" class="wpglobus_dialog_option wpglobus_dialog_cb" type="checkbox" {{checked}} />',
1548
+ '</div>'
1549
+ ].join('');
1550
+
1551
+ if (typeof post_id == 'undefined') {
1552
+ rows = '#the-list tr';
1553
+ } else {
1554
+ rows = '#the-list tr#'+post_id;
1555
+ }
1556
+ $(rows).each(function(){
1557
+ var $t = $(this),
1558
+ tid = $t.attr('id'),
1559
+ element = $t.find('textarea'),
1560
+ clone, name, meta_key,
1561
+ classes = _classes;
1562
+
1563
+ id = element.attr('id');
1564
+ if ( undefined === id ) {
1565
+ return true;
1566
+ }
1567
+ meta_key = $('#'+tid+'-key').val();
1568
+ clone = $('#'+id).clone();
1569
+ $(element).addClass('wpglobus-dialog-field-source hidden');
1570
+ name = element.attr('name');
1571
+ $(clone).attr('id', 'wpglobus-'+id);
1572
+ $(clone).attr('name', 'wpglobus-'+name);
1573
+ $(clone).attr('data-source-id', id);
1574
+ $(clone).attr('class', 'wpglobus-dialog-field');
1575
+ $(clone).val( WPGlobusCore.TextFilter($(element).val(), WPGlobusCoreData.language) );
1576
+ $(clone).insertAfter(element);
1577
+ cb = _cb.replace(/{{id}}/g, id);
1578
+ cb = cb.replace(/{{meta-key}}/g, meta_key);
1579
+ if ( undefined === WPGlobusAdmin.data.post_meta_settings[WPGlobusAdmin.data.post_type] ) {
1580
+ cb = cb.replace(/{{checked}}/, 'checked');
1581
+ } else {
1582
+ if ( undefined !== WPGlobusAdmin.data.post_meta_settings[WPGlobusAdmin.data.post_type][meta_key] && WPGlobusAdmin.data.post_meta_settings[WPGlobusAdmin.data.post_type][meta_key] == 'false' ) {
1583
+ cb = cb.replace(/{{checked}}/, '');
1584
+ classes = _classes+' wpglobus_dialog_start_hidden';
1585
+ } else {
1586
+ cb = cb.replace(/{{checked}}/, 'checked');
1587
+ classes = _classes;
1588
+ }
1589
+ }
1590
+ $t.append('<td style="width:20px;"><div id="wpglobus-dialog-start-'+id+'" data-type="control" data-source-type="textarea" data-source-id="'+id+'" class="'+classes+'"></div>'+cb+'</td>');
1591
+ });
1592
+ if ( ! added_control && $('#list-table .wpglobus_dialog_start').length > 0 ) {
1593
+ $('#list-table thead tr').append('<th class="wpglobus-control-head"><div class="wpglobus_dialog_settings wpglobus_dialog_icon"></div></th>');
1594
+ added_control = true;
1595
+ }
1596
+ }
1597
+
1598
+ add_elements();
1599
+
1600
+ $('body').on('change', '.wpglobus-dialog-field', function(){
1601
+ var $t = $(this),
1602
+ source_id = '#'+$t.data('source-id'),
1603
+ source = '', s = '', new_value;
1604
+
1605
+ if ( typeof source_id == 'undefined' ) {
1606
+ return;
1607
+ }
1608
+ source = $(source_id).val();
1609
+
1610
+ if ( ! /(\{:|\[:|<!--:)[a-z]{2}/.test(source) ) {
1611
+ $(source_id).val($t.val());
1612
+ } else {
1613
+ $.each(WPGlobusCoreData.enabled_languages, function(i,l){
1614
+ if ( l == WPGlobusCoreData.language ) {
1615
+ new_value = $t.val();
1616
+ } else {
1617
+ new_value = WPGlobusCore.TextFilter(source,l,'RETURN_EMPTY');
1618
+ }
1619
+ if ( '' != new_value ) {
1620
+ s = s + WPGlobusCore.addLocaleMarks(new_value,l);
1621
+ }
1622
+ });
1623
+ $(source_id).val(s);
1624
+ }
1625
+
1626
+ });
1627
+
1628
+ $(document).ajaxSend(function(event, jqxhr, settings){
1629
+ if ( 'add-meta' == settings.action ) {
1630
+ ajaxify_row_id = settings.element;
1631
+ }
1632
+ });
1633
+ $(document).ajaxComplete(function(event, jqxhr, settings){
1634
+ if ( 'add-meta' == settings.action && undefined !== jqxhr.responseXML ) {
1635
+ if ( 'newmeta' == ajaxify_row_id ) {
1636
+ add_elements('meta-'+$(jqxhr.responseXML.documentElement.outerHTML).find('meta').attr('id'));
1637
+ } else {
1638
+ add_elements(ajaxify_row_id);
1639
+ }
1640
+ }
1641
+ });
1642
+
1643
+ WPGlobusDialogApp.init({dialogTitle:'Edit meta'});
1644
+
1645
+ }
1646
+ };
1647
+
1648
+ new WPGlobusAdminApp.App();
1649
+
1650
+ return WPGlobusAdminApp;
1651
+
1652
+ }(window.WPGlobusAdminApp || {}, jQuery));
1653
+
1654
+ });
includes/js/wpglobus-admin-49.min.js ADDED
@@ -0,0 +1 @@
 
1
+ var WPGlobusCore;!function(t){var a;a=WPGlobusCore={strpos:function(t,a,e){var o=(t=""+t).indexOf(a,e);return o>=0&&o},TextFilter:function(t,e,o){if(void 0===t||""===t)return t;var n,i,l=[],s=!1;e=""==e?"en":e,o=void 0===o||""==o?"RETURN_IN_DEFAULT_LANGUAGE":o,l[0]=[],l[0].start=WPGlobusCoreData.locale_tag_start.replace("%s",e),l[0].end=WPGlobusCoreData.locale_tag_end,l[1]=[],l[1].start="\x3c!--:"+e+"--\x3e",l[1].end="\x3c!--:--\x3e",l[2]=[],l[2].start="[:"+e+"]",l[2].end="[:";for(var d=0;d<3;d++)if(!1!==(n=a.strpos(t,l[d].start))){n+=l[d].start.length,t=!1===(i=a.strpos(t,l[d].end,n))?t.substr(n):t.substr(n,i-n),s=!0;break}return s||("RETURN_EMPTY"==o?(e!=WPGlobusCoreData.default_language||/(\{:|\[:|<!--:)[a-z]{2}/.test(t))&&(t=""):e==WPGlobusCoreData.default_language?/(\{:|\[:|<!--:)[a-z]{2}/.test(t)&&(t=""):t=a.TextFilter(t,WPGlobusCoreData.default_language)),t},addLocaleMarks:function(t,a){return WPGlobusCoreData.locale_tag_start.replace("%s",a)+t+WPGlobusCoreData.locale_tag_end},getTranslations:function(e){var o,n={};return t.each(WPGlobusCoreData.enabled_languages,function(t,i){o=i==WPGlobusCoreData.default_language?"RETURN_IN_DEFAULT_LANGUAGE":"RETURN_EMPTY",n[i]=a.TextFilter(e,i,o)}),n},getString:function(e,o,n){if(void 0===e)return e;void 0===o&&(o=""),void 0===n&&(n=WPGlobusCoreData.language),(e=a.getTranslations(e))[n]=o;var i="";return t.each(e,function(t,e){""!=e&&t!=WPGlobusCoreData.default_language&&(i+=a.addLocaleMarks(e,t))}),""!=e[WPGlobusCoreData.default_language]&&(i=""==i?e[WPGlobusCoreData.default_language]:a.addLocaleMarks(e[WPGlobusCoreData.default_language],WPGlobusCoreData.default_language)+i),i}}}(jQuery);var WPGlobusDialogApp;!function(t){var a;a=WPGlobusDialogApp={option:{listenClass:".wpglobus_dialog_start",settingsClass:".wpglobus_dialog_settings",dialogTabs:"#wpglobus-dialog-tabs",dialogTitle:"",customData:null,callback:function(){},dialogOptions:{title:"",placeholder:"",formFooter:"",beforeOpen:function(){},close:function(){}},dialog:{}},form:void 0,element:void 0,element_by:"id",id:"",clone_id:"",wpglobus_id:"",type:"textarea",source:"",order:{},value:{},request:"core",attrs:{},dialogTitle:"",trClass:"wpglobus-translatable",startButton:['<span id="wpglobus-dialog-start-{{clone_id}}" ','style="{{style}}" ','data-type="control" data-dialog-title="{{title}}" ','data-source-type="" data-source-id="{{id}}" data-source-name="{{name}}" ','data-nodename="{{nodename}}"',"{{sbTitle}} ",'class="{{classes}}"></span>'].join(""),startButtonClass:"wpglobus_dialog_start wpglobus_dialog_icon",clicks:0,init:function(e){a.option.dialog=a.option.dialogOptions,a.option=t.extend(a.option,e),t(a.option.dialogTabs).tabs(),a.dialogTitle=a.option.dialogTitle,this.attachListener(),null!=a.option.customData&&void 0!==a.option.customData.addElements&&t.each(a.option.customData.addElements,function(t,e){a.addElement(e)})},convertToId:function(t){return t=(t=t.replace(/\]/g,"")).replace(/\[/g,"-")},addElement:function(e){var o={id:null,style:"",styleTextareaWrapper:"",sbTitle:"",onChangeClass:"",dialogTitle:"",dialog:a.option.dialogOptions};if("string"==typeof e)o.id=e;else{if("object"!=typeof e)return;o=t.extend(o,e)}var n,i,l,s=null,d=null,u=null,r=null,c=a.startButton,g="";if(a.element_by="name",0==(r=document.getElementsByName(o.id)).length&&(a.element_by="id",r=document.getElementById(o.id)),null!==r){if(d=o.id,"id"==a.element_by?s=t("#"+d):(g=(g=r[0].nodeName).toLowerCase(),s=t(g+'[name="'+d+'"]')),u=void 0===s.attr("name")||""==s.attr("name")?d:s.attr("name"),a.clone_id=a.convertToId(d),-1!=u.indexOf("wpglobus")||-1!=a.clone_id.indexOf("wpglobus"))return!1;if(t("#wpglobus-"+a.clone_id).length>0)return!1;if(t(g+'[name="wpglobus-'+u+'"]').length>0)return!1;n=t(s.clone()),l=s.attr("style")||"",s.attr("style","display:none;"),n.attr("id","wpglobus-"+a.clone_id).attr("name","wpglobus-"+u),n.addClass(a.trClass),""!=o.onChangeClass&&n.addClass(o.onChangeClass),"id"==a.element_by?n.attr("data-source-id",d).attr("data-source-name","").attr("data-source-get-by",a.element_by):n.attr("data-source-id","").attr("data-source-name",u).attr("data-source-get-by",a.element_by),"textarea"==g?(i=WPGlobusCore.getTranslations(s.val())[WPGlobusCoreData.language],n.val(i),n.attr("data-nodename","textarea"),""==o.style?n.attr("style",l+";width:95%;float:left;"):n.attr("style",l+";"+o.style)):(i=WPGlobusCore.getTranslations(s.val())[WPGlobusCoreData.language],n.attr("value",i),n.attr("data-nodename","input"),""!=o.style&&n.attr("style",l+";"+o.style)),""!=o.dialog&&n.attr("data-dialog",JSON.stringify(o.dialog)),c=c.replace(/{{clone_id}}/g,a.clone_id),c="id"==a.element_by?(c=(c=c.replace(/{{id}}/g,a.clone_id)).replace(/{{name}}/g,"")).replace(/{{nodename}}/g,""):(c=(c=c.replace(/{{id}}/g,"")).replace(/{{name}}/g,u)).replace(/{{nodename}}/g,g),c="textarea"==g?c.replace("{{style}}","float:left;margin-top:0;"):c.replace("{{style}}","");var b="textarea"==g?a.startButtonClass+" wpglobus-textarea wpglobus-textarea-"+a.clone_id:a.startButtonClass;c=c.replace("{{classes}}",b),c=""==o.dialogTitle?c.replace("{{title}}",a.dialogTitle):c.replace("{{title}}",o.dialogTitle),c=""==o.sbTitle?c.replace("{{sbTitle}}",o.sbTitle):c.replace("{{sbTitle}}",'title="'+o.sbTitle+'"'),t(c).insertAfter(s),t(n).insertAfter(s),"textarea"==g&&(t("#wpglobus-"+a.clone_id).addClass("wpglobus-textarea-"+a.clone_id),t(".wpglobus-textarea-"+a.clone_id).wrapAll('<div class="wpglobus-textarea-wrapper" style="'+o.styleTextareaWrapper+'"></div>'));var p,m=!1;if(""==o.onChangeClass)p="#wpglobus-"+a.clone_id;else{p="."+o.onChangeClass;var v=t._data(t(document)[0],"events");void 0===v?m=!0:void 0!==v.change&&t.each(v.change,function(t,a){if(a.selector==p)return m=!0,!1})}return!!m||(t(document).on("change",p,function(){var a=t(this),e=a.data("source-id");e=""==e?a.data("nodename")+'[name="'+a.data("source-name")+'"]':"#"+e,t(e).val(WPGlobusCore.getString(t(e).val(),a.val()))}),!0)}},saveDialog:function(){var e,o,n,i="",l="",s="";t(".wpglobus_dialog_textarea").each(function(a,d){e=t(d),o=e.val(),(n=e.data("language"))==WPGlobusAdmin.data.language&&(s=o),""!=o&&(i+=WPGlobusCore.addLocaleMarks(o,n),n==WPGlobusCoreData.default_language&&(l=o))}),i=i.length==l.length+8?l:i,t(a.id).val(i),i=""==s?l:s,t(a.wpglobus_id).val(i)},dialog:t("#wpglobus-dialog-wrapper").dialog({autoOpen:!1,width:650,modal:!0,dialogClass:"wpglobus-dialog",buttons:[{text:"Save",class:"wpglobus-button-save",click:function(){a.saveDialog(),a.dialog.dialog("close")}},{text:"Cancel",class:"wpglobus-button-cancel",click:function(){a.dialog.dialog("close")}}],open:function(e,o){var n=a.dialogTitle;void 0!==a.attrs.maxlength&&(t(".wpglobus_dialog_textarea").attr("maxlength",a.attrs.maxlength),n+=" | maxlength="+a.attrs.maxlength),t(".wpglobus-dialog .ui-dialog-title").text(n)},close:function(){a.runCallback(a.option.dialog.close),a.form[0].reset()}}),attachListener:function(){t(document).on("click",a.option.settingsClass,function(){t(".wpglobus_dialog_options_wrapper").hasClass("hidden")?t(".wpglobus_dialog_options_wrapper").removeClass("hidden"):t(".wpglobus_dialog_options_wrapper").addClass("hidden")}),t(document).on("click",".wpglobus_dialog_option",function(e){var o=t(this),n=o.data("object");a.order.action="save_post_meta_settings",a.order.post_type=WPGlobusAdmin.data.post_type,a.order.checked=o.prop("checked"),a.order.id=o.attr("id"),a.order.meta_key=o.data("meta-key"),a.ajax(a.order).done(function(a){"ok"==a.result&&("true"==a.checked?t(n).removeClass("wpglobus_dialog_start_hidden"):t(n).addClass("wpglobus_dialog_start_hidden"))}).fail(function(t){}).always(function(t,a){})}),t(document).on("click",a.option.listenClass,function(e){a.element=t(this),a.id=a.element.data("source-id"),""==a.id?(a.id=a.element.data("nodename")+'[name="'+a.element.data("source-name")+'"]',a.wpglobus_id="#wpglobus-"+a.convertToId(a.element.data("source-name"))):(a.wpglobus_id="#wpglobus-"+a.id,a.id="#"+a.id),a.clicks++,1==a.clicks&&setTimeout(function(){if(1==a.clicks)a.onClick(e);else{var o=t(a.id);o.hasClass("hidden")?o.removeClass("hidden").attr("style","display:block;"):o.addClass("hidden").attr("style","display:none;")}a.clicks=0},200)}),a.form=a.dialog.find("form#wpglobus-dialog-form").on("submit",function(t){t.preventDefault(),a.saveDialog()})},ajax:function(a){return t.ajax({type:"POST",url:WPGlobusAdmin.ajaxurl,data:{action:WPGlobusAdmin.process_ajax,order:a},dataType:"json",async:!1})},onClick:function(e){void 0===a.element.data("dialog-title")||""==a.element.data("dialog-title")?a.dialogTitle=a.option.dialogTitle:a.dialogTitle=a.element.data("dialog-title"),void 0!==a.id&&(a.attrs.maxlength=t(a.id).attr("maxlength")),a.source=a.element.data("source-value"),void 0===a.source&&(a.source=t(a.id).val(),"ajax"==a.request||(a.value=WPGlobusCore.getTranslations(a.source))),a.option.dialog=t.extend({},a.option.dialogOptions,t(a.wpglobus_id).data("dialog")),""!=a.option.dialog.title&&(a.dialogTitle=a.option.dialog.title),t.each(a.value,function(e,o){var n=t("#wpglobus-dialog-"+e);n.val(o),n.attr("placeholder",WPGlobusCore.TextFilter(a.option.dialog.placeholder,e,"RETURN_IN_DEFAULT_LANGUAGE"))}),t("#wpglobus-dialog-form-footer").html(a.option.dialog.formFooter),a.runCallback(a.option.dialog.beforeOpen),a.dialog.dialog("open")},runCallback:function(t){if("object"==typeof t){var a=Object.keys(t)[0],e=t[Object.keys(t)[0]];"window"===a?"function"==typeof window[e]&&window[e](t[Object.keys(t)[1]]):"function"==typeof window[a][e]&&window[a][e](t[Object.keys(t)[1]])}else"string"==typeof t&&"function"==typeof window[t]&&window[t]()}}}(jQuery),jQuery(document).ready(function(){"use strict";window.WPGlobusAdminApp=(t=window.WPGlobusAdminApp||{},a=jQuery,t.App=function(t){void 0===window.WPGlobusAdminApp&&(this.config={debug:!1,version:WPGlobusAdmin.version},this.status="ok","undefined"==typeof WPGlobusAdmin?(this.status="error",this.config.debug&&console.log("WPGlobus: error options loading")):this.config.debug&&console.dir(WPGlobusAdmin),this.config.disable_first_language=['<div id="disable_first_language" style="display:block;" class="redux-field-errors notice-red">',"<strong>","<span>&nbsp;</span>",WPGlobusAdmin.i18n.cannot_disable_language,"</strong>","</div>"].join(""),a.extend(this.config,t),"ok"===this.status&&this.init())},t.App.prototype={$document:a(document),init:function(){WPGlobusCoreData.multisite=this.parseBool(WPGlobusCoreData.multisite),this.adminInit(),a("#content").addClass("wpglobus-editor").attr("data-language",WPGlobusAdmin.data.default_language),a("textarea[id^=content_]").each(function(t,e){var o=a(e).attr("id").replace("content_","");a(e).attr("data-language",o)}),"post.php"===WPGlobusAdmin.page?(this.postEdit(),this.set_dialog(),"undefined"!=typeof WPGlobusAioseop&&WPGlobusAioseop.init()):"menu-edit"===WPGlobusAdmin.page?this.navMenus():"taxonomy-edit"===WPGlobusAdmin.page?WPGlobusAdmin.data.tag_id&&this.taxonomyEdit():"taxonomy-quick-edit"===WPGlobusAdmin.page?this.quickEdit("taxonomy"):"edit.php"===WPGlobusAdmin.page?this.quickEdit("post"):"options-general.php"==WPGlobusAdmin.page?(this.optionsGeneral(),WPGlobusDialogApp.init({customData:WPGlobusCoreData.page_custom_data})):"widgets.php"==WPGlobusAdmin.page?(WPGlobusWidgets.init(),WPGlobusDialogApp.init({dialogTitle:"Edit text"})):"wpglobus_options"==WPGlobusAdmin.page?this.start():"wpglobusAdminCentral"==WPGlobusAdmin.page?this.adminCentral():WPGlobusDialogApp.init({customData:WPGlobusCoreData.page_custom_data})},parseBool:function(t){return!/^(false|0)$/i.test(t)&&!!t},getCurrentTab:function(){return a(".wpglobus-post-body-tabs-list .ui-tabs-active").data("language")},adminInit:function(){var t=a(".wpglobus-addons-group a").data("key");if(void 0!==t)if(window.location.search.indexOf("page=wpglobus_options&tab="+t)>=0)WPGlobusCoreData.multisite?window.location=WPGlobusCoreData.pluginInstallLocation.multisite:window.location=WPGlobusCoreData.pluginInstallLocation.single;else{var e=a("#toplevel_page_wpglobus_options li").eq(t+1);WPGlobusCoreData.multisite?a(e).find("a").attr("href",WPGlobusCoreData.pluginInstallLocation.multisite).attr("onclick","window.location=jQuery(this).attr('href');return false;"):a(e).find("a").attr("href",WPGlobusCoreData.pluginInstallLocation.single).attr("onclick","window.location=jQuery(this).attr('href');return false;")}},optionsGeneral:function(){var t=a("#blogname"),e=a("body");t.addClass("hidden"),a("#wpglobus-blogname").insertAfter(t).removeClass("hidden"),e.on("blur",".wpglobus-blogname",function(){a(".wpglobus-blogname").each(function(e,o){var n=a(o);t.val(WPGlobusCore.getString(t.val(),n.val(),n.data("language")))})});var o=a("#blogdescription");o.addClass("hidden"),a("#wpglobus-blogdescription").insertAfter(o).removeClass("hidden"),e.on("blur",".wpglobus-blogdesc",function(){a(".wpglobus-blogdesc").each(function(t,e){var n=a(e);o.val(WPGlobusCore.getString(o.val(),n.val(),n.data("language")))})})},quickEdit:function(t){if(void 0!==WPGlobusAdmin.data.has_items&&WPGlobusAdmin.data.has_items){var e="",o=0;a(document).ajaxComplete(function(t,n,i){void 0!==i.data&&""!=e&&i.data.indexOf("action=inline-save-tax&")>=0&&(a("#"+e+" a.row-title").text(WPGlobusAdmin.qedit_titles[o][WPGlobusAdmin.data.language].name),a("#"+e+" .description").text(WPGlobusAdmin.qedit_titles[o][WPGlobusAdmin.data.language].description))});var n={};a("#the-list tr").each(function(e,i){var l=a(i),s="post"===t?"post-":"tag-";o=l.attr("id").replace(s,""),n[o]={},"post"===t?n[o].source=l.find(".post_title").text():"taxonomy"===t&&(n[o].source=a("#inline_"+o+" .name").text())});var i={};i.action="get_titles",i.type=t,i.taxonomy=void 0!==WPGlobusAdmin.data.taxonomy&&WPGlobusAdmin.data.taxonomy,i.title=n,a.ajax({type:"POST",url:WPGlobusAdmin.ajaxurl,data:{action:WPGlobusAdmin.process_ajax,order:i},dataType:"json"}).done(function(t){WPGlobusAdmin.qedit_titles=t.qedit_titles,a.each(t.bulkedit_post_titles,function(t,e){a("#inline_"+t+" .post_title").text(e[WPGlobusAdmin.data.language].name)})}).fail(function(t){}).always(function(t,a){}),a("body").on("change",".wpglobus-quick-edit-title",function(){var t="",e=[];a(".wpglobus-quick-edit-title").each(function(n,i){var l=a(i),s=l.data("language");""!==l.val()&&(t=WPGlobusCore.getString(t,l.val(),s)),WPGlobusAdmin.qedit_titles[o][s].name=l.val(),e[n]=s});var n=a(document).triggerHandler("wpglobus_get_translations",{string:t,lang:e,id:o});void 0!==n&&(t=n),a("input.ptitle").eq(0).attr("value",t),WPGlobusAdmin.qedit_titles[o].source=t}),void 0!==WPGlobusAdmin.data.tags&&a.each(WPGlobusAdmin.data.tags,function(t,a){WPGlobusAdmin.data.value[a].post_id={}}),a("button.save, input#bulk_edit").on("mouseenter",function(t){void 0!==WPGlobusAdmin.data.tags&&("bulk_edit"==t.currentTarget.id?a("input#bulk_edit").unbind("click"):a("button.save").unbind("click"),a("button.save, input#bulk_edit").on("click",function(t){var e=a.when(),n=(a(this),a.Deferred());n.resolve(function(e){e.next(".spinner").css({visibility:"visible"}),"bulk_edit"!=t.currentTarget.id&&a.ajaxSetup({async:!1});var o,n,i,l=e.parents("tr"),s=l.attr("id").replace("edit-","");a.each(WPGlobusAdmin.data.tags,function(t,a){if(0==(o=l.find("textarea[name='"+WPGlobusAdmin.data.names[a]+"']")).length)return!0;WPGlobusAdmin.data.value[a].post_id[s]=o.val(),n=WPGlobusAdmin.data.value[a].post_id[s].split(","),i=[];for(var e=0;e<n.length;e++)n[e]=n[e].trim(" "),""!=n[e]&&(void 0===WPGlobusAdmin.data.tag[a][n[e]]?i[e]=n[e]:i[e]=WPGlobusAdmin.data.tag[a][n[e]]);o.val(i.join(", "))})}(a(this))),e=e.then(function(){return a.when(n.done())}).then(function(){"bulk_edit"!=t.currentTarget.id&&setTimeout(function(){inlineEditPost.save(o),a.ajaxSetup({async:!0})},50)})}))}),a("#the-list").on("click","a.editinline",function(){var n=a(this);if(e=n.parents("tr").attr("id"),"post"===t)o=e.replace("post-","");else{if("taxonomy"!==t)return;o=e.replace("tag-","")}"post"===t&&void 0!==WPGlobusAdmin.data.tags&&a.each(WPGlobusAdmin.data.tags,function(t,e){if(""!=WPGlobusAdmin.data.value[e]){var n,i=a("#edit-"+o+' textarea[name="'+WPGlobusAdmin.data.names[e]+'"]').val();void 0!==i&&(n=i.split(","),a.each(n,function(t,a){i=i.replace(a,WPGlobusCore.TextFilter(a,WPGlobusCoreData.language))}),a("#edit-"+o+' textarea[name="'+WPGlobusAdmin.data.names[e]+'"]').val(i))}});var i=a("#edit-"+o+" input.ptitle").eq(0),l=i.parents("label");i.val(WPGlobusAdmin.qedit_titles[o].source),i.addClass("hidden"),a(WPGlobusAdmin.data.template).insertAfter(l),void 0===WPGlobusAdmin.qedit_titles[o]&&(WPGlobusAdmin.qedit_titles[o]={},WPGlobusAdmin.qedit_titles[o].source=a("#"+e+" .name a.row-title").text(),a(WPGlobusAdmin.data.enabled_languages).each(function(t,a){WPGlobusAdmin.qedit_titles[o][a]={},a==WPGlobusAdmin.data.default_language?WPGlobusAdmin.qedit_titles[o][a].name=WPGlobusAdmin.qedit_titles[o].source:WPGlobusAdmin.qedit_titles[o][a].name="",WPGlobusAdmin.qedit_titles[o][a].description=""})),a(".wpglobus-quick-edit-title").each(function(t,e){var n=a(e),i=n.data("language");n.attr("id",i+o),void 0!==WPGlobusAdmin.qedit_titles[o][i]&&(WPGlobusAdmin.qedit_titles[o][i].name=WPGlobusAdmin.qedit_titles[o][i].name.replace(/\\\'/g,"'"),WPGlobusAdmin.qedit_titles[o][i].name=WPGlobusAdmin.qedit_titles[o][i].name.replace(/\\\"/g,'"'),n.attr("value",WPGlobusAdmin.qedit_titles[o][i].name),WPGlobusAdmin.qedit_titles[o].source=WPGlobusCore.getString(WPGlobusAdmin.qedit_titles[o].source,WPGlobusAdmin.qedit_titles[o][i].name,i))}),a("input.ptitle").eq(0).attr("value",WPGlobusAdmin.qedit_titles[o].source)})}},taxonomyEdit:function(){var t=[];t[0]="name",t[1]="description",a.each(WPGlobusCoreData.enabled_languages,function(e,o){a.each(t,function(t,e){!function(t,e){var o,n=a("#"+t),i=n.clone(),l=n.attr("name"),s="wpglobus-element wpglobus-element_"+t+" wpglobus-element_"+e+" wpglobus-translatable";o=(o=document.getElementById(t)).nodeName,a(i).attr("id",t+"_"+e),a(i).attr("name",l+"_"+e),e!==WPGlobusCoreData.default_language&&(s+=" hidden"),a(i).attr("class",s),a(i).attr("data-save-to",t),a(i).attr("data-language",e),"INPUT"==o?a(i).attr("value",a("#wpglobus-link-tab-"+e).data(t)):"TEXTAREA"==o&&a(i).text(a("#wpglobus-link-tab-"+e).data(t)),n.addClass("hidden"),0==a(".wpglobus-element_"+t).length?a(i).insertAfter(n):a(i).insertAfter(a(".wpglobus-element_"+t).last())}(e,o)})}),a(".wpglobus-taxonomy-tabs").insertAfter("#ajax-response"),a(".wrap").tabs(),a("body").on("click",".wpglobus-taxonomy-tabs li",function(t){var e=a(this).data("language");a(".wpglobus-element").addClass("hidden"),a(".wpglobus-element_"+e).removeClass("hidden")}),a(".wpglobus-element").on("change",function(){var t=a(this).data("save-to"),e="";a(".wpglobus-element").each(function(o,n){var i=a(n),l=i.val();i.data("save-to")==t&&""!==l&&(e+=WPGlobusCore.addLocaleMarks(l,i.data("language")))}),a("#"+t).val(e)}),a(WPGlobusAdmin.data.multilingualSlug.title).insertAfter(".term-slug-wrap th label")},navMenus:function(){var t,e,o="#menu-to-edit .menu-item",n=function(){e!==a(o).length&&(clearInterval(t),a(o).each(function(t,e){var o=a(e);if(!o.hasClass("wpglobus-menu-item")){var n=a(e).attr("id");a.each(["input.edit-menu-item-title","input.edit-menu-item-attr-title"],function(t,e){var o=a("#"+n+" "+e),i=a(o);if(!i.hasClass("wpglobus-hidden")){i.addClass("wpglobus-hidden"),i.css("display","none");var l=i.parent("label"),s=i.parents("p");a(s).css("height","80px"),a(l).append('<div style="color:#f00;">'+WPGlobusAdmin.i18n.save_nav_menu+"</div>")}}),o.addClass("wpglobus-menu-item")}}))};a.ajaxSetup({beforeSend:function(i,l){void 0!==l.data&&l.data.indexOf("action=add-menu-item")>=0&&(e=a(o).length,t=setInterval(n,500))}}),a(o).each(function(t,e){var o=a(e).attr("id"),n=o.replace("menu-item-","");a.each(["input.edit-menu-item-title","input.edit-menu-item-attr-title"],function(t,e){var i=a("#"+o+" "+e);i.val()!=WPGlobusAdmin.data.items[n][e].source&&i.val(WPGlobusAdmin.data.items[n][e].source);var l=a("#"+o+" "+e).parents("p"),s=0;a.each(WPGlobusAdmin.data.open_languages,function(o,d){var u=i.clone();u.attr("id",i.attr("id")+"-"+d),u.attr("name",i.attr("id")+"-"+d),u.attr("data-language",d),u.attr("data-item-id",n),u.attr("placeholder",WPGlobusAdmin.data.en_language_name[d]);var r=WPGlobusAdmin.data.items[n][d][e].class;0===t&&d===WPGlobusAdmin.data.default_language?u.attr("class",r+" edit-menu-item-title"):u.attr("class",r),""!=WPGlobusAdmin.data.items[n][d][e].caption?u.attr("value",WPGlobusAdmin.data.items[n][d][e].caption):u.attr("value",""),u.css("margin-bottom","0.6em"),a(l).append(u),s=o}),s=40*(s+1),i.css("display","none").attr("class","").addClass("widefat wpglobus-hidden"),a(l).css("height",s+"px").addClass("wpglobus-menu-item-box")}),a(e).addClass("wpglobus-menu-item")}),a(".menus-move-left, .menus-move-right").each(function(t,e){var o,n=a(e),i=(n.parents("li").attr("id").replace("menu-item-",""),n.attr("title"));void 0!==i&&a.each(WPGlobusAdmin.data.post_titles,function(t,a){i.indexOf(t)>=0&&(o=i.replace(t,a),n.attr("title",o),n.text(o))})}),a(".edit-menu-item-title").trigger("change"),wpNavMenu.refreshAdvancedAccessibility(),wpNavMenu.menusChanged=!1,a(".wpglobus-menu-item").on("change",function(){var t,e,o=a(this),n=o.data("item-id");o.hasClass("wpglobus-item-title")&&(t=WPGlobusCore.getString(a("input#edit-menu-item-title-"+n).val(),o.val(),o.data("language")),void 0!==(e=a(document).triggerHandler("wpglobus_get_menu_translations",{string:t,lang:WPGlobusCoreData.open_languages,id:n,type:"input.edit-menu-item-title"}))&&(t=e),a("input#edit-menu-item-title-"+n).val(t)),o.hasClass("wpglobus-item-attr")&&(t=WPGlobusCore.getString(a("input#edit-menu-item-attr-title-"+n).val(),o.val(),o.data("language")),void 0!==(e=a(document).triggerHandler("wpglobus_get_menu_translations",{string:t,lang:WPGlobusCoreData.open_languages,id:n,type:"input.edit-menu-item-attr-title"}))&&(t=e),a("input#edit-menu-item-attr-title-"+n).val(t))})},postEdit:function(){a(document).on("heartbeat-send",function(t,e){void 0!==e.wp_autosave&&(e.wpglobus_heartbeat="wpglobus",a.each(WPGlobusAdmin.data.open_languages,function(t,o){var n=a("#title_"+o).val()||"";""!=(n=a.trim(n))&&(e.wp_autosave["post_title_"+o]=n),n=a("#content_"+o).val()||"",""!=(n=a.trim(n))&&(e.wp_autosave["content_"+o]=n)}))});var t="#postdivrich",e=!0,o="#post-body-content";if(!1===WPGlobusAdmin.data.support.editor&&(t="#titlediv",e=!1),!1===WPGlobusAdmin.data.support.title&&(e=!1),a(o).prepend(a(".wpglobus-post-body-tabs-list")),a.each(WPGlobusAdmin.tabs,function(o,n){"default"===n?(a(t).wrap('<div id="tab-default"></div>'),e&&a(a("#titlediv")).insertBefore(t)):(a(t+"-"+n).wrap('<div id="tab-'+n+'"></div>'),e&&a(a("#titlediv-"+n)).insertBefore(t+"-"+n))}),a(o).addClass("wpglobus-post-body-tabs").tabs({beforeActivate:function(t,e){var o=e.oldTab[0].id.replace("link-tab-",""),n=e.newTab[0].id.replace("link-tab-","");"default"==o&&(o=WPGlobusCoreData.default_language),"default"==n&&(n=WPGlobusCoreData.default_language);var i=a(document).triggerHandler("wpglobus_post_body_tabs",[o,n]);return!(!i&&void 0!==i)}}),a("#title").val(WPGlobusAdmin.title),a("#content").text(WPGlobusAdmin.content),"undefined"!=typeof WPGlobusVendor&&WPGlobusVendor.vendor.WPSEO&&("undefined"!=typeof wpglobus_wpseo?wpglobus_wpseo():"undefined"!=typeof WPGlobusYoastSeo&&("undefined"!=typeof WPGlobusYoastSeoPremium&&WPGlobusYoastSeoPremium&&WPGlobusYoastSeoPremium.init(),WPGlobusYoastSeo.init())),WPGlobusAdmin.data.modify_excerpt){var n=a("#excerpt");n.addClass("hidden").css({display:"none"}),a(WPGlobusAdmin.data.template).insertAfter(n),a("body").on("change",".wpglobus-excerpt",function(){var t=a(this);n.val(WPGlobusCore.getString(n.val(),t.val(),t.data("language")))})}if(void 0!==wp.utils&&void 0!==wp.utils.WordCounter){WPGlobusCoreData.wordCounter={};var i=this,l={};a.each(WPGlobusCoreData.enabled_languages,function(t,a){if(a==WPGlobusCoreData.default_language)return!0;l[t]="content_"+a,e=jQuery,o=new wp.utils.WordCounter,n=a,WPGlobusCoreData.wordCounter[n]={},WPGlobusCoreData.wordCounter[n].counter=o,e(function(){WPGlobusCoreData.wordCounter[n].content=e("#content_"+n),WPGlobusCoreData.wordCounter[n].count=e("#wp-word-count-"+n).find(".word-count-"+n),WPGlobusCoreData.wordCounter[n].prevCount=0;function t(t){var a,e;"object"==typeof t&&(t="tinymce"==t?i.getCurrentTab():t.target.id.replace("content_","")),void 0!==WPGlobusCoreData.wordCounter[t]&&(a=!WPGlobusCoreData.wordCounter[t].contentEditor||WPGlobusCoreData.wordCounter[t].contentEditor.isHidden()?WPGlobusCoreData.wordCounter[t].content.val():WPGlobusCoreData.wordCounter[t].contentEditor.getContent({format:"raw"}),(e=WPGlobusCoreData.wordCounter[t].counter.count(a))!==WPGlobusCoreData.wordCounter[t].prevCount&&WPGlobusCoreData.wordCounter[t].count.text(e),WPGlobusCoreData.wordCounter[t].prevCount=e)}e(document).on("tinymce-editor-init",function(a,o){if(-1!=e.inArray(o.id,l)){var n=o.id.replace("content_","");WPGlobusCoreData.wordCounter[n].contentEditor=o,o.on("nodechange keyup",_.debounce(t,1e3))}}),WPGlobusCoreData.wordCounter[n].content.on("input keyup",_.debounce(t,1e3)),t(n)});var e,o,n})}a(document).on("click","#publish, #save-post",function(){if(WPGlobusAdmin.data.open_languages.length>1){a(document).triggerHandler("wpglobus_before_save_post",{content_tabs_id:o});var t,e=a("#title").val(),n="",i="";0==e.length&&(t=WPGlobusAdmin.data.open_languages.indexOf(WPGlobusAdmin.data.default_language),WPGlobusAdmin.data.open_languages.splice(t,1),a(WPGlobusAdmin.data.open_languages).each(function(t,o){i=0==t?"":"-",(e=a("#title_"+o).val()).length>0&&(0==n.length&&(i=""),n=n+i+e)})),n.length>0&&a("#title").val(n)}void 0===WPGlobusAdmin.data.tagsdiv||WPGlobusAdmin.data.tagsdiv.length<1||a(WPGlobusAdmin.data.tagsdiv).each(function(t,e){if(0==a("#"+e).length)return!0;var o=e.replace("tagsdiv-","");if("undefined"===o)return!0;if(0==a("#tax-input-"+o).length)return!0;var n,i=[];a("#tagsdiv-"+o+" .tagchecklist li").each(function(t,e){n=(n=a(e).html()).replace(/<button.*<\/button>&nbsp;/,""),void 0===WPGlobusAdmin.data.tag[o][n]?i[t]=n:i[t]=WPGlobusAdmin.data.tag[o][n]}),a("#tax-input-"+o).val(i.join(", "))})}),a(".ui-state-default").on("click",function(){"link-tab-default"===a(this).attr("id")&&(a(window).scrollTop(a(window).scrollTop()+1),a(window).scrollTop(a(window).scrollTop()-1))}),a(document).on("tabsactivate",o,function(t,a){WPGlobusAdmin.currentTab=a.newTab[0].dataset.language}),a(document).triggerHandler("wpglobus_after_post_edit")},adminCentral:function(){a(".wpglobus-admin-central-tab").css({display:"none"}),a(".nav-tab-active").length>1&&a(".wpglobus-about-wrap .nav-tab-wrapper a").removeClass("nav-tab-active");var t=!0;0==location.hash.indexOf("#")&&a(".wpglobus-about-wrap .nav-tab-wrapper a").each(function(e,o){a(o).attr("href")==location.hash&&(t=!1,a(o).addClass("nav-tab-active"))}),t&&a(".wpglobus-about-wrap .nav-tab-wrapper a").eq(0).addClass("nav-tab-active");var e=a(".wpglobus-about-wrap .nav-tab-active").data("tab-id");""!=e&&a("#"+e).css({display:"block"}),a(document).on("click",".wpglobus-about-wrap .nav-tab",function(t){var e=a(this);e.hasClass("nav-tab-active")||(a(".wpglobus-admin-central-tab").css({display:"none"}),a(".wpglobus-about-wrap .nav-tab").removeClass("nav-tab-active"),e.addClass("nav-tab-active"),""!=e.data("tab-id")&&a("#"+e.data("tab-id")).css({display:"block"}))})},start:function(){var t=this;a("#wpglobus_flags").select2({formatResult:this.format,formatSelection:this.format,minimumResultsForSearch:-1,escapeMarkup:function(t){return t}}),a("body").on("click","#enabled_languages-list li:first input",function(e){return e.preventDefault(),a(".redux-save-warn").css({display:"none"}),a("#enabled_languages-list").find("li:first > input").val("1"),0===a("#disable_first_language").length&&a(t.config.disable_first_language).insertAfter("#info_bar"),!1})},format:function(t){return'<img class="wpglobus_flag" src="'+WPGlobusAdmin.flag_url+t.text+'"/>&nbsp;&nbsp;'+t.text},set_dialog:function(){if(void 0===WPGlobusAdmin.data.customFieldsEnabled||(WPGlobusAdmin.data.customFieldsEnabled=this.parseBool(WPGlobusAdmin.data.customFieldsEnabled),WPGlobusAdmin.data.customFieldsEnabled)){var t,e=!1,o=function(t){var o,n,i,l="wpglobus_dialog_start wpglobus_dialog_icon";i=['<div class="wpglobus_dialog_options_wrapper hidden">','<input style="width:initial;" id="wpglobus-cb-{{id}}" data-object="#wpglobus-dialog-start-{{id}}" data-meta-key="{{meta-key}}" class="wpglobus_dialog_option wpglobus_dialog_cb" type="checkbox" {{checked}} />',"</div>"].join(""),a(void 0===t?"#the-list tr":"#the-list tr#"+t).each(function(){var t,e,s,d=a(this),u=d.attr("id"),r=d.find("textarea"),c=l;if(void 0===(o=r.attr("id")))return!0;s=a("#"+u+"-key").val(),t=a("#"+o).clone(),a(r).addClass("wpglobus-dialog-field-source hidden"),e=r.attr("name"),a(t).attr("id","wpglobus-"+o),a(t).attr("name","wpglobus-"+e),a(t).attr("data-source-id",o),a(t).attr("class","wpglobus-dialog-field"),a(t).val(WPGlobusCore.TextFilter(a(r).val(),WPGlobusCoreData.language)),a(t).insertAfter(r),n=(n=i.replace(/{{id}}/g,o)).replace(/{{meta-key}}/g,s),void 0===WPGlobusAdmin.data.post_meta_settings[WPGlobusAdmin.data.post_type]?n=n.replace(/{{checked}}/,"checked"):void 0!==WPGlobusAdmin.data.post_meta_settings[WPGlobusAdmin.data.post_type][s]&&"false"==WPGlobusAdmin.data.post_meta_settings[WPGlobusAdmin.data.post_type][s]?(n=n.replace(/{{checked}}/,""),c=l+" wpglobus_dialog_start_hidden"):(n=n.replace(/{{checked}}/,"checked"),c=l),d.append('<td style="width:20px;"><div id="wpglobus-dialog-start-'+o+'" data-type="control" data-source-type="textarea" data-source-id="'+o+'" class="'+c+'"></div>'+n+"</td>")}),!e&&a("#list-table .wpglobus_dialog_start").length>0&&(a("#list-table thead tr").append('<th class="wpglobus-control-head"><div class="wpglobus_dialog_settings wpglobus_dialog_icon"></div></th>'),e=!0)};o(),a("body").on("change",".wpglobus-dialog-field",function(){var t,e=a(this),o="#"+e.data("source-id"),n="",i="";void 0!==o&&(n=a(o).val(),/(\{:|\[:|<!--:)[a-z]{2}/.test(n)?(a.each(WPGlobusCoreData.enabled_languages,function(a,o){""!=(t=o==WPGlobusCoreData.language?e.val():WPGlobusCore.TextFilter(n,o,"RETURN_EMPTY"))&&(i+=WPGlobusCore.addLocaleMarks(t,o))}),a(o).val(i)):a(o).val(e.val()))}),a(document).ajaxSend(function(a,e,o){"add-meta"==o.action&&(t=o.element)}),a(document).ajaxComplete(function(e,n,i){"add-meta"==i.action&&void 0!==n.responseXML&&o("newmeta"==t?"meta-"+a(n.responseXML.documentElement.outerHTML).find("meta").attr("id"):t)}),WPGlobusDialogApp.init({dialogTitle:"Edit meta"})}}},new t.App,t);var t,a});
includes/js/wpglobus-admin-debug.js ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * WPGlobus Admin Debug.
3
+ * Interface JS functions
4
+ *
5
+ * @since 1.8.1
6
+ *
7
+ * @package WPGlobus
8
+ * @subpackage Debug
9
+ */
10
+ /*jslint browser: true*/
11
+ /*global jQuery, console*/
12
+ (function($) {
13
+ "use strict";
14
+
15
+ if ( 'undefined' === typeof WPGlobusAdminDebug ) {
16
+ return;
17
+ }
18
+
19
+ var api = {
20
+ init: function(args) {
21
+ setTimeout(function(){
22
+ $('<a name="debug-box"></a>').appendTo('#wpwrap');
23
+ $('#wpglobus-admin-debug-box').detach().appendTo('#wpwrap');
24
+ $('#wpglobus-admin-debug-box').css({'display':'block'});
25
+ }, 1000);
26
+
27
+ setTimeout(function(){
28
+ var h = $('#wpglobus-admin-debug-box .table1').css('height').replace('px', '') * 1;
29
+ h += 50;
30
+ $('#wpglobus-admin-debug-box .table2').css({'margin-top':h+'px'});
31
+ }, 1200);
32
+ }
33
+ };
34
+
35
+ WPGlobusAdminDebug = $.extend({}, WPGlobusAdminDebug, api);
36
+ WPGlobusAdminDebug.init();
37
+
38
+ })(jQuery);
includes/js/wpglobus-admin-debug.min.js ADDED
@@ -0,0 +1 @@
 
1
+ !function(e){"use strict";if("undefined"!=typeof WPGlobusAdminDebug){var u={init:function(u){setTimeout(function(){e('<a name="debug-box"></a>').appendTo("#wpwrap"),e("#wpglobus-admin-debug-box").detach().appendTo("#wpwrap"),e("#wpglobus-admin-debug-box").css({display:"block"})},1e3),setTimeout(function(){var u=1*e("#wpglobus-admin-debug-box .table1").css("height").replace("px","");u+=50,e("#wpglobus-admin-debug-box .table2").css({"margin-top":u+"px"})},1200)}};WPGlobusAdminDebug=e.extend({},WPGlobusAdminDebug,u),WPGlobusAdminDebug.init()}}(jQuery);
includes/js/wpglobus-admin.js ADDED
@@ -0,0 +1,1601 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * WPGlobus Administration Core, Dialog, Admin
3
+ * Interface JS functions
4
+ *
5
+ * @since 1.0.0
6
+ *
7
+ * @package WPGlobus
8
+ * @subpackage Administration
9
+ */
10
+ /*jslint browser: true*/
11
+ /*global jQuery, console, WPGlobusCore, WPGlobusDialogApp, WPGlobusAdmin, inlineEditPost */
12
+
13
+ var WPGlobusCore;
14
+
15
+ (function($) {
16
+ var api;
17
+ api = WPGlobusCore = {
18
+ strpos: function( haystack, needle, offset){
19
+ haystack = "" + haystack;
20
+ var i = haystack.indexOf( needle, offset );
21
+ return i >= 0 ? i : false;
22
+ },
23
+
24
+ TextFilter: function(text, language, return_in){
25
+ if ( typeof text == 'undefined' || '' === text ) { return text; }
26
+
27
+ var pos_start, pos_end, possible_delimiters = [], is_local_text_found = false;;
28
+
29
+ language = '' == language ? 'en' : language;
30
+ return_in = typeof return_in == 'undefined' || '' == return_in ? 'RETURN_IN_DEFAULT_LANGUAGE' : return_in;
31
+
32
+ possible_delimiters[0] = [];
33
+ possible_delimiters[0]['start'] = WPGlobusCoreData.locale_tag_start.replace('%s', language);
34
+ possible_delimiters[0]['end'] = WPGlobusCoreData.locale_tag_end;
35
+
36
+ possible_delimiters[1] = [];
37
+ possible_delimiters[1]['start'] = '<!--:'+language+'-->';
38
+ possible_delimiters[1]['end'] = '<!--:-->';
39
+
40
+ possible_delimiters[2] = [];
41
+ possible_delimiters[2]['start'] = '[:'+language+']';
42
+ possible_delimiters[2]['end'] = '[:';
43
+
44
+
45
+
46
+ for (var i = 0; i < 3; i++) {
47
+
48
+ pos_start = api.strpos( text, possible_delimiters[i]['start'] );
49
+ if ( pos_start === false ) {
50
+ continue;
51
+ }
52
+
53
+ pos_start = pos_start + possible_delimiters[i]['start'].length;
54
+
55
+ pos_end = api.strpos( text, possible_delimiters[i]['end'], pos_start );
56
+
57
+ if ( pos_end === false ) {
58
+ text = text.substr( pos_start );
59
+ } else {
60
+ text = text.substr( pos_start, pos_end - pos_start );
61
+ }
62
+
63
+ is_local_text_found = true;
64
+ break;
65
+
66
+ }
67
+
68
+ if ( ! is_local_text_found ) {
69
+ if ( return_in == 'RETURN_EMPTY' ) {
70
+ if ( language == WPGlobusCoreData.default_language && ! /(\{:|\[:|<!--:)[a-z]{2}/.test(text) ) {
71
+ //
72
+ } else {
73
+ text = '';
74
+ }
75
+ } else {
76
+ // Try RETURN_IN_DEFAULT_LANGUAGE
77
+ if ( language == WPGlobusCoreData.default_language ) {
78
+ if ( /(\{:|\[:|<!--:)[a-z]{2}/.test(text) ) {
79
+ text = '';
80
+ }
81
+ } else {
82
+ text = api.TextFilter( text, WPGlobusCoreData.default_language );
83
+ }
84
+ }
85
+ }
86
+ return text;
87
+ },
88
+ addLocaleMarks: function(text, language) {
89
+ return WPGlobusCoreData.locale_tag_start.replace('%s', language) + text + WPGlobusCoreData.locale_tag_end;
90
+ },
91
+ getTranslations: function(text) {
92
+ var t = {},
93
+ return_in;
94
+ $.each(WPGlobusCoreData.enabled_languages, function(i,l){
95
+ return_in = l == WPGlobusCoreData.default_language ? 'RETURN_IN_DEFAULT_LANGUAGE' : 'RETURN_EMPTY';
96
+ t[l] = api.TextFilter(text, l, return_in);
97
+ });
98
+ return t;
99
+ },
100
+ getString: function(s, newVal, l) {
101
+ if ( 'undefined' === typeof(s) ) {
102
+ return s;
103
+ }
104
+ if ( 'undefined' === typeof(newVal) ) {
105
+ newVal = '';
106
+ }
107
+ if ( 'undefined' === typeof(l) ) {
108
+ l = WPGlobusCoreData.language;
109
+ }
110
+
111
+ s = api.getTranslations(s);
112
+ s[l] = newVal;
113
+
114
+ var cS = '';
115
+
116
+ $.each(s, function(ln,val){
117
+ if ( '' != val && ln != WPGlobusCoreData.default_language) {
118
+ cS += api.addLocaleMarks(val, ln);
119
+ }
120
+ });
121
+
122
+ if ( '' != s[WPGlobusCoreData.default_language] ) {
123
+ if ( '' == cS ) {
124
+ cS = s[WPGlobusCoreData.default_language];
125
+ } else {
126
+ cS = api.addLocaleMarks(s[WPGlobusCoreData.default_language], WPGlobusCoreData.default_language) + cS;
127
+ }
128
+ }
129
+ return cS;
130
+ }
131
+ };
132
+ })(jQuery);
133
+
134
+ var WPGlobusDialogApp;
135
+
136
+ (function($) {
137
+
138
+ var api;
139
+ api = WPGlobusDialogApp = {
140
+ option : {
141
+ listenClass : '.wpglobus_dialog_start',
142
+ settingsClass : '.wpglobus_dialog_settings',
143
+ dialogTabs: '#wpglobus-dialog-tabs',
144
+ dialogTitle: '',
145
+ customData: null,
146
+ callback: function(){}
147
+ },
148
+ form : undefined,
149
+ element : undefined,
150
+ element_by : 'id',
151
+ id : '',
152
+ clone_id: '',
153
+ wpglobus_id : '',
154
+ type : 'textarea',
155
+ source : '',
156
+ order : {},
157
+ value : {},
158
+ request : 'core',
159
+ attrs: {},
160
+ dialogTitle: '',
161
+ trClass: 'wpglobus-translatable',
162
+ startButton: [
163
+ '<span id="wpglobus-dialog-start-{{clone_id}}" ',
164
+ 'style="{{style}}" ',
165
+ 'data-type="control" data-dialog-title="{{title}}" ',
166
+ 'data-source-type="" data-source-id="{{id}}" data-source-name="{{name}}" ',
167
+ 'data-nodename="{{nodename}}"',
168
+ '{{sbTitle}} ',
169
+ 'class="{{classes}}"></span>'
170
+ ].join(''),
171
+ startButtonClass : 'wpglobus_dialog_start wpglobus_dialog_icon',
172
+ clicks: 0,
173
+ init: function(args) {
174
+ api.option = $.extend(api.option, args);
175
+ $(api.option.dialogTabs).tabs();
176
+ api.dialogTitle = api.option.dialogTitle;
177
+ this.attachListener();
178
+ if ( api.option.customData != null && typeof api.option.customData.addElements != 'undefined' ) {
179
+ $.each(api.option.customData.addElements, function(i,e) {
180
+ api.addElement(e);
181
+ });
182
+ }
183
+ },
184
+ convertToId: function(s){
185
+ s = s.replace(/\]/g,'');
186
+ s = s.replace(/\[/g,'-');
187
+ return s;
188
+ },
189
+ addElement: function(elem) {
190
+ var option = {
191
+ id: null,
192
+ dialogTitle: '',
193
+ style: '',
194
+ styleTextareaWrapper: '',
195
+ sbTitle: '',
196
+ onChangeClass: ''
197
+ }
198
+ if ( 'string' == typeof(elem) ) {
199
+ option.id = elem;
200
+ } else if ( 'object' == typeof(elem) ) {
201
+ option = $.extend(option, elem);
202
+ } else {
203
+ return;
204
+ }
205
+
206
+ var $element = null, id = null, name = null, node = null,
207
+ sb = api.startButton,
208
+ clone, v, style, nodeName = '';
209
+
210
+ api.element_by = 'id';
211
+
212
+ node = document.getElementById(option.id);
213
+ if ( null === node ) {
214
+ api.element_by = 'name';
215
+ node = document.getElementsByName(option.id);
216
+ } else {
217
+ nodeName = node.nodeName;
218
+ nodeName = nodeName.toLowerCase();
219
+ }
220
+ if ( 0 == node.length ) {
221
+ return;
222
+ } else {
223
+ id = option.id;
224
+ if ( 'id' == api.element_by ) {
225
+ $element = $('#'+id);
226
+ } else {
227
+ nodeName = node[0].nodeName;
228
+ nodeName = nodeName.toLowerCase();
229
+ $element = $(nodeName+'[name="'+id+'"]');
230
+ }
231
+ }
232
+
233
+ if ( 'undefined' === $element.attr('name') ) {
234
+ name = id;
235
+ } else {
236
+ name = $element.attr('name');
237
+ }
238
+ api.clone_id = api.convertToId(id);
239
+
240
+ if ( -1 != name.indexOf( 'wpglobus' ) || -1 != api.clone_id.indexOf( 'wpglobus' ) ) {
241
+ /* prevent add element to itself */
242
+ return;
243
+ }
244
+
245
+ if ( $( '#wpglobus-'+api.clone_id ).length > 0 ) {
246
+ // WPGlobus element exists already
247
+ return;
248
+ }
249
+ if ( $( nodeName+'[name="wpglobus-'+name+'"]' ).length > 0 ) {
250
+ // WPGlobus element exists already
251
+ return;
252
+ }
253
+
254
+ clone = $( $element.clone() );
255
+ //$element.addClass('hidden');
256
+ style = $element.attr('style') || '';
257
+ $element.attr( 'style', 'display:none;' );
258
+ clone.attr( 'id', 'wpglobus-'+api.clone_id ).attr( 'name', 'wpglobus-'+name );
259
+
260
+ /**
261
+ * add WPGlobus translatable class
262
+ */
263
+ clone.addClass( api.trClass );
264
+
265
+ if ( option.onChangeClass != '' ) {
266
+ /**
267
+ * add class to bind 'change' event
268
+ */
269
+ clone.addClass( option.onChangeClass );
270
+ }
271
+
272
+ if ( 'id' == api.element_by ) {
273
+ clone.attr('data-source-id', id).attr('data-source-name', '').attr('data-source-get-by',api.element_by);
274
+ } else {
275
+ clone.attr('data-source-id', '').attr('data-source-name', name).attr('data-source-get-by',api.element_by);
276
+ }
277
+
278
+ if ( 'textarea' == nodeName ) {
279
+ v = WPGlobusCore.getTranslations( $element.text() )[WPGlobusCoreData['language']];
280
+ clone.text( v );
281
+ clone.attr( 'data-nodename', 'textarea' );
282
+ if ( '' == option.style ) {
283
+ clone.attr( 'style', style + ';width:95%;float:left;' );
284
+ } else {
285
+ clone.attr( 'style', style + ';' + option.style );
286
+ }
287
+ } else {
288
+ v = WPGlobusCore.getTranslations( $element.val() )[WPGlobusCoreData['language']];
289
+ clone.attr( 'value', v );
290
+ clone.attr( 'data-nodename', 'input' );
291
+ if ( '' != option.style ) {
292
+ clone.attr( 'style', style + ';' + option.style );
293
+ }
294
+ }
295
+
296
+ sb = sb.replace(/{{clone_id}}/g, api.clone_id);
297
+ if ( 'id' == api.element_by ) {
298
+ sb = sb.replace(/{{id}}/g, api.clone_id);
299
+ sb = sb.replace(/{{name}}/g, '');
300
+ sb = sb.replace(/{{nodename}}/g, '');
301
+ } else {
302
+ sb = sb.replace(/{{id}}/g, '');
303
+ sb = sb.replace(/{{name}}/g, name);
304
+ sb = sb.replace(/{{nodename}}/g, nodeName);
305
+ }
306
+ sb = 'textarea' == nodeName ? sb.replace( '{{style}}', 'float:left;margin-top:0;' ) : sb.replace( '{{style}}', '' );
307
+ var startButtonClasses = 'textarea' == nodeName ? api.startButtonClass + ' wpglobus-textarea wpglobus-textarea-'+api.clone_id : api.startButtonClass;
308
+ sb = sb.replace( '{{classes}}', startButtonClasses );
309
+ sb = option.dialogTitle == '' ? sb.replace('{{title}}', api.dialogTitle) : sb.replace('{{title}}', option.dialogTitle);
310
+ sb = option.sbTitle == '' ? sb.replace('{{sbTitle}}', option.sbTitle) : sb.replace('{{sbTitle}}', 'title="'+option.sbTitle+'"');
311
+
312
+ $(sb).insertAfter($element);
313
+ $(clone).insertAfter($element);
314
+
315
+ if ( 'textarea' == nodeName ) {
316
+ $('#wpglobus-'+api.clone_id).addClass( 'wpglobus-textarea-'+api.clone_id );
317
+ $('.wpglobus-textarea-'+api.clone_id).wrapAll( '<div class="wpglobus-textarea-wrapper" style="'+option.styleTextareaWrapper+'"></div>' );
318
+ }
319
+
320
+ /**
321
+ * Bind change event
322
+ */
323
+ var selector, ret = false;
324
+ if ( option.onChangeClass == '' ) {
325
+ selector = '#wpglobus-' + api.clone_id;
326
+ } else {
327
+ selector = '.' + option.onChangeClass;
328
+ var $events = $._data( $( document )[0], 'events' );
329
+ if( typeof $events === 'undefined' ){
330
+ ret = true;
331
+ } else {
332
+ if ( typeof $events.change !== 'undefined' ) {
333
+ $.each( $events.change, function(i, ev){
334
+ if ( ev.selector == selector ) {
335
+ ret = true;
336
+ return false;
337
+ }
338
+ });
339
+ }
340
+ }
341
+ }
342
+
343
+ if ( ret ) {
344
+ /**
345
+ * Return because we had bound 'change' event already
346
+ */
347
+ return;
348
+ }
349
+
350
+ $( document ).on( 'change', selector, function() {
351
+ var $t = $(this),
352
+ sid = $t.data( 'source-id' );
353
+
354
+ if ( '' == sid ) {
355
+ sid = $t.data( 'nodename' ) + '[name="' + $t.data( 'source-name' ) + '"]';
356
+ } else {
357
+ sid = '#' + sid;
358
+ }
359
+ $(sid).val( WPGlobusCore.getString( $(sid).val(), $t.val() ) );
360
+ });
361
+ },
362
+ saveDialog: function() {
363
+ var s = '', sdl = '', scl = '', $e, val, l;
364
+ $('.wpglobus_dialog_textarea').each(function(indx,e){
365
+ $e = $(e);
366
+ val = $e.val();
367
+ l = $e.data('language');
368
+ if ( l == WPGlobusAdmin.data.language ) {
369
+ scl = val;
370
+ }
371
+ if ( val != '' ) {
372
+ s = s + WPGlobusCore.addLocaleMarks(val,l);
373
+ if ( l == WPGlobusCoreData.default_language ) {
374
+ sdl = val;
375
+ }
376
+ }
377
+ });
378
+ s = s.length == sdl.length + 8 ? sdl : s;
379
+ $(api.id).val(s);
380
+ s = scl == '' ? sdl : scl;
381
+ $(api.wpglobus_id).val(s);
382
+ },
383
+ dialog : $('#wpglobus-dialog-wrapper').dialog({
384
+ autoOpen: false,
385
+ //height: 250,
386
+ width: 650,
387
+ modal: true,
388
+ dialogClass: 'wpglobus-dialog',
389
+ buttons: [
390
+ {
391
+ text:'Save',
392
+ class: 'wpglobus-button-save',
393
+ click:function(){api.saveDialog(); api.dialog.dialog('close');}
394
+ },
395
+ {
396
+ text:'Cancel',
397
+ class: 'wpglobus-button-cancel',
398
+ click: function(){api.dialog.dialog('close');}
399
+ }
400
+ ],
401
+ open: function() {
402
+ var title = api.dialogTitle;
403
+ if ( typeof api.attrs.maxlength !== 'undefined' ) {
404
+ $('.wpglobus_dialog_textarea').attr('maxlength', api.attrs.maxlength);
405
+ title += ' | maxlength='+api.attrs.maxlength;
406
+ }
407
+ $('.wpglobus-dialog .ui-dialog-title').text(title);
408
+ },
409
+ close: function() {
410
+ api.form[0].reset();
411
+ //allFields.removeClass( "ui-state-error" );
412
+ }
413
+ }),
414
+ attachListener : function() {
415
+ $(document).on('click', api.option.settingsClass, function() {
416
+ if ( $('.wpglobus_dialog_options_wrapper').hasClass('hidden') ) {
417
+ $('.wpglobus_dialog_options_wrapper').removeClass('hidden');
418
+ } else {
419
+ $('.wpglobus_dialog_options_wrapper').addClass('hidden');
420
+ }
421
+ });
422
+ $(document).on('click', '.wpglobus_dialog_option', function(event) {
423
+ var $t = $(this), r;
424
+ var ob = $t.data('object');
425
+ api.order['action'] = 'save_post_meta_settings';
426
+ api.order['post_type'] = WPGlobusAdmin.data.post_type;
427
+ api.order['checked'] = $t.prop('checked');
428
+ api.order['id'] = $t.attr('id');
429
+ api.order['meta_key'] = $t.data('meta-key');
430
+ r = api.ajax(api.order);
431
+ r.done(function (result) {
432
+ if ( result.result == 'ok' ) {
433
+ if ( result.checked == 'true' ) {
434
+ $(ob).removeClass('wpglobus_dialog_start_hidden');
435
+ } else {
436
+ $(ob).addClass('wpglobus_dialog_start_hidden');
437
+ }
438
+ }
439
+ })
440
+ .fail(function (error) {})
441
+ .always(function (jqXHR, status){});
442
+ });
443
+ $(document).on('click', api.option.listenClass, function(e) {
444
+ api.element = $(this);
445
+ api.id = api.element.data('source-id');
446
+ if ( '' == api.id ) {
447
+ api.id = api.element.data('nodename') + '[name="'+api.element.data('source-name')+'"]';
448
+ api.wpglobus_id = '#wpglobus-'+api.convertToId( api.element.data('source-name') );
449
+ } else {
450
+ api.wpglobus_id = '#wpglobus-'+api.id;
451
+ api.id = '#'+api.id;
452
+ }
453
+
454
+ api.clicks++;
455
+ if ( api.clicks == 1 ) {
456
+ setTimeout(function () {
457
+ if (api.clicks == 1) {
458
+ api.onClick(e);
459
+ } else {
460
+ var s = $(api.id);
461
+ if ( s.hasClass('hidden') ) {
462
+ s.removeClass('hidden').attr('style', 'display:block;');
463
+ } else {
464
+ s.addClass('hidden').attr('style', 'display:none;');
465
+ }
466
+ }
467
+ api.clicks = 0;
468
+ }, 200);
469
+ }
470
+ });
471
+ api.form = api.dialog.find('form#wpglobus-dialog-form').on('submit', function( event ) {
472
+ event.preventDefault();
473
+ api.saveDialog();
474
+ });
475
+ },
476
+ ajax : function(order) {
477
+ return $.ajax({type:'POST', url:WPGlobusAdmin.ajaxurl, data:{action:WPGlobusAdmin.process_ajax, order:order}, dataType:'json', async:false});
478
+ },
479
+ onClick: function(ev) {
480
+ if ( typeof(api.element.data('dialog-title')) == 'undefined' || '' == api.element.data('dialog-title') ) {
481
+ api.dialogTitle = api.option.dialogTitle;
482
+ } else {
483
+ api.dialogTitle = api.element.data('dialog-title');
484
+ }
485
+ if ( typeof api.id !== 'undefined' ) {
486
+ api.attrs['maxlength'] = $(api.id).attr('maxlength');
487
+ }
488
+
489
+ api.source = api.element.data('source-value');
490
+ if ( typeof api.source === 'undefined' ) {
491
+ api.source = $(api.id).val();
492
+ if (api.request == 'ajax') {
493
+ // @todo revise ajax action
494
+ //api.order['action'] = 'get_translate';
495
+ //api.order['source'] = api.source;
496
+ //api.ajax(api.order);
497
+ } else {
498
+ api.value = WPGlobusCore.getTranslations(api.source);
499
+ }
500
+ }
501
+ $.each(api.value, function(l,e){
502
+ $('#wpglobus-dialog-'+l).val(e);
503
+ });
504
+ api.dialog.dialog('open');
505
+ }
506
+ };
507
+
508
+ })(jQuery);
509
+
510
+ jQuery(document).ready(function () {
511
+ "use strict";
512
+ window.WPGlobusAdminApp = (function (WPGlobusAdminApp, $) {
513
+ /* Object Constructor
514
+ ========================*/
515
+ WPGlobusAdminApp.App = function (config) {
516
+
517
+ if (window.WPGlobusAdminApp !== undefined) {
518
+ return;
519
+ }
520
+
521
+ this.config = {
522
+ debug: false,
523
+ version: WPGlobusAdmin.version
524
+ };
525
+
526
+ this.status = 'ok';
527
+
528
+ if ('undefined' === WPGlobusAdmin) {
529
+ this.status = 'error';
530
+ if (this.config.debug) {
531
+ console.log('Error options loading');
532
+ }
533
+ } else {
534
+ if (this.config.debug) {
535
+ console.dir(WPGlobusAdmin);
536
+ }
537
+ }
538
+
539
+ this.config.disable_first_language = [
540
+ '<div id="disable_first_language" style="display:block;" class="redux-field-errors notice-red">',
541
+ '<strong>',
542
+ '<span>&nbsp;</span>',
543
+ WPGlobusAdmin.i18n.cannot_disable_language,
544
+ '</strong>',
545
+ '</div>'
546
+ ].join('');
547
+
548
+ $.extend(this.config, config);
549
+
550
+ if ('ok' === this.status) {
551
+ this.init();
552
+ }
553
+ };
554
+
555
+ WPGlobusAdminApp.App.prototype = {
556
+ $document : $(document),
557
+ init: function () {
558
+ WPGlobusCoreData.multisite = this.parseBool(WPGlobusCoreData.multisite);
559
+ this.admin_init();
560
+ $('#content').addClass('wpglobus-editor').attr('data-language',WPGlobusAdmin.data.default_language);
561
+ $('textarea[id^=content_]').each(function(i,e){
562
+ var l=$(e).attr('id').replace('content_','');
563
+ $(e).attr('data-language',l);
564
+ });
565
+ if ('post.php' === WPGlobusAdmin.page) {
566
+ this.post_edit();
567
+ this.set_dialog();
568
+ if ( typeof WPGlobusAioseop != 'undefined' ) {
569
+ WPGlobusAioseop.init();
570
+ }
571
+ } else if ('menu-edit' === WPGlobusAdmin.page) {
572
+ this.nav_menus();
573
+ } else if ('taxonomy-edit' === WPGlobusAdmin.page) {
574
+ if (WPGlobusAdmin.data.tag_id) {
575
+ this.taxonomy_edit();
576
+ }
577
+ } else if ('taxonomy-quick-edit' === WPGlobusAdmin.page) {
578
+ this.quickEdit('taxonomy');
579
+ } else if ('edit.php' === WPGlobusAdmin.page) {
580
+ this.quickEdit('post');
581
+ } else if ('options-general.php' == WPGlobusAdmin.page) {
582
+ this.options_general();
583
+ } else if ('widgets.php' == WPGlobusAdmin.page) {
584
+ WPGlobusWidgets.init();
585
+ WPGlobusDialogApp.init({dialogTitle:'Edit text'});
586
+ } else if ('wpglobus_options' == WPGlobusAdmin.page) {
587
+ this.start();
588
+ } else if ('wpglobusAdminCentral' == WPGlobusAdmin.page) {
589
+ this.adminCentral();
590
+ } else {
591
+ // init WPGlobusDialogApp for using in a 3-party plugins
592
+ WPGlobusDialogApp.init({customData:WPGlobusCoreData.page_custom_data});
593
+ }
594
+ },
595
+ parseBool: function(b) {
596
+ return !(/^(false|0)$/i).test(b) && !!b;
597
+ },
598
+ getCurrentTab: function() {
599
+ return $( '.wpglobus-post-body-tabs-list .ui-tabs-active' ).data( 'language' );
600
+ },
601
+ admin_init: function () {
602
+ var order = $('.wpglobus-addons-group a').data('key');
603
+ if ( 'undefined' !== typeof order ) {
604
+ if ( window.location.search.indexOf('page=wpglobus_options&tab='+order) >= 0 ) {
605
+ if ( WPGlobusCoreData.multisite ) {
606
+ window.location = WPGlobusCoreData.pluginInstallLocation.multisite;
607
+ } else {
608
+ window.location = WPGlobusCoreData.pluginInstallLocation.single;
609
+ }
610
+ /**
611
+ * obsolete from 1.5.9
612
+ * @todo remove after testing @see class WPGlobus_Plugin_Install
613
+ */
614
+ //window.location = 'admin.php?page=wpglobus-addons';
615
+ } else {
616
+ var addon = $('#toplevel_page_wpglobus_options li').eq(order+1);
617
+ if ( WPGlobusCoreData.multisite ) {
618
+ $(addon).find('a').attr('href',WPGlobusCoreData.pluginInstallLocation.multisite).attr('onclick',"window.location=jQuery(this).attr('href');return false;");
619
+ } else {
620
+ $(addon).find('a').attr('href',WPGlobusCoreData.pluginInstallLocation.single).attr('onclick',"window.location=jQuery(this).attr('href');return false;");
621
+ }
622
+ /**
623
+ * obsolete from 1.5.9
624
+ * @todo remove after testing @see class WPGlobus_Plugin_Install
625
+ */
626
+ //$(addon).find('a').attr('href','admin.php?page=wpglobus-addons').attr('onclick',"window.location=jQuery(this).attr('href');return false;");
627
+ }
628
+ }
629
+ },
630
+ options_general: function () {
631
+ var $bn = $('#blogname'),
632
+ $body = $('body');
633
+
634
+ $bn.addClass('hidden');
635
+ $('#wpglobus-blogname').insertAfter($bn).removeClass('hidden');
636
+
637
+ $body.on('blur', '.wpglobus-blogname', function () {
638
+ $('.wpglobus-blogname').each( function (i, e) {
639
+ var $e = $(e);
640
+ $bn.val( WPGlobusCore.getString( $bn.val(), $e.val(), $e.data('language') ) );
641
+ });
642
+ });
643
+
644
+ var $bd = $('#blogdescription');
645
+ $bd.addClass('hidden');
646
+ $('#wpglobus-blogdescription').insertAfter($bd).removeClass('hidden');
647
+ $body.on('blur', '.wpglobus-blogdesc', function () {
648
+ $('.wpglobus-blogdesc').each( function (i, e) {
649
+ var $e = $(e);
650
+ $bd.val( WPGlobusCore.getString( $bd.val(), $e.val(), $e.data('language') ) );
651
+ });
652
+ });
653
+ },
654
+ quickEdit: function (type) {
655
+
656
+ /**
657
+ * For more info @see ajax handler 'wp_ajax_inline_save'
658
+ */
659
+ if (typeof WPGlobusAdmin.data.has_items === 'undefined') {
660
+ return;
661
+ }
662
+ if (!WPGlobusAdmin.data.has_items) {
663
+ return;
664
+ }
665
+ var full_id = '', id = 0;
666
+
667
+ $(document).ajaxComplete(function(event, jqxhr, settings){
668
+ if (typeof settings.data === 'undefined') {
669
+ return;
670
+ }
671
+ if ( full_id == '' ) {
672
+ return;
673
+ }
674
+ if (settings.data.indexOf('action=inline-save-tax&') >= 0) {
675
+ $('#'+full_id+' a.row-title').text(WPGlobusAdmin.qedit_titles[id][WPGlobusAdmin.data.language]['name']);
676
+ $('#'+full_id+' .description').text(WPGlobusAdmin.qedit_titles[id][WPGlobusAdmin.data.language]['description']);
677
+ }
678
+ });
679
+
680
+ var title = {};
681
+ $('#the-list tr').each(function (i, e) {
682
+ var $e = $(e);
683
+ var k = ( type === 'post' ? 'post-' : 'tag-' );
684
+ id = $e.attr('id').replace(k, ''); /* don't need var with id, see line 109 */
685
+ title[id] = {};
686
+ if ('post' === type) {
687
+ title[id]['source'] = $e.find('.post_title').text();
688
+ } else if ('taxonomy' === type) {
689
+ title[id]['source'] = $('#inline_' + id + ' .name').text();
690
+ }
691
+ });
692
+
693
+ var order = {};
694
+ order['action'] = 'get_titles';
695
+ order['type'] = type;
696
+ order['taxonomy'] = typeof WPGlobusAdmin.data.taxonomy === 'undefined' ? false : WPGlobusAdmin.data.taxonomy;
697
+ order['title'] = title;
698
+ $.ajax({type:'POST', url:WPGlobusAdmin.ajaxurl, data:{action:WPGlobusAdmin.process_ajax, order:order}, dataType:'json'})
699
+ .done(function (result) {
700
+ WPGlobusAdmin.qedit_titles = result.qedit_titles;
701
+ $.each(result.bulkedit_post_titles, function(id, obj){
702
+ $('#inline_'+id+' .post_title').text(obj[WPGlobusAdmin.data.language]['name']);
703
+ });
704
+ })
705
+ .fail(function (error) {
706
+ })
707
+ .always(function (jqXHR, status) {
708
+ });
709
+
710
+ $('body').on('change', '.wpglobus-quick-edit-title', function () {
711
+ var s = '';
712
+ var lang = [];
713
+ $('.wpglobus-quick-edit-title').each(function (index, e) {
714
+ var $e = $(e);
715
+ var l = $e.data('language');
716
+ if ($e.val() !== '') {
717
+ s = WPGlobusCore.getString( s, $e.val(), l );
718
+ }
719
+ WPGlobusAdmin.qedit_titles[ id ][ l ][ 'name' ] = $e.val();
720
+ lang[ index ] = l;
721
+ });
722
+
723
+ var so = $(document).triggerHandler( 'wpglobus_get_translations', {string:s, lang:lang, id:id} );
724
+ if ( typeof so !== 'undefined' ) {
725
+ s = so;
726
+ }
727
+ // $( 'input.ptitle' ).eq( 0 ).val( s ); // @todo remove after test
728
+ $( 'input.ptitle' ).eq( 0 ).attr( 'value', s ) ;
729
+ WPGlobusAdmin.qedit_titles[ id ][ 'source' ] = s;
730
+ });
731
+
732
+ if ( typeof WPGlobusAdmin.data.tags !== 'undefined' ) {
733
+ $.each( WPGlobusAdmin.data.tags, function(i,tag){
734
+ WPGlobusAdmin.data.value[tag]['post_id'] = {};
735
+ });
736
+ }
737
+
738
+ $('button.save, input#bulk_edit').on('mouseenter', function (event) {
739
+ /**
740
+ * Quick edit action for the "Tags" box in edit.php page.
741
+ */
742
+ if ( typeof WPGlobusAdmin.data.tags === 'undefined' ) {
743
+ return;
744
+ }
745
+
746
+ if (event.currentTarget.id=='bulk_edit') {
747
+ $('input#bulk_edit').unbind('click');
748
+ } else {
749
+ $('button.save').unbind('click');
750
+ }
751
+
752
+ $( 'button.save, input#bulk_edit').on('click', function (event) {
753
+ console.log( 'Start Updating' );
754
+ var promise = $.when();
755
+
756
+ var tagsHandler = function( $elem ) {
757
+ $elem.next('.spinner').css({'visibility':'visible'});
758
+ if (event.currentTarget.id != 'bulk_edit') {
759
+ $.ajaxSetup({async:false});
760
+ }
761
+ var p = $elem.parents('tr');
762
+ var id = p.attr('id').replace('edit-','');
763
+ var t,v,newTags;
764
+
765
+ $.each( WPGlobusAdmin.data.tags, function(index,tag){
766
+ t = p.find("textarea[name='" + WPGlobusAdmin.data.names[tag] + "']");
767
+ if ( t.length == 0 ) {
768
+ return true;
769
+ }
770
+ WPGlobusAdmin.data.value[tag]['post_id'][id] = t.val();
771
+ v = WPGlobusAdmin.data.value[tag]['post_id'][id].split(',');
772
+ newTags = [];
773
+ for(var i=0; i<v.length; i++) {
774
+ v[i] = v[i].trim(' ');
775
+ if ( v[i] != '' ) {
776
+ if ( typeof WPGlobusAdmin.data.tag[tag][v[i]] === 'undefined' ) {
777
+ newTags[i] = v[i];
778
+ } else {
779
+ newTags[i] = WPGlobusAdmin.data.tag[tag][v[i]];
780
+ }
781
+ }
782
+ }
783
+ t.val( newTags.join(', ') );
784
+ });
785
+ }
786
+
787
+ var $this = $(this);
788
+ var start = $.Deferred();
789
+ start.resolve( tagsHandler( $(this) ) );
790
+
791
+ promise = promise.then(function() {
792
+ return $.when(
793
+ start.done()
794
+ )
795
+ }).then( function() {
796
+ if (event.currentTarget.id != 'bulk_edit') {
797
+ setTimeout(
798
+ function() {
799
+ inlineEditPost.save(id);
800
+ $.ajaxSetup({async:true});
801
+ },
802
+ 50
803
+ );
804
+ }
805
+ });
806
+
807
+ });
808
+ });
809
+
810
+ $( '#the-list' ).on( 'click', 'a.editinline', function () {
811
+ var t = $(this);
812
+ full_id = t.parents('tr').attr('id');
813
+ if ('post' === type) {
814
+ id = full_id.replace('post-', '');
815
+ } else if ('taxonomy' === type) {
816
+ id = full_id.replace('tag-', '');
817
+ } else {
818
+ return;
819
+ }
820
+
821
+ if ( 'post' === type && 'undefined' !== typeof WPGlobusAdmin.data.tags ) {
822
+ /**
823
+ * @since 1.6.6
824
+ */
825
+ $.each( WPGlobusAdmin.data.tags, function(i,tag){
826
+ if ( WPGlobusAdmin.data.value[tag] != '' ) {
827
+ var val = $('#edit-' + id + ' textarea[name="' + WPGlobusAdmin.data.names[tag] + '"]').val(),
828
+ currentTags;
829
+ if ( 'undefined' !== typeof val ) {
830
+ currentTags = val.split(',');
831
+ $.each( currentTags, function(order,currentTag) {
832
+ val = val.replace(currentTag, WPGlobusCore.TextFilter(currentTag, WPGlobusCoreData.language));
833
+ });
834
+ $('#edit-' + id + ' textarea[name="' + WPGlobusAdmin.data.names[tag] + '"]').val(val);
835
+ }
836
+ }
837
+ });
838
+ }
839
+
840
+ var e = $('#edit-' + id + ' input.ptitle').eq(0);
841
+ var p = e.parents('label');
842
+ e.val(WPGlobusAdmin.qedit_titles[id].source);
843
+ e.addClass('hidden');
844
+ $(WPGlobusAdmin.data.template).insertAfter(p);
845
+
846
+ if ( typeof WPGlobusAdmin.qedit_titles[id] === 'undefined' ) {
847
+ WPGlobusAdmin.qedit_titles[id] = {};
848
+ WPGlobusAdmin.qedit_titles[id]['source'] = $('#'+full_id+' .name a.row-title').text();
849
+ $(WPGlobusAdmin.data.enabled_languages).each(function(i,l){
850
+ WPGlobusAdmin.qedit_titles[id][l] = {};
851
+ if ( l == WPGlobusAdmin.data.default_language ) {
852
+ WPGlobusAdmin.qedit_titles[id][l]['name'] = WPGlobusAdmin.qedit_titles[id]['source'];
853
+ } else {
854
+ WPGlobusAdmin.qedit_titles[id][l]['name'] = '';
855
+ }
856
+ WPGlobusAdmin.qedit_titles[id][l]['description'] = '';
857
+ });
858
+ }
859
+
860
+ $( '.wpglobus-quick-edit-title' ).each(function ( i, e ) {
861
+ var $e = $(e);
862
+ var l = $e.data( 'language' );
863
+ $e.attr( 'id', l + id );
864
+ if ( typeof WPGlobusAdmin.qedit_titles[id][l] !== 'undefined' ) {
865
+ WPGlobusAdmin.qedit_titles[id][l]['name'] = WPGlobusAdmin.qedit_titles[id][l]['name'].replace( /\\\'/g, "'" );
866
+ WPGlobusAdmin.qedit_titles[id][l]['name'] = WPGlobusAdmin.qedit_titles[id][l]['name'].replace( /\\\"/g, '"' );
867
+ $e.attr( 'value', WPGlobusAdmin.qedit_titles[id][l]['name'] );
868
+ WPGlobusAdmin.qedit_titles[id]['source'] =
869
+ WPGlobusCore.getString(
870
+ WPGlobusAdmin.qedit_titles[id]['source'],
871
+ WPGlobusAdmin.qedit_titles[id][l]['name'],
872
+ l
873
+ );
874
+ }
875
+ });
876
+ // $( 'input.ptitle' ).eq( 0 ).val( WPGlobusAdmin.qedit_titles[ id ][ 'source' ] ); // @todo remove after test
877
+ $( 'input.ptitle' ).eq( 0 ).attr( 'value', WPGlobusAdmin.qedit_titles[ id ][ 'source' ] );
878
+ });
879
+
880
+ },
881
+ taxonomy_edit: function () {
882
+
883
+ var elements = [];
884
+ elements[0] = 'name';
885
+ elements[1] = 'description';
886
+
887
+ var make_clone = function(id,language){
888
+ var $element = $('#'+id),
889
+ clone = $element.clone(),
890
+ name = $element.attr('name'),
891
+ classes = 'wpglobus-element wpglobus-element_'+id+' wpglobus-element_'+language+' wpglobus-translatable',
892
+ node;
893
+
894
+ node = document.getElementById(id);
895
+ node = node.nodeName;
896
+ $(clone).attr('id', id+'_'+language);
897
+ $(clone).attr('name', name+'_'+language);
898
+ if ( language !== WPGlobusCoreData.default_language ) {
899
+ classes += ' hidden';
900
+ }
901
+ $(clone).attr('class', classes);
902
+ $(clone).attr('data-save-to', id);
903
+ $(clone).attr('data-language', language);
904
+ if ( node == 'INPUT' ) {
905
+ $(clone).attr('value', $('#wpglobus-link-tab-'+language).data(id));
906
+ } else if ( node == 'TEXTAREA' ) {
907
+ $(clone).text($('#wpglobus-link-tab-'+language).data(id));
908
+ }
909
+ $element.addClass('hidden');
910
+ if ( $('.wpglobus-element_'+id).size() == 0 ) {
911
+ $(clone).insertAfter($element);
912
+ } else {
913
+ $(clone).insertAfter($('.wpglobus-element_'+id).last());
914
+ }
915
+ };
916
+
917
+ $.each(WPGlobusCoreData.enabled_languages, function(i,l){
918
+ $.each(elements, function(i,e){
919
+ make_clone(e,l);
920
+ });
921
+ });
922
+
923
+ $('.wpglobus-taxonomy-tabs').insertAfter('#ajax-response');
924
+
925
+ // Make class wrap as tabs container
926
+ // tabs on
927
+ $('.wrap').tabs();
928
+
929
+ $('body').on('click', '.wpglobus-taxonomy-tabs li', function(event){
930
+ var $t = $(this);
931
+ var language = $t.data('language');
932
+ $('.wpglobus-element').addClass('hidden');
933
+ $('.wpglobus-element_'+language).removeClass('hidden');
934
+ });
935
+
936
+ $('.wpglobus-element').on('change', function () {
937
+ var $this = $(this),
938
+ save_to = $this.data('save-to'),
939
+ s = '';
940
+
941
+ $('.wpglobus-element').each(function (index, element) {
942
+ var $e = $(element),
943
+ value = $e.val();
944
+ if ( $e.data('save-to') == save_to && value !== '' ) {
945
+ s = s + WPGlobusCore.addLocaleMarks(value, $e.data('language') )
946
+ }
947
+ });
948
+ $('#' + save_to).val(s);
949
+ });
950
+ },
951
+ nav_menus: function () {
952
+ var iID, menu_size,
953
+ menu_item = '#menu-to-edit .menu-item';
954
+
955
+ var timer = function () {
956
+ if (menu_size !== $(menu_item).size()) {
957
+ clearInterval(iID);
958
+ $(menu_item).each(function (index, li) {
959
+ var $li = $(li);
960
+ if ($li.hasClass('wpglobus-menu-item')) {
961
+ return; // the same as continue
962
+ }
963
+ var id = $(li).attr('id');
964
+ $.each(['input.edit-menu-item-title', 'input.edit-menu-item-attr-title'], function (input_index, input) {
965
+ var i = $('#' + id + ' ' + input);
966
+ var $i = $(i);
967
+ if (!$i.hasClass('wpglobus-hidden')) {
968
+ $i.addClass('wpglobus-hidden');
969
+ $i.css('display', 'none');
970
+ var l = $i.parent('label');
971
+ var p = $i.parents('p');
972
+ $(p).css('height', '80px');
973
+ $(l).append('<div style="color:#f00;">' + WPGlobusAdmin.i18n.save_nav_menu + '</div>');
974
+ }
975
+ });
976
+ $li.addClass('wpglobus-menu-item');
977
+ });
978
+ }
979
+ };
980
+
981
+ $.ajaxSetup({
982
+ beforeSend: function (jqXHR, PlainObject) {
983
+ if (typeof PlainObject.data === 'undefined') {
984
+ return;
985
+ }
986
+ if (PlainObject.data.indexOf('action=add-menu-item') >= 0) {
987
+ menu_size = $(menu_item).size();
988
+ iID = setInterval(timer, 500);
989
+ }
990
+ }
991
+ });
992
+
993
+ $(menu_item).each(function (index, li) {
994
+
995
+ var id = $(li).attr('id'),
996
+ item_id = id.replace('menu-item-', '');
997
+
998
+ $.each(['input.edit-menu-item-title', 'input.edit-menu-item-attr-title'], function (input_index, input) {
999
+ var $i = $('#' + id + ' ' + input);
1000
+ if ( $i.val() != WPGlobusAdmin.data.items[ item_id ][ input ][ 'source' ] ) {
1001
+ /**
1002
+ * fix for case when value resets by WP core
1003
+ */
1004
+ $i.val( WPGlobusAdmin.data.items[ item_id ][ input ][ 'source' ] );
1005
+ }
1006
+
1007
+ var p = $( '#' + id + ' ' + input ).parents('p');
1008
+ var height = 0;
1009
+
1010
+ $.each(WPGlobusAdmin.data.open_languages, function (index, language) {
1011
+ var new_element = $i.clone();
1012
+ new_element.attr('id', $i.attr('id') + '-' + language);
1013
+ new_element.attr('name', $i.attr('id') + '-' + language);
1014
+ new_element.attr('data-language', language);
1015
+ new_element.attr('data-item-id', item_id);
1016
+ new_element.attr('placeholder', WPGlobusAdmin.data.en_language_name[language]);
1017
+
1018
+ var classes = WPGlobusAdmin.data.items[item_id][language][input]['class'];
1019
+ if (input_index === 0 && language === WPGlobusAdmin.data.default_language) {
1020
+ new_element.attr('class', classes + ' edit-menu-item-title');
1021
+ } else {
1022
+ new_element.attr('class', classes);
1023
+ }
1024
+
1025
+ if ( WPGlobusAdmin.data.items[ item_id ][ language ][ input ][ 'caption' ] != '' ) {
1026
+ new_element.attr('value', WPGlobusAdmin.data.items[item_id][language][input]['caption']);
1027
+ } else {
1028
+ new_element.attr('value', '');
1029
+ }
1030
+ new_element.css('margin-bottom', '0.6em');
1031
+ $(p).append( new_element );
1032
+ height = index;
1033
+ });
1034
+ height = (height + 1) * 40;
1035
+ $i.css('display', 'none').attr('class', '').addClass('widefat wpglobus-hidden');
1036
+ $(p).css('height', height + 'px').addClass('wpglobus-menu-item-box');
1037
+
1038
+ });
1039
+ $(li).addClass('wpglobus-menu-item');
1040
+ });
1041
+
1042
+ $('.menus-move-left, .menus-move-right').each(function(index,e) {
1043
+ var $e = $(e), new_title;
1044
+ var item_id = $e.parents('li').attr('id').replace('menu-item-', '');
1045
+ var title = $e.attr('title');
1046
+ if ( typeof title !== 'undefined' ) {
1047
+ $.each(WPGlobusAdmin.data.post_titles, function(post_title, item_title) {
1048
+ if ( title.indexOf(post_title) >= 0 ) {
1049
+ new_title = title.replace(post_title, item_title);
1050
+ $e.attr('title', new_title);
1051
+ $e.text(new_title);
1052
+ }
1053
+ });
1054
+ }
1055
+ });
1056
+
1057
+ // Run the item handle title when the navigation label was loaded.
1058
+ // @see wp-admin\js\nav-menu.js:537
1059
+ $('.edit-menu-item-title').trigger('change');
1060
+ wpNavMenu.refreshAdvancedAccessibility();
1061
+ wpNavMenu.menusChanged = false;
1062
+
1063
+ $('.wpglobus-menu-item').on('change', function () {
1064
+ var $this = $(this),
1065
+ item_id = $this.data('item-id'),
1066
+ s, so;
1067
+ if ($this.hasClass('wpglobus-item-title')) {
1068
+ s = WPGlobusCore.getString( $('input#edit-menu-item-title-' + item_id).val(), $this.val(), $this.data('language') );
1069
+ so = $(document).triggerHandler('wpglobus_get_menu_translations', {string:s, lang:WPGlobusCoreData.open_languages, id:item_id, type:'input.edit-menu-item-title'});
1070
+ if ( typeof so !== 'undefined' ) {
1071
+ s = so;
1072
+ }
1073
+ $('input#edit-menu-item-title-' + item_id).val(s);
1074
+ }
1075
+ if ($this.hasClass('wpglobus-item-attr')) {
1076
+ s = WPGlobusCore.getString( $('input#edit-menu-item-attr-title-' + item_id).val(), $this.val(), $this.data('language') );
1077
+ so = $(document).triggerHandler('wpglobus_get_menu_translations', {string:s, lang:WPGlobusCoreData.open_languages, id:item_id, type:'input.edit-menu-item-attr-title'});
1078
+ if ( typeof so !== 'undefined' ) {
1079
+ s = so;
1080
+ }
1081
+ $('input#edit-menu-item-attr-title-' + item_id).val(s);
1082
+ }
1083
+
1084
+ });
1085
+ },
1086
+ post_edit: function () {
1087
+ // Hook into the heartbeat-send
1088
+ $(document).on('heartbeat-send', function(e, data) {
1089
+ if ( typeof data['wp_autosave'] !== 'undefined' ) {
1090
+ data['wpglobus_heartbeat'] = 'wpglobus';
1091
+ $.each(WPGlobusAdmin.data.open_languages, function(i,l){
1092
+ var v = $('#title_'+l).val() || '';
1093
+ v = $.trim(v);
1094
+ if ( v != '' ) {
1095
+ data['wp_autosave']['post_title_'+l] = v;
1096
+ }
1097
+ v = $('#content_'+l).val() || '';
1098
+ v = $.trim(v);
1099
+ if ( v != '' ) {
1100
+ data['wp_autosave']['content_'+l] = v;
1101
+ }
1102
+ });
1103
+ }
1104
+ });
1105
+
1106
+ var wrap_at = '#postdivrich',
1107
+ set_title = true,
1108
+ content_tabs_id = '#post-body-content';
1109
+ if ( WPGlobusAdmin.data.support['editor'] === false ) {
1110
+ wrap_at = '#titlediv';
1111
+ set_title = false;
1112
+ }
1113
+ if ( WPGlobusAdmin.data.support['title'] === false ) {
1114
+ set_title = false;
1115
+ }
1116
+ // Make post-body-content as tabs container
1117
+ $(content_tabs_id).prepend($('.wpglobus-post-body-tabs-list'));
1118
+ $.each(WPGlobusAdmin.tabs, function (index, suffix) {
1119
+ if ('default' === suffix) {
1120
+ $(wrap_at).wrap('<div id="tab-default"></div>');
1121
+ if ( set_title ) {
1122
+ $($('#titlediv')).insertBefore(wrap_at);
1123
+ }
1124
+ } else {
1125
+ $(wrap_at+'-' + suffix).wrap('<div id="tab-' + suffix + '"></div>');
1126
+ if ( set_title ) {
1127
+ $($('#titlediv-' + suffix)).insertBefore(wrap_at+'-' + suffix);
1128
+ }
1129
+ }
1130
+ });
1131
+
1132
+ // tabs on
1133
+ $(content_tabs_id).addClass('wpglobus-post-body-tabs').tabs({
1134
+ beforeActivate: function( event, ui ){
1135
+ var otab = ui.oldTab[0].id.replace('link-tab-','');
1136
+ var ntab = ui.newTab[0].id.replace('link-tab-','');
1137
+ if ( 'default' == otab ) {
1138
+ otab = WPGlobusCoreData.default_language;
1139
+ }
1140
+ if ( 'default' == ntab ) {
1141
+ ntab = WPGlobusCoreData.default_language;
1142
+ }
1143
+ var a = $(document).triggerHandler('wpglobus_post_body_tabs', [ otab, ntab ]);
1144
+ if ( a || typeof a === 'undefined' ) {
1145
+ return true;
1146
+ }
1147
+ return false;
1148
+ }
1149
+ }); // #post-body-content
1150
+
1151
+ // setup for default language
1152
+ $('#title').val(WPGlobusAdmin.title);
1153
+
1154
+ /**
1155
+ * See other places with the same bookmark.
1156
+ * @bookmark EDITOR_LINE_BREAKS
1157
+ */
1158
+ //$('#content').text(WPGlobusAdmin.content.replace(/\n/g, "<p>"));
1159
+
1160
+ $('#content').text(WPGlobusAdmin.content);
1161
+
1162
+ if (typeof WPGlobusVendor !== "undefined" && WPGlobusVendor.vendor.WPSEO ) {
1163
+ if ( typeof wpglobus_wpseo !== "undefined" ) {
1164
+ wpglobus_wpseo();
1165
+ } else if ( typeof WPGlobusYoastSeo !== "undefined" ) {
1166
+ /** since Yoast SEO 3.0 */
1167
+ WPGlobusYoastSeo.init();
1168
+ }
1169
+ }
1170
+
1171
+ if ( WPGlobusAdmin.data.modify_excerpt ) {
1172
+ /**
1173
+ * Add excerpt fields from template.
1174
+ */
1175
+ var $excerpt = $( '#excerpt' );
1176
+ $excerpt.addClass( 'hidden' ).css( {'display':'none'} );
1177
+ $( WPGlobusAdmin.data.template ).insertAfter( $excerpt );
1178
+ $( 'body' ).on( 'change', '.wpglobus-excerpt', function () {
1179
+ var $t = $( this );
1180
+ $excerpt.val( WPGlobusCore.getString( $excerpt.val(), $t.val(), $t.data('language') ) );
1181
+ });
1182
+ }
1183
+
1184
+ /** wp_editor word count */
1185
+ if ( typeof wp.utils !== 'undefined' && typeof wp.utils.WordCounter !== 'undefined' ) {
1186
+ /** from WordPress 4.3 @see \wp-admin\js\post.js */
1187
+ WPGlobusCoreData.wordCounter = {};
1188
+
1189
+ var self = this;
1190
+
1191
+ $.each( WPGlobusCoreData.enabled_languages, function( i, l ){
1192
+ if ( l == WPGlobusCoreData.default_language ) {
1193
+ return true;
1194
+ }
1195
+
1196
+ ( function( $, counter, l ) {
1197
+ WPGlobusCoreData.wordCounter[ l ] = {};
1198
+ WPGlobusCoreData.wordCounter[ l ][ 'counter' ] = counter;
1199
+
1200
+ $( function() {
1201
+
1202
+ WPGlobusCoreData.wordCounter[ l ][ 'content' ] = $( '#content_'+l );
1203
+ WPGlobusCoreData.wordCounter[ l ][ 'count' ] = $( '#wp-word-count-'+l ).find( '.word-count-'+l );
1204
+
1205
+ WPGlobusCoreData.wordCounter[ l ][ 'prevCount' ] = 0;
1206
+
1207
+ function update( l ) {
1208
+ var text, count;
1209
+
1210
+ if ( typeof l === 'object' ) {
1211
+
1212
+ if ( l == 'tinymce' ) {
1213
+ /** wysiwyg editor */
1214
+ l = self.getCurrentTab();
1215
+ } else {
1216
+ /** textarea */
1217
+ l = l.target.id.replace( 'content_', '' );
1218
+ }
1219
+
1220
+ }
1221
+
1222
+ if ( typeof WPGlobusCoreData.wordCounter[ l ] === 'undefined' ) {
1223
+ return;
1224
+ }
1225
+
1226
+ //if ( ! contentEditor || contentEditor.isHidden() ) {
1227
+ if ( ! WPGlobusCoreData.wordCounter[ l ][ 'contentEditor' ] ||
1228
+ WPGlobusCoreData.wordCounter[ l ][ 'contentEditor' ].isHidden() ) {
1229
+
1230
+ text = WPGlobusCoreData.wordCounter[ l ][ 'content' ].val();
1231
+
1232
+ } else {
1233
+ //text = contentEditor.getContent( { format: 'raw' } );
1234
+ text = WPGlobusCoreData.wordCounter[ l ][ 'contentEditor' ].getContent( { format: 'raw' } );
1235
+ }
1236
+
1237
+ //count = counter.count( text );
1238
+ count = WPGlobusCoreData.wordCounter[ l ][ 'counter' ].count( text );
1239
+
1240
+ //if ( count !== prevCount ) {
1241
+ if ( count !== WPGlobusCoreData.wordCounter[ l ][ 'prevCount' ] ) {
1242
+ //$count.text( count );
1243
+ WPGlobusCoreData.wordCounter[ l ][ 'count' ].text( count );
1244
+ }
1245
+
1246
+ //prevCount = count;
1247
+ WPGlobusCoreData.wordCounter[ l ][ 'prevCount' ] = count;
1248
+ }
1249
+
1250
+ $( document ).on( 'tinymce-editor-init', function( event, editor ) {
1251
+
1252
+ if ( -1 == editor.id.indexOf( 'content_' ) ) {
1253
+ return;
1254
+ }
1255
+ var l = editor.id.replace( 'content_', '' );
1256
+
1257
+ WPGlobusCoreData.wordCounter[ l ][ 'contentEditor' ] = editor;
1258
+
1259
+ editor.on( 'nodechange keyup', _.debounce( update, 1000 ) );
1260
+ } );
1261
+
1262
+ WPGlobusCoreData.wordCounter[l]['content'].on( 'input keyup', _.debounce( update, 1000 ) );
1263
+
1264
+ update( l );
1265
+
1266
+ } );
1267
+ } )( jQuery, new wp.utils.WordCounter(), l );
1268
+ });
1269
+
1270
+ }
1271
+
1272
+ if ( typeof(wpWordCount) !== 'undefined' ) {
1273
+ // wordpress 4.2.4 and earlier
1274
+ var last = 0,
1275
+ ls = WPGlobusCoreData.open_languages,
1276
+ $d = this.$document,
1277
+ lsb = {};
1278
+
1279
+ ls.shift();
1280
+
1281
+ $.each(WPGlobusCoreData.open_languages, function(i,e){
1282
+ lsb[e] = 0;
1283
+ });
1284
+
1285
+ var wpglobusWordCount = {
1286
+ settings : {
1287
+ strip : /<[a-zA-Z\/][^<>]*>/g, // strip HTML tags
1288
+ clean : /[0-9.(),;:!?%#$¿'"_+=\\/-]+/g, // regexp to remove punctuation, etc.
1289
+ w : /\S\s+/g, // word-counting regexp
1290
+ c : /\S/g // char-counting regexp for asian languages
1291
+ },
1292
+ block : lsb,
1293
+ wc : function(tx, l, type) {
1294
+ var t = this, w, tc = 0;
1295
+
1296
+ if ( l == WPGlobusCoreData.default_language ) {
1297
+ w = $('.word-count');
1298
+ } else {
1299
+ w = $('.word-count-'+l);
1300
+ }
1301
+
1302
+ if ( type === undefined )
1303
+ type = wordCountL10n.type;
1304
+ if ( type !== 'w' && type !== 'c' )
1305
+ type = 'w';
1306
+
1307
+ if ( t.block[l] )
1308
+ return;
1309
+
1310
+ t.block[l] = 1;
1311
+
1312
+ setTimeout( function() {
1313
+ if ( tx ) {
1314
+ tx = tx.replace( t.settings.strip, ' ' ).replace( /&nbsp;|&#160;/gi, ' ' );
1315
+ tx = tx.replace( t.settings.clean, '' );
1316
+ tx.replace( t.settings[type], function(){tc++;} );
1317
+ }
1318
+ w.html(tc.toString());
1319
+ setTimeout( function() { t.block[l] = 0; }, 2000 );
1320
+ }, 1 );
1321
+ }
1322
+ };
1323
+
1324
+ $d.bind( 'wpglobuscountwords', function(e, txt, l) {
1325
+ wpglobusWordCount.wc(txt, l);
1326
+ });
1327
+
1328
+ $.each(ls, function(i,l){
1329
+ var co = $('#content_'+l);
1330
+ $d.triggerHandler('wpglobuscountwords', [ co.val(), l ]);
1331
+ co.keyup( function(e) {
1332
+ var k = e.keyCode || e.charCode;
1333
+
1334
+ if ( k == last ) {
1335
+ return true;
1336
+ }
1337
+ if ( 13 == k || 8 == last || 46 == last )
1338
+ $d.triggerHandler('wpglobuscountwords', [ co.val(), l ]);
1339
+
1340
+ last = k;
1341
+ return true;
1342
+ });
1343
+ });
1344
+ // word recount for default language
1345
+ $(document).triggerHandler('wpglobuscountwords', [ $('#content').val(), WPGlobusCoreData.default_language ]);
1346
+ }
1347
+ // end word count
1348
+
1349
+ $('body').on('click', '#publish, #save-post', function() {
1350
+ if ( WPGlobusAdmin.data.open_languages.length > 1 ) {
1351
+ $(document).triggerHandler('wpglobus_before_save_post', {content_tabs_id:content_tabs_id});
1352
+ // if empty title in default language make it from another titles
1353
+ var t = $('#title').val(),
1354
+ index, title = '', delimiter = '';
1355
+
1356
+ if ( t.length == 0 ) {
1357
+ index = WPGlobusAdmin.data.open_languages.indexOf(WPGlobusAdmin.data.default_language);
1358
+ WPGlobusAdmin.data.open_languages.splice(index, 1);
1359
+ $(WPGlobusAdmin.data.open_languages).each(function(i,l){
1360
+ delimiter = i == 0 ? '' : '-';
1361
+ t = $('#title_'+l).val();
1362
+ if ( t.length > 0 ) {
1363
+ if ( title.length == 0 ) { delimiter = '';}
1364
+ title = title + delimiter + t;
1365
+ }
1366
+ });
1367
+ }
1368
+ if ( title.length > 0 ) {
1369
+ $('#title').val(title);
1370
+ }
1371
+ }
1372
+ if ( typeof WPGlobusAdmin.data.tagsdiv === 'undefined' || WPGlobusAdmin.data.tagsdiv.length < 1 ) {
1373
+ return;
1374
+ }
1375
+ $(WPGlobusAdmin.data.tagsdiv).each(function(i,tagsdiv){
1376
+ if ($('#' + tagsdiv).size() == 0) {
1377
+ /* next iteration */
1378
+ return true;
1379
+ }
1380
+
1381
+ var id = tagsdiv.replace('tagsdiv-', '');
1382
+ if ( 'undefined' === id ) {
1383
+ return true;
1384
+ }
1385
+ if ( $('#tax-input-'+id).size() == 0 ) {
1386
+ return true;
1387
+ }
1388
+
1389
+ var name, tags = [];
1390
+
1391
+ $('#tagsdiv-'+id+' .tagchecklist span').each(function(i,e){
1392
+ name = $(e).text();
1393
+ name = name.replace('X', '').trim(' ');
1394
+ if ( typeof WPGlobusAdmin.data.tag[id][name] === 'undefined' ) {
1395
+ tags[i] = name;
1396
+ } else {
1397
+ tags[i] = WPGlobusAdmin.data.tag[id][name];
1398
+ }
1399
+ });
1400
+ $('#tax-input-'+id).val(tags.join(', '));
1401
+ });
1402
+
1403
+ });
1404
+
1405
+ $('.ui-state-default').on('click', function () {
1406
+ if ('link-tab-default' === $(this).attr('id')) {
1407
+ $(window).scrollTop($(window).scrollTop() + 1);
1408
+ $(window).scrollTop($(window).scrollTop() - 1);
1409
+ }
1410
+ });
1411
+
1412
+ },
1413
+ adminCentral: function () {
1414
+ $( '.wpglobus-admin-central-tab' ).css({ 'display':'none' });
1415
+
1416
+ if ( $( '.nav-tab-active' ).length > 1 ) {
1417
+ $( '.wpglobus-about-wrap .nav-tab-wrapper a' ).removeClass( 'nav-tab-active' );
1418
+ }
1419
+
1420
+ var setFirstElement = true;
1421
+ if ( 0 == location.hash.indexOf( '#' ) ) {
1422
+ $( '.wpglobus-about-wrap .nav-tab-wrapper a').each( function( i, e ) {
1423
+ if ( $(e).attr( 'href' ) == location.hash ) {
1424
+ setFirstElement = false;
1425
+ $(e).addClass( 'nav-tab-active' );
1426
+ }
1427
+ });
1428
+ }
1429
+ if ( setFirstElement ) {
1430
+ $( '.wpglobus-about-wrap .nav-tab-wrapper a' ).eq(0).addClass( 'nav-tab-active' );
1431
+ }
1432
+
1433
+ var activePanel = $( '.wpglobus-about-wrap .nav-tab-active' ).data( 'tab-id' );
1434
+ if ( '' != activePanel ) {
1435
+ $( '#'+activePanel ).css({'display':'block'});
1436
+ }
1437
+
1438
+ $( document ).on( 'click', '.wpglobus-about-wrap .nav-tab', function(event){
1439
+ var $t = $( this );
1440
+ if ( $t.hasClass( 'nav-tab-active' ) ) {
1441
+ return;
1442
+ }
1443
+ $( '.wpglobus-admin-central-tab' ).css({ 'display':'none' });
1444
+ $( '.wpglobus-about-wrap .nav-tab' ).removeClass( 'nav-tab-active' );
1445
+ $t.addClass( 'nav-tab-active' );
1446
+ if ( '' != $t.data( 'tab-id' ) ) {
1447
+ $( '#' + $t.data( 'tab-id' ) ).css({ 'display':'block' });
1448
+ }
1449
+ });
1450
+ },
1451
+ start: function () {
1452
+ var t = this;
1453
+ $('#wpglobus_flags').select2({
1454
+ formatResult: this.format,
1455
+ formatSelection: this.format,
1456
+ minimumResultsForSearch: -1,
1457
+ escapeMarkup: function (m) {
1458
+ return m;
1459
+ }
1460
+ });
1461
+
1462
+ /** disable checked off first language */
1463
+ $('body').on('click', '#enabled_languages-list li:first input', function (event) {
1464
+ event.preventDefault();
1465
+ $('.redux-save-warn').css({'display': 'none'});
1466
+ $('#enabled_languages-list').find('li:first > input').val('1');
1467
+ if ($('#disable_first_language').length === 0) {
1468
+ $(t.config.disable_first_language).insertAfter('#info_bar');
1469
+ }
1470
+ return false;
1471
+ });
1472
+
1473
+ },
1474
+ format: function (language) {
1475
+ return '<img class="wpglobus_flag" src="' + WPGlobusAdmin.flag_url + language.text + '"/>&nbsp;&nbsp;' + language.text;
1476
+ },
1477
+ set_dialog: function() {
1478
+
1479
+ if ( 'undefined' !== typeof WPGlobusAdmin.data.customFieldsEnabled ) {
1480
+ WPGlobusAdmin.data.customFieldsEnabled = this.parseBool( WPGlobusAdmin.data.customFieldsEnabled );
1481
+ if ( ! WPGlobusAdmin.data.customFieldsEnabled ) {
1482
+ return;
1483
+ }
1484
+ }
1485
+
1486
+ var ajaxify_row_id, added_control = false;
1487
+ var add_elements = function(post_id) {
1488
+
1489
+ var id, rows, cb, _cb,
1490
+ _classes = 'wpglobus_dialog_start wpglobus_dialog_icon';
1491
+
1492
+ _cb = [
1493
+ '<div class="wpglobus_dialog_options_wrapper hidden">',
1494
+ '<input style="width:initial;" id="wpglobus-cb-{{id}}" data-object="#wpglobus-dialog-start-{{id}}" data-meta-key="{{meta-key}}" class="wpglobus_dialog_option wpglobus_dialog_cb" type="checkbox" {{checked}} />',
1495
+ '</div>'
1496
+ ].join('');
1497
+
1498
+ if (typeof post_id == 'undefined') {
1499
+ rows = '#the-list tr';
1500
+ } else {
1501
+ rows = '#the-list tr#'+post_id;
1502
+ }
1503
+ $(rows).each(function(){
1504
+ var $t = $(this),
1505
+ tid = $t.attr('id'),
1506
+ element = $t.find('textarea'),
1507
+ clone, name, meta_key,
1508
+ classes = _classes;
1509
+
1510
+ id = element.attr('id');
1511
+ if ( undefined === id ) {
1512
+ return true;
1513
+ }
1514
+ meta_key = $('#'+tid+'-key').val();
1515
+ clone = $('#'+id).clone();
1516
+ $(element).addClass('wpglobus-dialog-field-source hidden');
1517
+ name = element.attr('name');
1518
+ $(clone).attr('id', 'wpglobus-'+id);
1519
+ $(clone).attr('name', 'wpglobus-'+name);
1520
+ $(clone).attr('data-source-id', id);
1521
+ $(clone).attr('class', 'wpglobus-dialog-field');
1522
+ $(clone).val( WPGlobusCore.TextFilter($(element).val(), WPGlobusCoreData.language) );
1523
+ $(clone).insertAfter(element);
1524
+ cb = _cb.replace(/{{id}}/g, id);
1525
+ cb = cb.replace(/{{meta-key}}/g, meta_key);
1526
+ if ( undefined === WPGlobusAdmin.data.post_meta_settings[WPGlobusAdmin.data.post_type] ) {
1527
+ cb = cb.replace(/{{checked}}/, 'checked');
1528
+ } else {
1529
+ if ( undefined !== WPGlobusAdmin.data.post_meta_settings[WPGlobusAdmin.data.post_type][meta_key] && WPGlobusAdmin.data.post_meta_settings[WPGlobusAdmin.data.post_type][meta_key] == 'false' ) {
1530
+ cb = cb.replace(/{{checked}}/, '');
1531
+ classes = _classes+' wpglobus_dialog_start_hidden';
1532
+ } else {
1533
+ cb = cb.replace(/{{checked}}/, 'checked');
1534
+ classes = _classes;
1535
+ }
1536
+ }
1537
+ $t.append('<td style="width:20px;"><div id="wpglobus-dialog-start-'+id+'" data-type="control" data-source-type="textarea" data-source-id="'+id+'" class="'+classes+'"></div>'+cb+'</td>');
1538
+ });
1539
+ if ( ! added_control && $('#list-table .wpglobus_dialog_start').length > 0 ) {
1540
+ $('#list-table thead tr').append('<th class="wpglobus-control-head"><div class="wpglobus_dialog_settings wpglobus_dialog_icon"></div></th>');
1541
+ added_control = true;
1542
+ }
1543
+ }
1544
+
1545
+ add_elements();
1546
+
1547
+ $('body').on('change', '.wpglobus-dialog-field', function(){
1548
+ var $t = $(this),
1549
+ source_id = '#'+$t.data('source-id'),
1550
+ source = '', s = '', new_value;
1551
+
1552
+ if ( typeof source_id == 'undefined' ) {
1553
+ return;
1554
+ }
1555
+ source = $(source_id).val();
1556
+
1557
+ if ( ! /(\{:|\[:|<!--:)[a-z]{2}/.test(source) ) {
1558
+ $(source_id).val($t.val());
1559
+ } else {
1560
+ $.each(WPGlobusCoreData.enabled_languages, function(i,l){
1561
+ if ( l == WPGlobusCoreData.language ) {
1562
+ new_value = $t.val();
1563
+ } else {
1564
+ new_value = WPGlobusCore.TextFilter(source,l,'RETURN_EMPTY');
1565
+ }
1566
+ if ( '' != new_value ) {
1567
+ s = s + WPGlobusCore.addLocaleMarks(new_value,l);
1568
+ }
1569
+ });
1570
+ $(source_id).val(s);
1571
+ }
1572
+
1573
+ });
1574
+
1575
+ $(document).ajaxSend(function(event, jqxhr, settings){
1576
+ if ( 'add-meta' == settings.action ) {
1577
+ ajaxify_row_id = settings.element;
1578
+ }
1579
+ });
1580
+ $(document).ajaxComplete(function(event, jqxhr, settings){
1581
+ if ( 'add-meta' == settings.action && undefined !== jqxhr.responseXML ) {
1582
+ if ( 'newmeta' == ajaxify_row_id ) {
1583
+ add_elements('meta-'+$(jqxhr.responseXML.documentElement.outerHTML).find('meta').attr('id'));
1584
+ } else {
1585
+ add_elements(ajaxify_row_id);
1586
+ }
1587
+ }
1588
+ });
1589
+
1590
+ WPGlobusDialogApp.init({dialogTitle:'Edit meta'});
1591
+
1592
+ }
1593
+ };
1594
+
1595
+ new WPGlobusAdminApp.App();
1596
+
1597
+ return WPGlobusAdminApp;
1598
+
1599
+ }(window.WPGlobusAdminApp || {}, jQuery));
1600
+
1601
+ });
includes/js/wpglobus-admin.min.js ADDED
@@ -0,0 +1 @@
 
1
+ var WPGlobusCore;!function(t){var a;a=WPGlobusCore={strpos:function(t,a,e){var o=(t=""+t).indexOf(a,e);return o>=0&&o},TextFilter:function(t,e,o){if(void 0===t||""===t)return t;var n,i,l=[],s=!1;e=""==e?"en":e,o=void 0===o||""==o?"RETURN_IN_DEFAULT_LANGUAGE":o,l[0]=[],l[0].start=WPGlobusCoreData.locale_tag_start.replace("%s",e),l[0].end=WPGlobusCoreData.locale_tag_end,l[1]=[],l[1].start="\x3c!--:"+e+"--\x3e",l[1].end="\x3c!--:--\x3e",l[2]=[],l[2].start="[:"+e+"]",l[2].end="[:";for(var d=0;d<3;d++)if(!1!==(n=a.strpos(t,l[d].start))){n+=l[d].start.length,t=!1===(i=a.strpos(t,l[d].end,n))?t.substr(n):t.substr(n,i-n),s=!0;break}return s||("RETURN_EMPTY"==o?(e!=WPGlobusCoreData.default_language||/(\{:|\[:|<!--:)[a-z]{2}/.test(t))&&(t=""):e==WPGlobusCoreData.default_language?/(\{:|\[:|<!--:)[a-z]{2}/.test(t)&&(t=""):t=a.TextFilter(t,WPGlobusCoreData.default_language)),t},addLocaleMarks:function(t,a){return WPGlobusCoreData.locale_tag_start.replace("%s",a)+t+WPGlobusCoreData.locale_tag_end},getTranslations:function(e){var o,n={};return t.each(WPGlobusCoreData.enabled_languages,function(t,i){o=i==WPGlobusCoreData.default_language?"RETURN_IN_DEFAULT_LANGUAGE":"RETURN_EMPTY",n[i]=a.TextFilter(e,i,o)}),n},getString:function(e,o,n){if(void 0===e)return e;void 0===o&&(o=""),void 0===n&&(n=WPGlobusCoreData.language),(e=a.getTranslations(e))[n]=o;var i="";return t.each(e,function(t,e){""!=e&&t!=WPGlobusCoreData.default_language&&(i+=a.addLocaleMarks(e,t))}),""!=e[WPGlobusCoreData.default_language]&&(i=""==i?e[WPGlobusCoreData.default_language]:a.addLocaleMarks(e[WPGlobusCoreData.default_language],WPGlobusCoreData.default_language)+i),i}}}(jQuery);var WPGlobusDialogApp;!function(t){var a;a=WPGlobusDialogApp={option:{listenClass:".wpglobus_dialog_start",settingsClass:".wpglobus_dialog_settings",dialogTabs:"#wpglobus-dialog-tabs",dialogTitle:"",customData:null,callback:function(){}},form:void 0,element:void 0,element_by:"id",id:"",clone_id:"",wpglobus_id:"",type:"textarea",source:"",order:{},value:{},request:"core",attrs:{},dialogTitle:"",trClass:"wpglobus-translatable",startButton:['<span id="wpglobus-dialog-start-{{clone_id}}" ','style="{{style}}" ','data-type="control" data-dialog-title="{{title}}" ','data-source-type="" data-source-id="{{id}}" data-source-name="{{name}}" ','data-nodename="{{nodename}}"',"{{sbTitle}} ",'class="{{classes}}"></span>'].join(""),startButtonClass:"wpglobus_dialog_start wpglobus_dialog_icon",clicks:0,init:function(e){a.option=t.extend(a.option,e),t(a.option.dialogTabs).tabs(),a.dialogTitle=a.option.dialogTitle,this.attachListener(),null!=a.option.customData&&void 0!==a.option.customData.addElements&&t.each(a.option.customData.addElements,function(t,e){a.addElement(e)})},convertToId:function(t){return t=(t=t.replace(/\]/g,"")).replace(/\[/g,"-")},addElement:function(e){var o={id:null,dialogTitle:"",style:"",styleTextareaWrapper:"",sbTitle:"",onChangeClass:""};if("string"==typeof e)o.id=e;else{if("object"!=typeof e)return;o=t.extend(o,e)}var n,i,l,s=null,d=null,u=null,r=null,c=a.startButton,g="";if(a.element_by="id",null===(r=document.getElementById(o.id))?(a.element_by="name",r=document.getElementsByName(o.id)):g=(g=r.nodeName).toLowerCase(),0!=r.length&&(d=o.id,"id"==a.element_by?s=t("#"+d):(g=(g=r[0].nodeName).toLowerCase(),s=t(g+'[name="'+d+'"]')),u="undefined"===s.attr("name")?d:s.attr("name"),a.clone_id=a.convertToId(d),-1==u.indexOf("wpglobus")&&-1==a.clone_id.indexOf("wpglobus")&&!(t("#wpglobus-"+a.clone_id).length>0||t(g+'[name="wpglobus-'+u+'"]').length>0))){n=t(s.clone()),l=s.attr("style")||"",s.attr("style","display:none;"),n.attr("id","wpglobus-"+a.clone_id).attr("name","wpglobus-"+u),n.addClass(a.trClass),""!=o.onChangeClass&&n.addClass(o.onChangeClass),"id"==a.element_by?n.attr("data-source-id",d).attr("data-source-name","").attr("data-source-get-by",a.element_by):n.attr("data-source-id","").attr("data-source-name",u).attr("data-source-get-by",a.element_by),"textarea"==g?(i=WPGlobusCore.getTranslations(s.text())[WPGlobusCoreData.language],n.text(i),n.attr("data-nodename","textarea"),""==o.style?n.attr("style",l+";width:95%;float:left;"):n.attr("style",l+";"+o.style)):(i=WPGlobusCore.getTranslations(s.val())[WPGlobusCoreData.language],n.attr("value",i),n.attr("data-nodename","input"),""!=o.style&&n.attr("style",l+";"+o.style)),c=c.replace(/{{clone_id}}/g,a.clone_id),c="id"==a.element_by?(c=(c=c.replace(/{{id}}/g,a.clone_id)).replace(/{{name}}/g,"")).replace(/{{nodename}}/g,""):(c=(c=c.replace(/{{id}}/g,"")).replace(/{{name}}/g,u)).replace(/{{nodename}}/g,g),c="textarea"==g?c.replace("{{style}}","float:left;margin-top:0;"):c.replace("{{style}}","");var b="textarea"==g?a.startButtonClass+" wpglobus-textarea wpglobus-textarea-"+a.clone_id:a.startButtonClass;c=c.replace("{{classes}}",b),c=""==o.dialogTitle?c.replace("{{title}}",a.dialogTitle):c.replace("{{title}}",o.dialogTitle),c=""==o.sbTitle?c.replace("{{sbTitle}}",o.sbTitle):c.replace("{{sbTitle}}",'title="'+o.sbTitle+'"'),t(c).insertAfter(s),t(n).insertAfter(s),"textarea"==g&&(t("#wpglobus-"+a.clone_id).addClass("wpglobus-textarea-"+a.clone_id),t(".wpglobus-textarea-"+a.clone_id).wrapAll('<div class="wpglobus-textarea-wrapper" style="'+o.styleTextareaWrapper+'"></div>'));var p,m=!1;if(""==o.onChangeClass)p="#wpglobus-"+a.clone_id;else{p="."+o.onChangeClass;var v=t._data(t(document)[0],"events");void 0===v?m=!0:void 0!==v.change&&t.each(v.change,function(t,a){if(a.selector==p)return m=!0,!1})}m||t(document).on("change",p,function(){var a=t(this),e=a.data("source-id");e=""==e?a.data("nodename")+'[name="'+a.data("source-name")+'"]':"#"+e,t(e).val(WPGlobusCore.getString(t(e).val(),a.val()))})}},saveDialog:function(){var e,o,n,i="",l="",s="";t(".wpglobus_dialog_textarea").each(function(a,d){e=t(d),o=e.val(),(n=e.data("language"))==WPGlobusAdmin.data.language&&(s=o),""!=o&&(i+=WPGlobusCore.addLocaleMarks(o,n),n==WPGlobusCoreData.default_language&&(l=o))}),i=i.length==l.length+8?l:i,t(a.id).val(i),i=""==s?l:s,t(a.wpglobus_id).val(i)},dialog:t("#wpglobus-dialog-wrapper").dialog({autoOpen:!1,width:650,modal:!0,dialogClass:"wpglobus-dialog",buttons:[{text:"Save",class:"wpglobus-button-save",click:function(){a.saveDialog(),a.dialog.dialog("close")}},{text:"Cancel",class:"wpglobus-button-cancel",click:function(){a.dialog.dialog("close")}}],open:function(){var e=a.dialogTitle;void 0!==a.attrs.maxlength&&(t(".wpglobus_dialog_textarea").attr("maxlength",a.attrs.maxlength),e+=" | maxlength="+a.attrs.maxlength),t(".wpglobus-dialog .ui-dialog-title").text(e)},close:function(){a.form[0].reset()}}),attachListener:function(){t(document).on("click",a.option.settingsClass,function(){t(".wpglobus_dialog_options_wrapper").hasClass("hidden")?t(".wpglobus_dialog_options_wrapper").removeClass("hidden"):t(".wpglobus_dialog_options_wrapper").addClass("hidden")}),t(document).on("click",".wpglobus_dialog_option",function(e){var o=t(this),n=o.data("object");a.order.action="save_post_meta_settings",a.order.post_type=WPGlobusAdmin.data.post_type,a.order.checked=o.prop("checked"),a.order.id=o.attr("id"),a.order.meta_key=o.data("meta-key"),a.ajax(a.order).done(function(a){"ok"==a.result&&("true"==a.checked?t(n).removeClass("wpglobus_dialog_start_hidden"):t(n).addClass("wpglobus_dialog_start_hidden"))}).fail(function(t){}).always(function(t,a){})}),t(document).on("click",a.option.listenClass,function(e){a.element=t(this),a.id=a.element.data("source-id"),""==a.id?(a.id=a.element.data("nodename")+'[name="'+a.element.data("source-name")+'"]',a.wpglobus_id="#wpglobus-"+a.convertToId(a.element.data("source-name"))):(a.wpglobus_id="#wpglobus-"+a.id,a.id="#"+a.id),a.clicks++,1==a.clicks&&setTimeout(function(){if(1==a.clicks)a.onClick(e);else{var o=t(a.id);o.hasClass("hidden")?o.removeClass("hidden").attr("style","display:block;"):o.addClass("hidden").attr("style","display:none;")}a.clicks=0},200)}),a.form=a.dialog.find("form#wpglobus-dialog-form").on("submit",function(t){t.preventDefault(),a.saveDialog()})},ajax:function(a){return t.ajax({type:"POST",url:WPGlobusAdmin.ajaxurl,data:{action:WPGlobusAdmin.process_ajax,order:a},dataType:"json",async:!1})},onClick:function(e){void 0===a.element.data("dialog-title")||""==a.element.data("dialog-title")?a.dialogTitle=a.option.dialogTitle:a.dialogTitle=a.element.data("dialog-title"),void 0!==a.id&&(a.attrs.maxlength=t(a.id).attr("maxlength")),a.source=a.element.data("source-value"),void 0===a.source&&(a.source=t(a.id).val(),"ajax"==a.request||(a.value=WPGlobusCore.getTranslations(a.source))),t.each(a.value,function(a,e){t("#wpglobus-dialog-"+a).val(e)}),a.dialog.dialog("open")}}}(jQuery),jQuery(document).ready(function(){"use strict";window.WPGlobusAdminApp=(t=window.WPGlobusAdminApp||{},a=jQuery,t.App=function(t){void 0===window.WPGlobusAdminApp&&(this.config={debug:!1,version:WPGlobusAdmin.version},this.status="ok","undefined"===WPGlobusAdmin?(this.status="error",this.config.debug&&console.log("Error options loading")):this.config.debug&&console.dir(WPGlobusAdmin),this.config.disable_first_language=['<div id="disable_first_language" style="display:block;" class="redux-field-errors notice-red">',"<strong>","<span>&nbsp;</span>",WPGlobusAdmin.i18n.cannot_disable_language,"</strong>","</div>"].join(""),a.extend(this.config,t),"ok"===this.status&&this.init())},t.App.prototype={$document:a(document),init:function(){WPGlobusCoreData.multisite=this.parseBool(WPGlobusCoreData.multisite),this.admin_init(),a("#content").addClass("wpglobus-editor").attr("data-language",WPGlobusAdmin.data.default_language),a("textarea[id^=content_]").each(function(t,e){var o=a(e).attr("id").replace("content_","");a(e).attr("data-language",o)}),"post.php"===WPGlobusAdmin.page?(this.post_edit(),this.set_dialog(),"undefined"!=typeof WPGlobusAioseop&&WPGlobusAioseop.init()):"menu-edit"===WPGlobusAdmin.page?this.nav_menus():"taxonomy-edit"===WPGlobusAdmin.page?WPGlobusAdmin.data.tag_id&&this.taxonomy_edit():"taxonomy-quick-edit"===WPGlobusAdmin.page?this.quickEdit("taxonomy"):"edit.php"===WPGlobusAdmin.page?this.quickEdit("post"):"options-general.php"==WPGlobusAdmin.page?this.options_general():"widgets.php"==WPGlobusAdmin.page?(WPGlobusWidgets.init(),WPGlobusDialogApp.init({dialogTitle:"Edit text"})):"wpglobus_options"==WPGlobusAdmin.page?this.start():"wpglobusAdminCentral"==WPGlobusAdmin.page?this.adminCentral():WPGlobusDialogApp.init({customData:WPGlobusCoreData.page_custom_data})},parseBool:function(t){return!/^(false|0)$/i.test(t)&&!!t},getCurrentTab:function(){return a(".wpglobus-post-body-tabs-list .ui-tabs-active").data("language")},admin_init:function(){var t=a(".wpglobus-addons-group a").data("key");if(void 0!==t)if(window.location.search.indexOf("page=wpglobus_options&tab="+t)>=0)WPGlobusCoreData.multisite?window.location=WPGlobusCoreData.pluginInstallLocation.multisite:window.location=WPGlobusCoreData.pluginInstallLocation.single;else{var e=a("#toplevel_page_wpglobus_options li").eq(t+1);WPGlobusCoreData.multisite?a(e).find("a").attr("href",WPGlobusCoreData.pluginInstallLocation.multisite).attr("onclick","window.location=jQuery(this).attr('href');return false;"):a(e).find("a").attr("href",WPGlobusCoreData.pluginInstallLocation.single).attr("onclick","window.location=jQuery(this).attr('href');return false;")}},options_general:function(){var t=a("#blogname"),e=a("body");t.addClass("hidden"),a("#wpglobus-blogname").insertAfter(t).removeClass("hidden"),e.on("blur",".wpglobus-blogname",function(){a(".wpglobus-blogname").each(function(e,o){var n=a(o);t.val(WPGlobusCore.getString(t.val(),n.val(),n.data("language")))})});var o=a("#blogdescription");o.addClass("hidden"),a("#wpglobus-blogdescription").insertAfter(o).removeClass("hidden"),e.on("blur",".wpglobus-blogdesc",function(){a(".wpglobus-blogdesc").each(function(t,e){var n=a(e);o.val(WPGlobusCore.getString(o.val(),n.val(),n.data("language")))})})},quickEdit:function(t){if(void 0!==WPGlobusAdmin.data.has_items&&WPGlobusAdmin.data.has_items){var e="",o=0;a(document).ajaxComplete(function(t,n,i){void 0!==i.data&&""!=e&&i.data.indexOf("action=inline-save-tax&")>=0&&(a("#"+e+" a.row-title").text(WPGlobusAdmin.qedit_titles[o][WPGlobusAdmin.data.language].name),a("#"+e+" .description").text(WPGlobusAdmin.qedit_titles[o][WPGlobusAdmin.data.language].description))});var n={};a("#the-list tr").each(function(e,i){var l=a(i),s="post"===t?"post-":"tag-";o=l.attr("id").replace(s,""),n[o]={},"post"===t?n[o].source=l.find(".post_title").text():"taxonomy"===t&&(n[o].source=a("#inline_"+o+" .name").text())});var i={};i.action="get_titles",i.type=t,i.taxonomy=void 0!==WPGlobusAdmin.data.taxonomy&&WPGlobusAdmin.data.taxonomy,i.title=n,a.ajax({type:"POST",url:WPGlobusAdmin.ajaxurl,data:{action:WPGlobusAdmin.process_ajax,order:i},dataType:"json"}).done(function(t){WPGlobusAdmin.qedit_titles=t.qedit_titles,a.each(t.bulkedit_post_titles,function(t,e){a("#inline_"+t+" .post_title").text(e[WPGlobusAdmin.data.language].name)})}).fail(function(t){}).always(function(t,a){}),a("body").on("change",".wpglobus-quick-edit-title",function(){var t="",e=[];a(".wpglobus-quick-edit-title").each(function(n,i){var l=a(i),s=l.data("language");""!==l.val()&&(t=WPGlobusCore.getString(t,l.val(),s)),WPGlobusAdmin.qedit_titles[o][s].name=l.val(),e[n]=s});var n=a(document).triggerHandler("wpglobus_get_translations",{string:t,lang:e,id:o});void 0!==n&&(t=n),a("input.ptitle").eq(0).attr("value",t),WPGlobusAdmin.qedit_titles[o].source=t}),void 0!==WPGlobusAdmin.data.tags&&a.each(WPGlobusAdmin.data.tags,function(t,a){WPGlobusAdmin.data.value[a].post_id={}}),a("button.save, input#bulk_edit").on("mouseenter",function(t){void 0!==WPGlobusAdmin.data.tags&&("bulk_edit"==t.currentTarget.id?a("input#bulk_edit").unbind("click"):a("button.save").unbind("click"),a("button.save, input#bulk_edit").on("click",function(t){console.log("Start Updating");var e=a.when(),n=(a(this),a.Deferred());n.resolve(function(e){e.next(".spinner").css({visibility:"visible"}),"bulk_edit"!=t.currentTarget.id&&a.ajaxSetup({async:!1});var o,n,i,l=e.parents("tr"),s=l.attr("id").replace("edit-","");a.each(WPGlobusAdmin.data.tags,function(t,a){if(0==(o=l.find("textarea[name='"+WPGlobusAdmin.data.names[a]+"']")).length)return!0;WPGlobusAdmin.data.value[a].post_id[s]=o.val(),n=WPGlobusAdmin.data.value[a].post_id[s].split(","),i=[];for(var e=0;e<n.length;e++)n[e]=n[e].trim(" "),""!=n[e]&&(void 0===WPGlobusAdmin.data.tag[a][n[e]]?i[e]=n[e]:i[e]=WPGlobusAdmin.data.tag[a][n[e]]);o.val(i.join(", "))})}(a(this))),e=e.then(function(){return a.when(n.done())}).then(function(){"bulk_edit"!=t.currentTarget.id&&setTimeout(function(){inlineEditPost.save(o),a.ajaxSetup({async:!0})},50)})}))}),a("#the-list").on("click","a.editinline",function(){var n=a(this);if(e=n.parents("tr").attr("id"),"post"===t)o=e.replace("post-","");else{if("taxonomy"!==t)return;o=e.replace("tag-","")}"post"===t&&void 0!==WPGlobusAdmin.data.tags&&a.each(WPGlobusAdmin.data.tags,function(t,e){if(""!=WPGlobusAdmin.data.value[e]){var n,i=a("#edit-"+o+' textarea[name="'+WPGlobusAdmin.data.names[e]+'"]').val();void 0!==i&&(n=i.split(","),a.each(n,function(t,a){i=i.replace(a,WPGlobusCore.TextFilter(a,WPGlobusCoreData.language))}),a("#edit-"+o+' textarea[name="'+WPGlobusAdmin.data.names[e]+'"]').val(i))}});var i=a("#edit-"+o+" input.ptitle").eq(0),l=i.parents("label");i.val(WPGlobusAdmin.qedit_titles[o].source),i.addClass("hidden"),a(WPGlobusAdmin.data.template).insertAfter(l),void 0===WPGlobusAdmin.qedit_titles[o]&&(WPGlobusAdmin.qedit_titles[o]={},WPGlobusAdmin.qedit_titles[o].source=a("#"+e+" .name a.row-title").text(),a(WPGlobusAdmin.data.enabled_languages).each(function(t,a){WPGlobusAdmin.qedit_titles[o][a]={},a==WPGlobusAdmin.data.default_language?WPGlobusAdmin.qedit_titles[o][a].name=WPGlobusAdmin.qedit_titles[o].source:WPGlobusAdmin.qedit_titles[o][a].name="",WPGlobusAdmin.qedit_titles[o][a].description=""})),a(".wpglobus-quick-edit-title").each(function(t,e){var n=a(e),i=n.data("language");n.attr("id",i+o),void 0!==WPGlobusAdmin.qedit_titles[o][i]&&(WPGlobusAdmin.qedit_titles[o][i].name=WPGlobusAdmin.qedit_titles[o][i].name.replace(/\\\'/g,"'"),WPGlobusAdmin.qedit_titles[o][i].name=WPGlobusAdmin.qedit_titles[o][i].name.replace(/\\\"/g,'"'),n.attr("value",WPGlobusAdmin.qedit_titles[o][i].name),WPGlobusAdmin.qedit_titles[o].source=WPGlobusCore.getString(WPGlobusAdmin.qedit_titles[o].source,WPGlobusAdmin.qedit_titles[o][i].name,i))}),a("input.ptitle").eq(0).attr("value",WPGlobusAdmin.qedit_titles[o].source)})}},taxonomy_edit:function(){var t=[];t[0]="name",t[1]="description",a.each(WPGlobusCoreData.enabled_languages,function(e,o){a.each(t,function(t,e){!function(t,e){var o,n=a("#"+t),i=n.clone(),l=n.attr("name"),s="wpglobus-element wpglobus-element_"+t+" wpglobus-element_"+e+" wpglobus-translatable";o=(o=document.getElementById(t)).nodeName,a(i).attr("id",t+"_"+e),a(i).attr("name",l+"_"+e),e!==WPGlobusCoreData.default_language&&(s+=" hidden"),a(i).attr("class",s),a(i).attr("data-save-to",t),a(i).attr("data-language",e),"INPUT"==o?a(i).attr("value",a("#wpglobus-link-tab-"+e).data(t)):"TEXTAREA"==o&&a(i).text(a("#wpglobus-link-tab-"+e).data(t)),n.addClass("hidden"),0==a(".wpglobus-element_"+t).size()?a(i).insertAfter(n):a(i).insertAfter(a(".wpglobus-element_"+t).last())}(e,o)})}),a(".wpglobus-taxonomy-tabs").insertAfter("#ajax-response"),a(".wrap").tabs(),a("body").on("click",".wpglobus-taxonomy-tabs li",function(t){var e=a(this).data("language");a(".wpglobus-element").addClass("hidden"),a(".wpglobus-element_"+e).removeClass("hidden")}),a(".wpglobus-element").on("change",function(){var t=a(this).data("save-to"),e="";a(".wpglobus-element").each(function(o,n){var i=a(n),l=i.val();i.data("save-to")==t&&""!==l&&(e+=WPGlobusCore.addLocaleMarks(l,i.data("language")))}),a("#"+t).val(e)})},nav_menus:function(){var t,e,o="#menu-to-edit .menu-item",n=function(){e!==a(o).size()&&(clearInterval(t),a(o).each(function(t,e){var o=a(e);if(!o.hasClass("wpglobus-menu-item")){var n=a(e).attr("id");a.each(["input.edit-menu-item-title","input.edit-menu-item-attr-title"],function(t,e){var o=a("#"+n+" "+e),i=a(o);if(!i.hasClass("wpglobus-hidden")){i.addClass("wpglobus-hidden"),i.css("display","none");var l=i.parent("label"),s=i.parents("p");a(s).css("height","80px"),a(l).append('<div style="color:#f00;">'+WPGlobusAdmin.i18n.save_nav_menu+"</div>")}}),o.addClass("wpglobus-menu-item")}}))};a.ajaxSetup({beforeSend:function(i,l){void 0!==l.data&&l.data.indexOf("action=add-menu-item")>=0&&(e=a(o).size(),t=setInterval(n,500))}}),a(o).each(function(t,e){var o=a(e).attr("id"),n=o.replace("menu-item-","");a.each(["input.edit-menu-item-title","input.edit-menu-item-attr-title"],function(t,e){var i=a("#"+o+" "+e);i.val()!=WPGlobusAdmin.data.items[n][e].source&&i.val(WPGlobusAdmin.data.items[n][e].source);var l=a("#"+o+" "+e).parents("p"),s=0;a.each(WPGlobusAdmin.data.open_languages,function(o,d){var u=i.clone();u.attr("id",i.attr("id")+"-"+d),u.attr("name",i.attr("id")+"-"+d),u.attr("data-language",d),u.attr("data-item-id",n),u.attr("placeholder",WPGlobusAdmin.data.en_language_name[d]);var r=WPGlobusAdmin.data.items[n][d][e].class;0===t&&d===WPGlobusAdmin.data.default_language?u.attr("class",r+" edit-menu-item-title"):u.attr("class",r),""!=WPGlobusAdmin.data.items[n][d][e].caption?u.attr("value",WPGlobusAdmin.data.items[n][d][e].caption):u.attr("value",""),u.css("margin-bottom","0.6em"),a(l).append(u),s=o}),s=40*(s+1),i.css("display","none").attr("class","").addClass("widefat wpglobus-hidden"),a(l).css("height",s+"px").addClass("wpglobus-menu-item-box")}),a(e).addClass("wpglobus-menu-item")}),a(".menus-move-left, .menus-move-right").each(function(t,e){var o,n=a(e),i=(n.parents("li").attr("id").replace("menu-item-",""),n.attr("title"));void 0!==i&&a.each(WPGlobusAdmin.data.post_titles,function(t,a){i.indexOf(t)>=0&&(o=i.replace(t,a),n.attr("title",o),n.text(o))})}),a(".edit-menu-item-title").trigger("change"),wpNavMenu.refreshAdvancedAccessibility(),wpNavMenu.menusChanged=!1,a(".wpglobus-menu-item").on("change",function(){var t,e,o=a(this),n=o.data("item-id");o.hasClass("wpglobus-item-title")&&(t=WPGlobusCore.getString(a("input#edit-menu-item-title-"+n).val(),o.val(),o.data("language")),void 0!==(e=a(document).triggerHandler("wpglobus_get_menu_translations",{string:t,lang:WPGlobusCoreData.open_languages,id:n,type:"input.edit-menu-item-title"}))&&(t=e),a("input#edit-menu-item-title-"+n).val(t)),o.hasClass("wpglobus-item-attr")&&(t=WPGlobusCore.getString(a("input#edit-menu-item-attr-title-"+n).val(),o.val(),o.data("language")),void 0!==(e=a(document).triggerHandler("wpglobus_get_menu_translations",{string:t,lang:WPGlobusCoreData.open_languages,id:n,type:"input.edit-menu-item-attr-title"}))&&(t=e),a("input#edit-menu-item-attr-title-"+n).val(t))})},post_edit:function(){a(document).on("heartbeat-send",function(t,e){void 0!==e.wp_autosave&&(e.wpglobus_heartbeat="wpglobus",a.each(WPGlobusAdmin.data.open_languages,function(t,o){var n=a("#title_"+o).val()||"";""!=(n=a.trim(n))&&(e.wp_autosave["post_title_"+o]=n),n=a("#content_"+o).val()||"",""!=(n=a.trim(n))&&(e.wp_autosave["content_"+o]=n)}))});var t="#postdivrich",e=!0,o="#post-body-content";if(!1===WPGlobusAdmin.data.support.editor&&(t="#titlediv",e=!1),!1===WPGlobusAdmin.data.support.title&&(e=!1),a(o).prepend(a(".wpglobus-post-body-tabs-list")),a.each(WPGlobusAdmin.tabs,function(o,n){"default"===n?(a(t).wrap('<div id="tab-default"></div>'),e&&a(a("#titlediv")).insertBefore(t)):(a(t+"-"+n).wrap('<div id="tab-'+n+'"></div>'),e&&a(a("#titlediv-"+n)).insertBefore(t+"-"+n))}),a(o).addClass("wpglobus-post-body-tabs").tabs({beforeActivate:function(t,e){var o=e.oldTab[0].id.replace("link-tab-",""),n=e.newTab[0].id.replace("link-tab-","");"default"==o&&(o=WPGlobusCoreData.default_language),"default"==n&&(n=WPGlobusCoreData.default_language);var i=a(document).triggerHandler("wpglobus_post_body_tabs",[o,n]);return!(!i&&void 0!==i)}}),a("#title").val(WPGlobusAdmin.title),a("#content").text(WPGlobusAdmin.content),"undefined"!=typeof WPGlobusVendor&&WPGlobusVendor.vendor.WPSEO&&("undefined"!=typeof wpglobus_wpseo?wpglobus_wpseo():"undefined"!=typeof WPGlobusYoastSeo&&WPGlobusYoastSeo.init()),WPGlobusAdmin.data.modify_excerpt){var n=a("#excerpt");n.addClass("hidden").css({display:"none"}),a(WPGlobusAdmin.data.template).insertAfter(n),a("body").on("change",".wpglobus-excerpt",function(){var t=a(this);n.val(WPGlobusCore.getString(n.val(),t.val(),t.data("language")))})}if(void 0!==wp.utils&&void 0!==wp.utils.WordCounter){WPGlobusCoreData.wordCounter={};var i=this;a.each(WPGlobusCoreData.enabled_languages,function(t,a){if(a==WPGlobusCoreData.default_language)return!0;e=jQuery,o=new wp.utils.WordCounter,n=a,WPGlobusCoreData.wordCounter[n]={},WPGlobusCoreData.wordCounter[n].counter=o,e(function(){WPGlobusCoreData.wordCounter[n].content=e("#content_"+n),WPGlobusCoreData.wordCounter[n].count=e("#wp-word-count-"+n).find(".word-count-"+n),WPGlobusCoreData.wordCounter[n].prevCount=0;function t(t){var a,e;"object"==typeof t&&(t="tinymce"==t?i.getCurrentTab():t.target.id.replace("content_","")),void 0!==WPGlobusCoreData.wordCounter[t]&&(a=!WPGlobusCoreData.wordCounter[t].contentEditor||WPGlobusCoreData.wordCounter[t].contentEditor.isHidden()?WPGlobusCoreData.wordCounter[t].content.val():WPGlobusCoreData.wordCounter[t].contentEditor.getContent({format:"raw"}),(e=WPGlobusCoreData.wordCounter[t].counter.count(a))!==WPGlobusCoreData.wordCounter[t].prevCount&&WPGlobusCoreData.wordCounter[t].count.text(e),WPGlobusCoreData.wordCounter[t].prevCount=e)}e(document).on("tinymce-editor-init",function(a,e){if(-1!=e.id.indexOf("content_")){var o=e.id.replace("content_","");WPGlobusCoreData.wordCounter[o].contentEditor=e,e.on("nodechange keyup",_.debounce(t,1e3))}}),WPGlobusCoreData.wordCounter[n].content.on("input keyup",_.debounce(t,1e3)),t(n)});var e,o,n})}if("undefined"!=typeof wpWordCount){var l=0,s=WPGlobusCoreData.open_languages,d=this.$document,u={};s.shift(),a.each(WPGlobusCoreData.open_languages,function(t,a){u[a]=0});var r={settings:{strip:/<[a-zA-Z\/][^<>]*>/g,clean:/[0-9.(),;:!?%#$¿'"_+=\\/-]+/g,w:/\S\s+/g,c:/\S/g},block:u,wc:function(t,e,o){var n,i=this,l=0;n=e==WPGlobusCoreData.default_language?a(".word-count"):a(".word-count-"+e),void 0===o&&(o=wordCountL10n.type),"w"!==o&&"c"!==o&&(o="w"),i.block[e]||(i.block[e]=1,setTimeout(function(){t&&(t=(t=t.replace(i.settings.strip," ").replace(/&nbsp;|&#160;/gi," ")).replace(i.settings.clean,"")).replace(i.settings[o],function(){l++}),n.html(l.toString()),setTimeout(function(){i.block[e]=0},2e3)},1))}};d.bind("wpglobuscountwords",function(t,a,e){r.wc(a,e)}),a.each(s,function(t,e){var o=a("#content_"+e);d.triggerHandler("wpglobuscountwords",[o.val(),e]),o.keyup(function(t){var a=t.keyCode||t.charCode;return a==l||(13!=a&&8!=l&&46!=l||d.triggerHandler("wpglobuscountwords",[o.val(),e]),l=a,!0)})}),a(document).triggerHandler("wpglobuscountwords",[a("#content").val(),WPGlobusCoreData.default_language])}a("body").on("click","#publish, #save-post",function(){if(WPGlobusAdmin.data.open_languages.length>1){a(document).triggerHandler("wpglobus_before_save_post",{content_tabs_id:o});var t,e=a("#title").val(),n="",i="";0==e.length&&(t=WPGlobusAdmin.data.open_languages.indexOf(WPGlobusAdmin.data.default_language),WPGlobusAdmin.data.open_languages.splice(t,1),a(WPGlobusAdmin.data.open_languages).each(function(t,o){i=0==t?"":"-",(e=a("#title_"+o).val()).length>0&&(0==n.length&&(i=""),n=n+i+e)})),n.length>0&&a("#title").val(n)}void 0===WPGlobusAdmin.data.tagsdiv||WPGlobusAdmin.data.tagsdiv.length<1||a(WPGlobusAdmin.data.tagsdiv).each(function(t,e){if(0==a("#"+e).size())return!0;var o=e.replace("tagsdiv-","");if("undefined"===o)return!0;if(0==a("#tax-input-"+o).size())return!0;var n,i=[];a("#tagsdiv-"+o+" .tagchecklist span").each(function(t,e){n=(n=a(e).text()).replace("X","").trim(" "),void 0===WPGlobusAdmin.data.tag[o][n]?i[t]=n:i[t]=WPGlobusAdmin.data.tag[o][n]}),a("#tax-input-"+o).val(i.join(", "))})}),a(".ui-state-default").on("click",function(){"link-tab-default"===a(this).attr("id")&&(a(window).scrollTop(a(window).scrollTop()+1),a(window).scrollTop(a(window).scrollTop()-1))})},adminCentral:function(){a(".wpglobus-admin-central-tab").css({display:"none"}),a(".nav-tab-active").length>1&&a(".wpglobus-about-wrap .nav-tab-wrapper a").removeClass("nav-tab-active");var t=!0;0==location.hash.indexOf("#")&&a(".wpglobus-about-wrap .nav-tab-wrapper a").each(function(e,o){a(o).attr("href")==location.hash&&(t=!1,a(o).addClass("nav-tab-active"))}),t&&a(".wpglobus-about-wrap .nav-tab-wrapper a").eq(0).addClass("nav-tab-active");var e=a(".wpglobus-about-wrap .nav-tab-active").data("tab-id");""!=e&&a("#"+e).css({display:"block"}),a(document).on("click",".wpglobus-about-wrap .nav-tab",function(t){var e=a(this);e.hasClass("nav-tab-active")||(a(".wpglobus-admin-central-tab").css({display:"none"}),a(".wpglobus-about-wrap .nav-tab").removeClass("nav-tab-active"),e.addClass("nav-tab-active"),""!=e.data("tab-id")&&a("#"+e.data("tab-id")).css({display:"block"}))})},start:function(){var t=this;a("#wpglobus_flags").select2({formatResult:this.format,formatSelection:this.format,minimumResultsForSearch:-1,escapeMarkup:function(t){return t}}),a("body").on("click","#enabled_languages-list li:first input",function(e){return e.preventDefault(),a(".redux-save-warn").css({display:"none"}),a("#enabled_languages-list").find("li:first > input").val("1"),0===a("#disable_first_language").length&&a(t.config.disable_first_language).insertAfter("#info_bar"),!1})},format:function(t){return'<img class="wpglobus_flag" src="'+WPGlobusAdmin.flag_url+t.text+'"/>&nbsp;&nbsp;'+t.text},set_dialog:function(){if(void 0===WPGlobusAdmin.data.customFieldsEnabled||(WPGlobusAdmin.data.customFieldsEnabled=this.parseBool(WPGlobusAdmin.data.customFieldsEnabled),WPGlobusAdmin.data.customFieldsEnabled)){var t,e=!1,o=function(t){var o,n,i,l="wpglobus_dialog_start wpglobus_dialog_icon";i=['<div class="wpglobus_dialog_options_wrapper hidden">','<input style="width:initial;" id="wpglobus-cb-{{id}}" data-object="#wpglobus-dialog-start-{{id}}" data-meta-key="{{meta-key}}" class="wpglobus_dialog_option wpglobus_dialog_cb" type="checkbox" {{checked}} />',"</div>"].join(""),a(void 0===t?"#the-list tr":"#the-list tr#"+t).each(function(){var t,e,s,d=a(this),u=d.attr("id"),r=d.find("textarea"),c=l;if(void 0===(o=r.attr("id")))return!0;s=a("#"+u+"-key").val(),t=a("#"+o).clone(),a(r).addClass("wpglobus-dialog-field-source hidden"),e=r.attr("name"),a(t).attr("id","wpglobus-"+o),a(t).attr("name","wpglobus-"+e),a(t).attr("data-source-id",o),a(t).attr("class","wpglobus-dialog-field"),a(t).val(WPGlobusCore.TextFilter(a(r).val(),WPGlobusCoreData.language)),a(t).insertAfter(r),n=(n=i.replace(/{{id}}/g,o)).replace(/{{meta-key}}/g,s),void 0===WPGlobusAdmin.data.post_meta_settings[WPGlobusAdmin.data.post_type]?n=n.replace(/{{checked}}/,"checked"):void 0!==WPGlobusAdmin.data.post_meta_settings[WPGlobusAdmin.data.post_type][s]&&"false"==WPGlobusAdmin.data.post_meta_settings[WPGlobusAdmin.data.post_type][s]?(n=n.replace(/{{checked}}/,""),c=l+" wpglobus_dialog_start_hidden"):(n=n.replace(/{{checked}}/,"checked"),c=l),d.append('<td style="width:20px;"><div id="wpglobus-dialog-start-'+o+'" data-type="control" data-source-type="textarea" data-source-id="'+o+'" class="'+c+'"></div>'+n+"</td>")}),!e&&a("#list-table .wpglobus_dialog_start").length>0&&(a("#list-table thead tr").append('<th class="wpglobus-control-head"><div class="wpglobus_dialog_settings wpglobus_dialog_icon"></div></th>'),e=!0)};o(),a("body").on("change",".wpglobus-dialog-field",function(){var t,e=a(this),o="#"+e.data("source-id"),n="",i="";void 0!==o&&(n=a(o).val(),/(\{:|\[:|<!--:)[a-z]{2}/.test(n)?(a.each(WPGlobusCoreData.enabled_languages,function(a,o){""!=(t=o==WPGlobusCoreData.language?e.val():WPGlobusCore.TextFilter(n,o,"RETURN_EMPTY"))&&(i+=WPGlobusCore.addLocaleMarks(t,o))}),a(o).val(i)):a(o).val(e.val()))}),a(document).ajaxSend(function(a,e,o){"add-meta"==o.action&&(t=o.element)}),a(document).ajaxComplete(function(e,n,i){"add-meta"==i.action&&void 0!==n.responseXML&&o("newmeta"==t?"meta-"+a(n.responseXML.documentElement.outerHTML).find("meta").attr("id"):t)}),WPGlobusDialogApp.init({dialogTitle:"Edit meta"})}}},new t.App,t);var t,a});
includes/js/wpglobus-clean.js ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * WPGlobus Clean
3
+ * Interface JS functions
4
+ *
5
+ * @since 1.4.3
6
+ *
7
+ * @package WPGlobus
8
+ * @subpackage Administration
9
+ */
10
+ /*jslint browser: true*/
11
+ /*global jQuery, console, WPGlobusAdmin, WPGlobusClean*/
12
+ jQuery(document).ready(function($) {
13
+ "use strict";
14
+
15
+ if ( typeof WPGlobusClean === 'undefined' ) {
16
+ return;
17
+ }
18
+
19
+ if ( typeof WPGlobusAdmin === 'undefined' ) {
20
+ return;
21
+ }
22
+
23
+ var api = {
24
+ init: function() {
25
+ api.addListeners();
26
+ },
27
+ addListeners: function(order){
28
+ $( '#wpglobus-clean-activate' ).on( 'click', function(e){
29
+ $( '#wpglobus-clean-button' ).toggleClass( 'hidden' );
30
+ });
31
+ $( '#wpglobus-clean-button' ).one( 'click', function(e){
32
+ $( this ).toggleClass( 'hidden' );
33
+ $( '#wpglobus-clean-activate' ).prop( 'checked', '' );
34
+ api.clean();
35
+ });
36
+ },
37
+ beforeSend: function(order){
38
+ if ( typeof order.table !== 'undefined' ) {
39
+ $( '#'+order.table+' .wpglobus-spinner' ).css({'visibility':'visible'});
40
+ }
41
+ },
42
+ clean: function() {
43
+
44
+ var tables = WPGlobusClean.tables;
45
+
46
+ var promise = $.when();
47
+
48
+ $.each( WPGlobusClean.data, function( what, value ){
49
+
50
+ promise = promise.then( function() {
51
+
52
+ var order = {};
53
+ order['log'] = $( '#wpglobus-clean-log' ).prop( 'checked' );
54
+
55
+ if ( 'wpglobus_options' == what ) {
56
+ if ( $( '#cb-wpglobus_options' ).prop( 'checked' ) ) {
57
+ order['action'] = 'wpglobus-reset';
58
+ order['table'] = what;
59
+ } else {
60
+ order['action'] = 'die';
61
+ }
62
+ } else {
63
+ order['action'] = 'clean';
64
+ order['table'] = what;
65
+ }
66
+ return $.ajax({
67
+ beforeSend:function(){
68
+ if ( typeof api.beforeSend !== 'undefined' ) api.beforeSend(order);
69
+ },
70
+ type: 'POST',
71
+ url: WPGlobusAdmin.ajaxurl,
72
+ data: { action:WPGlobusAdmin.process_ajax, order:order },
73
+ dataType: 'json'
74
+ });
75
+ }, function(){
76
+ /* error in promise */
77
+ /* return $.ajax( ); */
78
+ }).then( function( result ) {
79
+ if ( typeof result.data !== 'undefined' ) {
80
+
81
+ $( '#'+result.data.table+' .wpglobus-spinner' ).css({'visibility':'hidden'});
82
+ if ( result.success ) {
83
+ $( '#'+result.data.table+' .wpglobus-result' ).html( '<img src="'+WPGlobusClean.icons.success+'" />' );
84
+ } else {
85
+ $( '#'+result.data.table+' .wpglobus-result' ).html( '<img src="'+WPGlobusClean.icons.error+'" />' );
86
+ }
87
+
88
+ }
89
+ });
90
+
91
+ });
92
+
93
+ promise.then(function(){
94
+ $( '.wpglobus-clean-box' ).addClass( 'hidden' );
95
+ $( '#cb-wpglobus_options' ).attr( 'disabled', 'disabled' );
96
+ });
97
+
98
+ }
99
+ };
100
+
101
+ WPGlobusClean = $.extend({}, WPGlobusClean, api);
102
+ WPGlobusClean.init();
103
+
104
+ });
includes/js/wpglobus-clean.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(document).ready(function(e){"use strict";if("undefined"!=typeof WPGlobusClean&&"undefined"!=typeof WPGlobusAdmin){var n={init:function(){n.addListeners()},addListeners:function(o){e("#wpglobus-clean-activate").on("click",function(n){e("#wpglobus-clean-button").toggleClass("hidden")}),e("#wpglobus-clean-button").one("click",function(o){e(this).toggleClass("hidden"),e("#wpglobus-clean-activate").prop("checked",""),n.clean()})},beforeSend:function(n){void 0!==n.table&&e("#"+n.table+" .wpglobus-spinner").css({visibility:"visible"})},clean:function(){WPGlobusClean.tables;var o=e.when();e.each(WPGlobusClean.data,function(l,t){o=o.then(function(){var o={};return o.log=e("#wpglobus-clean-log").prop("checked"),"wpglobus_options"==l?e("#cb-wpglobus_options").prop("checked")?(o.action="wpglobus-reset",o.table=l):o.action="die":(o.action="clean",o.table=l),e.ajax({beforeSend:function(){void 0!==n.beforeSend&&n.beforeSend(o)},type:"POST",url:WPGlobusAdmin.ajaxurl,data:{action:WPGlobusAdmin.process_ajax,order:o},dataType:"json"})},function(){}).then(function(n){void 0!==n.data&&(e("#"+n.data.table+" .wpglobus-spinner").css({visibility:"hidden"}),n.success?e("#"+n.data.table+" .wpglobus-result").html('<img src="'+WPGlobusClean.icons.success+'" />'):e("#"+n.data.table+" .wpglobus-result").html('<img src="'+WPGlobusClean.icons.error+'" />'))})}),o.then(function(){e(".wpglobus-clean-box").addClass("hidden"),e("#cb-wpglobus_options").attr("disabled","disabled")})}};WPGlobusClean=e.extend({},WPGlobusClean,n),WPGlobusClean.init()}});
includes/js/wpglobus-customize-control.js ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * WPGlobus Customize Control
3
+ * Interface JS functions
4
+ *
5
+ * @since 1.2.1
6
+ *
7
+ * @package WPGlobus
8
+ * @subpackage Customize Control
9
+ */
10
+ /*jslint browser: true*/
11
+ /*global jQuery, console, WPGlobusCoreData */
12
+
13
+ var WPGlobusCustomize;
14
+ jQuery(document).ready(function ($) {
15
+ "use strict";
16
+ if ( typeof WPGlobusCoreData.customize === 'undefined' ) {
17
+ return;
18
+ }
19
+
20
+ var api = {
21
+ languages: {},
22
+ index: 0,
23
+ length: 0,
24
+ positionSet: false,
25
+ selectorHtml: '<span style="margin-left:5px;" class="wpglobus-icon-globe"></span><span style="font-weight:bold;">{{language}}</span>',
26
+ init: function(args) {
27
+ $.each( WPGlobusCoreData.enabled_languages, function(i,e){
28
+ api.languages[i] = e;
29
+ api.length = i;
30
+ });
31
+ api.addLanguageSelector();
32
+ api.setElements();
33
+ api.addListeners();
34
+ },
35
+ setTitle: function() {
36
+ $(WPGlobusCoreData.customize.info.element).html(WPGlobusCoreData.customize.info.html);
37
+ },
38
+ getString: function(s) {
39
+ // using ':::' mark for correct work with url
40
+ var tr = WPGlobusCore.getTranslations(s),
41
+ sR = [], i = 0;
42
+ $.each(tr, function(l,t){
43
+ sR[i] = t == '' ? 'null' : t;
44
+ i++;
45
+ });
46
+ sR = sR.join(':::');
47
+ return sR;
48
+ },
49
+ setElements: function() {
50
+ api.setTitle();
51
+ var value;
52
+ $.each(WPGlobusCoreData.customize.addElements, function(i,e){
53
+ var $e = $(e.element);
54
+ $e.attr('id',i).val(e.value).trigger('change');
55
+ if ( e.type == 'textarea' ) {
56
+ if ( typeof e.textarea_attrs !== 'undefined' ) {
57
+ $e.addClass( e.textarea_attrs.class );
58
+ }
59
+ }
60
+ if ( typeof e.options !== 'undefined' ) {
61
+ if ( typeof e.options.setValue !== 'undefined' && e.options.setValue ) {
62
+ value = $(e.origin_element).val();
63
+ $e.data( 'source', value );
64
+ $e.val( WPGlobusCore.TextFilter( value, WPGlobusCoreData.language, 'RETURN_EMPTY' ) );
65
+ if ( $e.hasClass('wpglobus-control-url') ) {
66
+ $(e.origin_element).val( api.getString( value ) );
67
+ }
68
+ }
69
+ if ( typeof e.options.setLabel !== 'undefined' && e.options.setLabel ) {
70
+ $(e.title).text( $(e.origin_title).text() );
71
+ $(e.description).text( $(e.origin_description).text() );
72
+ }
73
+ }
74
+ $e.on('change',function (ev){
75
+ var $t = $(this),
76
+ $el = $( WPGlobusCoreData.customize.addElements[$(this).data('customize-setting-link')].origin_element );
77
+
78
+ $t.data( 'source', WPGlobusCore.getString( $t.data('source'), $t.val() ) );
79
+ if ( $t.hasClass('wpglobus-control-url') ) {
80
+ $el.val( api.getString( $t.data('source') ) );
81
+ } else {
82
+ $el.val( WPGlobusCore.getString( $el.val(), $t.val() ) );
83
+ }
84
+ if ( ! $t.hasClass('wpglobus-not-trigger-change') ) {
85
+ $el.trigger('change');
86
+ }
87
+ });
88
+ });
89
+ },
90
+ addLanguageSelector: function() {
91
+ $('<a style="margin-left:48px;" class="customize-controls-close wpglobus-customize-selector"><span class="wpglobus-globe"></span></a>').insertAfter('.customize-controls-preview-toggle');
92
+ $('.wpglobus-customize-selector').html( api.selectorHtml.replace('{{language}}', WPGlobusCoreData.language) );
93
+ },
94
+ setPosition: function(e) {
95
+ if ( typeof e.options.setPosition !== 'undefined' && e.options.setPosition ) {
96
+ var el = $(e.parent).detach();
97
+ el.insertBefore( e.origin_parent );
98
+ $(e.parent).css({'display':'block'});
99
+ }
100
+ },
101
+ addListeners: function() {
102
+ $(document).on('click','.control-section', function(ev){
103
+ if ( api.positionSet ) {
104
+ return;
105
+ }
106
+ api.positionSet = true;
107
+ $.each(WPGlobusCoreData.customize.addElements, function(i,e){
108
+ $(e.origin_parent).css({'display':'none'});
109
+ $(e.origin_parent+' label' ).css({'display':'none'}); // from WP4.3
110
+ if ( typeof e.options !== 'undefined' ) {
111
+ api.setPosition(e);
112
+ }
113
+ });
114
+ });
115
+
116
+ $(document).on('click','.wpglobus-customize-selector', function(ev){
117
+ if ( api.index > api.length-1 ) {
118
+ api.index = 0;
119
+ } else {
120
+ api.index++;
121
+ }
122
+
123
+ WPGlobusCoreData.language = api.languages[api.index];
124
+
125
+ $(this).html( api.selectorHtml.replace('{{language}}', WPGlobusCoreData.language) );
126
+
127
+ $('.wpglobus-customize-control').each(function(i,e){
128
+ if ( 'undefined' === typeof WPGlobusCoreData.customize.addElements[$(e).data('customize-setting-link')] ) {
129
+ return;
130
+ }
131
+ var or = $( WPGlobusCoreData.customize.addElements[$(e).data('customize-setting-link')].origin_element ),
132
+ $e = $(e);
133
+
134
+ if ( $e.hasClass('wpglobus-control-url') ) {
135
+ $e.val( WPGlobusCore.TextFilter( $e.data('source'), WPGlobusCoreData.language, 'RETURN_EMPTY' ) );
136
+ } else {
137
+ $e.val( WPGlobusCore.TextFilter( or.val(), WPGlobusCoreData.language, 'RETURN_EMPTY' ) );
138
+ }
139
+ });
140
+
141
+ });
142
+
143
+ $(document).ajaxSend(function(event, jqxhr, settings){
144
+ if ( 'undefined' == typeof settings.data ) {
145
+ return;
146
+ }
147
+ if ( settings.data.indexOf('action=customize_save') >= 0 ) {
148
+ var s=settings.data.split('&'),
149
+ ss, source;
150
+
151
+ $.each(s, function(i,e){
152
+ ss = e.split('=');
153
+ if ( 'customized' == ss[0] ) {
154
+ source = ss[1];
155
+ return;
156
+ }
157
+ });
158
+
159
+ var q = decodeURIComponent(source);
160
+ q = JSON.parse(q);
161
+ $.each(WPGlobusCoreData.customize.addElements, function(elem,value){
162
+ if ( typeof q[elem] !== 'undefined' ) {
163
+ q[value.origin] = $(WPGlobusCoreData.customize.addElements[elem].origin_element).val();
164
+ }
165
+ });
166
+ settings.data = settings.data.replace( source, JSON.stringify(q) );
167
+ }
168
+ });
169
+ }
170
+ };
171
+
172
+ WPGlobusCustomize = $.extend( {}, WPGlobusCustomize, api );
173
+
174
+ WPGlobusCustomize.init();
175
+
176
+ });
includes/js/wpglobus-customize-control.min.js ADDED
@@ -0,0 +1 @@
 
1
+ var WPGlobusCustomize;jQuery(document).ready(function(e){"use strict";if(void 0!==WPGlobusCoreData.customize){var t={languages:{},index:0,length:0,positionSet:!1,selectorHtml:'<span style="margin-left:5px;" class="wpglobus-icon-globe"></span><span style="font-weight:bold;">{{language}}</span>',init:function(o){e.each(WPGlobusCoreData.enabled_languages,function(e,o){t.languages[e]=o,t.length=e}),t.addLanguageSelector(),t.setElements(),t.addListeners()},setTitle:function(){e(WPGlobusCoreData.customize.info.element).html(WPGlobusCoreData.customize.info.html)},getString:function(t){var o=WPGlobusCore.getTranslations(t),a=[],s=0;return e.each(o,function(e,t){a[s]=""==t?"null":t,s++}),a=a.join(":::")},setElements:function(){t.setTitle();var o;e.each(WPGlobusCoreData.customize.addElements,function(a,s){var n=e(s.element);n.attr("id",a).val(s.value).trigger("change"),"textarea"==s.type&&void 0!==s.textarea_attrs&&n.addClass(s.textarea_attrs.class),void 0!==s.options&&(void 0!==s.options.setValue&&s.options.setValue&&(o=e(s.origin_element).val(),n.data("source",o),n.val(WPGlobusCore.TextFilter(o,WPGlobusCoreData.language,"RETURN_EMPTY")),n.hasClass("wpglobus-control-url")&&e(s.origin_element).val(t.getString(o))),void 0!==s.options.setLabel&&s.options.setLabel&&(e(s.title).text(e(s.origin_title).text()),e(s.description).text(e(s.origin_description).text()))),n.on("change",function(o){var a=e(this),s=e(WPGlobusCoreData.customize.addElements[e(this).data("customize-setting-link")].origin_element);a.data("source",WPGlobusCore.getString(a.data("source"),a.val())),a.hasClass("wpglobus-control-url")?s.val(t.getString(a.data("source"))):s.val(WPGlobusCore.getString(s.val(),a.val())),a.hasClass("wpglobus-not-trigger-change")||s.trigger("change")})})},addLanguageSelector:function(){e('<a style="margin-left:48px;" class="customize-controls-close wpglobus-customize-selector"><span class="wpglobus-globe"></span></a>').insertAfter(".customize-controls-preview-toggle"),e(".wpglobus-customize-selector").html(t.selectorHtml.replace("{{language}}",WPGlobusCoreData.language))},setPosition:function(t){if(void 0!==t.options.setPosition&&t.options.setPosition){e(t.parent).detach().insertBefore(t.origin_parent),e(t.parent).css({display:"block"})}},addListeners:function(){e(document).on("click",".control-section",function(o){t.positionSet||(t.positionSet=!0,e.each(WPGlobusCoreData.customize.addElements,function(o,a){e(a.origin_parent).css({display:"none"}),e(a.origin_parent+" label").css({display:"none"}),void 0!==a.options&&t.setPosition(a)}))}),e(document).on("click",".wpglobus-customize-selector",function(o){t.index>t.length-1?t.index=0:t.index++,WPGlobusCoreData.language=t.languages[t.index],e(this).html(t.selectorHtml.replace("{{language}}",WPGlobusCoreData.language)),e(".wpglobus-customize-control").each(function(t,o){if(void 0!==WPGlobusCoreData.customize.addElements[e(o).data("customize-setting-link")]){var a=e(WPGlobusCoreData.customize.addElements[e(o).data("customize-setting-link")].origin_element),s=e(o);s.hasClass("wpglobus-control-url")?s.val(WPGlobusCore.TextFilter(s.data("source"),WPGlobusCoreData.language,"RETURN_EMPTY")):s.val(WPGlobusCore.TextFilter(a.val(),WPGlobusCoreData.language,"RETURN_EMPTY"))}})}),e(document).ajaxSend(function(t,o,a){if(void 0!==a.data&&a.data.indexOf("action=customize_save")>=0){var s,n,i=a.data.split("&");e.each(i,function(e,t){"customized"!=(s=t.split("="))[0]||(n=s[1])});var l=decodeURIComponent(n);l=JSON.parse(l),e.each(WPGlobusCoreData.customize.addElements,function(t,o){void 0!==l[t]&&(l[o.origin]=e(WPGlobusCoreData.customize.addElements[t].origin_element).val())}),a.data=a.data.replace(n,JSON.stringify(l))}})}};(WPGlobusCustomize=e.extend({},WPGlobusCustomize,t)).init()}});
includes/js/wpglobus-customize-control140.js ADDED
@@ -0,0 +1,797 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * WPGlobus Customize Control
3
+ * Interface JS functions
4
+ *
5
+ * @since 1.4.0
6
+ *
7
+ * @package WPGlobus
8
+ * @subpackage Customize Control
9
+ */
10
+ /*jslint browser: true*/
11
+ /*global jQuery, console, WPGlobusCore, WPGlobusCoreData, WPGlobusCustomize, WPGlobusCustomizeOptions*/
12
+
13
+ jQuery(document).ready(function ($) {
14
+ "use strict";
15
+
16
+ var api = {
17
+ languages: {},
18
+ index: 0,
19
+ length: 0,
20
+ controlInstances: {},
21
+ controlWidgets: {},
22
+ //controlMenuItems: {},
23
+ instancesKeep: false,
24
+ widgetKeep: false,
25
+ action: false,
26
+ selectorHtml: '<span style="margin-left:5px;" class="wpglobus-icon-globe"></span><span style="font-weight:bold;">{{language}}</span>',
27
+ init: function(args) {
28
+
29
+ api.setTitle();
30
+
31
+ if ( WPGlobusCustomizeOptions.themeEnabled == 'false' ) {
32
+ return;
33
+ }
34
+
35
+ $.each( WPGlobusCoreData.enabled_languages, function(i,e){
36
+ api.languages[i] = e;
37
+ api.length = i;
38
+ });
39
+ api.addLanguageSelector();
40
+ api.setControlInstances();
41
+ api.setFieldsSection(); /* @since 1.6.0 */
42
+ api.attachListeners();
43
+ },
44
+ setFieldsSection: function() {
45
+
46
+ var sections = {},
47
+ $sectionTmpl = $( '.wpglobus-fields_settings_control_box' ).data( 'section-template' ),
48
+ sectionHtml = '',
49
+ itemsHtml = '',
50
+ checked = '';
51
+
52
+ $.each( WPGlobusCustomize.controlInstances, function(id, obj) {
53
+ if ( typeof sections[ obj.section ] === 'undefined' ) {
54
+ sections[ obj.section ] = {};
55
+ }
56
+ sections[ obj.section ][ id ] = obj;
57
+ });
58
+
59
+ $.each( sections, function( section, controls ) {
60
+ itemsHtml = '<ul>';
61
+ $.each( controls, function( id, control ) {
62
+
63
+ if ( control.userControl.enabled ) {
64
+ checked = ' checked ';
65
+ } else {
66
+ checked = ''
67
+ }
68
+ itemsHtml += '<li><input id="wpglobus-cb-control-'+id+'" data-control="'+id+'" class="wpglobus-customize-cb-control" type="checkbox"'+checked+' /> ' + control.title + '</li>';
69
+
70
+ });
71
+ itemsHtml += '</ul>';
72
+
73
+ sectionHtml = $sectionTmpl.replace( '{{section_title}}', wp.customize.section( section ).params.title );
74
+ sectionHtml = sectionHtml.replace( /{{section}}/g, section );
75
+ sectionHtml = sectionHtml.replace( '{{section_id}}', '"'+section+'"' );
76
+ sectionHtml = sectionHtml.replace( '{{items}}', itemsHtml );
77
+
78
+ $( sectionHtml ).insertBefore( $( '#' + WPGlobusCustomizeOptions.userControlSaveButton ) );
79
+ });
80
+
81
+ $( '#accordion-section-wpglobus_fields_settings_section' ).css({'margin-top':'15px'});
82
+ /** add Help button */
83
+ $( WPGlobusCustomizeOptions.helpButton ).insertAfter( $( '#accordion-section-wpglobus_fields_settings_section .customize-action' ) );
84
+ /** hide help by default */
85
+ $( '#accordion-section-wpglobus_fields_settings_section .customize-section-description' ).addClass( 'hidden' );
86
+
87
+ $( '.'+WPGlobusCustomizeOptions.userControlIconClass ).on( 'click', function(ev) {
88
+ var section = $(this).data( 'section' );
89
+ $( WPGlobusCustomizeOptions.userControlBoxSelector ).each( function( i, e ) {
90
+ if ( section == $(e).data( 'section' ) ) {
91
+ $(this).css({'display':'block'});
92
+ } else {
93
+ $(this).css({'display':'none'});
94
+ }
95
+ });
96
+ wp.customize.control( 'wpglobus_fields_settings_section' ).expand();
97
+ });
98
+ /** toggle help */
99
+ $( '.wpglobus-customize-icon-help.customize-help-toggle' ).on( 'click', function(ev) {
100
+ $( '#accordion-section-wpglobus_fields_settings_section .customize-section-description' ).toggleClass( 'hidden' );
101
+ });
102
+
103
+ },
104
+ setUserControls: function( control_id, obj ) {
105
+ var elem = obj.controlSelector + ' ' + obj.selector;
106
+ var cbIcon = '<img class="'+WPGlobusCustomizeOptions.userControlIconClass+'" data-section="'+obj.section+'" style="position:absolute;right:0px;" src="'+WPGlobusCustomizeOptions.userControlIcon+'" />';
107
+ $( cbIcon ).insertBefore( elem );
108
+
109
+ if ( ! obj.userControl.enabled ) {
110
+
111
+ if ( $( elem ).length > 1 ) {
112
+ /**
113
+ * in some cases
114
+ * for example @see Kirki https://wordpress.org/plugins/kirki/
115
+ */
116
+ $( elem ).each( function(i,e) {
117
+ $(e).removeClass( WPGlobusCustomize.controlClass );
118
+ });
119
+ } else {
120
+ $( elem ).removeClass( WPGlobusCustomize.controlClass ).val( obj.setting );
121
+ }
122
+
123
+ }
124
+
125
+ },
126
+ ctrlMenuItemsCallback: function( obj, control ) {
127
+ return;
128
+ // @todo remove from $disabled_setting_mask[]
129
+
130
+ if ( typeof control === 'undefined' ) {
131
+ control = wp.customize.control.instance( obj );
132
+ }
133
+
134
+ if ( typeof api.controlMenuItems[ obj ]['control'] !== 'undefined' ) {
135
+ return;
136
+ }
137
+
138
+ if ( control.elements != 0 ) {
139
+
140
+ api.controlMenuItems[ obj ]['control'] = control;
141
+ api.controlMenuItems[ obj ]['element'] = {};
142
+
143
+ $.each( WPGlobusCustomize.elementSelector, function(i,e){
144
+ var elements = control.container.find(e);
145
+ if ( elements.length > 0 ) {
146
+ $.each( elements, function(i, el) {
147
+ var $e = $(el);
148
+ if ( $e.hasClass( 'edit-menu-item-title' ) ) {
149
+
150
+ api.controlMenuItems[ obj ]['element'][ $e.attr('id') ] = {};
151
+ $e.addClass( 'wpglobus-customize-menu-item-control' );
152
+ $e.attr( 'data-menu-item', obj );
153
+ $e.attr( 'data-element', 'title' );
154
+ api.controlMenuItems[ obj ]['element'][ $e.attr('id') ]['value'] = control.elements.title();
155
+ api.controlMenuItems[ obj ]['element'][ $e.attr('id') ]['element'] = 'title';
156
+
157
+ /** set menu item title */
158
+ control.elements.title(
159
+ WPGlobusCore.TextFilter(
160
+ control.elements.title(),
161
+ WPGlobusCustomize.languageAdmin
162
+ )
163
+ );
164
+
165
+ /* set menu-item-title value */
166
+ $e.val(
167
+ WPGlobusCore.TextFilter(
168
+ api.controlMenuItems[ obj ]['element'][ $e.attr('id') ]['value'],
169
+ WPGlobusCoreData.language,
170
+ 'RETURN_EMPTY'
171
+ )
172
+ );
173
+
174
+ }
175
+ if ( $e.hasClass( 'edit-menu-item-attr-title' ) ) {
176
+
177
+ api.controlMenuItems[ obj ]['element'][ $e.attr('id') ] = {};
178
+ $e.addClass( 'wpglobus-customize-menu-item-control' );
179
+ $e.attr( 'data-menu-item', obj );
180
+ $e.attr( 'data-element', 'attr_title' );
181
+ api.controlMenuItems[ obj ]['element'][ $e.attr('id') ]['value'] = control.elements.attr_title();
182
+ api.controlMenuItems[ obj ]['element'][ $e.attr('id') ]['element'] = 'attr_title';
183
+
184
+ /* set menu-item-attr-title value */
185
+ $e.val(
186
+ WPGlobusCore.TextFilter(
187
+ api.controlMenuItems[ obj ]['element'][ $e.attr('id') ]['value'],
188
+ WPGlobusCoreData.language,
189
+ 'RETURN_EMPTY'
190
+ )
191
+ );
192
+
193
+ }
194
+ });
195
+
196
+ }
197
+ });
198
+
199
+ }
200
+
201
+ },
202
+ ctrlWidgetCallback: function( obj, control ) {
203
+
204
+ api.action = false;
205
+
206
+ if ( typeof api.controlWidgets[obj]['element'] !== 'undefined' ) {
207
+ return;
208
+ }
209
+
210
+ if ( typeof control === 'undefined' ) {
211
+ control = wp.customize.control.instance( obj );
212
+ }
213
+
214
+ api.controlWidgets[ obj ]['element'] = {};
215
+ api.controlWidgets[ obj ]['control'] = control;
216
+ api.controlWidgets[ obj ]['inWidgetTitle'] = control.container.find( '.in-widget-title' );
217
+
218
+ var submit = control.container.find( 'input[type=submit]' );
219
+
220
+ if ( submit.length != 0 ) {
221
+ submit.css({'display':'block'});
222
+ submit.attr( 'data-widget', obj );
223
+ api.controlWidgets[ obj ][ 'submit' ] = submit;
224
+ api.attachWidgetListeners( api.controlWidgets[ obj ] );
225
+ }
226
+
227
+ control.liveUpdateMode = false;
228
+
229
+ if ( typeof control.setting().title === 'undefined' ) {
230
+ api.controlWidgets[ obj ]['inWidgetTitle'].text( '' );
231
+ } else {
232
+ api.controlWidgets[ obj ]['inWidgetTitle'].text( ': ' + WPGlobusCore.TextFilter( control.setting().title, WPGlobusCustomize.languageAdmin ) );
233
+ }
234
+
235
+ $.each( WPGlobusCustomize.elementSelector, function(i,e){
236
+ var elements = control.container.find(e);
237
+ if ( elements.length != 0 ) {
238
+ /** widget can contain set of elements */
239
+ $.each( elements, function( indx, elem ) {
240
+
241
+ if ( 'undefined' === typeof elem.id || '' == elem.id ) {
242
+ /**
243
+ * In widget some elements may don't have id
244
+ * e.g. https://wordpress.org/plugins/widget-context/
245
+ */
246
+ return true;
247
+ }
248
+
249
+ var $element = $( elements[indx] );
250
+
251
+ if ( typeof api.controlWidgets[obj]['element'][ elem.id ] === 'undefined' ) {
252
+ api.controlWidgets[obj]['element'][ elem.id ] = {};
253
+ }
254
+
255
+ $element.addClass( 'wpglobus-customize-widget-control' );
256
+ $element.attr( 'data-widget', obj );
257
+
258
+ api.controlWidgets[obj]['element'][ elem.id ]['element'] = $element;
259
+ api.controlWidgets[obj]['element'][ elem.id ]['setting'] = control.setting();
260
+ api.controlWidgets[obj]['element'][ elem.id ]['selector'] = e;
261
+ api.controlWidgets[obj]['element'][ elem.id ]['value'] = elem.defaultValue;
262
+
263
+ $element.val(
264
+ WPGlobusCore.TextFilter(
265
+ elem.defaultValue,
266
+ WPGlobusCoreData.language,
267
+ 'RETURN_EMPTY'
268
+ )
269
+ );
270
+
271
+ });
272
+
273
+ }
274
+ });
275
+
276
+ /**
277
+ * Event handler after widget was added
278
+ */
279
+ $( document ).triggerHandler( 'wpglobus_customize_control_added_widget', [ obj ] );
280
+
281
+ },
282
+ ctrlCallback: function( context, obj, key ) {
283
+
284
+ var dis = false;
285
+ $.each( WPGlobusCustomize.disabledSections, function(i,e) {
286
+ if ( context.section() == e ) {
287
+ dis = true;
288
+ return false;
289
+ }
290
+ });
291
+
292
+ if (dis) return;
293
+
294
+ $.each( WPGlobusCustomize.disabledSettingMask, function(i,e) {
295
+ /** @see wp.customize.control elements */
296
+ if ( obj.indexOf( e ) >= 0 ){
297
+ dis = true;
298
+ return false;
299
+ }
300
+ });
301
+
302
+ if (dis) return;
303
+
304
+ var control = wp.customize.control.instance( obj );
305
+
306
+ /** check for obj is widget */
307
+ if ( obj.indexOf( 'widget' ) >= 0 ) {
308
+ if ( typeof api.controlWidgets[obj] === 'undefined' ) {
309
+ api.controlWidgets[obj] = {};
310
+ if ( api.action ) {
311
+ api.ctrlWidgetCallback( obj, control );
312
+ }
313
+ }
314
+ api.controlWidgets[ obj ]['parent'] = control.selector;
315
+ return false;
316
+ }
317
+
318
+ /**
319
+ if ( obj.indexOf( 'nav_menu_item' ) >= 0 ) {
320
+ if ( typeof api.controlMenuItems[obj] === 'undefined' ) {
321
+ api.controlMenuItems[obj] = {};
322
+ api.ctrlMenuItemsCallback( obj, control );
323
+ }
324
+ api.controlMenuItems[ obj ]['parent'] = control.selector;
325
+ return false;
326
+ } // */
327
+
328
+ if ( typeof api.controlInstances[ obj ] !== 'undefined' ) {
329
+ return;
330
+ }
331
+
332
+ var controlEnabled = true;
333
+
334
+ $.each( WPGlobusCustomize.elementSelector, function(i,e){
335
+ var element = control.container.find( e );
336
+ if ( element.length != 0 ) {
337
+
338
+ api.controlInstances[obj] = {};
339
+ api.controlInstances[obj]['element'] = element;
340
+ api.controlInstances[obj]['setting'] = control.setting();
341
+ api.controlInstances[obj]['selector'] = e;
342
+ api.controlInstances[obj]['controlSelector'] = control.selector;
343
+ api.controlInstances[obj]['type'] = '';
344
+ api.controlInstances[obj]['section'] = control.section();
345
+ api.controlInstances[obj]['title'] = null;
346
+ api.controlInstances[obj]['userControl'] = null;
347
+
348
+ $.each( WPGlobusCustomize.setLinkBy, function( i, piece ) {
349
+
350
+ if ( obj.indexOf( piece ) >= 0 ) {
351
+ api.controlInstances[obj]['type'] = 'link';
352
+ if ( '' == api.controlInstances[obj]['setting'] ) {
353
+ /** link perhaps was set to empty value */
354
+ api.controlInstances[obj]['setting'] = element[0].defaultValue;
355
+ }
356
+ element.addClass( 'wpglobus-control-link' );
357
+ }
358
+
359
+ });
360
+
361
+ if ( api.controlInstances[obj]['type'] === '' ) {
362
+ if ( e == 'textarea' ) {
363
+ api.controlInstances[obj]['type'] = 'textarea';
364
+ } else {
365
+ api.controlInstances[obj]['type'] = 'text';
366
+ }
367
+ }
368
+
369
+ element.val( WPGlobusCore.TextFilter( api.controlInstances[obj]['setting'], WPGlobusCoreData.language, 'RETURN_EMPTY' ) );
370
+ element.addClass( 'wpglobus-customize-control' );
371
+
372
+ /** use control.selector instead of element.parents('li').attr('id') to get id parent li element */
373
+ //element.attr( 'data-wpglobus-customize-control', element.parents('li').attr('id').replace( 'customize-control-', '') );
374
+ element.attr( 'data-wpglobus-customize-control', api.controlInstances[obj]['controlSelector'].replace( '#customize-control-', '') );
375
+
376
+ if ( api.controlInstances[obj]['type'] == 'link' ) {
377
+ api.controlInstances[obj]['setting'] = api.convertString( element[0].defaultValue );
378
+ };
379
+
380
+ /* Get control title */
381
+ api.controlInstances[obj]['title'] = $( control.selector + ' .customize-control-title' ).text();
382
+
383
+ /* Enable/disable user control */
384
+ if ( WPGlobusCustomizeOptions.userControl !== null &&
385
+ typeof WPGlobusCustomizeOptions.userControl[ WPGlobusCustomizeOptions.themeName ] !== 'undefined' ) {
386
+
387
+ if ( typeof WPGlobusCustomizeOptions.userControl[ WPGlobusCustomizeOptions.themeName ][ obj ] !== 'undefined' &&
388
+ WPGlobusCustomizeOptions.userControl[ WPGlobusCustomizeOptions.themeName ][ obj ] == 'disable' ) {
389
+
390
+ controlEnabled = false;
391
+ }
392
+
393
+ }
394
+ api.controlInstances[obj]['userControl'] = {};
395
+ api.controlInstances[obj]['userControl']['enabled'] = controlEnabled;
396
+
397
+ api.setUserControls( obj, api.controlInstances[obj] );
398
+ }
399
+ });
400
+
401
+ },
402
+ setControlInstances: function() {
403
+ wp.customize.control.each( api.ctrlCallback );
404
+ },
405
+ setTitle: function() {
406
+ $( WPGlobusCoreData.customize.info.element ).html( WPGlobusCoreData.customize.info.html );
407
+ },
408
+ convertString: function(text) {
409
+ if ( typeof text === 'undefined' ) {
410
+ return text;
411
+ }
412
+ var r = [], tr = WPGlobusCore.getTranslations( text ),
413
+ i = 0, rE = true;
414
+ $.each( tr, function(l,e) {
415
+ if ( e == '' ) {
416
+ r[i] = 'null';
417
+ } else {
418
+ rE = false;
419
+ r[i] = e;
420
+ }
421
+ i++;
422
+ });
423
+ if ( rE ) {
424
+ return '';
425
+ }
426
+ return r.join('|||');
427
+ },
428
+ getTranslations: function(text) {
429
+ var t = {},
430
+ ar = text.split('|||');
431
+ $.each(WPGlobusCoreData.enabled_languages, function(i,l){
432
+ t[l] = ar[i] === 'undefined' || ar[i] === 'null' ? '' : ar[i];
433
+ });
434
+ return t;
435
+ },
436
+ getString: function(s, newVal, lang) {
437
+ /** using '|||' mark for correct work with url */
438
+ if ( 'undefined' === typeof( s ) ) {
439
+ return s;
440
+ }
441
+ if ( 'undefined' === typeof( newVal ) ) {
442
+ newVal = '';
443
+ }
444
+ if ( 'undefined' === typeof( lang ) ) {
445
+ lang = WPGlobusCoreData.language;
446
+ }
447
+
448
+ var tr = api.getTranslations(s),
449
+ sR = [], i = 0;
450
+ $.each( tr, function(l,t){
451
+ if ( l == lang ) {
452
+ sR[i] = newVal;
453
+ } else {
454
+ sR[i] = t == '' ? 'null' : t;
455
+ }
456
+ i++;
457
+ });
458
+ sR = sR.join('|||');
459
+ return sR;
460
+ },
461
+ addLanguageSelector: function() {
462
+
463
+ $( WPGlobusCustomize.selectorButton ).insertAfter('.customize-controls-preview-toggle');
464
+ $('.wpglobus-customize-selector').html( api.selectorHtml.replace('{{language}}', WPGlobusCoreData.language) );
465
+
466
+ $( document ).on( 'click', '.wpglobus-customize-selector', function(ev){
467
+ if ( api.index > api.length-1 ) {
468
+ api.index = 0;
469
+ } else {
470
+ api.index++;
471
+ }
472
+
473
+ WPGlobusCoreData.language = api.languages[ api.index ];
474
+
475
+ $(this).html( api.selectorHtml.replace( '{{language}}', WPGlobusCoreData.language ) );
476
+
477
+ /**
478
+ * Event after language was changed
479
+ */
480
+ $( document ).triggerHandler( 'wpglobus_customize_control_language', [ WPGlobusCoreData.language ] );
481
+
482
+ $( '.wpglobus-customize-control' ).each( function(i,e){
483
+ var $e = $(e),
484
+ inst = $e.data( 'customize-setting-link' );
485
+
486
+ if ( 'undefined' === typeof WPGlobusCustomize.controlInstances[inst] ) {
487
+ /**
488
+ * try get control element from attribute data-wpglobus-customize-control
489
+ * for example @see Blink theme, customize control element footer-text instead of blink_footer-text
490
+ */
491
+ inst = $e.data( 'wpglobus-customize-control' );
492
+ if ( 'undefined' === typeof WPGlobusCustomize.controlInstances[inst] ) {
493
+ return;
494
+ }
495
+ }
496
+ if ( $e.hasClass( 'wpglobus-control-link' ) ) {
497
+ var t = api.getTranslations( WPGlobusCustomize.controlInstances[inst].setting );
498
+ $e.val( t[ WPGlobusCoreData.language ] );
499
+ } else {
500
+ $e.val( WPGlobusCore.TextFilter( WPGlobusCustomize.controlInstances[inst].setting, WPGlobusCoreData.language, 'RETURN_EMPTY' ) );
501
+ }
502
+ });
503
+
504
+ /** widgets */
505
+ $( '.wpglobus-customize-widget-control' ).each( function(i, e){
506
+
507
+ var $e = $(e), obj = $e.data( 'widget' );
508
+
509
+ if ( 'undefined' === typeof $e.attr('id') ) {
510
+ return true;
511
+ }
512
+
513
+ $e.val(
514
+ WPGlobusCore.TextFilter(
515
+ WPGlobusCustomize.controlWidgets[ obj ][ 'element' ][ $e.attr('id') ][ 'value' ],
516
+ WPGlobusCoreData.language,
517
+ 'RETURN_EMPTY'
518
+ )
519
+ );
520
+
521
+ });
522
+
523
+ /** menu items */
524
+ /**
525
+ $( '.wpglobus-customize-menu-item-control' ).each( function(i, e){
526
+ var $e = $(e);
527
+
528
+ $e.val(
529
+ WPGlobusCore.TextFilter(
530
+ WPGlobusCustomize.controlMenuItems[ $e.data( 'menu-item' ) ][ 'element' ][ $e.attr('id') ]['value'],
531
+ WPGlobusCoreData.language,
532
+ 'RETURN_EMPTY'
533
+ )
534
+ );
535
+
536
+ }); // */
537
+
538
+ });
539
+
540
+ },
541
+ updateElements: function( force ) {
542
+ if ( typeof force === 'undefined' ) {
543
+ force = true;
544
+ }
545
+ /** updateElements simple controls */
546
+ $.each( WPGlobusCustomize.controlInstances, function( inst, data ) {
547
+ if ( ! data.userControl.enabled ) {
548
+ /* next iteration */
549
+ return true;
550
+ }
551
+ var control = wp.customize.control.instance( inst );
552
+ if ( data.type == 'link' ) {
553
+ var t = api.getTranslations( WPGlobusCustomize.controlInstances[inst].setting );
554
+ if ( force ) {
555
+ control.setting.set( t[ WPGlobusCoreData.language ] );
556
+ data.element.val( control.setting() );
557
+ } else {
558
+ data.element.val( t[ WPGlobusCoreData.language ] );
559
+ }
560
+ } else {
561
+ if ( force ) {
562
+ control.setting.set( WPGlobusCore.TextFilter( WPGlobusCustomize.controlInstances[inst].setting, WPGlobusCoreData.language, 'RETURN_EMPTY' ) );
563
+ data.element.val( control.setting() );
564
+ } else {
565
+ data.element.val( WPGlobusCore.TextFilter( WPGlobusCustomize.controlInstances[inst].setting, WPGlobusCoreData.language, 'RETURN_EMPTY' ) );
566
+ }
567
+ }
568
+ });
569
+
570
+ /** updateElements menu items */
571
+ /**
572
+ $.each( WPGlobusCustomize.controlMenuItems, function( menuItem, object ) {
573
+ if ( typeof object.element === 'undefined' ) {
574
+ return;
575
+ }
576
+ $.each( object.element, function( id, obj ) {
577
+ $( '#' + id ).val(
578
+ WPGlobusCore.TextFilter( obj.value, WPGlobusCoreData.language, 'RETURN_EMPTY' )
579
+ );
580
+ });
581
+ }); // */
582
+ },
583
+ onSubmitEvents: function( ev ) {
584
+
585
+ if ( ev.type == 'mouseenter' ) {
586
+
587
+ $.each( api.controlWidgets[ $(this).data('widget') ]['element'], function(id,e) {
588
+ $( '#' + id ).val( e.value );
589
+ });
590
+
591
+ } else if ( ev.type == 'mouseleave' ) {
592
+
593
+ if ( ! api.widgetKeep ) {
594
+ $.each( api.controlWidgets[ $(this).data('widget') ]['element'], function(id,e) {
595
+ $( '#' + id ).val( WPGlobusCore.TextFilter( e.value, WPGlobusCoreData.language, 'RETURN_EMPTY' ) );
596
+ });
597
+ }
598
+
599
+ } else if ( ev.type == 'click' ) {
600
+ api.widgetKeep = true;
601
+ }
602
+
603
+ },
604
+ attachWidgetListeners: function( obj ) {
605
+
606
+ if ( typeof obj['submit'][0]['id'] !== 'undefined' ) {
607
+
608
+ $( document ).on( 'mouseenter', '#' + obj['submit'][0]['id'], api.onSubmitEvents )
609
+ .on( 'mouseleave', '#' + obj['submit'][0]['id'], api.onSubmitEvents )
610
+ .on( 'click', '#' + obj['submit'][0]['id'], api.onSubmitEvents );
611
+
612
+ }
613
+
614
+ },
615
+ attachListeners: function() {
616
+ /** attachListeners: simple controls */
617
+ $( '.wpglobus-customize-control' ).on( 'keyup', function(ev) {
618
+ var $t = $(this),
619
+ inst = $t.data( 'customize-setting-link' );
620
+
621
+ if ( 'undefined' === typeof WPGlobusCustomize.controlInstances[inst] ) {
622
+ /**
623
+ * try get control element from attribute data-wpglobus-customize-control
624
+ * for example @see Blink theme, customize control element footer-text instead of blink_footer-text
625
+ */
626
+ inst = $t.data( 'wpglobus-customize-control' );
627
+ if ( 'undefined' === typeof WPGlobusCustomize.controlInstances[inst] ) {
628
+ return;
629
+ }
630
+ }
631
+
632
+ if ( WPGlobusCustomize.controlInstances[inst]['type'] == 'link' ) {
633
+
634
+ WPGlobusCustomize.controlInstances[inst]['setting'] = api.getString(
635
+ WPGlobusCustomize.controlInstances[inst]['setting'],
636
+ $t.val(),
637
+ WPGlobusCoreData.language
638
+ );
639
+
640
+ } else {
641
+
642
+ WPGlobusCustomize.controlInstances[inst]['setting'] = WPGlobusCore.getString(
643
+ WPGlobusCustomize.controlInstances[inst]['setting'],
644
+ $t.val(),
645
+ WPGlobusCoreData.language
646
+ );
647
+
648
+ }
649
+ });
650
+
651
+ /** attachListeners: widgets */
652
+ $( document ).on( 'keyup', '.wpglobus-customize-widget-control', function(ev) {
653
+ var $t = $(this),
654
+ obj = $t.data( 'widget' );
655
+
656
+ if ( 'undefined' === typeof WPGlobusCustomize.controlWidgets[ obj ] ) {
657
+ return;
658
+ }
659
+
660
+ WPGlobusCustomize.controlWidgets[ obj ]['element'][ $t.attr('id') ]['value'] = WPGlobusCore.getString(
661
+ WPGlobusCustomize.controlWidgets[ obj ]['element'][ $t.attr('id') ]['value'],
662
+ $t.val(),
663
+ WPGlobusCoreData.language
664
+ );
665
+
666
+ });
667
+
668
+ /** attachListeners: menu items */
669
+ /**
670
+ $( document ).on( 'keyup', '.wpglobus-customize-menu-item-control', function(ev) {
671
+ var $t = $(this),
672
+ obj = $t.data( 'menu-item' );
673
+
674
+ if ( 'undefined' === typeof WPGlobusCustomize.controlMenuItems[ obj ] ) {
675
+ return;
676
+ }
677
+
678
+ WPGlobusCustomize.controlMenuItems[ obj ]['element'][ $t.attr('id') ][ 'value' ] = WPGlobusCore.getString(
679
+ WPGlobusCustomize.controlMenuItems[ obj ]['element'][ $t.attr('id') ][ 'value' ],
680
+ $t.val(),
681
+ WPGlobusCoreData.language
682
+ );
683
+
684
+ }); // */
685
+
686
+ /** attachListeners: Save&Publish button */
687
+ $( '#save' ).on( 'mouseenter', function( event ) {
688
+
689
+ /** Save&Publish simple controls */
690
+ $.each( WPGlobusCustomize.controlInstances, function( inst, data ) {
691
+ if ( data.userControl.enabled ) {
692
+ var control = wp.customize.control.instance( inst );
693
+ control.setting.set( data.setting );
694
+ data.element.val( control.setting() );
695
+ }
696
+ });
697
+
698
+ /** Save&Publish menu items */
699
+ /**
700
+ $.each( WPGlobusCustomize.controlMenuItems, function( menuItem, object ) {
701
+ if ( typeof object.element === 'undefined' ) {
702
+ return;
703
+ }
704
+ var control = wp.customize.control.instance( menuItem );
705
+ $.each( object.element, function( id, obj ) {
706
+ $( '#' + id ).val( obj.value );
707
+ control.elements[ obj.element ]( obj.value );
708
+ });
709
+ }); // */
710
+
711
+ }).on( 'mouseleave', function( event ) {
712
+ if ( ! api.instancesKeep ) {
713
+ api.updateElements();
714
+ }
715
+ }).on( 'click', function(event){
716
+ api.instancesKeep = true;
717
+ });
718
+
719
+ /**
720
+ * attachListeners: ajaxComplete event handler
721
+ */
722
+ $(document).on( 'ajaxComplete', function( ev, response ) {
723
+
724
+ if ( typeof response.responseText === 'undefined' ) {
725
+ return;
726
+ }
727
+
728
+ if ( '{"success":true,"data":[]}' == response.responseText ) {
729
+
730
+ /** Save&Publish ajax complete */
731
+ api.updateElements( false );
732
+
733
+ } else {
734
+
735
+ if ( response.responseText.indexOf( 'WP_CUSTOMIZER_SIGNATURE' ) >= 0 ) {
736
+ api.action = 'customizerAjaxComplete';
737
+ api.setControlInstances();
738
+ }
739
+
740
+ $.each( WPGlobusCustomize.controlWidgets, function( obj, data ) {
741
+ /** Apply widget ajax complete */
742
+
743
+ var w = obj.replace( '_', '-' );
744
+
745
+ if ( response.responseText.indexOf( w ) >= 0 ) {
746
+
747
+ data.submit.css({'display':'block'});
748
+ data.control.liveUpdateMode = false;
749
+
750
+ $.each( data['element'], function( id, e ) {
751
+ $( '#' + id ).val( WPGlobusCore.TextFilter( e.value, WPGlobusCoreData.language, 'RETURN_EMPTY' ) );
752
+ });
753
+
754
+ data.inWidgetTitle.text( ': ' + WPGlobusCore.TextFilter( data.control.setting().title, WPGlobusCustomize.languageAdmin ) );
755
+ api.widgetKeep = false;
756
+
757
+ return false;
758
+ }
759
+
760
+ });
761
+
762
+ }
763
+
764
+ });
765
+
766
+ /**
767
+ * attachListeners: Event handler for tracking clicks by widgets title
768
+ */
769
+ $(document).on( 'click', '.widget-title, .widget-title-action', function(ev){
770
+ var id = $(this).parents( '.customize-control-widget_form' ).attr( 'id' );
771
+ $.each( api.controlWidgets, function( obj, d ) {
772
+ if ( '#'+id == d.parent ) {
773
+ api.ctrlWidgetCallback( obj );
774
+ return false;
775
+ }
776
+ });
777
+ });
778
+
779
+ /**
780
+ * attachListeners: Event handler for tracking clicks by menu item title
781
+ */
782
+ /**
783
+ $(document).on( 'click', '.control-section-nav_menu .accordion-section-title', function(ev){
784
+ $.each( api.controlMenuItems, function( obj, d ) {
785
+ api.ctrlMenuItemsCallback( obj );
786
+ });
787
+ }); // */
788
+
789
+
790
+ }
791
+ };
792
+
793
+ WPGlobusCustomize = $.extend( {}, WPGlobusCustomize, api );
794
+
795
+ WPGlobusCustomize.init();
796
+
797
+ });
includes/js/wpglobus-customize-control140.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(document).ready(function(t){"use strict";var e={languages:{},index:0,length:0,controlInstances:{},controlWidgets:{},instancesKeep:!1,widgetKeep:!1,action:!1,selectorHtml:'<span style="margin-left:5px;" class="wpglobus-icon-globe"></span><span style="font-weight:bold;">{{language}}</span>',init:function(o){e.setTitle(),"false"!=WPGlobusCustomizeOptions.themeEnabled&&(t.each(WPGlobusCoreData.enabled_languages,function(t,o){e.languages[t]=o,e.length=t}),e.addLanguageSelector(),e.setControlInstances(),e.setFieldsSection(),e.attachListeners())},setFieldsSection:function(){var e={},o=t(".wpglobus-fields_settings_control_box").data("section-template"),n="",s="",l="";t.each(WPGlobusCustomize.controlInstances,function(t,o){void 0===e[o.section]&&(e[o.section]={}),e[o.section][t]=o}),t.each(e,function(e,i){s="<ul>",t.each(i,function(t,e){l=e.userControl.enabled?" checked ":"",s+='<li><input id="wpglobus-cb-control-'+t+'" data-control="'+t+'" class="wpglobus-customize-cb-control" type="checkbox"'+l+" /> "+e.title+"</li>"}),s+="</ul>",n=(n=(n=(n=o.replace("{{section_title}}",wp.customize.section(e).params.title)).replace(/{{section}}/g,e)).replace("{{section_id}}",'"'+e+'"')).replace("{{items}}",s),t(n).insertBefore(t("#"+WPGlobusCustomizeOptions.userControlSaveButton))}),t("#accordion-section-wpglobus_fields_settings_section").css({"margin-top":"15px"}),t(WPGlobusCustomizeOptions.helpButton).insertAfter(t("#accordion-section-wpglobus_fields_settings_section .customize-action")),t("#accordion-section-wpglobus_fields_settings_section .customize-section-description").addClass("hidden"),t("."+WPGlobusCustomizeOptions.userControlIconClass).on("click",function(e){var o=t(this).data("section");t(WPGlobusCustomizeOptions.userControlBoxSelector).each(function(e,n){o==t(n).data("section")?t(this).css({display:"block"}):t(this).css({display:"none"})}),wp.customize.control("wpglobus_fields_settings_section").expand()}),t(".wpglobus-customize-icon-help.customize-help-toggle").on("click",function(e){t("#accordion-section-wpglobus_fields_settings_section .customize-section-description").toggleClass("hidden")})},setUserControls:function(e,o){var n=o.controlSelector+" "+o.selector,s='<img class="'+WPGlobusCustomizeOptions.userControlIconClass+'" data-section="'+o.section+'" style="position:absolute;right:0px;" src="'+WPGlobusCustomizeOptions.userControlIcon+'" />';t(s).insertBefore(n),o.userControl.enabled||(t(n).length>1?t(n).each(function(e,o){t(o).removeClass(WPGlobusCustomize.controlClass)}):t(n).removeClass(WPGlobusCustomize.controlClass).val(o.setting))},ctrlMenuItemsCallback:function(t,e){},ctrlWidgetCallback:function(o,n){if(e.action=!1,void 0===e.controlWidgets[o].element){void 0===n&&(n=wp.customize.control.instance(o)),e.controlWidgets[o].element={},e.controlWidgets[o].control=n,e.controlWidgets[o].inWidgetTitle=n.container.find(".in-widget-title");var s=n.container.find("input[type=submit]");0!=s.length&&(s.css({display:"block"}),s.attr("data-widget",o),e.controlWidgets[o].submit=s,e.attachWidgetListeners(e.controlWidgets[o])),n.liveUpdateMode=!1,void 0===n.setting().title?e.controlWidgets[o].inWidgetTitle.text(""):e.controlWidgets[o].inWidgetTitle.text(": "+WPGlobusCore.TextFilter(n.setting().title,WPGlobusCustomize.languageAdmin)),t.each(WPGlobusCustomize.elementSelector,function(s,l){var i=n.container.find(l);0!=i.length&&t.each(i,function(s,a){if(void 0===a.id||""==a.id)return!0;var c=t(i[s]);void 0===e.controlWidgets[o].element[a.id]&&(e.controlWidgets[o].element[a.id]={}),c.addClass("wpglobus-customize-widget-control"),c.attr("data-widget",o),e.controlWidgets[o].element[a.id].element=c,e.controlWidgets[o].element[a.id].setting=n.setting(),e.controlWidgets[o].element[a.id].selector=l,e.controlWidgets[o].element[a.id].value=a.defaultValue,c.val(WPGlobusCore.TextFilter(a.defaultValue,WPGlobusCoreData.language,"RETURN_EMPTY"))})}),t(document).triggerHandler("wpglobus_customize_control_added_widget",[o])}},ctrlCallback:function(o,n,s){var l=!1;if(t.each(WPGlobusCustomize.disabledSections,function(t,e){if(o.section()==e)return l=!0,!1}),!l&&(t.each(WPGlobusCustomize.disabledSettingMask,function(t,e){if(n.indexOf(e)>=0)return l=!0,!1}),!l)){var i=wp.customize.control.instance(n);if(n.indexOf("widget")>=0)return void 0===e.controlWidgets[n]&&(e.controlWidgets[n]={},e.action&&e.ctrlWidgetCallback(n,i)),e.controlWidgets[n].parent=i.selector,!1;if(void 0===e.controlInstances[n]){var a=!0;t.each(WPGlobusCustomize.elementSelector,function(o,s){var l=i.container.find(s);0!=l.length&&(e.controlInstances[n]={},e.controlInstances[n].element=l,e.controlInstances[n].setting=i.setting(),e.controlInstances[n].selector=s,e.controlInstances[n].controlSelector=i.selector,e.controlInstances[n].type="",e.controlInstances[n].section=i.section(),e.controlInstances[n].title=null,e.controlInstances[n].userControl=null,t.each(WPGlobusCustomize.setLinkBy,function(t,o){n.indexOf(o)>=0&&(e.controlInstances[n].type="link",""==e.controlInstances[n].setting&&(e.controlInstances[n].setting=l[0].defaultValue),l.addClass("wpglobus-control-link"))}),""===e.controlInstances[n].type&&(e.controlInstances[n].type="textarea"==s?"textarea":"text"),l.val(WPGlobusCore.TextFilter(e.controlInstances[n].setting,WPGlobusCoreData.language,"RETURN_EMPTY")),l.addClass("wpglobus-customize-control"),l.attr("data-wpglobus-customize-control",e.controlInstances[n].controlSelector.replace("#customize-control-","")),"link"==e.controlInstances[n].type&&(e.controlInstances[n].setting=e.convertString(l[0].defaultValue)),e.controlInstances[n].title=t(i.selector+" .customize-control-title").text(),null!==WPGlobusCustomizeOptions.userControl&&void 0!==WPGlobusCustomizeOptions.userControl[WPGlobusCustomizeOptions.themeName]&&void 0!==WPGlobusCustomizeOptions.userControl[WPGlobusCustomizeOptions.themeName][n]&&"disable"==WPGlobusCustomizeOptions.userControl[WPGlobusCustomizeOptions.themeName][n]&&(a=!1),e.controlInstances[n].userControl={},e.controlInstances[n].userControl.enabled=a,e.setUserControls(n,e.controlInstances[n]))})}}},setControlInstances:function(){wp.customize.control.each(e.ctrlCallback)},setTitle:function(){t(WPGlobusCoreData.customize.info.element).html(WPGlobusCoreData.customize.info.html)},convertString:function(e){if(void 0===e)return e;var o=[],n=WPGlobusCore.getTranslations(e),s=0,l=!0;return t.each(n,function(t,e){""==e?o[s]="null":(l=!1,o[s]=e),s++}),l?"":o.join("|||")},getTranslations:function(e){var o={},n=e.split("|||");return t.each(WPGlobusCoreData.enabled_languages,function(t,e){o[e]="undefined"===n[t]||"null"===n[t]?"":n[t]}),o},getString:function(o,n,s){if(void 0===o)return o;void 0===n&&(n=""),void 0===s&&(s=WPGlobusCoreData.language);var l=e.getTranslations(o),i=[],a=0;return t.each(l,function(t,e){i[a]=t==s?n:""==e?"null":e,a++}),i=i.join("|||")},addLanguageSelector:function(){t(WPGlobusCustomize.selectorButton).insertAfter(".customize-controls-preview-toggle"),t(".wpglobus-customize-selector").html(e.selectorHtml.replace("{{language}}",WPGlobusCoreData.language)),t(document).on("click",".wpglobus-customize-selector",function(o){e.index>e.length-1?e.index=0:e.index++,WPGlobusCoreData.language=e.languages[e.index],t(this).html(e.selectorHtml.replace("{{language}}",WPGlobusCoreData.language)),t(document).triggerHandler("wpglobus_customize_control_language",[WPGlobusCoreData.language]),t(".wpglobus-customize-control").each(function(o,n){var s=t(n),l=s.data("customize-setting-link");if(void 0!==WPGlobusCustomize.controlInstances[l]||(l=s.data("wpglobus-customize-control"),void 0!==WPGlobusCustomize.controlInstances[l]))if(s.hasClass("wpglobus-control-link")){var i=e.getTranslations(WPGlobusCustomize.controlInstances[l].setting);s.val(i[WPGlobusCoreData.language])}else s.val(WPGlobusCore.TextFilter(WPGlobusCustomize.controlInstances[l].setting,WPGlobusCoreData.language,"RETURN_EMPTY"))}),t(".wpglobus-customize-widget-control").each(function(e,o){var n=t(o),s=n.data("widget");if(void 0===n.attr("id"))return!0;n.val(WPGlobusCore.TextFilter(WPGlobusCustomize.controlWidgets[s].element[n.attr("id")].value,WPGlobusCoreData.language,"RETURN_EMPTY"))})})},updateElements:function(o){void 0===o&&(o=!0),t.each(WPGlobusCustomize.controlInstances,function(t,n){if(!n.userControl.enabled)return!0;var s=wp.customize.control.instance(t);if("link"==n.type){var l=e.getTranslations(WPGlobusCustomize.controlInstances[t].setting);o?(s.setting.set(l[WPGlobusCoreData.language]),n.element.val(s.setting())):n.element.val(l[WPGlobusCoreData.language])}else o?(s.setting.set(WPGlobusCore.TextFilter(WPGlobusCustomize.controlInstances[t].setting,WPGlobusCoreData.language,"RETURN_EMPTY")),n.element.val(s.setting())):n.element.val(WPGlobusCore.TextFilter(WPGlobusCustomize.controlInstances[t].setting,WPGlobusCoreData.language,"RETURN_EMPTY"))})},onSubmitEvents:function(o){"mouseenter"==o.type?t.each(e.controlWidgets[t(this).data("widget")].element,function(e,o){t("#"+e).val(o.value)}):"mouseleave"==o.type?e.widgetKeep||t.each(e.controlWidgets[t(this).data("widget")].element,function(e,o){t("#"+e).val(WPGlobusCore.TextFilter(o.value,WPGlobusCoreData.language,"RETURN_EMPTY"))}):"click"==o.type&&(e.widgetKeep=!0)},attachWidgetListeners:function(o){void 0!==o.submit[0].id&&t(document).on("mouseenter","#"+o.submit[0].id,e.onSubmitEvents).on("mouseleave","#"+o.submit[0].id,e.onSubmitEvents).on("click","#"+o.submit[0].id,e.onSubmitEvents)},attachListeners:function(){t(".wpglobus-customize-control").on("keyup",function(o){var n=t(this),s=n.data("customize-setting-link");void 0===WPGlobusCustomize.controlInstances[s]&&(s=n.data("wpglobus-customize-control"),void 0===WPGlobusCustomize.controlInstances[s])||("link"==WPGlobusCustomize.controlInstances[s].type?WPGlobusCustomize.controlInstances[s].setting=e.getString(WPGlobusCustomize.controlInstances[s].setting,n.val(),WPGlobusCoreData.language):WPGlobusCustomize.controlInstances[s].setting=WPGlobusCore.getString(WPGlobusCustomize.controlInstances[s].setting,n.val(),WPGlobusCoreData.language))}),t(document).on("keyup",".wpglobus-customize-widget-control",function(e){var o=t(this),n=o.data("widget");void 0!==WPGlobusCustomize.controlWidgets[n]&&(WPGlobusCustomize.controlWidgets[n].element[o.attr("id")].value=WPGlobusCore.getString(WPGlobusCustomize.controlWidgets[n].element[o.attr("id")].value,o.val(),WPGlobusCoreData.language))}),t("#save").on("mouseenter",function(e){t.each(WPGlobusCustomize.controlInstances,function(t,e){if(e.userControl.enabled){var o=wp.customize.control.instance(t);o.setting.set(e.setting),e.element.val(o.setting())}})}).on("mouseleave",function(t){e.instancesKeep||e.updateElements()}).on("click",function(t){e.instancesKeep=!0}),t(document).on("ajaxComplete",function(o,n){void 0!==n.responseText&&('{"success":true,"data":[]}'==n.responseText?e.updateElements(!1):(n.responseText.indexOf("WP_CUSTOMIZER_SIGNATURE")>=0&&(e.action="customizerAjaxComplete",e.setControlInstances()),t.each(WPGlobusCustomize.controlWidgets,function(o,s){var l=o.replace("_","-");if(n.responseText.indexOf(l)>=0)return s.submit.css({display:"block"}),s.control.liveUpdateMode=!1,t.each(s.element,function(e,o){t("#"+e).val(WPGlobusCore.TextFilter(o.value,WPGlobusCoreData.language,"RETURN_EMPTY"))}),s.inWidgetTitle.text(": "+WPGlobusCore.TextFilter(s.control.setting().title,WPGlobusCustomize.languageAdmin)),e.widgetKeep=!1,!1})))}),t(document).on("click",".widget-title, .widget-title-action",function(o){var n=t(this).parents(".customize-control-widget_form").attr("id");t.each(e.controlWidgets,function(t,o){if("#"+n==o.parent)return e.ctrlWidgetCallback(t),!1})})}};WPGlobusCustomize=t.extend({},WPGlobusCustomize,e),WPGlobusCustomize.init()});
includes/js/wpglobus-customize-control170.js ADDED
@@ -0,0 +1,1069 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * WPGlobus Customize Control
3
+ * Interface JS functions
4
+ *
5
+ * @since 1.7.0
6
+ *
7
+ * @package WPGlobus
8
+ * @subpackage Customize Control
9
+ */
10
+ /*jslint browser: true*/
11
+ /*global jQuery, console, WPGlobusCore, WPGlobusCoreData, WPGlobusCustomize, WPGlobusCustomizeOptions*/
12
+
13
+ jQuery(document).ready(function ($) {
14
+ "use strict";
15
+
16
+ var api = {
17
+ languages: {},
18
+ index: 0,
19
+ length: 0,
20
+ controlInstances: {},
21
+ controlWidgets: {},
22
+ //controlMenuItems: {},
23
+ instancesKeep: false,
24
+ widgetKeep: false,
25
+ action: false,
26
+ customizeSave: false,
27
+ selectorHtml: '<span style="margin-left:5px;" class="wpglobus-icon-globe"></span><span style="font-weight:bold;">{{language}}</span>',
28
+ settingsSectionExpand: function() {
29
+ $(document).triggerHandler( 'wpglobus_fields_settings_section_expand', [this, api] );
30
+ },
31
+ init: function(args) {
32
+
33
+ api.setTitle();
34
+
35
+ if ( WPGlobusCustomizeOptions.themeEnabled == 'false' ) {
36
+ return;
37
+ }
38
+
39
+ $.each( WPGlobusCoreData.enabled_languages, function(i,e){
40
+ api.languages[i] = e;
41
+ api.length = i;
42
+ });
43
+ api.addLanguageSelector();
44
+ api.setControlInstances();
45
+ api.setFieldsSection(); /* @since 1.6.0 */
46
+ api.attachListeners();
47
+ /**
48
+ * @since 1.8.2
49
+ */
50
+ api.setTinymce();
51
+ },
52
+ updateTinymce: function(event) {
53
+ if ( 'tinymce' == WPGlobusCustomize.controlInstances[this.id]['type'] ) {
54
+ WPGlobusCustomize.controlInstances[this.id]['setting'] =
55
+ WPGlobusCore.getString( WPGlobusCustomize.controlInstances[this.id]['setting'], event.target.textContent, WPGlobusCoreData.language );
56
+ }
57
+ },
58
+ setTinymce: function(type) {
59
+ /**
60
+ * If theme uses tinymce editor then we need to add 'tinymce-editor-init' event listener.
61
+ */
62
+ $(document).on('tinymce-editor-init', function( event, editor ) {
63
+ if ( 'object' === typeof api.controlInstances[editor.id] ) {
64
+ /**
65
+ * Set type of control instance as 'tinymce'.
66
+ */
67
+ api.controlInstances[editor.id]['type'] = 'tinymce';
68
+ $(editor.iframeElement).addClass('wpglobus-customize-control').css({'width':'99%'});
69
+ editor.on( 'input', _.debounce( api.updateTinymce, 300 ) );
70
+ }
71
+ });
72
+ },
73
+ getSize: function(type) {
74
+ if ( 'undefined' === typeof type ) {
75
+ return _.size( api.controlInstances );
76
+ } else if ( 'widget' == type ) {
77
+ return _.size( api.controlWidgets );
78
+ } else if ( 'nav_menu' == type ) {
79
+ //return _.size( api.controlMenuItems );
80
+ }
81
+ return null;
82
+ },
83
+ setFieldsSection: function() {
84
+
85
+ var sections = {},
86
+ $sectionTmpl = $( '.wpglobus-fields_settings_control_box' ).data( 'section-template' ),
87
+ sectionHtml = '',
88
+ itemsHtml = '',
89
+ checked = '';
90
+
91
+ $.each( WPGlobusCustomize.controlInstances, function(id, obj) {
92
+ if ( typeof sections[ obj.section ] === 'undefined' ) {
93
+ sections[ obj.section ] = {};
94
+ }
95
+ sections[ obj.section ][ id ] = obj;
96
+ });
97
+
98
+ $.each( sections, function( section, controls ) {
99
+ itemsHtml = '<ul>';
100
+ $.each( controls, function( id, control ) {
101
+
102
+ if ( control.userControl.enabled ) {
103
+ checked = ' checked ';
104
+ } else {
105
+ checked = '';
106
+ }
107
+ itemsHtml += '<li id="'+control.fieldSettings.itemID+'">';
108
+ itemsHtml += '<input id="'+control.fieldSettings.cbID+'" data-control="'+id+'" class="wpglobus-customize-cb-control" type="checkbox"'+checked+' /> ' + '<span class="wpglobus-cb-control-title">'+control.title+'</span>';
109
+ itemsHtml += '</li>';
110
+ });
111
+ itemsHtml += '</ul>';
112
+
113
+ if ( 'undefined' === typeof wp.customize.section( section ) ) {
114
+ /**
115
+ * Case when theme's author removed a panel ( $wp_customize->remove_panel )
116
+ * but did not remove its sections ( $wp_customize->remove_section ).
117
+ * The orphaned sections have "undefined" type.
118
+ * For example, the "About us" and "Contact us" sections in
119
+ * @link https://wordpress.org/themes/responsiveboat/
120
+ *
121
+ * @since 1.7.8.2
122
+ */
123
+ return true;
124
+ }
125
+
126
+ sectionHtml = $sectionTmpl.replace( '{{section_title}}', wp.customize.section( section ).params.title );
127
+ sectionHtml = sectionHtml.replace( /{{section}}/g, section );
128
+ sectionHtml = sectionHtml.replace( '{{section_id}}', '"'+section+'"' );
129
+ sectionHtml = sectionHtml.replace( '{{items}}', itemsHtml );
130
+
131
+ $( sectionHtml ).insertBefore( $( '#' + WPGlobusCustomizeOptions.userControlSaveButton ) );
132
+ });
133
+
134
+ $( '#accordion-section-wpglobus_fields_settings_section' ).css({'margin-top':'15px'});
135
+ /** add Help button */
136
+ $( WPGlobusCustomizeOptions.helpButton ).insertAfter( $( '#accordion-section-wpglobus_fields_settings_section .customize-action' ) );
137
+ /**
138
+ * Hide help by default.
139
+ */
140
+ $( '#accordion-section-wpglobus_fields_settings_section .customize-section-description' ).addClass( 'hidden' );
141
+
142
+ /**
143
+ * Attach an event handler for user control icon.
144
+ */
145
+ $(document).on( 'click', '.'+WPGlobusCustomizeOptions.userControlIconClass, function(ev) {
146
+ var section = $(this).data( 'section' );
147
+ $( WPGlobusCustomizeOptions.userControlBoxSelector ).each( function( i, e ) {
148
+ if ( section == $(e).data( 'section' ) ) {
149
+ $(this).css({'display':'block'});
150
+ } else {
151
+ $(this).css({'display':'none'});
152
+ }
153
+ });
154
+ wp.customize.control( 'wpglobus_fields_settings_section' ).expand({
155
+ completeCallback: api.settingsSectionExpand
156
+ });
157
+ });
158
+
159
+ /**
160
+ * Toggle help.
161
+ */
162
+ $( '.wpglobus-customize-icon-help.customize-help-toggle' ).on( 'click', function(ev) {
163
+ $( '#accordion-section-wpglobus_fields_settings_section .customize-section-description' ).toggleClass( 'hidden' );
164
+ });
165
+
166
+ },
167
+ setUserControls: function( control_id, obj ) {
168
+ var elem = obj.controlSelector + ' ' + obj.selector;
169
+ var cbIcon = '<img class="'+WPGlobusCustomizeOptions.userControlIconClass+'" data-section="'+obj.section+'" style="position:absolute;right:0px;cursor:pointer;" src="'+WPGlobusCustomizeOptions.userControlIcon+'" />';
170
+ $( cbIcon ).insertBefore( elem );
171
+
172
+ if ( ! obj.userControl.enabled ) {
173
+
174
+ if ( $( elem ).length > 1 ) {
175
+ /**
176
+ * in some cases
177
+ * for example @see Kirki https://wordpress.org/plugins/kirki/
178
+ */
179
+ $( elem ).each( function(i,e) {
180
+ $(e).removeClass( WPGlobusCustomize.controlClass );
181
+ });
182
+ } else {
183
+ $( elem ).removeClass( WPGlobusCustomize.controlClass ).val( obj.setting );
184
+ }
185
+
186
+ }
187
+
188
+ },
189
+ ctrlMenuItemsCallback: function( obj, control ) {
190
+ return;
191
+ /**
192
+ * @todo remove from $disabled_setting_mask[]
193
+ */
194
+ if ( typeof control === 'undefined' ) {
195
+ control = wp.customize.control.instance( obj );
196
+ }
197
+
198
+ if ( typeof api.controlMenuItems[ obj ]['control'] !== 'undefined' ) {
199
+ return;
200
+ }
201
+
202
+ if ( control.elements != 0 ) {
203
+
204
+ api.controlMenuItems[ obj ]['control'] = control;
205
+ api.controlMenuItems[ obj ]['element'] = {};
206
+
207
+ $.each( WPGlobusCustomize.elementSelector, function(i,e){
208
+ var elements = control.container.find(e);
209
+ if ( elements.length > 0 ) {
210
+ $.each( elements, function(i, el) {
211
+ var $e = $(el);
212
+ if ( $e.hasClass( 'edit-menu-item-title' ) ) {
213
+
214
+ api.controlMenuItems[ obj ]['element'][ $e.attr('id') ] = {};
215
+ $e.addClass( 'wpglobus-customize-menu-item-control' );
216
+ $e.attr( 'data-menu-item', obj );
217
+ $e.attr( 'data-element', 'title' );
218
+ api.controlMenuItems[ obj ]['element'][ $e.attr('id') ]['value'] = control.elements.title();
219
+ api.controlMenuItems[ obj ]['element'][ $e.attr('id') ]['element'] = 'title';
220
+
221
+ /** set menu item title */
222
+ control.elements.title(
223
+ WPGlobusCore.TextFilter(
224
+ control.elements.title(),
225
+ WPGlobusCustomize.languageAdmin
226
+ )
227
+ );
228
+
229
+ /**
230
+ * Set menu-item-title value.
231
+ */
232
+ $e.val(
233
+ WPGlobusCore.TextFilter(
234
+ api.controlMenuItems[ obj ]['element'][ $e.attr('id') ]['value'],
235
+ WPGlobusCoreData.language,
236
+ 'RETURN_EMPTY'
237
+ )
238
+ );
239
+
240
+ }
241
+ if ( $e.hasClass( 'edit-menu-item-attr-title' ) ) {
242
+
243
+ api.controlMenuItems[ obj ]['element'][ $e.attr('id') ] = {};
244
+ $e.addClass( 'wpglobus-customize-menu-item-control' );
245
+ $e.attr( 'data-menu-item', obj );
246
+ $e.attr( 'data-element', 'attr_title' );
247
+ api.controlMenuItems[ obj ]['element'][ $e.attr('id') ]['value'] = control.elements.attr_title();
248
+ api.controlMenuItems[ obj ]['element'][ $e.attr('id') ]['element'] = 'attr_title';
249
+
250
+ /**
251
+ * Set menu-item-attr-title value.
252
+ */
253
+ $e.val(
254
+ WPGlobusCore.TextFilter(
255
+ api.controlMenuItems[ obj ]['element'][ $e.attr('id') ]['value'],
256
+ WPGlobusCoreData.language,
257
+ 'RETURN_EMPTY'
258
+ )
259
+ );
260
+
261
+ }
262
+ });
263
+
264
+ }
265
+ });
266
+
267
+ }
268
+
269
+ },
270
+ ctrlWidgetCallback: function( obj, control ) {
271
+
272
+ api.action = false;
273
+
274
+ if ( typeof api.controlWidgets[obj]['element'] !== 'undefined' ) {
275
+ return;
276
+ }
277
+
278
+ if ( typeof control === 'undefined' ) {
279
+ control = wp.customize.control.instance( obj );
280
+ }
281
+
282
+ api.controlWidgets[ obj ]['element'] = {};
283
+ api.controlWidgets[ obj ]['control'] = control;
284
+ api.controlWidgets[ obj ]['inWidgetTitle'] = control.container.find( '.in-widget-title' );
285
+
286
+ api.controlWidgets[ obj ]['parent'] = control.selector;
287
+
288
+ var submit = control.container.find( 'input[type=submit]' );
289
+
290
+ if ( submit.length != 0 ) {
291
+ submit.css({'display':'block'});
292
+ submit.attr( 'data-widget', obj );
293
+ api.controlWidgets[ obj ][ 'submit' ] = submit;
294
+ api.attachWidgetListeners( api.controlWidgets[ obj ] );
295
+ }
296
+
297
+ control.liveUpdateMode = false;
298
+
299
+ if ( typeof control.setting().title === 'undefined' ) {
300
+ api.controlWidgets[ obj ]['inWidgetTitle'].text( '' );
301
+ } else {
302
+ api.controlWidgets[ obj ]['inWidgetTitle'].text( ': ' + WPGlobusCore.TextFilter( control.setting().title, WPGlobusCustomize.languageAdmin ) );
303
+ }
304
+
305
+ $.each( WPGlobusCustomize.elementSelector, function(i,e){
306
+ var elements = control.container.find(e);
307
+ if ( elements.length != 0 ) {
308
+ /**
309
+ * Widget can contain set of elements.
310
+ */
311
+ $.each( elements, function( indx, elem ) {
312
+
313
+ if ( 'undefined' === typeof elem.id || '' == elem.id ) {
314
+ /**
315
+ * In widget some elements may don't have id
316
+ * e.g. https://wordpress.org/plugins/widget-context/
317
+ */
318
+ return true;
319
+ }
320
+
321
+ var $element = $( elements[indx] );
322
+
323
+ if ( typeof api.controlWidgets[obj]['element'][ elem.id ] === 'undefined' ) {
324
+ api.controlWidgets[obj]['element'][ elem.id ] = {};
325
+ }
326
+
327
+ $element.addClass( 'wpglobus-customize-widget-control' );
328
+ $element.attr( 'data-widget', obj );
329
+
330
+ api.controlWidgets[obj]['element'][ elem.id ]['element'] = $element;
331
+ api.controlWidgets[obj]['element'][ elem.id ]['setting'] = control.setting();
332
+ api.controlWidgets[obj]['element'][ elem.id ]['selector'] = e;
333
+ api.controlWidgets[obj]['element'][ elem.id ]['value'] = elem.defaultValue;
334
+
335
+ $element.val(
336
+ WPGlobusCore.TextFilter(
337
+ elem.defaultValue,
338
+ WPGlobusCoreData.language,
339
+ 'RETURN_EMPTY'
340
+ )
341
+ );
342
+
343
+ });
344
+
345
+ }
346
+ });
347
+
348
+ /**
349
+ * Event handler after widget was added
350
+ */
351
+ $( document ).triggerHandler( 'wpglobus_customize_control_added_widget', [ obj ] );
352
+
353
+ },
354
+ ctrlCallback: function( context, obj, key ) {
355
+
356
+ var dis = false;
357
+ $.each( WPGlobusCustomize.disabledSections, function(i,e) {
358
+ if ( context.section() == e ) {
359
+ dis = true;
360
+ return false;
361
+ }
362
+ });
363
+
364
+ if (dis) return;
365
+
366
+ $.each( WPGlobusCustomize.disabledSettingMask, function(i,e) {
367
+ /** @see wp.customize.control elements */
368
+ if ( obj.indexOf( e ) >= 0 ){
369
+ dis = true;
370
+ return false;
371
+ }
372
+ });
373
+
374
+ if (dis) return;
375
+
376
+ var control = wp.customize.control.instance( obj );
377
+
378
+ /**
379
+ * To check for object is widget.
380
+ */
381
+ if ( obj.indexOf( 'widget' ) >= 0 ) {
382
+ if ( typeof api.controlWidgets[obj] === 'undefined' ) {
383
+ api.controlWidgets[obj] = {};
384
+ if ( api.action ) {
385
+ api.ctrlWidgetCallback( obj, control );
386
+ }
387
+ }
388
+
389
+ api.controlWidgets[ obj ]['parent'] = control.selector;
390
+
391
+ if ( $(control.selector).length != 1 ) {
392
+ /**
393
+ * Don't add MutationObserver for non-existing parent of control element.
394
+ * @see https://wordpress.org/themes/ascend/
395
+ */
396
+ api.controlWidgets[ obj ]['observer'] = null;
397
+ } else {
398
+ /**
399
+ * Add Mutation Observer for widget.
400
+ */
401
+ api.controlWidgets[ obj ]['observer'] = new MutationObserver( function( mutations ) {
402
+ mutations.forEach( function( mutation ) {
403
+ if ( 'class' == mutation.attributeName ) {
404
+ if ( -1 != mutation.target.className.indexOf( 'expanding' ) ) {
405
+ /**
406
+ * @todo Now are using 'expanding' class maybe need to use 'widget-rendered' with delay.
407
+ */
408
+ api.ctrlWidgetCallback( obj );
409
+ }
410
+ }
411
+ });
412
+ });
413
+
414
+ api.controlWidgets[ obj ]['observer'].observe(
415
+ document.querySelector( api.controlWidgets[ obj ]['parent'] ),
416
+ { attributes: true, childList: true, characterData: true }
417
+ );
418
+ }
419
+
420
+ return false;
421
+ }
422
+
423
+ /**
424
+ if ( obj.indexOf( 'nav_menu_item' ) >= 0 ) {
425
+ if ( typeof api.controlMenuItems[obj] === 'undefined' ) {
426
+ api.controlMenuItems[obj] = {};
427
+ api.ctrlMenuItemsCallback( obj, control );
428
+ }
429
+ api.controlMenuItems[ obj ]['parent'] = control.selector;
430
+ return false;
431
+ } */
432
+
433
+ if ( typeof api.controlInstances[ obj ] !== 'undefined' ) {
434
+ return;
435
+ }
436
+
437
+ var controlEnabled = true;
438
+
439
+ $.each( WPGlobusCustomize.elementSelector, function(i,e){
440
+ var element = control.container.find( e );
441
+ if ( element.length != 0 ) {
442
+
443
+ api.controlInstances[obj] = {};
444
+ api.controlInstances[obj]['element'] = element;
445
+ api.controlInstances[obj]['elementID'] = element.attr('id') ? '#'+element.attr('id') : undefined;
446
+ api.controlInstances[obj]['setting'] = control.setting();
447
+ api.controlInstances[obj]['selector'] = e;
448
+ /**
449
+ * To get element in DOM @see parent li.customize-control of this control.
450
+ * And element with 'data-customize-setting-link' attribute.
451
+ */
452
+ api.controlInstances[obj]['controlSelector'] = control.selector;
453
+ api.controlInstances[obj]['type'] = '';
454
+ api.controlInstances[obj]['section'] = control.section();
455
+ api.controlInstances[obj]['title'] = null;
456
+ api.controlInstances[obj]['userControl'] = null;
457
+ /**
458
+ * Field Settings for Fields Settings section in WPGlobus Settings panel.
459
+ * @see #accordion-section-wpglobus_fields_settings_section
460
+ */
461
+ api.controlInstances[obj]['fieldSettings'] = {};
462
+ api.controlInstances[obj]['fieldSettings']['itemID'] = 'item-wpglobus-cb-control-'+WPGlobusDialogApp.convertToId(obj);
463
+ api.controlInstances[obj]['fieldSettings']['cbID'] = 'wpglobus-cb-control-'+WPGlobusDialogApp.convertToId(obj);
464
+
465
+
466
+ // Let's test with Zerif Lite theme.
467
+ //
468
+ // When we open yoursite/wp-admin/customize.php:
469
+ //
470
+ // wp.customize.control('zerif_bigtitle_redbutton_url').setting() =
471
+ // "{:en}http://wpglobus.com/hot-news-1{:}{:de}http://wpglobus.com/de/hot-news-2{:}"
472
+ // WPGlobusCustomize.controlInstances['zerif_bigtitle_redbutton_url'].setting =
473
+ // "http://wpglobus.com/hot-news-1|||http://wpglobus.com/de/hot-news-2|||null|||null"
474
+
475
+ // After first saving of changeset we have:
476
+ //
477
+ // wp.customize.control('zerif_bigtitle_redbutton_url').setting() =
478
+ // "http://wpglobus.com/hot-news-1/"
479
+ // WPGlobusCustomize.controlInstances['zerif_bigtitle_redbutton_url'].setting =
480
+ // "http://wpglobus.com/hot-news-1/|||http://wpglobus.com/de/hot-news-2|||null|||null"
481
+
482
+ // Reload page with changeset_uuid in URL:
483
+ //
484
+ // wp.customize.control('zerif_bigtitle_redbutton_url').setting() =
485
+ // "http://wpglobus.com/hot-news-1/|||http://wpglobus.com/de/hot-news-2|||null|||null"
486
+ // WPGlobusCustomize.controlInstances['zerif_bigtitle_redbutton_url'].setting =
487
+ // "http://wpglobus.com/hot-news-1/|||http://wpglobus.com/de/hot-news-2|||null|||null"
488
+
489
+ // So, we must set correct URL value for default language when changeset was loaded.
490
+
491
+ $.each( WPGlobusCustomize.setLinkBy, function( i, piece ) {
492
+
493
+ if ( obj.indexOf( piece ) >= 0 ) {
494
+ api.controlInstances[obj]['type'] = 'link';
495
+
496
+ if ( '' == api.controlInstances[obj]['setting'] ) {
497
+ /** link perhaps was set to empty value */
498
+ api.controlInstances[obj]['setting'] = element[0].defaultValue;
499
+ }
500
+
501
+ if ( WPGlobusCustomize.changeset_uuid ) {
502
+ /**
503
+ * @since 1.7.9
504
+ */
505
+ var val = wp.customize.control(obj).setting();
506
+ if ( -1 !== val.indexOf( '|||' ) ) {
507
+ var value = api.getTranslations(val);
508
+ wp.customize.control(obj).setting( value[WPGlobusCoreData.default_language] );
509
+ $(
510
+ WPGlobusCustomize.controlInstances[obj].controlSelector +
511
+ ' ' +
512
+ WPGlobusCustomize.controlInstances[obj].selector
513
+ ).val( value[WPGlobusCoreData.default_language] );
514
+ }
515
+
516
+ }
517
+ element.addClass( 'wpglobus-control-link' );
518
+ }
519
+
520
+ });
521
+
522
+ if ( api.controlInstances[obj]['type'] === '' ) {
523
+ if ( e == 'textarea' ) {
524
+ api.controlInstances[obj]['type'] = 'textarea';
525
+ } else {
526
+ api.controlInstances[obj]['type'] = 'text';
527
+ }
528
+ }
529
+
530
+ element.val( WPGlobusCore.TextFilter( api.controlInstances[obj]['setting'], WPGlobusCoreData.language, 'RETURN_EMPTY' ) );
531
+ element.addClass( 'wpglobus-customize-control' );
532
+
533
+ /**
534
+ * Use control.selector instead of element.parents('li').attr('id') to get id parent li element
535
+ * element.attr( 'data-wpglobus-customize-control', element.parents('li').attr('id').replace( 'customize-control-', '') );
536
+ */
537
+ element.attr( 'data-wpglobus-customize-control', api.controlInstances[obj]['controlSelector'].replace( '#customize-control-', '') );
538
+
539
+ if ( api.controlInstances[obj]['type'] == 'link' ) {
540
+ api.controlInstances[obj]['setting'] = api.convertString( element[0].defaultValue );
541
+ };
542
+
543
+ /** Get control title. */
544
+ api.controlInstances[obj]['title'] = control.params.label;
545
+
546
+ /** Enable/disable user control. */
547
+ if ( WPGlobusCustomizeOptions.userControl !== null &&
548
+ typeof WPGlobusCustomizeOptions.userControl[ WPGlobusCustomizeOptions.themeName ] !== 'undefined' ) {
549
+
550
+ if ( typeof WPGlobusCustomizeOptions.userControl[ WPGlobusCustomizeOptions.themeName ][ obj ] !== 'undefined' &&
551
+ WPGlobusCustomizeOptions.userControl[ WPGlobusCustomizeOptions.themeName ][ obj ] == 'disable' ) {
552
+
553
+ controlEnabled = false;
554
+ }
555
+
556
+ }
557
+ api.controlInstances[obj]['userControl'] = {};
558
+ api.controlInstances[obj]['userControl']['enabled'] = controlEnabled;
559
+
560
+ api.setUserControls( obj, api.controlInstances[obj] );
561
+ }
562
+ });
563
+
564
+ },
565
+ setControlInstances: function() {
566
+ wp.customize.control.each( api.ctrlCallback );
567
+ },
568
+ setTitle: function() {
569
+ $( WPGlobusCoreData.customize.info.element ).html( WPGlobusCoreData.customize.info.html );
570
+ },
571
+ convertString: function(text) {
572
+ if ( typeof text === 'undefined' ) {
573
+ return text;
574
+ }
575
+ var r = [], tr = WPGlobusCore.getTranslations( text ),
576
+ i = 0, rE = true;
577
+
578
+ if ( text == tr[WPGlobusCoreData.default_language] ) {
579
+ /**
580
+ * Don't convert if text is in default language only.
581
+ */
582
+ return text;
583
+ }
584
+
585
+ $.each( tr, function(l,e) {
586
+ if ( e == '' ) {
587
+ r[i] = 'null';
588
+ } else {
589
+ rE = false;
590
+ r[i] = e;
591
+ }
592
+ i++;
593
+ });
594
+ if ( rE ) {
595
+ return '';
596
+ }
597
+ return r.join('|||');
598
+ },
599
+ getTranslations: function(text) {
600
+ if ( 'undefined' === typeof(text) ) {
601
+ return text;
602
+ }
603
+
604
+ var t = {},
605
+ ar = text.split('|||');
606
+ $.each(WPGlobusCoreData.enabled_languages, function(i,l){
607
+ t[l] = typeof ar[i] === 'undefined' || ar[i] === 'null' ? '' : ar[i];
608
+ });
609
+ return t;
610
+ },
611
+ getString: function(s, newVal, lang) {
612
+ /** using '|||' mark for correct work with url */
613
+ if ( 'undefined' === typeof( s ) ) {
614
+ return s;
615
+ }
616
+ if ( 'undefined' === typeof( newVal ) ) {
617
+ newVal = '';
618
+ }
619
+ if ( 'undefined' === typeof( lang ) ) {
620
+ lang = WPGlobusCoreData.language;
621
+ }
622
+
623
+ var tr = api.getTranslations(s),
624
+ sR = [], i = 0, rE = true;
625
+
626
+ $.each( tr, function(l,t){
627
+ if ( l == lang ) {
628
+ newVal = newVal.trim();
629
+ sR[i] = newVal == '' ? 'null' : newVal;
630
+ } else {
631
+ sR[i] = t == '' ? 'null' : t;
632
+ }
633
+ if ( l != WPGlobusCoreData.default_language ) {
634
+ if ( sR[i] != 'null' ) {
635
+ rE = false;
636
+ }
637
+ }
638
+ i++;
639
+ });
640
+ if ( rE ) {
641
+ /**
642
+ * Don't convert if sR is in default language only.
643
+ */
644
+ sR = sR[0];
645
+ } else {
646
+ sR = sR.join('|||');
647
+ }
648
+
649
+ return sR;
650
+ },
651
+ addLanguageSelector: function() {
652
+
653
+ $( WPGlobusCustomize.selectorButton ).insertAfter('.customize-controls-preview-toggle');
654
+ $('.wpglobus-customize-selector').html( api.selectorHtml.replace('{{language}}', WPGlobusCoreData.language) );
655
+
656
+ $( document ).on( 'click', '.wpglobus-customize-selector', function(ev){
657
+ if ( api.index > api.length-1 ) {
658
+ api.index = 0;
659
+ } else {
660
+ api.index++;
661
+ }
662
+
663
+ WPGlobusCoreData.language = api.languages[ api.index ];
664
+
665
+ $(this).html( api.selectorHtml.replace( '{{language}}', WPGlobusCoreData.language ) );
666
+
667
+ /**
668
+ * Event after language was changed
669
+ */
670
+ $( document ).triggerHandler( 'wpglobus_customize_control_language', [ WPGlobusCoreData.language ] );
671
+
672
+ $( '.wpglobus-customize-control' ).each( function(i,e){
673
+ var $e = $(e),
674
+ inst = $e.data( 'customize-setting-link' );
675
+
676
+ if ( 'undefined' === typeof WPGlobusCustomize.controlInstances[inst] ) {
677
+ /**
678
+ * try get control element from attribute data-wpglobus-customize-control
679
+ * for example @see Blink theme, customize control element footer-text instead of blink_footer-text
680
+ */
681
+ inst = $e.data( 'wpglobus-customize-control' );
682
+ if ( 'undefined' === typeof WPGlobusCustomize.controlInstances[inst] ) {
683
+ return;
684
+ }
685
+ }
686
+
687
+ if ( $e.hasClass( 'wpglobus-control-link' ) ) {
688
+ var t = api.getTranslations( WPGlobusCustomize.controlInstances[inst].setting );
689
+ $e.val( t[ WPGlobusCoreData.language ] );
690
+ } else {
691
+ /**
692
+ * @since 1.8.2
693
+ */
694
+ var t = WPGlobusCore.TextFilter( WPGlobusCustomize.controlInstances[inst].setting, WPGlobusCoreData.language, 'RETURN_EMPTY' );
695
+ if ( 'tinymce' == WPGlobusCustomize.controlInstances[inst]['type'] ) {
696
+ tinymce.get(inst).setContent( t, {format:'raw'} );
697
+ }
698
+ $e.val( WPGlobusCore.TextFilter( t, 'RETURN_EMPTY' ) );
699
+ }
700
+ });
701
+
702
+ /** widgets */
703
+ $( '.wpglobus-customize-widget-control' ).each( function(i, e){
704
+
705
+ var $e = $(e), obj = $e.data( 'widget' );
706
+
707
+ if ( 'undefined' === typeof $e.attr('id') ) {
708
+ return true;
709
+ }
710
+
711
+ $e.val(
712
+ WPGlobusCore.TextFilter(
713
+ WPGlobusCustomize.controlWidgets[ obj ][ 'element' ][ $e.attr('id') ][ 'value' ],
714
+ WPGlobusCoreData.language,
715
+ 'RETURN_EMPTY'
716
+ )
717
+ );
718
+
719
+ });
720
+
721
+ /** menu items */
722
+ /**
723
+ $( '.wpglobus-customize-menu-item-control' ).each( function(i, e){
724
+ var $e = $(e);
725
+
726
+ $e.val(
727
+ WPGlobusCore.TextFilter(
728
+ WPGlobusCustomize.controlMenuItems[ $e.data( 'menu-item' ) ][ 'element' ][ $e.attr('id') ]['value'],
729
+ WPGlobusCoreData.language,
730
+ 'RETURN_EMPTY'
731
+ )
732
+ );
733
+
734
+ }); */
735
+
736
+ });
737
+
738
+ },
739
+ updateElements: function( force ) {
740
+ if ( typeof force === 'undefined' ) {
741
+ force = true;
742
+ }
743
+
744
+ /** updateElements simple controls */
745
+ $.each( WPGlobusCustomize.controlInstances, function( inst, data ) {
746
+ if ( ! data.userControl.enabled ) {
747
+ /* next iteration */
748
+ return true;
749
+ }
750
+ var control = wp.customize.control.instance( inst );
751
+ if ( data.type == 'link' ) {
752
+ var t = api.getTranslations( WPGlobusCustomize.controlInstances[inst].setting );
753
+ if ( force ) {
754
+ control.setting.set( t[ WPGlobusCoreData.language ] );
755
+ data.element.val( control.setting() );
756
+ } else {
757
+ data.element.val( t[ WPGlobusCoreData.language ] );
758
+ }
759
+ } else if ( data.type == 'tinymce' ) {
760
+ /**
761
+ * @since 1.8.2
762
+ * @todo check for 'force' param.
763
+ */
764
+ //if ( force ) {
765
+ var t = WPGlobusCore.TextFilter( WPGlobusCustomize.controlInstances[inst].setting, WPGlobusCoreData.language, 'RETURN_EMPTY' );
766
+ /**
767
+ * First we need to set content for tinymce editor.
768
+ */
769
+ tinymce.get(inst).setContent( t, {format:'raw'} );
770
+ /**
771
+ * But user could choose Text mode, so we set value for textarea anyway.
772
+ */
773
+ data.element.val( t );
774
+ //data.element.val( tinymce.get(inst).getContent() );
775
+ //} else {
776
+ //data.element.val( WPGlobusCore.TextFilter( WPGlobusCustomize.controlInstances[inst].setting, WPGlobusCoreData.language, 'RETURN_EMPTY' ) );
777
+ //}
778
+ } else {
779
+ if ( force ) {
780
+ control.setting.set( WPGlobusCore.TextFilter( WPGlobusCustomize.controlInstances[inst].setting, WPGlobusCoreData.language, 'RETURN_EMPTY' ) );
781
+ data.element.val( control.setting() );
782
+ } else {
783
+ data.element.val( WPGlobusCore.TextFilter( WPGlobusCustomize.controlInstances[inst].setting, WPGlobusCoreData.language, 'RETURN_EMPTY' ) );
784
+ }
785
+ }
786
+ });
787
+
788
+ /** updateElements menu items */
789
+ /**
790
+ $.each( WPGlobusCustomize.controlMenuItems, function( menuItem, object ) {
791
+ if ( typeof object.element === 'undefined' ) {
792
+ return;
793
+ }
794
+ $.each( object.element, function( id, obj ) {
795
+ $( '#' + id ).val(
796
+ WPGlobusCore.TextFilter( obj.value, WPGlobusCoreData.language, 'RETURN_EMPTY' )
797
+ );
798
+ });
799
+ }); */
800
+ },
801
+ onSubmitEvents: function( ev ) {
802
+
803
+ if ( ev.type == 'mouseenter' ) {
804
+
805
+ $.each( api.controlWidgets[ $(this).data('widget') ]['element'], function(id,e) {
806
+ $( '#' + id ).val( e.value );
807
+ });
808
+
809
+ } else if ( ev.type == 'mouseleave' ) {
810
+
811
+ if ( ! api.widgetKeep ) {
812
+ $.each( api.controlWidgets[ $(this).data('widget') ]['element'], function(id,e) {
813
+ $( '#' + id ).val( WPGlobusCore.TextFilter( e.value, WPGlobusCoreData.language, 'RETURN_EMPTY' ) );
814
+ });
815
+ }
816
+
817
+ } else if ( ev.type == 'click' ) {
818
+ api.widgetKeep = true;
819
+ }
820
+
821
+ },
822
+ attachWidgetListeners: function( obj ) {
823
+
824
+ if ( typeof obj['submit'][0]['id'] !== 'undefined' ) {
825
+
826
+ $( document ).on( 'mouseenter', '#' + obj['submit'][0]['id'], api.onSubmitEvents )
827
+ .on( 'mouseleave', '#' + obj['submit'][0]['id'], api.onSubmitEvents )
828
+ .on( 'click', '#' + obj['submit'][0]['id'], api.onSubmitEvents );
829
+
830
+ }
831
+
832
+ },
833
+ attachListeners: function() {
834
+ /** attachListeners: simple controls */
835
+ $( '.wpglobus-customize-control' ).on( 'keyup', function(ev) {
836
+ var $t = $(this),
837
+ inst = $t.data( 'customize-setting-link' );
838
+
839
+ if ( 'undefined' === typeof WPGlobusCustomize.controlInstances[inst] ) {
840
+ /**
841
+ * try get control element from attribute data-wpglobus-customize-control
842
+ * for example @see Blink theme, customize control element footer-text instead of blink_footer-text
843
+ */
844
+ inst = $t.data( 'wpglobus-customize-control' );
845
+ if ( 'undefined' === typeof WPGlobusCustomize.controlInstances[inst] ) {
846
+ /**
847
+ * Now don't return from callback, we have trigger.
848
+ * @since 1.7.10
849
+ */
850
+ //return;
851
+ }
852
+ }
853
+
854
+ /**
855
+ * @since 1.7.10
856
+ */
857
+ if ( 'undefined' !== typeof $(document).triggerHandler( 'wpglobus_customize_control_keyup', [ $t, inst ] ) ) {
858
+ return;
859
+ }
860
+
861
+ if ( WPGlobusCustomize.controlInstances[inst]['type'] == 'link' ) {
862
+
863
+ WPGlobusCustomize.controlInstances[inst]['setting'] = api.getString(
864
+ WPGlobusCustomize.controlInstances[inst]['setting'],
865
+ $t.val(),
866
+ WPGlobusCoreData.language
867
+ );
868
+
869
+ } else {
870
+
871
+ WPGlobusCustomize.controlInstances[inst]['setting'] = WPGlobusCore.getString(
872
+ WPGlobusCustomize.controlInstances[inst]['setting'],
873
+ $t.val(),
874
+ WPGlobusCoreData.language
875
+ );
876
+
877
+ }
878
+ });
879
+
880
+ /** attachListeners: widgets */
881
+ $( document ).on( 'keyup', '.wpglobus-customize-widget-control', function(ev) {
882
+ var $t = $(this),
883
+ obj = $t.data( 'widget' );
884
+
885
+ if ( 'undefined' === typeof WPGlobusCustomize.controlWidgets[ obj ] ) {
886
+ return;
887
+ }
888
+
889
+ WPGlobusCustomize.controlWidgets[ obj ]['element'][ $t.attr('id') ]['value'] = WPGlobusCore.getString(
890
+ WPGlobusCustomize.controlWidgets[ obj ]['element'][ $t.attr('id') ]['value'],
891
+ $t.val(),
892
+ WPGlobusCoreData.language
893
+ );
894
+
895
+ });
896
+
897
+ /** attachListeners: menu items */
898
+ /**
899
+ $( document ).on( 'keyup', '.wpglobus-customize-menu-item-control', function(ev) {
900
+ var $t = $(this),
901
+ obj = $t.data( 'menu-item' );
902
+
903
+ if ( 'undefined' === typeof WPGlobusCustomize.controlMenuItems[ obj ] ) {
904
+ return;
905
+ }
906
+
907
+ WPGlobusCustomize.controlMenuItems[ obj ]['element'][ $t.attr('id') ][ 'value' ] = WPGlobusCore.getString(
908
+ WPGlobusCustomize.controlMenuItems[ obj ]['element'][ $t.attr('id') ][ 'value' ],
909
+ $t.val(),
910
+ WPGlobusCoreData.language
911
+ );
912
+
913
+ }); */
914
+
915
+ /** attachListeners: Save&Publish button */
916
+ $(document).on( 'mouseenter', '#save', function( event ) {
917
+
918
+ /** Save&Publish simple controls */
919
+ $.each( WPGlobusCustomize.controlInstances, function( inst, data ) {
920
+ if ( data.userControl.enabled ) {
921
+
922
+ var control = wp.customize.control.instance( inst );
923
+
924
+ /**
925
+ * @since 1.8.2
926
+ */
927
+ if ( 'tinymce' == data.type ) {
928
+ tinymce.get(inst).setContent( data.setting, {format:'raw'} );
929
+ }
930
+ /**
931
+ * But user could choose Text mode, so we set value for textarea anyway.
932
+ */
933
+ control.setting.set( data.setting );
934
+ data.element.val( control.setting() );
935
+ }
936
+ });
937
+
938
+ /** Save&Publish menu items */
939
+ /**
940
+ $.each( WPGlobusCustomize.controlMenuItems, function( menuItem, object ) {
941
+ if ( typeof object.element === 'undefined' ) {
942
+ return;
943
+ }
944
+ var control = wp.customize.control.instance( menuItem );
945
+ $.each( object.element, function( id, obj ) {
946
+ $( '#' + id ).val( obj.value );
947
+ control.elements[ obj.element ]( obj.value );
948
+ });
949
+ }); */
950
+
951
+ }).on( 'mouseleave', '#save', function( event ) {
952
+ if ( ! api.instancesKeep ) {
953
+ api.updateElements();
954
+ wp.customize.previewer.refresh();
955
+ }
956
+ });
957
+
958
+ /**
959
+ * Don't use $(document) for this case.
960
+ */
961
+ $('#save').on('click', function(event){
962
+ api.instancesKeep = true;
963
+ });
964
+
965
+ /**
966
+ * AttachListeners: ajaxSend event handler.
967
+ */
968
+ $(document).on( 'ajaxSend', function( ev, jqXHR, ajaxOptions ) {
969
+ if ( typeof ajaxOptions.data === 'undefined' ) {
970
+ return;
971
+ }
972
+ if ( -1 != ajaxOptions.data.indexOf( 'wp_customize=on' ) && -1 != ajaxOptions.data.indexOf( 'action=customize_save' ) ) {
973
+ api.customizeSave = true;
974
+ }
975
+ });
976
+
977
+ /**
978
+ * AttachListeners: ajaxComplete event handler.
979
+ */
980
+ $(document).on( 'ajaxComplete', function( ev, response ) {
981
+
982
+ if ( typeof response.responseText === 'undefined' ) {
983
+ return;
984
+ }
985
+ /**
986
+ * @todo check adding new widget.
987
+ */
988
+ if ( api.customizeSave ) {
989
+
990
+ /** Save&Publish ajax complete */
991
+ api.updateElements( false );
992
+ if ( api.instancesKeep ) {
993
+ api.instancesKeep = false;
994
+ }
995
+
996
+ } else {
997
+
998
+ if ( response.responseText.indexOf( 'WP_CUSTOMIZER_SIGNATURE' ) >= 0 ) {
999
+ api.action = 'customizerAjaxComplete';
1000
+ api.setControlInstances();
1001
+ }
1002
+
1003
+ $.each( WPGlobusCustomize.controlWidgets, function( obj, data ) {
1004
+ /** Apply widget ajax complete */
1005
+
1006
+ var w = obj.replace( '_', '-' );
1007
+
1008
+ if ( response.responseText.indexOf( w ) >= 0 ) {
1009
+
1010
+ data.submit.css({'display':'block'});
1011
+ data.control.liveUpdateMode = false;
1012
+
1013
+ $.each( data['element'], function( id, e ) {
1014
+ $( '#' + id ).val( WPGlobusCore.TextFilter( e.value, WPGlobusCoreData.language, 'RETURN_EMPTY' ) );
1015
+ });
1016
+
1017
+ data.inWidgetTitle.text( ': ' + WPGlobusCore.TextFilter( data.control.setting().title, WPGlobusCustomize.languageAdmin ) );
1018
+ api.widgetKeep = false;
1019
+
1020
+ return false;
1021
+ }
1022
+
1023
+ });
1024
+
1025
+ }
1026
+
1027
+ api.customizeSave = false;
1028
+
1029
+ wp.customize.previewer.refresh();
1030
+
1031
+ });
1032
+
1033
+ /**
1034
+ * AttachListeners: Event handler for tracking clicks by widgets title.
1035
+ */
1036
+ /**
1037
+ * @todo remove this listener after testing with WP4.7.
1038
+ */
1039
+ /*
1040
+ $(document).on( 'click', '.widget-title, .widget-title-action', function(ev){
1041
+ return;
1042
+ var id = $(this).parents( '.customize-control-widget_form' ).attr( 'id' );
1043
+ $.each( api.controlWidgets, function( obj, d ) {
1044
+ if ( '#'+id == d.parent ) {
1045
+ api.ctrlWidgetCallback( obj );
1046
+ return false;
1047
+ }
1048
+ });
1049
+ }); */
1050
+
1051
+ /**
1052
+ * attachListeners: Event handler for tracking clicks by menu item title.
1053
+ */
1054
+ /**
1055
+ $(document).on( 'click', '.control-section-nav_menu .accordion-section-title', function(ev){
1056
+ $.each( api.controlMenuItems, function( obj, d ) {
1057
+ api.ctrlMenuItemsCallback( obj );
1058
+ });
1059
+ }); */
1060
+
1061
+
1062
+ }
1063
+ };
1064
+
1065
+ WPGlobusCustomize = $.extend( {}, WPGlobusCustomize, api );
1066
+
1067
+ WPGlobusCustomize.init();
1068
+
1069
+ });
includes/js/wpglobus-customize-control170.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(document).ready(function(t){"use strict";var e={languages:{},index:0,length:0,controlInstances:{},controlWidgets:{},instancesKeep:!1,widgetKeep:!1,action:!1,customizeSave:!1,selectorHtml:'<span style="margin-left:5px;" class="wpglobus-icon-globe"></span><span style="font-weight:bold;">{{language}}</span>',settingsSectionExpand:function(){t(document).triggerHandler("wpglobus_fields_settings_section_expand",[this,e])},init:function(o){e.setTitle(),"false"!=WPGlobusCustomizeOptions.themeEnabled&&(t.each(WPGlobusCoreData.enabled_languages,function(t,o){e.languages[t]=o,e.length=t}),e.addLanguageSelector(),e.setControlInstances(),e.setFieldsSection(),e.attachListeners(),e.setTinymce())},updateTinymce:function(t){"tinymce"==WPGlobusCustomize.controlInstances[this.id].type&&(WPGlobusCustomize.controlInstances[this.id].setting=WPGlobusCore.getString(WPGlobusCustomize.controlInstances[this.id].setting,t.target.textContent,WPGlobusCoreData.language))},setTinymce:function(o){t(document).on("tinymce-editor-init",function(o,n){"object"==typeof e.controlInstances[n.id]&&(e.controlInstances[n.id].type="tinymce",t(n.iframeElement).addClass("wpglobus-customize-control").css({width:"99%"}),n.on("input",_.debounce(e.updateTinymce,300)))})},getSize:function(t){return void 0===t?_.size(e.controlInstances):"widget"==t?_.size(e.controlWidgets):null},setFieldsSection:function(){var o={},n=t(".wpglobus-fields_settings_control_box").data("section-template"),s="",i="",l="";t.each(WPGlobusCustomize.controlInstances,function(t,e){void 0===o[e.section]&&(o[e.section]={}),o[e.section][t]=e}),t.each(o,function(e,o){if(i="<ul>",t.each(o,function(t,e){l=e.userControl.enabled?" checked ":"",i+='<li id="'+e.fieldSettings.itemID+'">',i+='<input id="'+e.fieldSettings.cbID+'" data-control="'+t+'" class="wpglobus-customize-cb-control" type="checkbox"'+l+' /> <span class="wpglobus-cb-control-title">'+e.title+"</span>",i+="</li>"}),i+="</ul>",void 0===wp.customize.section(e))return!0;s=(s=(s=(s=n.replace("{{section_title}}",wp.customize.section(e).params.title)).replace(/{{section}}/g,e)).replace("{{section_id}}",'"'+e+'"')).replace("{{items}}",i),t(s).insertBefore(t("#"+WPGlobusCustomizeOptions.userControlSaveButton))}),t("#accordion-section-wpglobus_fields_settings_section").css({"margin-top":"15px"}),t(WPGlobusCustomizeOptions.helpButton).insertAfter(t("#accordion-section-wpglobus_fields_settings_section .customize-action")),t("#accordion-section-wpglobus_fields_settings_section .customize-section-description").addClass("hidden"),t(document).on("click","."+WPGlobusCustomizeOptions.userControlIconClass,function(o){var n=t(this).data("section");t(WPGlobusCustomizeOptions.userControlBoxSelector).each(function(e,o){n==t(o).data("section")?t(this).css({display:"block"}):t(this).css({display:"none"})}),wp.customize.control("wpglobus_fields_settings_section").expand({completeCallback:e.settingsSectionExpand})}),t(".wpglobus-customize-icon-help.customize-help-toggle").on("click",function(e){t("#accordion-section-wpglobus_fields_settings_section .customize-section-description").toggleClass("hidden")})},setUserControls:function(e,o){var n=o.controlSelector+" "+o.selector,s='<img class="'+WPGlobusCustomizeOptions.userControlIconClass+'" data-section="'+o.section+'" style="position:absolute;right:0px;cursor:pointer;" src="'+WPGlobusCustomizeOptions.userControlIcon+'" />';t(s).insertBefore(n),o.userControl.enabled||(t(n).length>1?t(n).each(function(e,o){t(o).removeClass(WPGlobusCustomize.controlClass)}):t(n).removeClass(WPGlobusCustomize.controlClass).val(o.setting))},ctrlMenuItemsCallback:function(t,e){},ctrlWidgetCallback:function(o,n){if(e.action=!1,void 0===e.controlWidgets[o].element){void 0===n&&(n=wp.customize.control.instance(o)),e.controlWidgets[o].element={},e.controlWidgets[o].control=n,e.controlWidgets[o].inWidgetTitle=n.container.find(".in-widget-title"),e.controlWidgets[o].parent=n.selector;var s=n.container.find("input[type=submit]");0!=s.length&&(s.css({display:"block"}),s.attr("data-widget",o),e.controlWidgets[o].submit=s,e.attachWidgetListeners(e.controlWidgets[o])),n.liveUpdateMode=!1,void 0===n.setting().title?e.controlWidgets[o].inWidgetTitle.text(""):e.controlWidgets[o].inWidgetTitle.text(": "+WPGlobusCore.TextFilter(n.setting().title,WPGlobusCustomize.languageAdmin)),t.each(WPGlobusCustomize.elementSelector,function(s,i){var l=n.container.find(i);0!=l.length&&t.each(l,function(s,a){if(void 0===a.id||""==a.id)return!0;var c=t(l[s]);void 0===e.controlWidgets[o].element[a.id]&&(e.controlWidgets[o].element[a.id]={}),c.addClass("wpglobus-customize-widget-control"),c.attr("data-widget",o),e.controlWidgets[o].element[a.id].element=c,e.controlWidgets[o].element[a.id].setting=n.setting(),e.controlWidgets[o].element[a.id].selector=i,e.controlWidgets[o].element[a.id].value=a.defaultValue,c.val(WPGlobusCore.TextFilter(a.defaultValue,WPGlobusCoreData.language,"RETURN_EMPTY"))})}),t(document).triggerHandler("wpglobus_customize_control_added_widget",[o])}},ctrlCallback:function(o,n,s){var i=!1;if(t.each(WPGlobusCustomize.disabledSections,function(t,e){if(o.section()==e)return i=!0,!1}),!i&&(t.each(WPGlobusCustomize.disabledSettingMask,function(t,e){if(n.indexOf(e)>=0)return i=!0,!1}),!i)){var l=wp.customize.control.instance(n);if(n.indexOf("widget")>=0)return void 0===e.controlWidgets[n]&&(e.controlWidgets[n]={},e.action&&e.ctrlWidgetCallback(n,l)),e.controlWidgets[n].parent=l.selector,1!=t(l.selector).length?e.controlWidgets[n].observer=null:(e.controlWidgets[n].observer=new MutationObserver(function(t){t.forEach(function(t){"class"==t.attributeName&&-1!=t.target.className.indexOf("expanding")&&e.ctrlWidgetCallback(n)})}),e.controlWidgets[n].observer.observe(document.querySelector(e.controlWidgets[n].parent),{attributes:!0,childList:!0,characterData:!0})),!1;if(void 0===e.controlInstances[n]){var a=!0;t.each(WPGlobusCustomize.elementSelector,function(o,s){var i=l.container.find(s);0!=i.length&&(e.controlInstances[n]={},e.controlInstances[n].element=i,e.controlInstances[n].elementID=i.attr("id")?"#"+i.attr("id"):void 0,e.controlInstances[n].setting=l.setting(),e.controlInstances[n].selector=s,e.controlInstances[n].controlSelector=l.selector,e.controlInstances[n].type="",e.controlInstances[n].section=l.section(),e.controlInstances[n].title=null,e.controlInstances[n].userControl=null,e.controlInstances[n].fieldSettings={},e.controlInstances[n].fieldSettings.itemID="item-wpglobus-cb-control-"+WPGlobusDialogApp.convertToId(n),e.controlInstances[n].fieldSettings.cbID="wpglobus-cb-control-"+WPGlobusDialogApp.convertToId(n),t.each(WPGlobusCustomize.setLinkBy,function(o,s){if(n.indexOf(s)>=0){if(e.controlInstances[n].type="link",""==e.controlInstances[n].setting&&(e.controlInstances[n].setting=i[0].defaultValue),WPGlobusCustomize.changeset_uuid){var l=wp.customize.control(n).setting();if(-1!==l.indexOf("|||")){var a=e.getTranslations(l);wp.customize.control(n).setting(a[WPGlobusCoreData.default_language]),t(WPGlobusCustomize.controlInstances[n].controlSelector+" "+WPGlobusCustomize.controlInstances[n].selector).val(a[WPGlobusCoreData.default_language])}}i.addClass("wpglobus-control-link")}}),""===e.controlInstances[n].type&&(e.controlInstances[n].type="textarea"==s?"textarea":"text"),i.val(WPGlobusCore.TextFilter(e.controlInstances[n].setting,WPGlobusCoreData.language,"RETURN_EMPTY")),i.addClass("wpglobus-customize-control"),i.attr("data-wpglobus-customize-control",e.controlInstances[n].controlSelector.replace("#customize-control-","")),"link"==e.controlInstances[n].type&&(e.controlInstances[n].setting=e.convertString(i[0].defaultValue)),e.controlInstances[n].title=l.params.label,null!==WPGlobusCustomizeOptions.userControl&&void 0!==WPGlobusCustomizeOptions.userControl[WPGlobusCustomizeOptions.themeName]&&void 0!==WPGlobusCustomizeOptions.userControl[WPGlobusCustomizeOptions.themeName][n]&&"disable"==WPGlobusCustomizeOptions.userControl[WPGlobusCustomizeOptions.themeName][n]&&(a=!1),e.controlInstances[n].userControl={},e.controlInstances[n].userControl.enabled=a,e.setUserControls(n,e.controlInstances[n]))})}}},setControlInstances:function(){wp.customize.control.each(e.ctrlCallback)},setTitle:function(){t(WPGlobusCoreData.customize.info.element).html(WPGlobusCoreData.customize.info.html)},convertString:function(e){if(void 0===e)return e;var o=[],n=WPGlobusCore.getTranslations(e),s=0,i=!0;return e==n[WPGlobusCoreData.default_language]?e:(t.each(n,function(t,e){""==e?o[s]="null":(i=!1,o[s]=e),s++}),i?"":o.join("|||"))},getTranslations:function(e){if(void 0===e)return e;var o={},n=e.split("|||");return t.each(WPGlobusCoreData.enabled_languages,function(t,e){o[e]=void 0===n[t]||"null"===n[t]?"":n[t]}),o},getString:function(o,n,s){if(void 0===o)return o;void 0===n&&(n=""),void 0===s&&(s=WPGlobusCoreData.language);var i=e.getTranslations(o),l=[],a=0,c=!0;return t.each(i,function(t,e){t==s?(n=n.trim(),l[a]=""==n?"null":n):l[a]=""==e?"null":e,t!=WPGlobusCoreData.default_language&&"null"!=l[a]&&(c=!1),a++}),l=c?l[0]:l.join("|||")},addLanguageSelector:function(){t(WPGlobusCustomize.selectorButton).insertAfter(".customize-controls-preview-toggle"),t(".wpglobus-customize-selector").html(e.selectorHtml.replace("{{language}}",WPGlobusCoreData.language)),t(document).on("click",".wpglobus-customize-selector",function(o){e.index>e.length-1?e.index=0:e.index++,WPGlobusCoreData.language=e.languages[e.index],t(this).html(e.selectorHtml.replace("{{language}}",WPGlobusCoreData.language)),t(document).triggerHandler("wpglobus_customize_control_language",[WPGlobusCoreData.language]),t(".wpglobus-customize-control").each(function(o,n){var s=t(n),i=s.data("customize-setting-link");if(void 0!==WPGlobusCustomize.controlInstances[i]||(i=s.data("wpglobus-customize-control"),void 0!==WPGlobusCustomize.controlInstances[i]))if(s.hasClass("wpglobus-control-link")){var l=e.getTranslations(WPGlobusCustomize.controlInstances[i].setting);s.val(l[WPGlobusCoreData.language])}else{l=WPGlobusCore.TextFilter(WPGlobusCustomize.controlInstances[i].setting,WPGlobusCoreData.language,"RETURN_EMPTY");"tinymce"==WPGlobusCustomize.controlInstances[i].type&&tinymce.get(i).setContent(l,{format:"raw"}),s.val(WPGlobusCore.TextFilter(l,"RETURN_EMPTY"))}}),t(".wpglobus-customize-widget-control").each(function(e,o){var n=t(o),s=n.data("widget");if(void 0===n.attr("id"))return!0;n.val(WPGlobusCore.TextFilter(WPGlobusCustomize.controlWidgets[s].element[n.attr("id")].value,WPGlobusCoreData.language,"RETURN_EMPTY"))})})},updateElements:function(o){void 0===o&&(o=!0),t.each(WPGlobusCustomize.controlInstances,function(t,n){if(!n.userControl.enabled)return!0;var s=wp.customize.control.instance(t);if("link"==n.type){var i=e.getTranslations(WPGlobusCustomize.controlInstances[t].setting);o?(s.setting.set(i[WPGlobusCoreData.language]),n.element.val(s.setting())):n.element.val(i[WPGlobusCoreData.language])}else if("tinymce"==n.type){i=WPGlobusCore.TextFilter(WPGlobusCustomize.controlInstances[t].setting,WPGlobusCoreData.language,"RETURN_EMPTY");tinymce.get(t).setContent(i,{format:"raw"}),n.element.val(i)}else o?(s.setting.set(WPGlobusCore.TextFilter(WPGlobusCustomize.controlInstances[t].setting,WPGlobusCoreData.language,"RETURN_EMPTY")),n.element.val(s.setting())):n.element.val(WPGlobusCore.TextFilter(WPGlobusCustomize.controlInstances[t].setting,WPGlobusCoreData.language,"RETURN_EMPTY"))})},onSubmitEvents:function(o){"mouseenter"==o.type?t.each(e.controlWidgets[t(this).data("widget")].element,function(e,o){t("#"+e).val(o.value)}):"mouseleave"==o.type?e.widgetKeep||t.each(e.controlWidgets[t(this).data("widget")].element,function(e,o){t("#"+e).val(WPGlobusCore.TextFilter(o.value,WPGlobusCoreData.language,"RETURN_EMPTY"))}):"click"==o.type&&(e.widgetKeep=!0)},attachWidgetListeners:function(o){void 0!==o.submit[0].id&&t(document).on("mouseenter","#"+o.submit[0].id,e.onSubmitEvents).on("mouseleave","#"+o.submit[0].id,e.onSubmitEvents).on("click","#"+o.submit[0].id,e.onSubmitEvents)},attachListeners:function(){t(".wpglobus-customize-control").on("keyup",function(o){var n=t(this),s=n.data("customize-setting-link");void 0===WPGlobusCustomize.controlInstances[s]&&(s=n.data("wpglobus-customize-control"),WPGlobusCustomize.controlInstances[s]),void 0===t(document).triggerHandler("wpglobus_customize_control_keyup",[n,s])&&("link"==WPGlobusCustomize.controlInstances[s].type?WPGlobusCustomize.controlInstances[s].setting=e.getString(WPGlobusCustomize.controlInstances[s].setting,n.val(),WPGlobusCoreData.language):WPGlobusCustomize.controlInstances[s].setting=WPGlobusCore.getString(WPGlobusCustomize.controlInstances[s].setting,n.val(),WPGlobusCoreData.language))}),t(document).on("keyup",".wpglobus-customize-widget-control",function(e){var o=t(this),n=o.data("widget");void 0!==WPGlobusCustomize.controlWidgets[n]&&(WPGlobusCustomize.controlWidgets[n].element[o.attr("id")].value=WPGlobusCore.getString(WPGlobusCustomize.controlWidgets[n].element[o.attr("id")].value,o.val(),WPGlobusCoreData.language))}),t(document).on("mouseenter","#save",function(e){t.each(WPGlobusCustomize.controlInstances,function(t,e){if(e.userControl.enabled){var o=wp.customize.control.instance(t);"tinymce"==e.type&&tinymce.get(t).setContent(e.setting,{format:"raw"}),o.setting.set(e.setting),e.element.val(o.setting())}})}).on("mouseleave","#save",function(t){e.instancesKeep||(e.updateElements(),wp.customize.previewer.refresh())}),t("#save").on("click",function(t){e.instancesKeep=!0}),t(document).on("ajaxSend",function(t,o,n){void 0!==n.data&&-1!=n.data.indexOf("wp_customize=on")&&-1!=n.data.indexOf("action=customize_save")&&(e.customizeSave=!0)}),t(document).on("ajaxComplete",function(o,n){void 0!==n.responseText&&(e.customizeSave?(e.updateElements(!1),e.instancesKeep&&(e.instancesKeep=!1)):(n.responseText.indexOf("WP_CUSTOMIZER_SIGNATURE")>=0&&(e.action="customizerAjaxComplete",e.setControlInstances()),t.each(WPGlobusCustomize.controlWidgets,function(o,s){var i=o.replace("_","-");if(n.responseText.indexOf(i)>=0)return s.submit.css({display:"block"}),s.control.liveUpdateMode=!1,t.each(s.element,function(e,o){t("#"+e).val(WPGlobusCore.TextFilter(o.value,WPGlobusCoreData.language,"RETURN_EMPTY"))}),s.inWidgetTitle.text(": "+WPGlobusCore.TextFilter(s.control.setting().title,WPGlobusCustomize.languageAdmin)),e.widgetKeep=!1,!1})),e.customizeSave=!1,wp.customize.previewer.refresh())})}};WPGlobusCustomize=t.extend({},WPGlobusCustomize,e),WPGlobusCustomize.init()});
includes/js/wpglobus-customize-control190.js ADDED
@@ -0,0 +1,1197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * WPGlobus Customize Control
3
+ * Interface JS functions
4
+ *
5
+ * @since 1.9.0
6
+ *
7
+ * @package WPGlobus
8
+ * @subpackage Customize Control
9
+ */
10
+ /*jslint browser: true*/
11
+ /*global jQuery, console, WPGlobusCore, WPGlobusCoreData, WPGlobusCustomize, WPGlobusCustomizeOptions*/
12
+
13
+ jQuery(document).ready(function ($) {
14
+ "use strict";
15
+
16
+ var api = {
17
+ languages: {},
18
+ index: 0,
19
+ length: 0,
20
+ controlInstances: {},
21
+ controlWidgets: {},
22
+ //controlMenuItems: {},
23
+ instancesKeep: false,
24
+ widgetKeep: false,
25
+ action: false,
26
+ customizeSave: false,
27
+ selectorHtml: '<span style="margin-left:5px;" class="wpglobus-icon-globe"></span><span class="current-language" style="font-weight:bold;">{{language}}</span>',
28
+ settingsSectionExpand: function() {
29
+ $(document).triggerHandler( 'wpglobus_fields_settings_section_expand', [this, api] );
30
+ },
31
+ init: function(args) {
32
+
33
+ api.setTitle();
34
+
35
+ if ( WPGlobusCustomizeOptions.themeEnabled == 'false' ) {
36
+ return;
37
+ }
38
+
39
+ $.each( WPGlobusCoreData.enabled_languages, function(i,e){
40
+ api.languages[i] = e;
41
+ api.length = i;
42
+ });
43
+ api.addLanguageSelector();
44
+ api.setControlInstances();
45
+ api.setFieldsSection(); /* @since 1.6.0 */
46
+ api.attachListeners();
47
+ /**
48
+ * @since 1.8.2
49
+ */
50
+ api.setTinymce();
51
+ },
52
+ updateTinymce: function(event) {
53
+ if ( 'tinymce' == WPGlobusCustomize.controlInstances[this.id]['type'] ) {
54
+ WPGlobusCustomize.controlInstances[this.id]['setting'] =
55
+ WPGlobusCore.getString( WPGlobusCustomize.controlInstances[this.id]['setting'], event.target.textContent, WPGlobusCoreData.language );
56
+ }
57
+ },
58
+ setTinymce: function(type) {
59
+ /**
60
+ * If theme uses tinymce editor then we need to add 'tinymce-editor-init' event listener.
61
+ */
62
+ $(document).on('tinymce-editor-init', function( event, editor ) {
63
+ if ( 'object' === typeof api.controlInstances[editor.id] ) {
64
+ /**
65
+ * Set type of control instance as 'tinymce'.
66
+ */
67
+ api.controlInstances[editor.id]['type'] = 'tinymce';
68
+ $(editor.iframeElement).addClass('wpglobus-customize-control').css({'width':'99%'});
69
+ editor.on( 'input', _.debounce( api.updateTinymce, 300 ) );
70
+ }
71
+ });
72
+ },
73
+ getSize: function(type) {
74
+ if ( 'undefined' === typeof type ) {
75
+ return _.size( api.controlInstances );
76
+ } else if ( 'widget' == type ) {
77
+ return _.size( api.controlWidgets );
78
+ } else if ( 'nav_menu' == type ) {
79
+ //return _.size( api.controlMenuItems );
80
+ }
81
+ return null;
82
+ },
83
+ setFieldsSection: function() {
84
+
85
+ var sections = {},
86
+ $sectionTmpl = $( '.wpglobus-fields_settings_control_box' ).data( 'section-template' ),
87
+ sectionHtml = '',
88
+ itemsHtml = '',
89
+ checked = '';
90
+
91
+ $.each( WPGlobusCustomize.controlInstances, function(id, obj) {
92
+ if ( typeof sections[ obj.section ] === 'undefined' ) {
93
+ sections[ obj.section ] = {};
94
+ }
95
+ sections[ obj.section ][ id ] = obj;
96
+ });
97
+
98
+ $.each( sections, function( section, controls ) {
99
+ itemsHtml = '<ul>';
100
+ $.each( controls, function( id, control ) {
101
+
102
+ if ( control.userControl.enabled ) {
103
+ checked = ' checked ';
104
+ } else {
105
+ checked = '';
106
+ }
107
+ itemsHtml += '<li id="'+control.fieldSettings.itemID+'">';
108
+ itemsHtml += '<input id="'+control.fieldSettings.cbID+'" data-control="'+id+'" class="wpglobus-customize-cb-control" type="checkbox"'+checked+' /> ' + '<span class="wpglobus-cb-control-title">'+control.title+'</span>';
109
+ itemsHtml += '</li>';
110
+ });
111
+ itemsHtml += '</ul>';
112
+
113
+ if ( 'undefined' === typeof wp.customize.section( section ) ) {
114
+ /**
115
+ * Case when theme's author removed a panel ( $wp_customize->remove_panel )
116
+ * but did not remove its sections ( $wp_customize->remove_section ).
117
+ * The orphaned sections have "undefined" type.
118
+ * For example, the "About us" and "Contact us" sections in
119
+ * @link https://wordpress.org/themes/responsiveboat/
120
+ *
121
+ * @since 1.7.8.2
122
+ */
123
+ return true;
124
+ }
125
+
126
+ sectionHtml = $sectionTmpl.replace( '{{section_title}}', wp.customize.section( section ).params.title );
127
+ sectionHtml = sectionHtml.replace( /{{section}}/g, section );
128
+ sectionHtml = sectionHtml.replace( '{{section_id}}', '"'+section+'"' );
129
+ sectionHtml = sectionHtml.replace( '{{items}}', itemsHtml );
130
+
131
+ $( sectionHtml ).insertBefore( $( '#' + WPGlobusCustomizeOptions.userControlSaveButton ) );
132
+ });
133
+
134
+ $( '#accordion-section-wpglobus_fields_settings_section' ).css({'margin-top':'15px'});
135
+ /** add Help button */
136
+ $( WPGlobusCustomizeOptions.helpButton ).insertAfter( $( '#accordion-section-wpglobus_fields_settings_section .customize-action' ) );
137
+ /**
138
+ * Hide help by default.
139
+ */
140
+ $( '#accordion-section-wpglobus_fields_settings_section .customize-section-description' ).addClass( 'hidden' );
141
+
142
+ /**
143
+ * Attach an event handler for user control icon.
144
+ */
145
+ $(document).on( 'click', '.'+WPGlobusCustomizeOptions.userControlIconClass, function(ev) {
146
+ var section = $(this).data( 'section' );
147
+ $( WPGlobusCustomizeOptions.userControlBoxSelector ).each( function( i, e ) {
148
+ if ( section == $(e).data( 'section' ) ) {
149
+ $(this).css({'display':'block'});
150
+ } else {
151
+ $(this).css({'display':'none'});
152
+ }
153
+ });
154
+ wp.customize.control( 'wpglobus_fields_settings_section' ).expand({
155
+ completeCallback: api.settingsSectionExpand
156
+ });
157
+ });
158
+
159
+ /**
160
+ * Toggle help.
161
+ */
162
+ $( '.wpglobus-customize-icon-help.customize-help-toggle' ).on( 'click', function(ev) {
163
+ $( '#accordion-section-wpglobus_fields_settings_section .customize-section-description' ).toggleClass( 'hidden' );
164
+ });
165
+
166
+ },
167
+ setUserControls: function( control_id, obj ) {
168
+ var elem = obj.controlSelector + ' ' + obj.selector;
169
+ var cbIcon = '<img class="'+WPGlobusCustomizeOptions.userControlIconClass+'" data-section="'+obj.section+'" style="position:absolute;right:0px;cursor:pointer;" src="'+WPGlobusCustomizeOptions.userControlIcon+'" />';
170
+ $( cbIcon ).insertBefore( elem );
171
+
172
+ if ( ! obj.userControl.enabled ) {
173
+
174
+ if ( $( elem ).length > 1 ) {
175
+ /**
176
+ * in some cases
177
+ * for example @see Kirki https://wordpress.org/plugins/kirki/
178
+ */
179
+ $( elem ).each( function(i,e) {
180
+ $(e).removeClass( WPGlobusCustomize.controlClass );
181
+ });
182
+ } else {
183
+ $( elem ).removeClass( WPGlobusCustomize.controlClass ).val( obj.setting );
184
+ }
185
+
186
+ }
187
+
188
+ },
189
+ ctrlMenuItemsCallback: function( obj, control ) {
190
+ return;
191
+ /**
192
+ * @todo remove from $disabled_setting_mask[]
193
+ */
194
+ if ( typeof control === 'undefined' ) {
195
+ control = wp.customize.control.instance( obj );
196
+ }
197
+
198
+ if ( typeof api.controlMenuItems[ obj ]['control'] !== 'undefined' ) {
199
+ return;
200
+ }
201
+
202
+ if ( control.elements != 0 ) {
203
+
204
+ api.controlMenuItems[ obj ]['control'] = control;
205
+ api.controlMenuItems[ obj ]['element'] = {};
206
+
207
+ $.each( WPGlobusCustomize.elementSelector, function(i,e){
208
+ var elements = control.container.find(e);
209
+ if ( elements.length > 0 ) {
210
+ $.each( elements, function(i, el) {
211
+ var $e = $(el);
212
+ if ( $e.hasClass( 'edit-menu-item-title' ) ) {
213
+
214
+ api.controlMenuItems[ obj ]['element'][ $e.attr('id') ] = {};
215
+ $e.addClass( 'wpglobus-customize-menu-item-control' );
216
+ $e.attr( 'data-menu-item', obj );
217
+ $e.attr( 'data-element', 'title' );
218
+ api.controlMenuItems[ obj ]['element'][ $e.attr('id') ]['value'] = control.elements.title();
219
+ api.controlMenuItems[ obj ]['element'][ $e.attr('id') ]['element'] = 'title';
220
+
221
+ /** set menu item title */
222
+ control.elements.title(
223
+ WPGlobusCore.TextFilter(
224
+ control.elements.title(),
225
+ WPGlobusCustomize.languageAdmin
226
+ )
227
+ );
228
+
229
+ /**
230
+ * Set menu-item-title value.
231
+ */
232
+ $e.val(
233
+ WPGlobusCore.TextFilter(
234
+ api.controlMenuItems[ obj ]['element'][ $e.attr('id') ]['value'],
235
+ WPGlobusCoreData.language,
236
+ 'RETURN_EMPTY'
237
+ )
238
+ );
239
+
240
+ }
241
+ if ( $e.hasClass( 'edit-menu-item-attr-title' ) ) {
242
+
243
+ api.controlMenuItems[ obj ]['element'][ $e.attr('id') ] = {};
244
+ $e.addClass( 'wpglobus-customize-menu-item-control' );
245
+ $e.attr( 'data-menu-item', obj );
246
+ $e.attr( 'data-element', 'attr_title' );
247
+ api.controlMenuItems[ obj ]['element'][ $e.attr('id') ]['value'] = control.elements.attr_title();
248
+ api.controlMenuItems[ obj ]['element'][ $e.attr('id') ]['element'] = 'attr_title';
249
+
250
+ /**
251
+ * Set menu-item-attr-title value.
252
+ */
253
+ $e.val(
254
+ WPGlobusCore.TextFilter(
255
+ api.controlMenuItems[ obj ]['element'][ $e.attr('id') ]['value'],
256
+ WPGlobusCoreData.language,
257
+ 'RETURN_EMPTY'
258
+ )
259
+ );
260
+
261
+ }
262
+ });
263
+
264
+ }
265
+ });
266
+
267
+ }
268
+
269
+ },
270
+ ctrlWidgetCallback: function( obj, control ) {
271
+
272
+ api.action = false;
273
+
274
+ if ( typeof api.controlWidgets[obj]['element'] !== 'undefined' ) {
275
+ return;
276
+ }
277
+
278
+ if ( typeof control === 'undefined' ) {
279
+ control = wp.customize.control.instance( obj );
280
+ }
281
+
282
+ api.controlWidgets[ obj ]['element'] = {};
283
+ api.controlWidgets[ obj ]['control'] = control;
284
+ api.controlWidgets[ obj ]['inWidgetTitle'] = control.container.find( '.in-widget-title' );
285
+
286
+ api.controlWidgets[ obj ]['parent'] = control.selector;
287
+
288
+ var submit = control.container.find( 'input[type=submit]' );
289
+
290
+ if ( submit.length != 0 ) {
291
+ submit.css({'display':'block'});
292
+ submit.attr( 'data-widget', obj );
293
+ api.controlWidgets[ obj ][ 'submit' ] = submit;
294
+ api.attachWidgetListeners( api.controlWidgets[ obj ] );
295
+ }
296
+
297
+ control.liveUpdateMode = false;
298
+
299
+ if ( typeof control.setting().title === 'undefined' ) {
300
+ api.controlWidgets[ obj ]['inWidgetTitle'].text( '' );
301
+ } else {
302
+ api.controlWidgets[ obj ]['inWidgetTitle'].text( ': ' + WPGlobusCore.TextFilter( control.setting().title, WPGlobusCustomize.languageAdmin ) );
303
+ }
304
+
305
+ $.each( WPGlobusCustomize.elementSelector, function(i,e){
306
+ var elements = control.container.find(e);
307
+ if ( elements.length != 0 ) {
308
+ /**
309
+ * Widget can contain set of elements.
310
+ */
311
+ $.each( elements, function( indx, elem ) {
312
+
313
+ if ( 'undefined' === typeof elem.id || '' == elem.id ) {
314
+ /**
315
+ * In widget some elements may don't have id
316
+ * e.g. https://wordpress.org/plugins/widget-context/
317
+ */
318
+ return true;
319
+ }
320
+
321
+ var $element = $( elements[indx] );
322
+
323
+ if ( typeof api.controlWidgets[obj]['element'][ elem.id ] === 'undefined' ) {
324
+ api.controlWidgets[obj]['element'][ elem.id ] = {};
325
+ }
326
+
327
+ $element.addClass( 'wpglobus-customize-widget-control' );
328
+ $element.attr( 'data-widget', obj );
329
+
330
+ api.controlWidgets[obj]['element'][ elem.id ]['element'] = $element;
331
+ api.controlWidgets[obj]['element'][ elem.id ]['setting'] = control.setting();
332
+ api.controlWidgets[obj]['element'][ elem.id ]['selector'] = e;
333
+ api.controlWidgets[obj]['element'][ elem.id ]['value'] = elem.defaultValue;
334
+
335
+ $element.val(
336
+ WPGlobusCore.TextFilter(
337
+ elem.defaultValue,
338
+ WPGlobusCoreData.language,
339
+ 'RETURN_EMPTY'
340
+ )
341
+ );
342
+
343
+ });
344
+
345
+ }
346
+ });
347
+
348
+ /**
349
+ * Event handler after widget was added
350
+ */
351
+ $( document ).triggerHandler( 'wpglobus_customize_control_added_widget', [ obj ] );
352
+
353
+ },
354
+ ctrlCallback: function( context, obj, key ) {
355
+
356
+ var dis = false;
357
+ $.each( WPGlobusCustomize.disabledSections, function(i,e) {
358
+ if ( context.section() == e ) {
359
+ dis = true;
360
+ return false;
361
+ }
362
+ });
363
+
364
+ if (dis) return;
365
+
366
+ $.each( WPGlobusCustomize.disabledSettingMask, function(i,e) {
367
+ /** @see wp.customize.control elements */
368
+ if ( obj.indexOf( e ) >= 0 ){
369
+ dis = true;
370
+ return false;
371
+ }
372
+ });
373
+
374
+ if (dis) return;
375
+
376
+ var control = wp.customize.control.instance( obj );
377
+
378
+ /**
379
+ * To check for object is widget.
380
+ */
381
+ if ( obj.indexOf( 'widget' ) >= 0 ) {
382
+ if ( typeof api.controlWidgets[obj] === 'undefined' ) {
383
+ api.controlWidgets[obj] = {};
384
+ if ( api.action ) {
385
+ api.ctrlWidgetCallback( obj, control );
386
+ }
387
+ }
388
+
389
+ api.controlWidgets[ obj ]['parent'] = control.selector;
390
+
391
+ if ( $(control.selector).length != 1 ) {
392
+ /**
393
+ * Don't add MutationObserver for non-existing parent of control element.
394
+ * @see https://wordpress.org/themes/ascend/
395
+ */
396
+ api.controlWidgets[ obj ]['observer'] = null;
397
+ } else {
398
+ /**
399
+ * Add Mutation Observer for widget.
400
+ */
401
+ api.controlWidgets[ obj ]['observer'] = new MutationObserver( function( mutations ) {
402
+ mutations.forEach( function( mutation ) {
403
+ if ( 'class' == mutation.attributeName ) {
404
+ if ( -1 != mutation.target.className.indexOf( 'expanding' ) ) {
405
+ /**
406
+ * @todo Now are using 'expanding' class maybe need to use 'widget-rendered' with delay.
407
+ */
408
+ api.ctrlWidgetCallback( obj );
409
+ }
410
+ }
411
+ });
412
+ });
413
+
414
+ api.controlWidgets[ obj ]['observer'].observe(
415
+ document.querySelector( api.controlWidgets[ obj ]['parent'] ),
416
+ { attributes: true, childList: true, characterData: true }
417
+ );
418
+ }
419
+
420
+ return false;
421
+ }
422
+
423
+ /**
424
+ if ( obj.indexOf( 'nav_menu_item' ) >= 0 ) {
425
+ if ( typeof api.controlMenuItems[obj] === 'undefined' ) {
426
+ api.controlMenuItems[obj] = {};
427
+ api.ctrlMenuItemsCallback( obj, control );
428
+ }
429
+ api.controlMenuItems[ obj ]['parent'] = control.selector;
430
+ return false;
431
+ } */
432
+
433
+ if ( typeof api.controlInstances[ obj ] !== 'undefined' ) {
434
+ return;
435
+ }
436
+
437
+ var controlEnabled = true;
438
+
439
+ $.each( WPGlobusCustomize.elementSelector, function(i,e){
440
+ var element = control.container.find( e );
441
+ if ( element.length != 0 ) {
442
+
443
+ if ( 'function' !== typeof(control.setting) ) {
444
+ /**
445
+ * @since 1.9.0
446
+ */
447
+ return true;
448
+ }
449
+
450
+
451
+
452
+ api.controlInstances[obj] = {};
453
+ api.controlInstances[obj]['element'] = element;
454
+ api.controlInstances[obj]['elementID'] = element.attr('id') ? '#'+element.attr('id') : undefined;
455
+ api.controlInstances[obj]['setting'] = control.setting();
456
+ api.controlInstances[obj]['selector'] = e;
457
+ /**
458
+ * To get element in DOM @see parent li.customize-control of this control.
459
+ * And element with 'data-customize-setting-link' attribute.
460
+ */
461
+ api.controlInstances[obj]['controlSelector'] = control.selector;
462
+ api.controlInstances[obj]['type'] = '';
463
+ api.controlInstances[obj]['section'] = control.section();
464
+ api.controlInstances[obj]['title'] = null;
465
+ api.controlInstances[obj]['userControl'] = null;
466
+ /**
467
+ * Field Settings for Fields Settings section in WPGlobus Settings panel.
468
+ * @see #accordion-section-wpglobus_fields_settings_section
469
+ */
470
+ api.controlInstances[obj]['fieldSettings'] = {};
471
+ api.controlInstances[obj]['fieldSettings']['itemID'] = 'item-wpglobus-cb-control-'+WPGlobusDialogApp.convertToId(obj);
472
+ api.controlInstances[obj]['fieldSettings']['cbID'] = 'wpglobus-cb-control-'+WPGlobusDialogApp.convertToId(obj);
473
+
474
+
475
+ // Let's test with Zerif Lite theme.
476
+ //
477
+ // When we open yoursite/wp-admin/customize.php:
478
+ //
479
+ // wp.customize.control('zerif_bigtitle_redbutton_url').setting() =
480
+ // "{:en}http://wpglobus.com/hot-news-1{:}{:de}http://wpglobus.com/de/hot-news-2{:}"
481
+ // WPGlobusCustomize.controlInstances['zerif_bigtitle_redbutton_url'].setting =
482
+ // "http://wpglobus.com/hot-news-1|||http://wpglobus.com/de/hot-news-2|||null|||null"
483
+
484
+ // After first saving of changeset we have:
485
+ //
486
+ // wp.customize.control('zerif_bigtitle_redbutton_url').setting() =
487
+ // "http://wpglobus.com/hot-news-1/"
488
+ // WPGlobusCustomize.controlInstances['zerif_bigtitle_redbutton_url'].setting =
489
+ // "http://wpglobus.com/hot-news-1/|||http://wpglobus.com/de/hot-news-2|||null|||null"
490
+
491
+ // Reload page with changeset_uuid in URL:
492
+ //
493
+ // wp.customize.control('zerif_bigtitle_redbutton_url').setting() =
494
+ // "http://wpglobus.com/hot-news-1/|||http://wpglobus.com/de/hot-news-2|||null|||null"
495
+ // WPGlobusCustomize.controlInstances['zerif_bigtitle_redbutton_url'].setting =
496
+ // "http://wpglobus.com/hot-news-1/|||http://wpglobus.com/de/hot-news-2|||null|||null"
497
+
498
+ // So, we must set correct URL value for default language when changeset was loaded.
499
+
500
+ $.each( WPGlobusCustomize.setLinkBy, function( i, piece ) {
501
+
502
+ if ( obj.indexOf( piece ) >= 0 ) {
503
+ api.controlInstances[obj]['type'] = 'link';
504
+
505
+ if ( '' == api.controlInstances[obj]['setting'] ) {
506
+ /** link perhaps was set to empty value */
507
+ api.controlInstances[obj]['setting'] = element[0].defaultValue;
508
+ }
509
+
510
+ if ( WPGlobusCustomize.changeset_uuid ) {
511
+ /**
512
+ * @since 1.7.9
513
+ */
514
+ var val = wp.customize.control(obj).setting();
515
+ if ( -1 !== val.indexOf( '|||' ) ) {
516
+ var value = api.getTranslations(val);
517
+ wp.customize.control(obj).setting( value[WPGlobusCoreData.default_language] );
518
+ $(
519
+ WPGlobusCustomize.controlInstances[obj].controlSelector +
520
+ ' ' +
521
+ WPGlobusCustomize.controlInstances[obj].selector
522
+ ).val( value[WPGlobusCoreData.default_language] );
523
+ }
524
+
525
+ }
526
+ element.addClass( 'wpglobus-control-link' );
527
+ }
528
+
529
+ });
530
+
531
+ if ( api.controlInstances[obj]['type'] === '' ) {
532
+ if ( e == 'textarea' ) {
533
+ api.controlInstances[obj]['type'] = 'textarea';
534
+ } else {
535
+ api.controlInstances[obj]['type'] = 'text';
536
+ }
537
+ }
538
+
539
+ element.val( WPGlobusCore.TextFilter( api.controlInstances[obj]['setting'], WPGlobusCoreData.language, 'RETURN_EMPTY' ) );
540
+ element.addClass( 'wpglobus-customize-control' );
541
+
542
+ /**
543
+ * Use control.selector instead of element.parents('li').attr('id') to get id parent li element
544
+ * element.attr( 'data-wpglobus-customize-control', element.parents('li').attr('id').replace( 'customize-control-', '') );
545
+ */
546
+ element.attr( 'data-wpglobus-customize-control', api.controlInstances[obj]['controlSelector'].replace( '#customize-control-', '') );
547
+
548
+ if ( api.controlInstances[obj]['type'] == 'link' ) {
549
+ api.controlInstances[obj]['setting'] = api.convertString( element[0].defaultValue );
550
+ };
551
+
552
+ /** Get control title. */
553
+ api.controlInstances[obj]['title'] = control.params.label;
554
+
555
+ /** Enable/disable user control. */
556
+ if ( WPGlobusCustomizeOptions.userControl !== null &&
557
+ typeof WPGlobusCustomizeOptions.userControl[ WPGlobusCustomizeOptions.themeName ] !== 'undefined' ) {
558
+
559
+ if ( typeof WPGlobusCustomizeOptions.userControl[ WPGlobusCustomizeOptions.themeName ][ obj ] !== 'undefined' &&
560
+ WPGlobusCustomizeOptions.userControl[ WPGlobusCustomizeOptions.themeName ][ obj ] == 'disable' ) {
561
+
562
+ controlEnabled = false;
563
+ }
564
+
565
+ }
566
+ api.controlInstances[obj]['userControl'] = {};
567
+ api.controlInstances[obj]['userControl']['enabled'] = controlEnabled;
568
+
569
+ api.setUserControls( obj, api.controlInstances[obj] );
570
+ }
571
+ });
572
+
573
+ },
574
+ setControlInstances: function() {
575
+ wp.customize.control.each( api.ctrlCallback );
576
+ },
577
+ setTitle: function() {
578
+ $( WPGlobusCoreData.customize.info.element ).html( WPGlobusCoreData.customize.info.html );
579
+ },
580
+ convertString: function(text) {
581
+ if ( typeof text === 'undefined' ) {
582
+ return text;
583
+ }
584
+ var r = [], tr = WPGlobusCore.getTranslations( text ),
585
+ i = 0, rE = true;
586
+
587
+ if ( text == tr[WPGlobusCoreData.default_language] ) {
588
+ /**
589
+ * Don't convert if text is in default language only.
590
+ */
591
+ return text;
592
+ }
593
+
594
+ $.each( tr, function(l,e) {
595
+ if ( e == '' ) {
596
+ r[i] = 'null';
597
+ } else {
598
+ rE = false;
599
+ r[i] = e;
600
+ }
601
+ i++;
602
+ });
603
+ if ( rE ) {
604
+ return '';
605
+ }
606
+ return r.join('|||');
607
+ },
608
+ getTranslations: function(text) {
609
+ if ( 'undefined' === typeof(text) ) {
610
+ return text;
611
+ }
612
+
613
+ var t = {},
614
+ ar = text.split('|||');
615
+ $.each(WPGlobusCoreData.enabled_languages, function(i,l){
616
+ t[l] = typeof ar[i] === 'undefined' || ar[i] === 'null' ? '' : ar[i];
617
+ });
618
+ return t;
619
+ },
620
+ getString: function(s, newVal, lang) {
621
+ /** using '|||' mark for correct work with url */
622
+ if ( 'undefined' === typeof( s ) ) {
623
+ return s;
624
+ }
625
+ if ( 'undefined' === typeof( newVal ) ) {
626
+ newVal = '';
627
+ }
628
+ if ( 'undefined' === typeof( lang ) ) {
629
+ lang = WPGlobusCoreData.language;
630
+ }
631
+
632
+ var tr = api.getTranslations(s),
633
+ sR = [], i = 0, rE = true;
634
+
635
+ $.each( tr, function(l,t){
636
+ if ( l == lang ) {
637
+ newVal = newVal.trim();
638
+ sR[i] = newVal == '' ? 'null' : newVal;
639
+ } else {
640
+ sR[i] = t == '' ? 'null' : t;
641
+ }
642
+ if ( l != WPGlobusCoreData.default_language ) {
643
+ if ( sR[i] != 'null' ) {
644
+ rE = false;
645
+ }
646
+ }
647
+ i++;
648
+ });
649
+ if ( rE ) {
650
+ /**
651
+ * Don't convert if sR is in default language only.
652
+ */
653
+ sR = sR[0];
654
+ } else {
655
+ sR = sR.join('|||');
656
+ }
657
+
658
+ return sR;
659
+ },
660
+ addLanguageSelector: function() {
661
+
662
+ if ( 'dropdown' == WPGlobusCustomize.selectorType ) {
663
+ /**
664
+ * @since 1.9.0
665
+ */
666
+ api.addLanguageSelectorDropdown();
667
+ return;
668
+ }
669
+
670
+ $( WPGlobusCustomize.selectorButton ).insertAfter('.customize-controls-preview-toggle');
671
+ $('.wpglobus-customize-selector').html( api.selectorHtml.replace('{{language}}', WPGlobusCoreData.language) );
672
+
673
+ $( document ).on( 'click', '.wpglobus-customize-selector', function(ev){
674
+
675
+ if ( api.index > api.length-1 ) {
676
+ api.index = 0;
677
+ } else {
678
+ api.index++;
679
+ }
680
+
681
+ WPGlobusCoreData.language = api.languages[ api.index ];
682
+
683
+ $(this).html( api.selectorHtml.replace( '{{language}}', WPGlobusCoreData.language ) );
684
+
685
+ /**
686
+ * Event after language was changed
687
+ */
688
+ $( document ).triggerHandler( 'wpglobus_customize_control_language', [ WPGlobusCoreData.language ] );
689
+
690
+ api.setControlsValue();
691
+
692
+ });
693
+
694
+ },
695
+ addLanguageSelectorDropdown: function() {
696
+ /**
697
+ * @since 1.9.0
698
+ */
699
+ $(WPGlobusCustomize.selectorButton).insertAfter('.customize-controls-preview-toggle');
700
+ $('.wpglobus-customize-selector').html( api.selectorHtml.replace('{{language}}', WPGlobusCoreData.language) );
701
+
702
+ var offset = $('.wpglobus-customize-selector').offset();
703
+ var top = offset.top+46; top = top+'px;'
704
+ var left = offset.left+'px;';
705
+ var statusBoxDelta = 0;
706
+
707
+ var dropList =
708
+ '<ul class="wpglobus-customize-selector-dropdown" style="display:none;position:fixed;width:46px;border-left:1px solid #ddd;border-right:1px solid #ddd;background-color:#eee;margin:-1px 0 0;padding:0;top:'+top+'left:'+left+'">';
709
+
710
+ $.each(WPGlobusCoreData.enabled_languages, function(i, lang) {
711
+ dropList += '<li class="item" style="text-align:center;cursor:pointer;border-bottom:1px solid #ddd;margin:0;" data-language="'+lang+'">';
712
+ dropList += '<span class="value value-'+lang+'" style="font-size:15px;">'+lang+'</span>';
713
+ dropList += '</li>';
714
+ });
715
+
716
+ dropList += '<li class="item wpglobus-customize-item-settings" style="text-align:center;cursor:pointer;border-bottom:1px solid #ddd;margin:0;">'+
717
+ '<span style="padding-top:14px;" class="dashicons dashicons-admin-tools"></span>'+
718
+ '</li>';
719
+ dropList += '</ul>';
720
+
721
+ /**
722
+ * Add dropdown selector list.
723
+ */
724
+ $('.wpglobus-customize-selector').after(dropList);
725
+
726
+ /**
727
+ * Selector.
728
+ */
729
+ $(document).on('mouseenter', '.wpglobus-customize-selector', function(ev) {
730
+ $('.wpglobus-customize-selector-dropdown').css({'display':'block'});
731
+ statusBoxDelta = ev.screenY;
732
+ });
733
+ $(document).on('mouseleave', '.wpglobus-customize-selector', function(ev) {
734
+ if ( statusBoxDelta != 0 && ev.screenY - statusBoxDelta <= 0) {
735
+ $('.wpglobus-customize-selector-dropdown').css({'display':'none'});
736
+ }
737
+ });
738
+
739
+ /**
740
+ * Dropdown list.
741
+ */
742
+ $(document).on('mouseleave', '.wpglobus-customize-selector-dropdown', function(ev) {
743
+ $('.wpglobus-customize-selector-dropdown').css({'display':'none'});
744
+ });
745
+
746
+ /**
747
+ * Dropdown items.
748
+ */
749
+ $(document).on('mouseenter', '.wpglobus-customize-selector-dropdown .item', function(ev) {
750
+ var $t = $(this);
751
+ var lang = $t.data('language');
752
+ $t.addClass('active');
753
+ $t.css({'background-color':'#fff'});
754
+ $t.find('.value-'+lang).css({'font-weight':'bold'});
755
+ });
756
+ $(document).on('mouseleave', '.wpglobus-customize-selector-dropdown .item', function(ev) {
757
+ var $t = $(this);
758
+ $t.removeClass('active');
759
+ $t.css({'background-color':'#eee'});
760
+ $(this).find('.value').css({'font-weight':''});
761
+ });
762
+ $(document).on('click', '.wpglobus-customize-selector-dropdown .item', function(ev) {
763
+ var newLang = $(this).data('language');
764
+
765
+ if ( 'undefined' === typeof(newLang) ) {
766
+ return;
767
+ }
768
+ if ( newLang != $('.wpglobus-customize-selector').data('language') ) {
769
+ api.languageChanged(newLang);
770
+ } else {
771
+ // debug.
772
+ }
773
+
774
+ });
775
+
776
+ /**
777
+ * Settings.
778
+ */
779
+ $(document).on('click', '.wpglobus-customize-item-settings', function(ev) {
780
+ wp.customize.control( 'wpglobus_fields_settings_section' ).expand({
781
+ completeCallback: api.settingsSectionExpand
782
+ });
783
+ $('.wpglobus-customize-selector-dropdown').css({'display':'none'});
784
+ });
785
+ },
786
+ languageChanged: function(newLang) {
787
+ /**
788
+ * @since 1.9.0
789
+ */
790
+ WPGlobusCoreData.language = newLang;
791
+ $('.wpglobus-customize-selector').data('language', newLang);
792
+ $('.wpglobus-customize-selector .current-language').text(newLang);
793
+ /**
794
+ * Event after language was changed.
795
+ */
796
+ $(document).triggerHandler( 'wpglobus_customize_control_language', [ WPGlobusCoreData.language ] );
797
+ api.setControlsValue();
798
+ },
799
+ setControlsValue: function() {
800
+ /**
801
+ * @since 1.9.0
802
+ */
803
+ $( '.wpglobus-customize-control' ).each( function(i,e){
804
+ var $e = $(e),
805
+ inst = $e.data( 'customize-setting-link' );
806
+
807
+ if ( 'undefined' === typeof WPGlobusCustomize.controlInstances[inst] ) {
808
+ /**
809
+ * try get control element from attribute data-wpglobus-customize-control
810
+ * for example @see Blink theme, customize control element footer-text instead of blink_footer-text
811
+ */
812
+ inst = $e.data( 'wpglobus-customize-control' );
813
+ if ( 'undefined' === typeof WPGlobusCustomize.controlInstances[inst] ) {
814
+ return;
815
+ }
816
+ }
817
+
818
+ if ( $e.hasClass( 'wpglobus-control-link' ) ) {
819
+ var t = api.getTranslations( WPGlobusCustomize.controlInstances[inst].setting );
820
+ $e.val( t[ WPGlobusCoreData.language ] );
821
+ } else {
822
+ /**
823
+ * @since 1.8.2
824
+ */
825
+ var t = WPGlobusCore.TextFilter( WPGlobusCustomize.controlInstances[inst].setting, WPGlobusCoreData.language, 'RETURN_EMPTY' );
826
+ if ( 'tinymce' == WPGlobusCustomize.controlInstances[inst]['type'] ) {
827
+ tinymce.get(inst).setContent( t, {format:'raw'} );
828
+ }
829
+ $e.val( WPGlobusCore.TextFilter( t, 'RETURN_EMPTY' ) );
830
+ }
831
+ });
832
+
833
+ /** widgets */
834
+ $( '.wpglobus-customize-widget-control' ).each( function(i, e){
835
+
836
+ var $e = $(e), obj = $e.data( 'widget' );
837
+
838
+ if ( 'undefined' === typeof $e.attr('id') ) {
839
+ return true;
840
+ }
841
+
842
+ $e.val(
843
+ WPGlobusCore.TextFilter(
844
+ WPGlobusCustomize.controlWidgets[ obj ][ 'element' ][ $e.attr('id') ][ 'value' ],
845
+ WPGlobusCoreData.language,
846
+ 'RETURN_EMPTY'
847
+ )
848
+ );
849
+
850
+ });
851
+
852
+ /** menu items */
853
+ /**
854
+ $( '.wpglobus-customize-menu-item-control' ).each( function(i, e){
855
+ var $e = $(e);
856
+
857
+ $e.val(
858
+ WPGlobusCore.TextFilter(
859
+ WPGlobusCustomize.controlMenuItems[ $e.data( 'menu-item' ) ][ 'element' ][ $e.attr('id') ]['value'],
860
+ WPGlobusCoreData.language,
861
+ 'RETURN_EMPTY'
862
+ )
863
+ );
864
+
865
+ }); */
866
+ },
867
+ updateElements: function( force ) {
868
+ if ( typeof force === 'undefined' ) {
869
+ force = true;
870
+ }
871
+
872
+ /** updateElements simple controls */
873
+ $.each( WPGlobusCustomize.controlInstances, function( inst, data ) {
874
+ if ( ! data.userControl.enabled ) {
875
+ /* next iteration */
876
+ return true;
877
+ }
878
+ var control = wp.customize.control.instance( inst );
879
+ if ( data.type == 'link' ) {
880
+ var t = api.getTranslations( WPGlobusCustomize.controlInstances[inst].setting );
881
+ if ( force ) {
882
+ control.setting.set( t[ WPGlobusCoreData.language ] );
883
+ data.element.val( control.setting() );
884
+ } else {
885
+ data.element.val( t[ WPGlobusCoreData.language ] );
886
+ }
887
+ } else if ( data.type == 'tinymce' ) {
888
+ /**
889
+ * @since 1.8.2
890
+ * @todo check for 'force' param.
891
+ */
892
+ //if ( force ) {
893
+ var t = WPGlobusCore.TextFilter( WPGlobusCustomize.controlInstances[inst].setting, WPGlobusCoreData.language, 'RETURN_EMPTY' );
894
+ /**
895
+ * First we need to set content for tinymce editor.
896
+ */
897
+ tinymce.get(inst).setContent( t, {format:'raw'} );
898
+ /**
899
+ * But user could choose Text mode, so we set value for textarea anyway.
900
+ */
901
+ data.element.val( t );
902
+ //data.element.val( tinymce.get(inst).getContent() );
903
+ //} else {
904
+ //data.element.val( WPGlobusCore.TextFilter( WPGlobusCustomize.controlInstances[inst].setting, WPGlobusCoreData.language, 'RETURN_EMPTY' ) );
905
+ //}
906
+ } else {
907
+ if ( force ) {
908
+ control.setting.set( WPGlobusCore.TextFilter( WPGlobusCustomize.controlInstances[inst].setting, WPGlobusCoreData.language, 'RETURN_EMPTY' ) );
909
+ data.element.val( control.setting() );
910
+ } else {
911
+ data.element.val( WPGlobusCore.TextFilter( WPGlobusCustomize.controlInstances[inst].setting, WPGlobusCoreData.language, 'RETURN_EMPTY' ) );
912
+ }
913
+ }
914
+ });
915
+
916
+ /** updateElements menu items */
917
+ /**
918
+ $.each( WPGlobusCustomize.controlMenuItems, function( menuItem, object ) {
919
+ if ( typeof object.element === 'undefined' ) {
920
+ return;
921
+ }
922
+ $.each( object.element, function( id, obj ) {
923
+ $( '#' + id ).val(
924
+ WPGlobusCore.TextFilter( obj.value, WPGlobusCoreData.language, 'RETURN_EMPTY' )
925
+ );
926
+ });
927
+ }); */
928
+ },
929
+ onSubmitEvents: function( ev ) {
930
+
931
+ if ( ev.type == 'mouseenter' ) {
932
+
933
+ $.each( api.controlWidgets[ $(this).data('widget') ]['element'], function(id,e) {
934
+ $( '#' + id ).val( e.value );
935
+ });
936
+
937
+ } else if ( ev.type == 'mouseleave' ) {
938
+
939
+ if ( ! api.widgetKeep ) {
940
+ $.each( api.controlWidgets[ $(this).data('widget') ]['element'], function(id,e) {
941
+ $( '#' + id ).val( WPGlobusCore.TextFilter( e.value, WPGlobusCoreData.language, 'RETURN_EMPTY' ) );
942
+ });
943
+ }
944
+
945
+ } else if ( ev.type == 'click' ) {
946
+ api.widgetKeep = true;
947
+ }
948
+
949
+ },
950
+ attachWidgetListeners: function( obj ) {
951
+
952
+ if ( typeof obj['submit'][0]['id'] !== 'undefined' ) {
953
+
954
+ $( document ).on( 'mouseenter', '#' + obj['submit'][0]['id'], api.onSubmitEvents )
955
+ .on( 'mouseleave', '#' + obj['submit'][0]['id'], api.onSubmitEvents )
956
+ .on( 'click', '#' + obj['submit'][0]['id'], api.onSubmitEvents );
957
+
958
+ }
959
+
960
+ },
961
+ attachListeners: function() {
962
+ /** attachListeners: simple controls */
963
+ $( '.wpglobus-customize-control' ).on( 'keyup', function(ev) {
964
+ var $t = $(this),
965
+ inst = $t.data( 'customize-setting-link' );
966
+
967
+ if ( 'undefined' === typeof WPGlobusCustomize.controlInstances[inst] ) {
968
+ /**
969
+ * try get control element from attribute data-wpglobus-customize-control
970
+ * for example @see Blink theme, customize control element footer-text instead of blink_footer-text
971
+ */
972
+ inst = $t.data( 'wpglobus-customize-control' );
973
+ if ( 'undefined' === typeof WPGlobusCustomize.controlInstances[inst] ) {
974
+ /**
975
+ * Now don't return from callback, we have trigger.
976
+ * @since 1.7.10
977
+ */
978
+ //return;
979
+ }
980
+ }
981
+
982
+ /**
983
+ * @since 1.7.10
984
+ */
985
+ if ( 'undefined' !== typeof $(document).triggerHandler( 'wpglobus_customize_control_keyup', [ $t, inst ] ) ) {
986
+ return;
987
+ }
988
+
989
+ if ( WPGlobusCustomize.controlInstances[inst]['type'] == 'link' ) {
990
+
991
+ WPGlobusCustomize.controlInstances[inst]['setting'] = api.getString(
992
+ WPGlobusCustomize.controlInstances[inst]['setting'],
993
+ $t.val(),
994
+ WPGlobusCoreData.language
995
+ );
996
+
997
+ } else {
998
+
999
+ WPGlobusCustomize.controlInstances[inst]['setting'] = WPGlobusCore.getString(
1000
+ WPGlobusCustomize.controlInstances[inst]['setting'],
1001
+ $t.val(),
1002
+ WPGlobusCoreData.language
1003
+ );
1004
+
1005
+ }
1006
+ });
1007
+
1008
+ /** attachListeners: widgets */
1009
+ $( document ).on( 'keyup', '.wpglobus-customize-widget-control', function(ev) {
1010
+ var $t = $(this),
1011
+ obj = $t.data( 'widget' );
1012
+
1013
+ if ( 'undefined' === typeof WPGlobusCustomize.controlWidgets[ obj ] ) {
1014
+ return;
1015
+ }
1016
+
1017
+ WPGlobusCustomize.controlWidgets[ obj ]['element'][ $t.attr('id') ]['value'] = WPGlobusCore.getString(
1018
+ WPGlobusCustomize.controlWidgets[ obj ]['element'][ $t.attr('id') ]['value'],
1019
+ $t.val(),
1020
+ WPGlobusCoreData.language
1021
+ );
1022
+
1023
+ });
1024
+
1025
+ /** attachListeners: menu items */
1026
+ /**
1027
+ $( document ).on( 'keyup', '.wpglobus-customize-menu-item-control', function(ev) {
1028
+ var $t = $(this),
1029
+ obj = $t.data( 'menu-item' );
1030
+
1031
+ if ( 'undefined' === typeof WPGlobusCustomize.controlMenuItems[ obj ] ) {
1032
+ return;
1033
+ }
1034
+
1035
+ WPGlobusCustomize.controlMenuItems[ obj ]['element'][ $t.attr('id') ][ 'value' ] = WPGlobusCore.getString(
1036
+ WPGlobusCustomize.controlMenuItems[ obj ]['element'][ $t.attr('id') ][ 'value' ],
1037
+ $t.val(),
1038
+ WPGlobusCoreData.language
1039
+ );
1040
+
1041
+ }); */
1042
+
1043
+ /** attachListeners: Save&Publish button */
1044
+ $(document).on( 'mouseenter', '#save', function( event ) {
1045
+
1046
+ /** Save&Publish simple controls */
1047
+ $.each( WPGlobusCustomize.controlInstances, function( inst, data ) {
1048
+ if ( data.userControl.enabled ) {
1049
+
1050
+ var control = wp.customize.control.instance( inst );
1051
+
1052
+ /**
1053
+ * @since 1.8.2
1054
+ */
1055
+ if ( 'tinymce' == data.type ) {
1056
+ tinymce.get(inst).setContent( data.setting, {format:'raw'} );
1057
+ }
1058
+ /**
1059
+ * But user could choose Text mode, so we set value for textarea anyway.
1060
+ */
1061
+ control.setting.set( data.setting );
1062
+ data.element.val( control.setting() );
1063
+ }
1064
+ });
1065
+
1066
+ /** Save&Publish menu items */
1067
+ /**
1068
+ $.each( WPGlobusCustomize.controlMenuItems, function( menuItem, object ) {
1069
+ if ( typeof object.element === 'undefined' ) {
1070
+ return;
1071
+ }
1072
+ var control = wp.customize.control.instance( menuItem );
1073
+ $.each( object.element, function( id, obj ) {
1074
+ $( '#' + id ).val( obj.value );
1075
+ control.elements[ obj.element ]( obj.value );
1076
+ });
1077
+ }); */
1078
+
1079
+ }).on( 'mouseleave', '#save', function( event ) {
1080
+ if ( ! api.instancesKeep ) {
1081
+ api.updateElements();
1082
+ wp.customize.previewer.refresh();
1083
+ }
1084
+ });
1085
+
1086
+ /**
1087
+ * Don't use $(document) for this case.
1088
+ */
1089
+ $('#save').on('click', function(event){
1090
+ api.instancesKeep = true;
1091
+ });
1092
+
1093
+ /**
1094
+ * AttachListeners: ajaxSend event handler.
1095
+ */
1096
+ $(document).on( 'ajaxSend', function( ev, jqXHR, ajaxOptions ) {
1097
+ if ( typeof ajaxOptions.data === 'undefined' ) {
1098
+ return;
1099
+ }
1100
+ if ( -1 != ajaxOptions.data.indexOf( 'wp_customize=on' ) && -1 != ajaxOptions.data.indexOf( 'action=customize_save' ) ) {
1101
+ api.customizeSave = true;
1102
+ }
1103
+ });
1104
+
1105
+ /**
1106
+ * AttachListeners: ajaxComplete event handler.
1107
+ */
1108
+ $(document).on( 'ajaxComplete', function( ev, response ) {
1109
+
1110
+ if ( typeof response.responseText === 'undefined' ) {
1111
+ return;
1112
+ }
1113
+ /**
1114
+ * @todo check adding new widget.
1115
+ */
1116
+ if ( api.customizeSave ) {
1117
+
1118
+ /** Save&Publish ajax complete */
1119
+ api.updateElements( false );
1120
+ if ( api.instancesKeep ) {
1121
+ api.instancesKeep = false;
1122
+ }
1123
+
1124
+ } else {
1125
+
1126
+ if ( response.responseText.indexOf( 'WP_CUSTOMIZER_SIGNATURE' ) >= 0 ) {
1127
+ api.action = 'customizerAjaxComplete';
1128
+ api.setControlInstances();
1129
+ }
1130
+
1131
+ $.each( WPGlobusCustomize.controlWidgets, function( obj, data ) {
1132
+ /** Apply widget ajax complete */
1133
+
1134
+ var w = obj.replace( '_', '-' );
1135
+
1136
+ if ( response.responseText.indexOf( w ) >= 0 ) {
1137
+
1138
+ data.submit.css({'display':'block'});
1139
+ data.control.liveUpdateMode = false;
1140
+
1141
+ $.each( data['element'], function( id, e ) {
1142
+ $( '#' + id ).val( WPGlobusCore.TextFilter( e.value, WPGlobusCoreData.language, 'RETURN_EMPTY' ) );
1143
+ });
1144
+
1145
+ data.inWidgetTitle.text( ': ' + WPGlobusCore.TextFilter( data.control.setting().title, WPGlobusCustomize.languageAdmin ) );
1146
+ api.widgetKeep = false;
1147
+
1148
+ return false;
1149
+ }
1150
+
1151
+ });
1152
+
1153
+ }
1154
+
1155
+ api.customizeSave = false;
1156
+
1157
+ wp.customize.previewer.refresh();
1158
+
1159
+ });
1160
+
1161
+ /**
1162
+ * AttachListeners: Event handler for tracking clicks by widgets title.
1163
+ */
1164
+ /**
1165
+ * @todo remove this listener after testing with WP4.7.
1166
+ */
1167
+ /*
1168
+ $(document).on( 'click', '.widget-title, .widget-title-action', function(ev){
1169
+ return;
1170
+ var id = $(this).parents( '.customize-control-widget_form' ).attr( 'id' );
1171
+ $.each( api.controlWidgets, function( obj, d ) {
1172
+ if ( '#'+id == d.parent ) {
1173
+ api.ctrlWidgetCallback( obj );
1174
+ return false;
1175
+ }
1176
+ });
1177
+ }); */
1178
+
1179
+ /**
1180
+ * attachListeners: Event handler for tracking clicks by menu item title.
1181
+ */
1182
+ /**
1183
+ $(document).on( 'click', '.control-section-nav_menu .accordion-section-title', function(ev){
1184
+ $.each( api.controlMenuItems, function( obj, d ) {
1185
+ api.ctrlMenuItemsCallback( obj );
1186
+ });
1187
+ }); */
1188
+
1189
+
1190
+ }
1191
+ };
1192
+
1193
+ WPGlobusCustomize = $.extend( {}, WPGlobusCustomize, api );
1194
+
1195
+ WPGlobusCustomize.init();
1196
+
1197
+ });
includes/js/wpglobus-customize-control190.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(document).ready(function(e){"use strict";var t={languages:{},index:0,length:0,controlInstances:{},controlWidgets:{},instancesKeep:!1,widgetKeep:!1,action:!1,customizeSave:!1,selectorHtml:'<span style="margin-left:5px;" class="wpglobus-icon-globe"></span><span class="current-language" style="font-weight:bold;">{{language}}</span>',settingsSectionExpand:function(){e(document).triggerHandler("wpglobus_fields_settings_section_expand",[this,t])},init:function(o){t.setTitle(),"false"!=WPGlobusCustomizeOptions.themeEnabled&&(e.each(WPGlobusCoreData.enabled_languages,function(e,o){t.languages[e]=o,t.length=e}),t.addLanguageSelector(),t.setControlInstances(),t.setFieldsSection(),t.attachListeners(),t.setTinymce())},updateTinymce:function(e){"tinymce"==WPGlobusCustomize.controlInstances[this.id].type&&(WPGlobusCustomize.controlInstances[this.id].setting=WPGlobusCore.getString(WPGlobusCustomize.controlInstances[this.id].setting,e.target.textContent,WPGlobusCoreData.language))},setTinymce:function(o){e(document).on("tinymce-editor-init",function(o,n){"object"==typeof t.controlInstances[n.id]&&(t.controlInstances[n.id].type="tinymce",e(n.iframeElement).addClass("wpglobus-customize-control").css({width:"99%"}),n.on("input",_.debounce(t.updateTinymce,300)))})},getSize:function(e){return void 0===e?_.size(t.controlInstances):"widget"==e?_.size(t.controlWidgets):null},setFieldsSection:function(){var o={},n=e(".wpglobus-fields_settings_control_box").data("section-template"),s="",l="",i="";e.each(WPGlobusCustomize.controlInstances,function(e,t){void 0===o[t.section]&&(o[t.section]={}),o[t.section][e]=t}),e.each(o,function(t,o){if(l="<ul>",e.each(o,function(e,t){i=t.userControl.enabled?" checked ":"",l+='<li id="'+t.fieldSettings.itemID+'">',l+='<input id="'+t.fieldSettings.cbID+'" data-control="'+e+'" class="wpglobus-customize-cb-control" type="checkbox"'+i+' /> <span class="wpglobus-cb-control-title">'+t.title+"</span>",l+="</li>"}),l+="</ul>",void 0===wp.customize.section(t))return!0;s=(s=(s=(s=n.replace("{{section_title}}",wp.customize.section(t).params.title)).replace(/{{section}}/g,t)).replace("{{section_id}}",'"'+t+'"')).replace("{{items}}",l),e(s).insertBefore(e("#"+WPGlobusCustomizeOptions.userControlSaveButton))}),e("#accordion-section-wpglobus_fields_settings_section").css({"margin-top":"15px"}),e(WPGlobusCustomizeOptions.helpButton).insertAfter(e("#accordion-section-wpglobus_fields_settings_section .customize-action")),e("#accordion-section-wpglobus_fields_settings_section .customize-section-description").addClass("hidden"),e(document).on("click","."+WPGlobusCustomizeOptions.userControlIconClass,function(o){var n=e(this).data("section");e(WPGlobusCustomizeOptions.userControlBoxSelector).each(function(t,o){n==e(o).data("section")?e(this).css({display:"block"}):e(this).css({display:"none"})}),wp.customize.control("wpglobus_fields_settings_section").expand({completeCallback:t.settingsSectionExpand})}),e(".wpglobus-customize-icon-help.customize-help-toggle").on("click",function(t){e("#accordion-section-wpglobus_fields_settings_section .customize-section-description").toggleClass("hidden")})},setUserControls:function(t,o){var n=o.controlSelector+" "+o.selector,s='<img class="'+WPGlobusCustomizeOptions.userControlIconClass+'" data-section="'+o.section+'" style="position:absolute;right:0px;cursor:pointer;" src="'+WPGlobusCustomizeOptions.userControlIcon+'" />';e(s).insertBefore(n),o.userControl.enabled||(e(n).length>1?e(n).each(function(t,o){e(o).removeClass(WPGlobusCustomize.controlClass)}):e(n).removeClass(WPGlobusCustomize.controlClass).val(o.setting))},ctrlMenuItemsCallback:function(e,t){},ctrlWidgetCallback:function(o,n){if(t.action=!1,void 0===t.controlWidgets[o].element){void 0===n&&(n=wp.customize.control.instance(o)),t.controlWidgets[o].element={},t.controlWidgets[o].control=n,t.controlWidgets[o].inWidgetTitle=n.container.find(".in-widget-title"),t.controlWidgets[o].parent=n.selector;var s=n.container.find("input[type=submit]");0!=s.length&&(s.css({display:"block"}),s.attr("data-widget",o),t.controlWidgets[o].submit=s,t.attachWidgetListeners(t.controlWidgets[o])),n.liveUpdateMode=!1,void 0===n.setting().title?t.controlWidgets[o].inWidgetTitle.text(""):t.controlWidgets[o].inWidgetTitle.text(": "+WPGlobusCore.TextFilter(n.setting().title,WPGlobusCustomize.languageAdmin)),e.each(WPGlobusCustomize.elementSelector,function(s,l){var i=n.container.find(l);0!=i.length&&e.each(i,function(s,a){if(void 0===a.id||""==a.id)return!0;var c=e(i[s]);void 0===t.controlWidgets[o].element[a.id]&&(t.controlWidgets[o].element[a.id]={}),c.addClass("wpglobus-customize-widget-control"),c.attr("data-widget",o),t.controlWidgets[o].element[a.id].element=c,t.controlWidgets[o].element[a.id].setting=n.setting(),t.controlWidgets[o].element[a.id].selector=l,t.controlWidgets[o].element[a.id].value=a.defaultValue,c.val(WPGlobusCore.TextFilter(a.defaultValue,WPGlobusCoreData.language,"RETURN_EMPTY"))})}),e(document).triggerHandler("wpglobus_customize_control_added_widget",[o])}},ctrlCallback:function(o,n,s){var l=!1;if(e.each(WPGlobusCustomize.disabledSections,function(e,t){if(o.section()==t)return l=!0,!1}),!l&&(e.each(WPGlobusCustomize.disabledSettingMask,function(e,t){if(n.indexOf(t)>=0)return l=!0,!1}),!l)){var i=wp.customize.control.instance(n);if(n.indexOf("widget")>=0)return void 0===t.controlWidgets[n]&&(t.controlWidgets[n]={},t.action&&t.ctrlWidgetCallback(n,i)),t.controlWidgets[n].parent=i.selector,1!=e(i.selector).length?t.controlWidgets[n].observer=null:(t.controlWidgets[n].observer=new MutationObserver(function(e){e.forEach(function(e){"class"==e.attributeName&&-1!=e.target.className.indexOf("expanding")&&t.ctrlWidgetCallback(n)})}),t.controlWidgets[n].observer.observe(document.querySelector(t.controlWidgets[n].parent),{attributes:!0,childList:!0,characterData:!0})),!1;if(void 0===t.controlInstances[n]){var a=!0;e.each(WPGlobusCustomize.elementSelector,function(o,s){var l=i.container.find(s);if(0!=l.length){if("function"!=typeof i.setting)return!0;t.controlInstances[n]={},t.controlInstances[n].element=l,t.controlInstances[n].elementID=l.attr("id")?"#"+l.attr("id"):void 0,t.controlInstances[n].setting=i.setting(),t.controlInstances[n].selector=s,t.controlInstances[n].controlSelector=i.selector,t.controlInstances[n].type="",t.controlInstances[n].section=i.section(),t.controlInstances[n].title=null,t.controlInstances[n].userControl=null,t.controlInstances[n].fieldSettings={},t.controlInstances[n].fieldSettings.itemID="item-wpglobus-cb-control-"+WPGlobusDialogApp.convertToId(n),t.controlInstances[n].fieldSettings.cbID="wpglobus-cb-control-"+WPGlobusDialogApp.convertToId(n),e.each(WPGlobusCustomize.setLinkBy,function(o,s){if(n.indexOf(s)>=0){if(t.controlInstances[n].type="link",""==t.controlInstances[n].setting&&(t.controlInstances[n].setting=l[0].defaultValue),WPGlobusCustomize.changeset_uuid){var i=wp.customize.control(n).setting();if(-1!==i.indexOf("|||")){var a=t.getTranslations(i);wp.customize.control(n).setting(a[WPGlobusCoreData.default_language]),e(WPGlobusCustomize.controlInstances[n].controlSelector+" "+WPGlobusCustomize.controlInstances[n].selector).val(a[WPGlobusCoreData.default_language])}}l.addClass("wpglobus-control-link")}}),""===t.controlInstances[n].type&&(t.controlInstances[n].type="textarea"==s?"textarea":"text"),l.val(WPGlobusCore.TextFilter(t.controlInstances[n].setting,WPGlobusCoreData.language,"RETURN_EMPTY")),l.addClass("wpglobus-customize-control"),l.attr("data-wpglobus-customize-control",t.controlInstances[n].controlSelector.replace("#customize-control-","")),"link"==t.controlInstances[n].type&&(t.controlInstances[n].setting=t.convertString(l[0].defaultValue)),t.controlInstances[n].title=i.params.label,null!==WPGlobusCustomizeOptions.userControl&&void 0!==WPGlobusCustomizeOptions.userControl[WPGlobusCustomizeOptions.themeName]&&void 0!==WPGlobusCustomizeOptions.userControl[WPGlobusCustomizeOptions.themeName][n]&&"disable"==WPGlobusCustomizeOptions.userControl[WPGlobusCustomizeOptions.themeName][n]&&(a=!1),t.controlInstances[n].userControl={},t.controlInstances[n].userControl.enabled=a,t.setUserControls(n,t.controlInstances[n])}})}}},setControlInstances:function(){wp.customize.control.each(t.ctrlCallback)},setTitle:function(){e(WPGlobusCoreData.customize.info.element).html(WPGlobusCoreData.customize.info.html)},convertString:function(t){if(void 0===t)return t;var o=[],n=WPGlobusCore.getTranslations(t),s=0,l=!0;return t==n[WPGlobusCoreData.default_language]?t:(e.each(n,function(e,t){""==t?o[s]="null":(l=!1,o[s]=t),s++}),l?"":o.join("|||"))},getTranslations:function(t){if(void 0===t)return t;var o={},n=t.split("|||");return e.each(WPGlobusCoreData.enabled_languages,function(e,t){o[t]=void 0===n[e]||"null"===n[e]?"":n[e]}),o},getString:function(o,n,s){if(void 0===o)return o;void 0===n&&(n=""),void 0===s&&(s=WPGlobusCoreData.language);var l=t.getTranslations(o),i=[],a=0,c=!0;return e.each(l,function(e,t){e==s?(n=n.trim(),i[a]=""==n?"null":n):i[a]=""==t?"null":t,e!=WPGlobusCoreData.default_language&&"null"!=i[a]&&(c=!1),a++}),i=c?i[0]:i.join("|||")},addLanguageSelector:function(){"dropdown"!=WPGlobusCustomize.selectorType?(e(WPGlobusCustomize.selectorButton).insertAfter(".customize-controls-preview-toggle"),e(".wpglobus-customize-selector").html(t.selectorHtml.replace("{{language}}",WPGlobusCoreData.language)),e(document).on("click",".wpglobus-customize-selector",function(o){t.index>t.length-1?t.index=0:t.index++,WPGlobusCoreData.language=t.languages[t.index],e(this).html(t.selectorHtml.replace("{{language}}",WPGlobusCoreData.language)),e(document).triggerHandler("wpglobus_customize_control_language",[WPGlobusCoreData.language]),t.setControlsValue()})):t.addLanguageSelectorDropdown()},addLanguageSelectorDropdown:function(){e(WPGlobusCustomize.selectorButton).insertAfter(".customize-controls-preview-toggle"),e(".wpglobus-customize-selector").html(t.selectorHtml.replace("{{language}}",WPGlobusCoreData.language));var o=e(".wpglobus-customize-selector").offset(),n=o.top+46,s=0,l='<ul class="wpglobus-customize-selector-dropdown" style="display:none;position:fixed;width:46px;border-left:1px solid #ddd;border-right:1px solid #ddd;background-color:#eee;margin:-1px 0 0;padding:0;top:'+(n+="px;")+"left:"+(o.left+"px;")+'">';e.each(WPGlobusCoreData.enabled_languages,function(e,t){l+='<li class="item" style="text-align:center;cursor:pointer;border-bottom:1px solid #ddd;margin:0;" data-language="'+t+'">',l+='<span class="value value-'+t+'" style="font-size:15px;">'+t+"</span>",l+="</li>"}),l+='<li class="item wpglobus-customize-item-settings" style="text-align:center;cursor:pointer;border-bottom:1px solid #ddd;margin:0;"><span style="padding-top:14px;" class="dashicons dashicons-admin-tools"></span></li>',l+="</ul>",e(".wpglobus-customize-selector").after(l),e(document).on("mouseenter",".wpglobus-customize-selector",function(t){e(".wpglobus-customize-selector-dropdown").css({display:"block"}),s=t.screenY}),e(document).on("mouseleave",".wpglobus-customize-selector",function(t){0!=s&&t.screenY-s<=0&&e(".wpglobus-customize-selector-dropdown").css({display:"none"})}),e(document).on("mouseleave",".wpglobus-customize-selector-dropdown",function(t){e(".wpglobus-customize-selector-dropdown").css({display:"none"})}),e(document).on("mouseenter",".wpglobus-customize-selector-dropdown .item",function(t){var o=e(this),n=o.data("language");o.addClass("active"),o.css({"background-color":"#fff"}),o.find(".value-"+n).css({"font-weight":"bold"})}),e(document).on("mouseleave",".wpglobus-customize-selector-dropdown .item",function(t){var o=e(this);o.removeClass("active"),o.css({"background-color":"#eee"}),e(this).find(".value").css({"font-weight":""})}),e(document).on("click",".wpglobus-customize-selector-dropdown .item",function(o){var n=e(this).data("language");void 0!==n&&n!=e(".wpglobus-customize-selector").data("language")&&t.languageChanged(n)}),e(document).on("click",".wpglobus-customize-item-settings",function(o){wp.customize.control("wpglobus_fields_settings_section").expand({completeCallback:t.settingsSectionExpand}),e(".wpglobus-customize-selector-dropdown").css({display:"none"})})},languageChanged:function(o){WPGlobusCoreData.language=o,e(".wpglobus-customize-selector").data("language",o),e(".wpglobus-customize-selector .current-language").text(o),e(document).triggerHandler("wpglobus_customize_control_language",[WPGlobusCoreData.language]),t.setControlsValue()},setControlsValue:function(){e(".wpglobus-customize-control").each(function(o,n){var s=e(n),l=s.data("customize-setting-link");if(void 0!==WPGlobusCustomize.controlInstances[l]||(l=s.data("wpglobus-customize-control"),void 0!==WPGlobusCustomize.controlInstances[l]))if(s.hasClass("wpglobus-control-link")){var i=t.getTranslations(WPGlobusCustomize.controlInstances[l].setting);s.val(i[WPGlobusCoreData.language])}else{i=WPGlobusCore.TextFilter(WPGlobusCustomize.controlInstances[l].setting,WPGlobusCoreData.language,"RETURN_EMPTY");"tinymce"==WPGlobusCustomize.controlInstances[l].type&&tinymce.get(l).setContent(i,{format:"raw"}),s.val(WPGlobusCore.TextFilter(i,"RETURN_EMPTY"))}}),e(".wpglobus-customize-widget-control").each(function(t,o){var n=e(o),s=n.data("widget");if(void 0===n.attr("id"))return!0;n.val(WPGlobusCore.TextFilter(WPGlobusCustomize.controlWidgets[s].element[n.attr("id")].value,WPGlobusCoreData.language,"RETURN_EMPTY"))})},updateElements:function(o){void 0===o&&(o=!0),e.each(WPGlobusCustomize.controlInstances,function(e,n){if(!n.userControl.enabled)return!0;var s=wp.customize.control.instance(e);if("link"==n.type){var l=t.getTranslations(WPGlobusCustomize.controlInstances[e].setting);o?(s.setting.set(l[WPGlobusCoreData.language]),n.element.val(s.setting())):n.element.val(l[WPGlobusCoreData.language])}else if("tinymce"==n.type){l=WPGlobusCore.TextFilter(WPGlobusCustomize.controlInstances[e].setting,WPGlobusCoreData.language,"RETURN_EMPTY");tinymce.get(e).setContent(l,{format:"raw"}),n.element.val(l)}else o?(s.setting.set(WPGlobusCore.TextFilter(WPGlobusCustomize.controlInstances[e].setting,WPGlobusCoreData.language,"RETURN_EMPTY")),n.element.val(s.setting())):n.element.val(WPGlobusCore.TextFilter(WPGlobusCustomize.controlInstances[e].setting,WPGlobusCoreData.language,"RETURN_EMPTY"))})},onSubmitEvents:function(o){"mouseenter"==o.type?e.each(t.controlWidgets[e(this).data("widget")].element,function(t,o){e("#"+t).val(o.value)}):"mouseleave"==o.type?t.widgetKeep||e.each(t.controlWidgets[e(this).data("widget")].element,function(t,o){e("#"+t).val(WPGlobusCore.TextFilter(o.value,WPGlobusCoreData.language,"RETURN_EMPTY"))}):"click"==o.type&&(t.widgetKeep=!0)},attachWidgetListeners:function(o){void 0!==o.submit[0].id&&e(document).on("mouseenter","#"+o.submit[0].id,t.onSubmitEvents).on("mouseleave","#"+o.submit[0].id,t.onSubmitEvents).on("click","#"+o.submit[0].id,t.onSubmitEvents)},attachListeners:function(){e(".wpglobus-customize-control").on("keyup",function(o){var n=e(this),s=n.data("customize-setting-link");void 0===WPGlobusCustomize.controlInstances[s]&&(s=n.data("wpglobus-customize-control"),WPGlobusCustomize.controlInstances[s]),void 0===e(document).triggerHandler("wpglobus_customize_control_keyup",[n,s])&&("link"==WPGlobusCustomize.controlInstances[s].type?WPGlobusCustomize.controlInstances[s].setting=t.getString(WPGlobusCustomize.controlInstances[s].setting,n.val(),WPGlobusCoreData.language):WPGlobusCustomize.controlInstances[s].setting=WPGlobusCore.getString(WPGlobusCustomize.controlInstances[s].setting,n.val(),WPGlobusCoreData.language))}),e(document).on("keyup",".wpglobus-customize-widget-control",function(t){var o=e(this),n=o.data("widget");void 0!==WPGlobusCustomize.controlWidgets[n]&&(WPGlobusCustomize.controlWidgets[n].element[o.attr("id")].value=WPGlobusCore.getString(WPGlobusCustomize.controlWidgets[n].element[o.attr("id")].value,o.val(),WPGlobusCoreData.language))}),e(document).on("mouseenter","#save",function(t){e.each(WPGlobusCustomize.controlInstances,function(e,t){if(t.userControl.enabled){var o=wp.customize.control.instance(e);"tinymce"==t.type&&tinymce.get(e).setContent(t.setting,{format:"raw"}),o.setting.set(t.setting),t.element.val(o.setting())}})}).on("mouseleave","#save",function(e){t.instancesKeep||(t.updateElements(),wp.customize.previewer.refresh())}),e("#save").on("click",function(e){t.instancesKeep=!0}),e(document).on("ajaxSend",function(e,o,n){void 0!==n.data&&-1!=n.data.indexOf("wp_customize=on")&&-1!=n.data.indexOf("action=customize_save")&&(t.customizeSave=!0)}),e(document).on("ajaxComplete",function(o,n){void 0!==n.responseText&&(t.customizeSave?(t.updateElements(!1),t.instancesKeep&&(t.instancesKeep=!1)):(n.responseText.indexOf("WP_CUSTOMIZER_SIGNATURE")>=0&&(t.action="customizerAjaxComplete",t.setControlInstances()),e.each(WPGlobusCustomize.controlWidgets,function(o,s){var l=o.replace("_","-");if(n.responseText.indexOf(l)>=0)return s.submit.css({display:"block"}),s.control.liveUpdateMode=!1,e.each(s.element,function(t,o){e("#"+t).val(WPGlobusCore.TextFilter(o.value,WPGlobusCoreData.language,"RETURN_EMPTY"))}),s.inWidgetTitle.text(": "+WPGlobusCore.TextFilter(s.control.setting().title,WPGlobusCustomize.languageAdmin)),t.widgetKeep=!1,!1})),t.customizeSave=!1,wp.customize.previewer.refresh())})}};WPGlobusCustomize=e.extend({},WPGlobusCustomize,t),WPGlobusCustomize.init()});
includes/js/wpglobus-customize-options-preview.js ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * WPGlobus Customize Preview
3
+ * Interface JS functions
4
+ *
5
+ * @since 1.4.6
6
+ *
7
+ * @package WPGlobus
8
+ * @subpackage Customize Preview
9
+ */
10
+ /*jslint browser: true*/
11
+ /*global jQuery, console */
12
+ jQuery(document).ready(function ($) {
13
+ /*
14
+ wp.customize( 'wpglobus_customize_language_selector_mode', function( value ) {
15
+ value.bind( function( newval ) {
16
+ //$( '.nav-menu' ).html( newval );
17
+ } );
18
+ } ); */
19
+
20
+ });
includes/js/wpglobus-customize-options-preview.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(document).ready(function(e){});
includes/js/wpglobus-customize-options.js ADDED
@@ -0,0 +1,411 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * WPGlobus Customize Options
3
+ * Interface JS functions
4
+ *
5
+ * @since 1.4.6
6
+ *
7
+ * @package WPGlobus
8
+ * @subpackage Customize Options
9
+ */
10
+ /*jslint browser: true*/
11
+ /*global jQuery, console, WPGlobusCore, WPGlobusCoreData, WPGlobusCustomizeOptions*/
12
+ jQuery(document).ready(function ($) {
13
+ "use strict";
14
+
15
+ var api = {
16
+ listID: '#wpglobus-sortable',
17
+ customizeSave: false,
18
+ customizeSaveData: '',
19
+ init: function() {
20
+ $( '#wpglobus-sortable' ).sortable({
21
+ update: api.sortUpdate
22
+ });
23
+ api.setJSCodeSection();
24
+ api.addListeners();
25
+ api.ajaxListener();
26
+ },
27
+ setJSCodeSection: function() {
28
+ var el = WPGlobusCustomizeOptions.settings['wpglobus_js_editor_section'];
29
+ if ( 'undefined' === typeof el ) {
30
+ return;
31
+ }
32
+ if ( 'undefined' === typeof el['wpglobus_customize_js_editor'] ) {
33
+ return
34
+ }
35
+ $('#customize-control-wpglobus_customize_js_editor .customize-control-title')
36
+ .css({'width':'50%'})
37
+ .after('<span class="wpglobus-customize-js-editor-expand" style="float:right;"><a href="#">'+WPGlobusCustomizeOptions.i18n['expandShrink']+'</a></span>');
38
+
39
+ /**
40
+ * Expand/Shrink editor.
41
+ */
42
+ $(document).on('click', '.wpglobus-customize-js-editor-expand', function(ev){
43
+ var $t = $(this),
44
+ $f = $('#customize-controls');
45
+ $t.toggleClass('expanded');
46
+ if ( $t.hasClass('expanded') ) {
47
+ $f.css({'width':'500px'});
48
+ } else {
49
+ $f.css({'width':''});
50
+ }
51
+ });
52
+
53
+ /**
54
+ * Set defaults.
55
+ */
56
+ $('#sub-accordion-section-wpglobus_js_editor_section .customize-section-back').on('click', function(ev){
57
+ $('#customize-controls').css({'width':''});
58
+ $('.wpglobus-customize-js-editor-expand').removeClass('expanded');
59
+ });
60
+
61
+ },
62
+ addListeners: function() {
63
+
64
+ $( 'body' ).on( 'change', '.wpglobus-listen-change', function(ev){
65
+ api.setState( false );
66
+ });
67
+
68
+ $( 'body' ).on( 'change', '#wpglobus-sortable input.wpglobus-language-item', function(ev){
69
+ var $t = $( this );
70
+ if ( ! $t.prop( 'checked' ) ) {
71
+ api.removeLanguage( $t );
72
+ }
73
+ });
74
+
75
+ $( '#customize-control-wpglobus_add_languages_select_box select' ).on(
76
+ 'change',
77
+ function(event){
78
+ api.addLanguage( event, this );
79
+ }
80
+ );
81
+
82
+ /** open Addons page in new tab */
83
+ $( '#accordion-section-' + WPGlobusCustomizeOptions.sections.wpglobus_addons_section + ' .accordion-section-title' ).off( 'click keydown' );
84
+ $( 'body' ).on(
85
+ 'click',
86
+ '#accordion-section-' + WPGlobusCustomizeOptions.sections.wpglobus_addons_section + ' .accordion-section-title',
87
+ function(ev) {
88
+ window.open( WPGlobusCustomizeOptions.addonsPage, '_blank' );
89
+ }
90
+ );
91
+
92
+ /** Save Fields Control settings & Reload customize page */
93
+ $( document ).on( 'click', '#' + WPGlobusCustomizeOptions.userControlSaveButton, function(){ api.userControlAjax( this ) } );
94
+
95
+ /**
96
+ * Init for wpglobus_js_editor_section.
97
+ * @since 1.9.7
98
+ */
99
+ $(document).on(
100
+ 'click',
101
+ '#accordion-section-' + WPGlobusCustomizeOptions.sections.wpglobus_js_editor_section + ' .accordion-section-title',
102
+ function(ev) {
103
+ /**
104
+ * Fix Code Editor height.
105
+ */
106
+ $('#customize-control-wpglobus_customize_js_editor .CodeMirror').css({'height':'40em'});
107
+ }
108
+ );
109
+ },
110
+ removeLanguage: function( t ) {
111
+ var l = t.data( 'language' ),
112
+ e = $( '#customize-control-wpglobus_add_languages_select_box select option' ).eq(0);
113
+ $( '<option value="'+l+'">' +
114
+ WPGlobusCustomizeOptions.config.language_name[l] + ' (' + WPGlobusCustomizeOptions.config.en_language_name[l] + ') ' +
115
+ '</option>' ).insertAfter( e );
116
+ t.parent('li').remove();
117
+ },
118
+ addLanguage: function( event, t ) {
119
+ var code = $(t).attr( 'value' ),
120
+ s = $( '#wpglobus-item-skeleton' ).html(),
121
+ item = '',
122
+ li_class = $( api.listID + ' li').attr( 'class' );
123
+
124
+ if ( code == 'select' ) return;
125
+
126
+ item = s.replace(
127
+ '{{flag}}',
128
+ 'src="' +WPGlobusCustomizeOptions.config.flags_url + WPGlobusCustomizeOptions.config.flag[code] + '"'
129
+ );
130
+ item = item.replace( '{{name}}', code );
131
+ item = item.replace( '{{id}}', code );
132
+ item = item.replace( 'checked="{{checked}}"', 'checked="checked"' );
133
+ item = item.replace( 'disabled="{{disabled}}"', '' );
134
+ item = item.replace( '{{item}}', WPGlobusCustomizeOptions.config.en_language_name[ code ] + ' (' +code+ ') ' );
135
+ item = item.replace( '{{order}}', '#' );
136
+ item = item.replace( '{{language}}', code );
137
+ item = item.replace( '{{edit-link}}', WPGlobusCustomizeOptions.editLink.replace( '{{language}}', code ) );
138
+ $( '<li class="' + li_class + '">' + item + '</li>' ).appendTo( api.listID );
139
+ api.setOrder();
140
+
141
+ var opts = $(t).find( 'option' );
142
+ $.each( opts, function(i, e) {
143
+ if ( $(e).attr('value') == code ) {
144
+ $(e).remove();
145
+ }
146
+ });
147
+
148
+ },
149
+ sortUpdate: function( event, ui ) {
150
+ api.setState( false );
151
+ api.setOrder();
152
+ },
153
+ setOrder: function() {
154
+
155
+ $( '#wpglobus-sortable input.wpglobus-language-item' ).each( function( i, e ){
156
+ var $e = $(e);
157
+ if ( i == 0 ) {
158
+ $e.prop( 'disabled', 'disabled' ).prop( 'checked', 'checked' );
159
+ } else {
160
+ $e.removeProp( 'disabled' );
161
+ }
162
+ $e.data( 'order', i );
163
+ } );
164
+
165
+ },
166
+ setState: function( state ) {
167
+ wp.customize.state( 'saved' ).set( state );
168
+ },
169
+ getCustomizeSaveData: function() {
170
+ return api.customizeSaveData;
171
+ },
172
+ enabledUserControl: function(setting) {
173
+ if ( 'undefined' === typeof WPGlobusCustomize.controlInstances[setting] ) {
174
+ return false;
175
+ }
176
+ return WPGlobusCustomize.controlInstances[setting].userControl.enabled;
177
+ },
178
+ userControlAjax: function( btn ) {
179
+
180
+ $( btn ).prop( 'disabled', true );
181
+
182
+ var order = {};
183
+ order[ 'action' ] = 'cb-controls-save';
184
+ order[ 'controls' ] = {};
185
+ $( '.wpglobus-customize-cb-control' ).each( function(i, cb){
186
+ var $t = $( cb );
187
+ if ( $t.prop( 'checked' ) ) {
188
+ // do nothing
189
+ } else {
190
+ var ctrl = $t.data( 'control' );
191
+ ctrl = ctrl.replace( '[', '{{');
192
+ ctrl = ctrl.replace( ']', '}}');
193
+ order[ 'controls' ][ ctrl ] = 'disable';
194
+ }
195
+ });
196
+
197
+ $.ajax({
198
+ beforeSend:function(){},
199
+ type: 'POST',
200
+ url: WPGlobusCustomizeOptions.ajaxurl,
201
+ data: { action:WPGlobusCustomizeOptions.process_ajax, order:order },
202
+ dataType: 'json'
203
+ })
204
+ .always(function() {
205
+ location.reload(true);
206
+ });
207
+
208
+ },
209
+ ajax: function(ajaxAction, data) {
210
+
211
+ if ( 'wpglobus_customize_save' == ajaxAction ) {
212
+
213
+ var order = {};
214
+ order['action'] = 'wpglobus_customize_save';
215
+ order['options'] = {};
216
+
217
+ $.each( WPGlobusCustomizeOptions.settings, function( section, el ) {
218
+
219
+ $.each( el, function( id, obj ) {
220
+
221
+ if ( id == 'wpglobus_customize_enabled_languages' ) {
222
+
223
+ order[ 'options' ][ obj.option ] = {};
224
+ $( '#wpglobus-sortable input.wpglobus-language-item' ).each( function( i, e ) {
225
+ order[ 'options' ][ obj.option ][ $(this).data('language') ] = '1';
226
+ });
227
+
228
+ return true;
229
+ }
230
+
231
+ if ( -1 != api.customizeSaveData.indexOf( 'wpglobus_customize_post_type_' ) &&
232
+ -1 != id.indexOf( 'wpglobus_customize_post_type_' ) ) {
233
+
234
+ if ( typeof order[ 'options' ][ obj.option ] === 'undefined' ) {
235
+ order[ 'options' ][ obj.option ] = {};
236
+ }
237
+ order[ 'options' ][ obj.option ][ id.replace( 'wpglobus_customize_post_type_', '' ) ] =
238
+ $( '#customize-control-' + id + ' input' ).prop( 'checked' ) ? 1 : 0;
239
+
240
+ } else {
241
+
242
+ if ( -1 != api.customizeSaveData.indexOf( id ) ) {
243
+
244
+ var s = $( '#customize-control-' + id + ' ' + obj.type ),
245
+ val = '';
246
+
247
+ if ( 'textarea' == obj.type ) {
248
+ val = s.val();
249
+ } else if ( 'wpglobus_checkbox' == obj.type ) {
250
+ s = $( '#customize-control-' + id + ' input' );
251
+ if ( id == 'wpglobus_customize_selector_wp_list_pages' ) {
252
+ val = s.prop( 'checked' ) ? 1 : 0;
253
+ } else {
254
+ val = s.prop( 'checked' ) ? 1 : '';
255
+ }
256
+ } else if ( 'checkbox' == obj.type ) {
257
+ val = s.prop( 'checked' ) ? 1 : '';
258
+ } else if ( 'select' == obj.type ) {
259
+ val = s.val();
260
+ } else if ( 'code_editor' == obj.type ) {
261
+ var control = wp.customize.control.instance(id);
262
+ if ( 'undefined' !== typeof control ) {
263
+ val = control.setting();
264
+ }
265
+ }
266
+ order['options'][obj.option] = val;
267
+
268
+ if ( 'code_editor' == obj.type ) {
269
+ if ( 'undefined' === typeof control ) {
270
+ /**
271
+ * If control is undefined then we don't need to save code.
272
+ */
273
+ delete order['options'][obj.option];
274
+ }
275
+ }
276
+ }
277
+ }
278
+
279
+ });
280
+
281
+ });
282
+
283
+ }
284
+
285
+ $.ajax({
286
+ beforeSend:function(){},
287
+ type: 'POST',
288
+ url: WPGlobusCustomizeOptions.ajaxurl,
289
+ data: { action:WPGlobusCustomizeOptions.process_ajax, order:order },
290
+ dataType: 'json'
291
+ });
292
+ },
293
+ getChangesetData: function(ajaxData) {
294
+ /**
295
+ * @since 1.7.9
296
+ */
297
+ if ( 'undefined' !== typeof ajaxData ) {
298
+
299
+ var changesetData = /customize_changeset_data=([^&]+)/.exec(ajaxData);
300
+
301
+ if ( 'undefined' === typeof changesetData[1] ) {
302
+ return;
303
+ }
304
+
305
+ var settingsJson = decodeURIComponent( changesetData[1] );
306
+ var settings = JSON.parse(settingsJson);
307
+ var values, value;
308
+
309
+ $.each( settings, function(setting, data) {
310
+
311
+ if ( 'undefined' !== typeof WPGlobusCustomize.controlInstances[setting] ) {
312
+
313
+ value = '';
314
+ if ( 'link' == WPGlobusCustomize.controlInstances[setting]['type'] ) {
315
+ if ( 1 ) {
316
+ /**
317
+ * In "customize changeset" post we must save URL with ||| delimiters
318
+ * otherwise we lost value after validating "$setting->validate( $value )"
319
+ * @see function post_value() in wp-includes\class-wp-customize-manager.php
320
+ */
321
+ value = WPGlobusCustomize.controlInstances[setting].setting;
322
+ } else {
323
+ /**
324
+ * Using standard language marks {:en}url{:}.
325
+ * This is correct code and approach but need to find ability to prevent validating.
326
+ * @see upper comment.
327
+ */
328
+ values = WPGlobusCustomize.getTranslations( WPGlobusCustomize.controlInstances[setting].setting );
329
+ /**
330
+ * @todo make function to get string with language marks from object.
331
+ */
332
+ $.each(WPGlobusCoreData.enabled_languages, function(i,l){
333
+ if ( '' != values[l] && 'undefined' !== typeof values[l] ) {
334
+ value = value + WPGlobusCore.addLocaleMarks(values[l], l);
335
+ }
336
+ });
337
+ }
338
+ } else {
339
+
340
+ value = WPGlobusCustomize.controlInstances[setting].setting;
341
+
342
+ }
343
+ settings[setting]['value'] = value;
344
+ }
345
+ });
346
+
347
+ var newChangeset = JSON.stringify(settings);
348
+ newChangeset = encodeURIComponent(newChangeset);
349
+ newChangeset = newChangeset.replace( /%20/g, '+' );
350
+
351
+ ajaxData = ajaxData.replace( changesetData[1], newChangeset );
352
+
353
+ }
354
+
355
+ return ajaxData;
356
+ },
357
+ ajaxListener: function() {
358
+ /**
359
+ * ajaxSend event handler
360
+ */
361
+ $( document ).on( 'ajaxSend', function( ev, jqXHR, ajaxOptions ) {
362
+ if ( typeof ajaxOptions.data === 'undefined' ) {
363
+ return;
364
+ }
365
+
366
+ if ( -1 != ajaxOptions.data.indexOf('wp_customize=on') && -1 != ajaxOptions.data.indexOf('action=customize_save') ) {
367
+
368
+ if ( -1 != ajaxOptions.data.indexOf('customized=') ) {
369
+ api.customizeSave = true;
370
+ api.customizeSaveData = ajaxOptions.data;
371
+ } else if ( -1 != ajaxOptions.data.indexOf('customize_changeset_data=') ) {
372
+ /**
373
+ * Ajax action when are saved changeset.
374
+ *
375
+ * @since 1.7.9
376
+ */
377
+ ajaxOptions.data = api.getChangesetData(ajaxOptions.data);
378
+ }
379
+
380
+ }
381
+ });
382
+
383
+ $( document ).on( 'ajaxComplete', function( ev, response, ajaxOptions ) {
384
+ if ( typeof response.responseText === 'undefined' ) {
385
+ return;
386
+ }
387
+ if ( api.customizeSave ) {
388
+ api.customizeSave = false;
389
+ api.ajax('wpglobus_customize_save');
390
+ }
391
+ });
392
+
393
+ $( document ).on( 'ajaxStop', function() {
394
+ /**
395
+ * We need to use ajaxStop (together with ajaxComplete) event to make save options in Customizer
396
+ * cause is Redux Framework makes unbind ajaxComplete event
397
+ * @see https://github.com/reduxframework/redux-framework/issues/2896
398
+ */
399
+ if ( api.customizeSave ) {
400
+ api.customizeSave = false;
401
+ api.ajax('wpglobus_customize_save');
402
+ }
403
+ });
404
+ }
405
+ };
406
+
407
+ WPGlobusCustomizeOptions = $.extend( {}, WPGlobusCustomizeOptions, api );
408
+
409
+ WPGlobusCustomizeOptions.init();
410
+
411
+ });
includes/js/wpglobus-customize-options.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(document).ready(function(e){"use strict";var o={listID:"#wpglobus-sortable",customizeSave:!1,customizeSaveData:"",init:function(){e("#wpglobus-sortable").sortable({update:o.sortUpdate}),o.setJSCodeSection(),o.addListeners(),o.ajaxListener()},setJSCodeSection:function(){var o=WPGlobusCustomizeOptions.settings.wpglobus_js_editor_section;void 0!==o&&void 0!==o.wpglobus_customize_js_editor&&(e("#customize-control-wpglobus_customize_js_editor .customize-control-title").css({width:"50%"}).after('<span class="wpglobus-customize-js-editor-expand" style="float:right;"><a href="#">'+WPGlobusCustomizeOptions.i18n.expandShrink+"</a></span>"),e(document).on("click",".wpglobus-customize-js-editor-expand",function(o){var t=e(this),s=e("#customize-controls");t.toggleClass("expanded"),t.hasClass("expanded")?s.css({width:"500px"}):s.css({width:""})}),e("#sub-accordion-section-wpglobus_js_editor_section .customize-section-back").on("click",function(o){e("#customize-controls").css({width:""}),e(".wpglobus-customize-js-editor-expand").removeClass("expanded")}))},addListeners:function(){e("body").on("change",".wpglobus-listen-change",function(e){o.setState(!1)}),e("body").on("change","#wpglobus-sortable input.wpglobus-language-item",function(t){var s=e(this);s.prop("checked")||o.removeLanguage(s)}),e("#customize-control-wpglobus_add_languages_select_box select").on("change",function(e){o.addLanguage(e,this)}),e("#accordion-section-"+WPGlobusCustomizeOptions.sections.wpglobus_addons_section+" .accordion-section-title").off("click keydown"),e("body").on("click","#accordion-section-"+WPGlobusCustomizeOptions.sections.wpglobus_addons_section+" .accordion-section-title",function(e){window.open(WPGlobusCustomizeOptions.addonsPage,"_blank")}),e(document).on("click","#"+WPGlobusCustomizeOptions.userControlSaveButton,function(){o.userControlAjax(this)}),e(document).on("click","#accordion-section-"+WPGlobusCustomizeOptions.sections.wpglobus_js_editor_section+" .accordion-section-title",function(o){e("#customize-control-wpglobus_customize_js_editor .CodeMirror").css({height:"40em"})})},removeLanguage:function(o){var t=o.data("language"),s=e("#customize-control-wpglobus_add_languages_select_box select option").eq(0);e('<option value="'+t+'">'+WPGlobusCustomizeOptions.config.language_name[t]+" ("+WPGlobusCustomizeOptions.config.en_language_name[t]+") </option>").insertAfter(s),o.parent("li").remove()},addLanguage:function(t,s){var n=e(s).attr("value"),i=e("#wpglobus-item-skeleton").html(),a="",c=e(o.listID+" li").attr("class");if("select"!=n){a=(a=(a=(a=(a=(a=(a=(a=(a=i.replace("{{flag}}",'src="'+WPGlobusCustomizeOptions.config.flags_url+WPGlobusCustomizeOptions.config.flag[n]+'"')).replace("{{name}}",n)).replace("{{id}}",n)).replace('checked="{{checked}}"','checked="checked"')).replace('disabled="{{disabled}}"',"")).replace("{{item}}",WPGlobusCustomizeOptions.config.en_language_name[n]+" ("+n+") ")).replace("{{order}}","#")).replace("{{language}}",n)).replace("{{edit-link}}",WPGlobusCustomizeOptions.editLink.replace("{{language}}",n)),e('<li class="'+c+'">'+a+"</li>").appendTo(o.listID),o.setOrder();var u=e(s).find("option");e.each(u,function(o,t){e(t).attr("value")==n&&e(t).remove()})}},sortUpdate:function(e,t){o.setState(!1),o.setOrder()},setOrder:function(){e("#wpglobus-sortable input.wpglobus-language-item").each(function(o,t){var s=e(t);0==o?s.prop("disabled","disabled").prop("checked","checked"):s.removeProp("disabled"),s.data("order",o)})},setState:function(e){wp.customize.state("saved").set(e)},getCustomizeSaveData:function(){return o.customizeSaveData},enabledUserControl:function(e){return void 0!==WPGlobusCustomize.controlInstances[e]&&WPGlobusCustomize.controlInstances[e].userControl.enabled},userControlAjax:function(o){e(o).prop("disabled",!0);var t={};t.action="cb-controls-save",t.controls={},e(".wpglobus-customize-cb-control").each(function(o,s){var n=e(s);if(n.prop("checked"));else{var i=n.data("control");i=(i=i.replace("[","{{")).replace("]","}}"),t.controls[i]="disable"}}),e.ajax({beforeSend:function(){},type:"POST",url:WPGlobusCustomizeOptions.ajaxurl,data:{action:WPGlobusCustomizeOptions.process_ajax,order:t},dataType:"json"}).always(function(){location.reload(!0)})},ajax:function(t,s){if("wpglobus_customize_save"==t){var n={};n.action="wpglobus_customize_save",n.options={},e.each(WPGlobusCustomizeOptions.settings,function(t,s){e.each(s,function(t,s){if("wpglobus_customize_enabled_languages"==t)return n.options[s.option]={},e("#wpglobus-sortable input.wpglobus-language-item").each(function(o,t){n.options[s.option][e(this).data("language")]="1"}),!0;if(-1!=o.customizeSaveData.indexOf("wpglobus_customize_post_type_")&&-1!=t.indexOf("wpglobus_customize_post_type_"))void 0===n.options[s.option]&&(n.options[s.option]={}),n.options[s.option][t.replace("wpglobus_customize_post_type_","")]=e("#customize-control-"+t+" input").prop("checked")?1:0;else if(-1!=o.customizeSaveData.indexOf(t)){var i=e("#customize-control-"+t+" "+s.type),a="";if("textarea"==s.type)a=i.val();else if("wpglobus_checkbox"==s.type)i=e("#customize-control-"+t+" input"),a="wpglobus_customize_selector_wp_list_pages"==t?i.prop("checked")?1:0:i.prop("checked")?1:"";else if("checkbox"==s.type)a=i.prop("checked")?1:"";else if("select"==s.type)a=i.val();else if("code_editor"==s.type){var c=wp.customize.control.instance(t);void 0!==c&&(a=c.setting())}n.options[s.option]=a,"code_editor"==s.type&&void 0===c&&delete n.options[s.option]}})})}e.ajax({beforeSend:function(){},type:"POST",url:WPGlobusCustomizeOptions.ajaxurl,data:{action:WPGlobusCustomizeOptions.process_ajax,order:n},dataType:"json"})},getChangesetData:function(o){if(void 0!==o){var t=/customize_changeset_data=([^&]+)/.exec(o);if(void 0===t[1])return;var s,n=decodeURIComponent(t[1]),i=JSON.parse(n);e.each(i,function(e,o){void 0!==WPGlobusCustomize.controlInstances[e]&&(s="",s=(WPGlobusCustomize.controlInstances[e].type,WPGlobusCustomize.controlInstances[e].setting),i[e].value=s)});var a=JSON.stringify(i);a=(a=encodeURIComponent(a)).replace(/%20/g,"+"),o=o.replace(t[1],a)}return o},ajaxListener:function(){e(document).on("ajaxSend",function(e,t,s){void 0!==s.data&&-1!=s.data.indexOf("wp_customize=on")&&-1!=s.data.indexOf("action=customize_save")&&(-1!=s.data.indexOf("customized=")?(o.customizeSave=!0,o.customizeSaveData=s.data):-1!=s.data.indexOf("customize_changeset_data=")&&(s.data=o.getChangesetData(s.data)))}),e(document).on("ajaxComplete",function(e,t,s){void 0!==t.responseText&&o.customizeSave&&(o.customizeSave=!1,o.ajax("wpglobus_customize_save"))}),e(document).on("ajaxStop",function(){o.customizeSave&&(o.customizeSave=!1,o.ajax("wpglobus_customize_save"))})}};WPGlobusCustomizeOptions=e.extend({},WPGlobusCustomizeOptions,o),WPGlobusCustomizeOptions.init()});
includes/js/wpglobus-customize-preview.js ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * WPGlobus Customize Preview
3
+ * Interface JS functions
4
+ *
5
+ * @since 1.2.1
6
+ *
7
+ * @package WPGlobus
8
+ * @subpackage Customize Preview
9
+ */
10
+ /*jslint browser: true*/
11
+ /*global jQuery, console, WPGlobusCustomize */
12
+ jQuery(document).ready(function ($) {
13
+
14
+ wp.customize( 'wpglobus_blogname', function( value ) {
15
+ value.bind( function( newval ) {
16
+ $( '.site-title a, #site-title a' ).html( newval );
17
+ $( 'a.site-title' ).html( newval ); // https://wordpress.org/themes/customizr/
18
+ } );
19
+ } );
20
+
21
+ wp.customize( 'wpglobus_blogdescription', function( value ) {
22
+ value.bind( function( newval ) {
23
+ $( '.site-description, #site-description' ).html( newval );
24
+ } );
25
+ } );
26
+
27
+ setTimeout(function(){
28
+ $( '.site-title a, #site-title a' ).html( WPGlobusCustomize.blogname );
29
+ $( '.site-description, #site-description' ).html( WPGlobusCustomize.blogdescription );
30
+ $( 'a.site-title' ).html( WPGlobusCustomize.blogname ); // https://wordpress.org/themes/customizr/
31
+ }, 500);
32
+ });
includes/js/wpglobus-customize-preview.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(document).ready(function(t){wp.customize("wpglobus_blogname",function(i){i.bind(function(i){t(".site-title a, #site-title a").html(i),t("a.site-title").html(i)})}),wp.customize("wpglobus_blogdescription",function(i){i.bind(function(i){t(".site-description, #site-description").html(i)})}),setTimeout(function(){t(".site-title a, #site-title a").html(WPGlobusCustomize.blogname),t(".site-description, #site-description").html(WPGlobusCustomize.blogdescription),t("a.site-title").html(WPGlobusCustomize.blogname)},500)});
includes/js/wpglobus-form.js ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*jslint browser: true*/
2
+ /*global jQuery, console */
3
+ jQuery(document).ready(function ($) {
4
+ "use strict";
5
+ var codeRegex = /^[a-z]{2}$/,
6
+ code = $('#wpglobus_language_code'),
7
+ name = $('#wpglobus_language_name'),
8
+ en_name = $('#wpglobus_en_language_name'),
9
+ allFields = $([]).add(code).add(name).add(en_name);
10
+
11
+ function checkRegexp( o, regexp, n ) {
12
+ if ( !( regexp.test( o.val() ) ) ) {
13
+ o.addClass('wpglobus-state-error');
14
+ return false;
15
+ } else {
16
+ return true;
17
+ }
18
+ }
19
+
20
+ $('#wpglobus_edit_form').on('submit', function(event){
21
+ var valid = true;
22
+ allFields.removeClass( "wpglobus-state-error" );
23
+ valid = valid && checkRegexp( code, codeRegex, "" );
24
+
25
+ if ( ! valid ) {
26
+ event.preventDefault();
27
+ }
28
+ });
29
+ });
includes/js/wpglobus-form.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(document).ready(function(a){"use strict";var e=/^[a-z]{2}$/,s=a("#wpglobus_language_code"),u=a("#wpglobus_language_name"),o=a("#wpglobus_en_language_name"),r=a([]).add(s).add(u).add(o);a("#wpglobus_edit_form").on("submit",function(a){var u=!0;r.removeClass("wpglobus-state-error");var o,t;(u=u&&(o=s,t=e,!!t.test(o.val())||(o.addClass("wpglobus-state-error"),!1)))||a.preventDefault()})});
includes/js/wpglobus-media-post-php.js ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * WPGlobus Media Administration.
3
+ * Interface JS functions
4
+ *
5
+ * @since 1.7.3
6
+ *
7
+ * @package WPGlobus
8
+ * @subpackage Media
9
+ */
10
+ /*jslint browser: true*/
11
+ /*global jQuery, console, WPGlobusAdmin*/
12
+ (function ($) {
13
+ "use strict";
14
+
15
+ $(document).on('wpglobus_after_post_edit', function (evnt) {
16
+
17
+ $(document).ajaxSend(function (event, request, settings) {
18
+ if ('undefined' === typeof settings.data) {
19
+ return;
20
+ }
21
+
22
+ if ('undefined' === typeof WPGlobusAdmin) {
23
+ return;
24
+ }
25
+
26
+ if (-1 != settings.data.indexOf('action=send-attachment-to-editor')) {
27
+ settings.data = settings.data + '&wpglobusLanguageTab=' + WPGlobusAdmin.currentTab;
28
+ }
29
+ });
30
+
31
+ });
32
+
33
+ })(jQuery);
includes/js/wpglobus-media-post-php.min.js ADDED
@@ -0,0 +1 @@
 
1
+ !function(t){"use strict";t(document).on("wpglobus_after_post_edit",function(n){t(document).ajaxSend(function(t,n,a){void 0!==a.data&&"undefined"!=typeof WPGlobusAdmin&&-1!=a.data.indexOf("action=send-attachment-to-editor")&&(a.data=a.data+"&wpglobusLanguageTab="+WPGlobusAdmin.currentTab)})})}(jQuery);
includes/js/wpglobus-media.js ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * WPGlobus Media Administration.
3
+ * Interface JS functions
4
+ *
5
+ * @since 1.7.3
6
+ *
7
+ * @package WPGlobus
8
+ * @subpackage Media
9
+ */
10
+ /*jslint browser: true*/
11
+ /*global jQuery, console, WPGlobusCore, WPGlobusMedia*/
12
+ (function($) {
13
+ "use strict";
14
+
15
+ if ( 'undefined' === typeof WPGlobusCore ) {
16
+ return;
17
+ }
18
+ if ( 'undefined' === typeof WPGlobusMedia ) {
19
+ return;
20
+ }
21
+
22
+ var api = {
23
+ content : {},
24
+ save : true,
25
+ resetContent : true,
26
+ init: function(args) {
27
+ var wpglobusTabs = $('.wpglobus-post-body-tabs');
28
+ if ( wpglobusTabs.length != 1 ) {
29
+ return;
30
+ }
31
+ wpglobusTabs.insertBefore('.wp_attachment_details');
32
+ wpglobusTabs.tabs();
33
+ api.iniSet();
34
+ api.setContent();
35
+ api.attachListeners();
36
+ },
37
+ iniSet: function() {
38
+ $.each( WPGlobusMedia.attachment, function( name, id ){
39
+ api.content[id] = $('#'+id).val();
40
+ $('#'+id).addClass('wpglobus-translatable');
41
+ });
42
+ },
43
+ setContent: function( beforeSave ) {
44
+ if ( 'undefined' === typeof beforeSave ) {
45
+ beforeSave = false;
46
+ }
47
+ if ( beforeSave ) {
48
+ $.each( WPGlobusMedia.attachment, function( name, id ){
49
+ $('#'+id).val( api.content[id] );
50
+ });
51
+ } else {
52
+ $.each( WPGlobusMedia.attachment, function( name, id ){
53
+ $('#'+id).val( WPGlobusCore.TextFilter( api.content[id], WPGlobusMedia.language, 'RETURN_EMPTY' ) );
54
+ });
55
+ }
56
+ },
57
+ attachListeners: function() {
58
+ /**
59
+ * Switch language.
60
+ */
61
+ $(document).on( 'tabsactivate', '.wpglobus-post-body-tabs', function( event, ui ) {
62
+ WPGlobusMedia.language = ui.newTab[0].dataset.language;
63
+ api.setContent();
64
+ });
65
+
66
+ /**
67
+ * Keyup event.
68
+ */
69
+ $.each( WPGlobusMedia.attachment, function( name, id ){
70
+ $(document).on( 'keyup', '#'+id, function( evnt ) {
71
+ api.content[ evnt.currentTarget.id ] = WPGlobusCore.getString( api.content[ evnt.currentTarget.id ], evnt.currentTarget.value, WPGlobusMedia.language );
72
+ });
73
+ });
74
+
75
+ /**
76
+ * Update event.
77
+ */
78
+ $(document).on( 'mouseenter', '#publish', function( event ) {
79
+ api.setContent( api.save );
80
+ }).on( 'mouseleave', '#publish', function( event ) {
81
+ if ( api.resetContent ) {
82
+ api.setContent();
83
+ }
84
+ api.resetContent = true;
85
+ }).on( 'click', '#publish', function( event ) {
86
+ api.resetContent = false;
87
+ });
88
+
89
+ /**
90
+ * Before an Ajax request is sent.
91
+ */
92
+ $( document ).ajaxSend(function( event, request, settings ) {
93
+ if ( 'undefined' === typeof settings.data ) {
94
+ return;
95
+ }
96
+ if ( -1 != settings.data.indexOf( 'action=send-attachment-to-editor' ) ) {
97
+ settings.data = settings.data + '&wpglobusLanguageTab=' + WPGlobusAdmin.currentTab;
98
+ }
99
+
100
+ });
101
+
102
+ }
103
+ };
104
+
105
+ WPGlobusMedia = $.extend({}, WPGlobusMedia, api);
106
+ WPGlobusMedia.init();
107
+
108
+ })(jQuery);
includes/js/wpglobus-media.min.js ADDED
@@ -0,0 +1 @@
 
1
+ !function(t){"use strict";if("undefined"!=typeof WPGlobusCore&&"undefined"!=typeof WPGlobusMedia){var e={content:{},save:!0,resetContent:!0,init:function(n){var a=t(".wpglobus-post-body-tabs");1==a.length&&(a.insertBefore(".wp_attachment_details"),a.tabs(),e.iniSet(),e.setContent(),e.attachListeners())},iniSet:function(){t.each(WPGlobusMedia.attachment,function(n,a){e.content[a]=t("#"+a).val(),t("#"+a).addClass("wpglobus-translatable")})},setContent:function(n){void 0===n&&(n=!1),n?t.each(WPGlobusMedia.attachment,function(n,a){t("#"+a).val(e.content[a])}):t.each(WPGlobusMedia.attachment,function(n,a){t("#"+a).val(WPGlobusCore.TextFilter(e.content[a],WPGlobusMedia.language,"RETURN_EMPTY"))})},attachListeners:function(){t(document).on("tabsactivate",".wpglobus-post-body-tabs",function(t,n){WPGlobusMedia.language=n.newTab[0].dataset.language,e.setContent()}),t.each(WPGlobusMedia.attachment,function(n,a){t(document).on("keyup","#"+a,function(t){e.content[t.currentTarget.id]=WPGlobusCore.getString(e.content[t.currentTarget.id],t.currentTarget.value,WPGlobusMedia.language)})}),t(document).on("mouseenter","#publish",function(t){e.setContent(e.save)}).on("mouseleave","#publish",function(t){e.resetContent&&e.setContent(),e.resetContent=!0}).on("click","#publish",function(t){e.resetContent=!1}),t(document).ajaxSend(function(t,e,n){void 0!==n.data&&-1!=n.data.indexOf("action=send-attachment-to-editor")&&(n.data=n.data+"&wpglobusLanguageTab="+WPGlobusAdmin.currentTab)})}};WPGlobusMedia=t.extend({},WPGlobusMedia,e),WPGlobusMedia.init()}}(jQuery);
includes/js/wpglobus-plugin-install.js ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * WPGlobus Plugin Install
3
+ * Interface JS functions
4
+ *
5
+ * @since 1.5.9
6
+ *
7
+ * @package WPGlobus
8
+ * @subpackage Administration
9
+ */
10
+ /*jslint browser: true*/
11
+ /*global jQuery, console*/
12
+ jQuery(document).ready(function($) {
13
+ "use strict";
14
+
15
+ if ( typeof WPGlobusPluginInstall === 'undefined' ) {
16
+ return;
17
+ }
18
+
19
+ var api = {
20
+ pluginInstalled: '<li><span class="button button-disabled">' + WPGlobusPluginInstall.i18n.installed + '</span></li>',
21
+ columnName: '<a href="{{href}}" class="" target="_blank">{{name}}<img src="{{img}}" class="plugin-icon"></a>',
22
+ currentVersion: '<strong>' + WPGlobusPluginInstall.i18n.current_version + ': </strong>{{version}}',
23
+ init: function() {
24
+
25
+ $.each( WPGlobusPluginInstall.pluginCard.paid, function(i, card) {
26
+ var ccard = '.plugin-card-' + card;
27
+ $( ccard + ' .column-rating' ).css({'visibility':'hidden'});
28
+ $( ccard + ' .column-downloaded' ).css({'visibility':'hidden'});
29
+
30
+ /**
31
+ * Hide the version and the entire row
32
+ * because we do not have the live data anymore.
33
+ * @since 1.6.7
34
+ */
35
+ $(ccard + ' .column-rating').css({'display': 'none'});
36
+ $(ccard + ' .column-updated').css({'display': 'none'});
37
+
38
+
39
+ var actions = $( ccard + ' .plugin-action-buttons li' );
40
+ if ( actions.length == 1 ) {
41
+ /** add Installed button if it was lost */
42
+ if ( WPGlobusPluginInstall.pluginData[ card ].plugin_data !== null ) {
43
+ $( ccard + ' .plugin-action-buttons' ).prepend( api.pluginInstalled );
44
+ }
45
+ }
46
+
47
+ $( ccard + ' .plugin-action-buttons .button' ).each( function(i,e){
48
+ /**
49
+ * Remove class 'install-now' to prevent action of standard install
50
+ * @since 1.6.3
51
+ * @see wp-admin\js\updates.js
52
+ */
53
+ if ( $(e).hasClass( 'install-now' ) ) {
54
+ $(e).removeClass( 'install-now' ).addClass( 'wpglobus-install-now' );
55
+ }
56
+ });
57
+
58
+ $( ccard + ' .plugin-action-buttons .wpglobus-install-now' )
59
+ .attr( 'href', WPGlobusPluginInstall.pluginData[ card ].extra_data.product_url )
60
+ .attr( 'target', '_blank' );
61
+
62
+ $( ccard + ' .open-plugin-details-modal' ).css({'display':'none'});
63
+
64
+ var name = api.columnName.replace( '{{href}}', WPGlobusPluginInstall.pluginData[ card ].extra_data.details_url );
65
+ name = name.replace( '{{name}}', WPGlobusPluginInstall.pluginData[ card ].card.name );
66
+ name = name.replace( '{{img}}', WPGlobusPluginInstall.pluginData[ card ].card.icons['1x'] );
67
+ $( ccard + ' .column-name h3' ).html( name );
68
+
69
+ if ( WPGlobusPluginInstall.pluginData[ card ].plugin_data === null ) {
70
+ $( ccard + ' .column-updated' ).css({'visibility':'hidden'});
71
+ } else {
72
+ $( ccard + ' .column-updated' ).html( api.currentVersion.replace( '{{version}}', WPGlobusPluginInstall.pluginData[ card ].plugin_data.Version ) );
73
+ }
74
+
75
+ $( ccard ).prepend( '<div class="plugin-card-header" style="text-align:center;height:40px;background-color:#00a0d2;padding-top:15px;"><h3 style="color:#fff;">' + WPGlobusPluginInstall.i18n.card_header + '</h3></div>' );
76
+
77
+ });
78
+
79
+ $( '.plugin-action-buttons .wpglobus-install-now' ).css({'background-color':'#0f0'}).text( WPGlobusPluginInstall.i18n.get_it );
80
+
81
+ /**
82
+ * Fix links for WPGlobus for Black Studio TinyMCE Widget plugin
83
+ */
84
+ $( '.plugin-card.plugin-card-wpglobus-for-black-studio-widget a' ).each( function( i, link ){
85
+ var $l = $( link ), href = $l.attr( 'href' ), nHref;
86
+ if ( -1 !== href.indexOf( 'wpglobus-for-black-studio-widget' ) && ! $l.hasClass( 'button' ) ) {
87
+ nHref = href.replace( 'wpglobus-for-black-studio-widget', WPGlobusPluginInstall.pluginData['wpglobus-for-black-studio-widget'].extra_data.correctLink );
88
+ $l.attr( 'href', nHref );
89
+ }
90
+ });
91
+
92
+ },
93
+ };
94
+
95
+ WPGlobusPluginInstall = $.extend({}, WPGlobusPluginInstall, api);
96
+ WPGlobusPluginInstall.init();
97
+
98
+ });
includes/js/wpglobus-plugin-install.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(document).ready(function(l){"use strict";if("undefined"!=typeof WPGlobusPluginInstall){var n={pluginInstalled:'<li><span class="button button-disabled">'+WPGlobusPluginInstall.i18n.installed+"</span></li>",columnName:'<a href="{{href}}" class="" target="_blank">{{name}}<img src="{{img}}" class="plugin-icon"></a>',currentVersion:"<strong>"+WPGlobusPluginInstall.i18n.current_version+": </strong>{{version}}",init:function(){l.each(WPGlobusPluginInstall.pluginCard.paid,function(a,t){var i=".plugin-card-"+t;l(i+" .column-rating").css({visibility:"hidden"}),l(i+" .column-downloaded").css({visibility:"hidden"}),l(i+" .column-rating").css({display:"none"}),l(i+" .column-updated").css({display:"none"});1==l(i+" .plugin-action-buttons li").length&&null!==WPGlobusPluginInstall.pluginData[t].plugin_data&&l(i+" .plugin-action-buttons").prepend(n.pluginInstalled),l(i+" .plugin-action-buttons .button").each(function(n,a){l(a).hasClass("install-now")&&l(a).removeClass("install-now").addClass("wpglobus-install-now")}),l(i+" .plugin-action-buttons .wpglobus-install-now").attr("href",WPGlobusPluginInstall.pluginData[t].extra_data.product_url).attr("target","_blank"),l(i+" .open-plugin-details-modal").css({display:"none"});var s=n.columnName.replace("{{href}}",WPGlobusPluginInstall.pluginData[t].extra_data.details_url);s=(s=s.replace("{{name}}",WPGlobusPluginInstall.pluginData[t].card.name)).replace("{{img}}",WPGlobusPluginInstall.pluginData[t].card.icons["1x"]),l(i+" .column-name h3").html(s),null===WPGlobusPluginInstall.pluginData[t].plugin_data?l(i+" .column-updated").css({visibility:"hidden"}):l(i+" .column-updated").html(n.currentVersion.replace("{{version}}",WPGlobusPluginInstall.pluginData[t].plugin_data.Version)),l(i).prepend('<div class="plugin-card-header" style="text-align:center;height:40px;background-color:#00a0d2;padding-top:15px;"><h3 style="color:#fff;">'+WPGlobusPluginInstall.i18n.card_header+"</h3></div>")}),l(".plugin-action-buttons .wpglobus-install-now").css({"background-color":"#0f0"}).text(WPGlobusPluginInstall.i18n.get_it),l(".plugin-card.plugin-card-wpglobus-for-black-studio-widget a").each(function(n,a){var t,i=l(a),s=i.attr("href");-1===s.indexOf("wpglobus-for-black-studio-widget")||i.hasClass("button")||(t=s.replace("wpglobus-for-black-studio-widget",WPGlobusPluginInstall.pluginData["wpglobus-for-black-studio-widget"].extra_data.correctLink),i.attr("href",t))})}};WPGlobusPluginInstall=l.extend({},WPGlobusPluginInstall,n),WPGlobusPluginInstall.init()}});
includes/js/wpglobus-vendor-acf.js ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * WPGlobus Administration ACF plugin fields
3
+ * Interface JS functions
4
+ *
5
+ * @since 1.0.5
6
+ *
7
+ * @package WPGlobus
8
+ * @subpackage Administration
9
+ */
10
+ /*jslint browser: true */
11
+ /*global jQuery, console, WPGlobusAcf, WPGlobusDialogApp */
12
+
13
+ jQuery(document).ready(function ($) {
14
+ "use strict";
15
+
16
+ if (typeof WPGlobusAcf == 'undefined') {
17
+ return;
18
+ }
19
+
20
+ var api = {
21
+ option : {},
22
+ init : function (args) {
23
+ api.option = $.extend(api.option, args);
24
+ if (api.option.pro) {
25
+ api.startAcf('.acf-field');
26
+ } else {
27
+ api.startAcf('.acf_postbox .field');
28
+ }
29
+ api.attachListeners();
30
+ },
31
+ disabledField: function (id) {
32
+ var res = false;
33
+ if (api.option.pro) {
34
+ var pId = $('#' + id).parents('.acf-field').attr('id');
35
+ $.each(WPGlobusAcf.disabledFields, function (i, e) {
36
+ if (e == pId) {
37
+ res = true;
38
+ }
39
+ });
40
+ } else {
41
+ var id = id.replace('acf-field-', '');
42
+ $.each(WPGlobusAcf.disabledFields, function (i, e) {
43
+ if (e == id) {
44
+ res = true;
45
+ }
46
+ });
47
+ }
48
+ return res;
49
+ },
50
+ startAcf : function (acf_class) {
51
+ var id;
52
+ var style = 'width:90%;';
53
+ var element, clone, name;
54
+ if ($('.acf_postbox').parents('#postbox-container-2').length == 1) {
55
+ style = 'width:97%';
56
+ }
57
+ //$('.acf_postbox .field').each(function(){
58
+ $(acf_class).each(function () {
59
+ var $t = $(this), id, h;
60
+ if ($t.hasClass('field_type-textarea') || $t.hasClass('acf-field-textarea')) {
61
+ id = $t.find('textarea').attr('id');
62
+ if (api.disabledField(id)) {
63
+ return true;
64
+ }
65
+ h = $('#' + id).height() + 20;
66
+ WPGlobusDialogApp.addElement({
67
+ id : id,
68
+ dialogTitle : 'Edit ACF field',
69
+ style : 'width:97%;float:left;',
70
+ styleTextareaWrapper: 'height:' + h + 'px;',
71
+ sbTitle : 'Click for edit',
72
+ onChangeClass : 'wpglobus-on-change-acf-field'
73
+ });
74
+ } else if ($t.hasClass('field_type-text') || $t.hasClass('acf-field-text')) {
75
+ id = $t.find('input').attr('id');
76
+ if (api.disabledField(id)) {
77
+ return true;
78
+ }
79
+ WPGlobusDialogApp.addElement({
80
+ id : id,
81
+ dialogTitle : 'Edit ACF field',
82
+ style : 'width:97%;float:left;',
83
+ sbTitle : 'Click for edit',
84
+ onChangeClass: 'wpglobus-on-change-acf-field'
85
+ });
86
+ }
87
+ });
88
+ },
89
+ attachListeners: function() {
90
+ if (api.option.pro) {
91
+ /**
92
+ * Attach listener for new ACF fields that was added in repeater field type.
93
+ */
94
+ var t = this;
95
+ if (acf.add_action) { // ACF v5
96
+ acf.add_action('append', function($el) {
97
+ t.replaceCloneIndex($el);
98
+ });
99
+ }
100
+ }
101
+ },
102
+ replaceCloneIndex: function($el) {
103
+ var cloneindex = $el.data('id');
104
+ $el.find('[data-source-id*="acfcloneindex"]').each(function(){
105
+ $(this).attr('data-source-id', $(this).attr('data-source-id').replace('acfcloneindex', cloneindex));
106
+ });
107
+ }
108
+ }
109
+
110
+ WPGlobusAcf = $.extend({}, WPGlobusAcf, api);
111
+
112
+ WPGlobusAcf.init({'pro': WPGlobusAcf.pro});
113
+
114
+ });
includes/js/wpglobus-vendor-acf.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(document).ready(function(e){"use strict";if("undefined"!=typeof WPGlobusAcf){var t={option:{},init:function(i){t.option=e.extend(t.option,i),t.option.pro?t.startAcf(".acf-field"):t.startAcf(".acf_postbox .field"),t.attachListeners()},disabledField:function(i){var a=!1;if(t.option.pro){var d=e("#"+i).parents(".acf-field").attr("id");e.each(WPGlobusAcf.disabledFields,function(e,t){t==d&&(a=!0)})}else{i=i.replace("acf-field-","");e.each(WPGlobusAcf.disabledFields,function(e,t){t==i&&(a=!0)})}return a},startAcf:function(i){e(".acf_postbox").parents("#postbox-container-2").length,e(i).each(function(){var i,a,d=e(this);if(d.hasClass("field_type-textarea")||d.hasClass("acf-field-textarea")){if(i=d.find("textarea").attr("id"),t.disabledField(i))return!0;a=e("#"+i).height()+20,WPGlobusDialogApp.addElement({id:i,dialogTitle:"Edit ACF field",style:"width:97%;float:left;",styleTextareaWrapper:"height:"+a+"px;",sbTitle:"Click for edit",onChangeClass:"wpglobus-on-change-acf-field"})}else if(d.hasClass("field_type-text")||d.hasClass("acf-field-text")){if(i=d.find("input").attr("id"),t.disabledField(i))return!0;WPGlobusDialogApp.addElement({id:i,dialogTitle:"Edit ACF field",style:"width:97%;float:left;",sbTitle:"Click for edit",onChangeClass:"wpglobus-on-change-acf-field"})}})},attachListeners:function(){if(t.option.pro){var e=this;acf.add_action&&acf.add_action("append",function(t){e.replaceCloneIndex(t)})}},replaceCloneIndex:function(t){var i=t.data("id");t.find('[data-source-id*="acfcloneindex"]').each(function(){e(this).attr("data-source-id",e(this).attr("data-source-id").replace("acfcloneindex",i))})}};WPGlobusAcf=e.extend({},WPGlobusAcf,t),WPGlobusAcf.init({pro:WPGlobusAcf.pro})}});
includes/js/wpglobus-vendor-aioseop.js ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * WPGlobus Administration All on one seo pack
3
+ * Interface JS functions
4
+ *
5
+ * @since 1.0.8
6
+ *
7
+ * @package WPGlobus
8
+ * @subpackage Administration
9
+ */
10
+ /* jslint browser: true */
11
+ /* global jQuery, console, WPGlobusCore, WPGlobusCoreData */
12
+
13
+ var WPGlobusAioseop;
14
+
15
+ (function($) {
16
+ "use strict";
17
+ var api;
18
+ api = WPGlobusAioseop = {
19
+ init: function() {
20
+ if ( 0 == $('#aiosp_snippet_wrapper').size() ) {
21
+ /* maybe All in One SEO Pack Pro license key is not set yet or invalid */
22
+ return;
23
+ }
24
+ // tabs on
25
+ $('#wpglobus-aioseop-tabs').removeClass('hidden wpglobus-hidden').tabs();
26
+ $('#wpglobus-aioseop-tabs').insertBefore($('#aiosp_snippet_wrapper'));
27
+ $('#aiosp_snippet_wrapper, #aiosp_title_wrapper, #aiosp_description_wrapper, #aiosp_keywords_wrapper').addClass('hidden');
28
+ api.setCounters();
29
+ api.attachListeners();
30
+
31
+ },
32
+ setCounters: function() {
33
+ $('.wpglobus_countable').each(function(i,e){
34
+ var $e = $(e), extra = 0,
35
+ counter = $e.data('field-count');
36
+ if ( typeof $e.data('extra-element') !== 'undefined' ) {
37
+ extra = $('#'+$e.data('extra-element')).data('extra-length');
38
+ }
39
+ $('input[name='+counter+']').val( $e.val().length+extra );
40
+ });
41
+ },
42
+ countChars: function($field,cntfield) {
43
+ var extra = 0, field_size,
44
+ cntfield = 'input[name='+cntfield+']',
45
+ max_size = $field.data('max-size');
46
+
47
+ if ( typeof $field.data('extra-element') !== 'undefined' ) {
48
+ extra = $('#'+$field.data('extra-element')).data('extra-length');
49
+ }
50
+
51
+ field_size = $field.val().length + extra;
52
+ $(cntfield).val( field_size );
53
+ if ( field_size > max_size ) {
54
+ $(cntfield).css({'color':'#fff','background-color':'#f00'});
55
+ } else {
56
+ if ( field_size > max_size - 6 ) {
57
+ $(cntfield).css({'color':'#515151','background-color':'#ff0'});
58
+ } else {
59
+ $(cntfield).css({'color':'#515151','background-color':'#eee'});
60
+ }
61
+ }
62
+ },
63
+ attachListeners: function() {
64
+ $('.wpglobus_countable').on('keyup', function(event) {
65
+ var $t = $(this);
66
+ api.countChars($t, $t.data('field-count'));
67
+ });
68
+
69
+ $('body').on('click', '.wpglobus-post-body-tabs-list li', function(event){
70
+ var $t = $(this);
71
+ if ( $t.hasClass('wpglobus-post-tab') ) {
72
+ $('#wpglobus-aioseop-tabs').tabs('option','active', $t.data('order'));
73
+ }
74
+ });
75
+
76
+ // title
77
+ $('.wpglobus-aioseop_title').on('keyup', function(event){
78
+ var $t = $(this);
79
+ $('#'+'aioseop_snippet_title_'+$t.data('language')).text($t.val());
80
+ });
81
+ $('body').on('change', '.wpglobus-aioseop_title', function(event){
82
+ var $t = $(this),
83
+ save_to = 'input[name=aiosp_title]';
84
+ $(save_to).val( WPGlobusCore.getString( $(save_to).val(), $t.val(), $t.data('language')) );
85
+ });
86
+
87
+ // description
88
+ $('.wpglobus-aioseop_description').on('keyup', function(event){
89
+ var $t = $(this);
90
+ $('#'+'aioseop_snippet_description_'+$t.data('language')).text($t.val());
91
+ });
92
+
93
+ $('body').on('change', '.wpglobus-aioseop_description', function(event){
94
+ var $t = $(this),
95
+ save_to = 'textarea[name=aiosp_description]';
96
+ $(save_to).val( WPGlobusCore.getString( $(save_to).val(), $t.val(), $t.data('language')) );
97
+ });
98
+
99
+ // keywords
100
+ $('body').on('change', '.wpglobus-aioseop_keywords', function(event){
101
+ var $t = $(this),
102
+ save_to = 'input[name=aiosp_keywords]';
103
+ $(save_to).val( WPGlobusCore.getString( $(save_to).val(), $t.val(), $t.data('language')) );
104
+ });
105
+
106
+ }
107
+ };
108
+ })(jQuery);
includes/js/wpglobus-vendor-aioseop.min.js ADDED
@@ -0,0 +1 @@
 
1
+ var WPGlobusAioseop;!function(a){"use strict";var o;o=WPGlobusAioseop={init:function(){0!=a("#aiosp_snippet_wrapper").size()&&(a("#wpglobus-aioseop-tabs").removeClass("hidden wpglobus-hidden").tabs(),a("#wpglobus-aioseop-tabs").insertBefore(a("#aiosp_snippet_wrapper")),a("#aiosp_snippet_wrapper, #aiosp_title_wrapper, #aiosp_description_wrapper, #aiosp_keywords_wrapper").addClass("hidden"),o.setCounters(),o.attachListeners())},setCounters:function(){a(".wpglobus_countable").each(function(o,t){var e=a(t),s=0,n=e.data("field-count");void 0!==e.data("extra-element")&&(s=a("#"+e.data("extra-element")).data("extra-length")),a("input[name="+n+"]").val(e.val().length+s)})},countChars:function(o,t){var e,s=0,n=(t="input[name="+t+"]",o.data("max-size"));void 0!==o.data("extra-element")&&(s=a("#"+o.data("extra-element")).data("extra-length")),e=o.val().length+s,a(t).val(e),e>n?a(t).css({color:"#fff","background-color":"#f00"}):e>n-6?a(t).css({color:"#515151","background-color":"#ff0"}):a(t).css({color:"#515151","background-color":"#eee"})},attachListeners:function(){a(".wpglobus_countable").on("keyup",function(t){var e=a(this);o.countChars(e,e.data("field-count"))}),a("body").on("click",".wpglobus-post-body-tabs-list li",function(o){var t=a(this);t.hasClass("wpglobus-post-tab")&&a("#wpglobus-aioseop-tabs").tabs("option","active",t.data("order"))}),a(".wpglobus-aioseop_title").on("keyup",function(o){var t=a(this);a("#aioseop_snippet_title_"+t.data("language")).text(t.val())}),a("body").on("change",".wpglobus-aioseop_title",function(o){var t=a(this),e="input[name=aiosp_title]";a(e).val(WPGlobusCore.getString(a(e).val(),t.val(),t.data("language")))}),a(".wpglobus-aioseop_description").on("keyup",function(o){var t=a(this);a("#aioseop_snippet_description_"+t.data("language")).text(t.val())}),a("body").on("change",".wpglobus-aioseop_description",function(o){var t=a(this),e="textarea[name=aiosp_description]";a(e).val(WPGlobusCore.getString(a(e).val(),t.val(),t.data("language")))}),a("body").on("change",".wpglobus-aioseop_keywords",function(o){var t=a(this),e="input[name=aiosp_keywords]";a(e).val(WPGlobusCore.getString(a(e).val(),t.val(),t.data("language")))})}}}(jQuery);
includes/js/wpglobus-widgets.js ADDED
@@ -0,0 +1,461 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * WPGlobus Administration Widgets
3
+ * Interface JS functions
4
+ *
5
+ * @since 1.0.6
6
+ *
7
+ * @package WPGlobus
8
+ * @subpackage Administration
9
+ */
10
+ /*jslint browser: true*/
11
+ /*global jQuery, console, WPGlobusCore, WPGlobusCoreData, WPGlobusWidgets*/
12
+
13
+ //var WPGlobusWidgets;
14
+
15
+ (function($) {
16
+ "use strict";
17
+
18
+ if ( typeof WPGlobusWidgets === 'undefined' ) {
19
+ return;
20
+ }
21
+
22
+ var api = {
23
+ saveArbitraryTextOrHTML: false,
24
+ editor: {},
25
+ languageBoxActive: false,
26
+ languageBoxTimeout: null,
27
+ init: function() {
28
+ api.addElements();
29
+ api.attachListeners();
30
+ api.arbitraryTextOrHTML();
31
+ },
32
+ wysiwygClean: function(){
33
+ // remove wpglobus textarea and dialog start button from wysiwyg
34
+ $('.wpglobus-dialog-field').each(function(i,e){
35
+ var source = $(e).data('source-id');
36
+ if ( $('#'+source+'-tmce').size() == 1 ) {
37
+ var ds = $(e).next('.wpglobus_dialog_start');
38
+ $(e).remove();
39
+ $(ds).remove();
40
+ }
41
+ });
42
+ },
43
+ setupWidgetControl: function(widgetName, controls, editor) {
44
+
45
+ var ret = false;
46
+ $.each( api.editor, function(id, data){
47
+ if ( data['widgetName'] == widgetName ) {
48
+ ret = true;
49
+ return false;
50
+ }
51
+ });
52
+
53
+ if (ret) return;
54
+
55
+ var controlElementID = controls.$el[0].id;
56
+ if ( '' == controlElementID ) {
57
+ /**
58
+ * We have empty controls.$el[0].id @since WP 4.8.1.
59
+ * Fix it.
60
+ */
61
+ var p = controls.$el[0].offsetParent;
62
+ controlElementID = $(p).attr('id');
63
+ if ( 'undefined' === typeof controlElementID ) {
64
+ /**
65
+ * Case when WYSIWYG text widgets more than 1.
66
+ * @since 1.8.6
67
+ */
68
+ $('.widget').each( function(i,e){
69
+ var id = $(e).attr('id');
70
+ if( -1 != id.indexOf(widgetName) ) {
71
+ controlElementID = id;
72
+ return false;
73
+ }
74
+
75
+ });
76
+ }
77
+ }
78
+
79
+ if ( 'undefined' === typeof controlElementID ) {
80
+ /**
81
+ * For testing purposes.
82
+ * Maybe there will be changes in next versions WP.
83
+ */
84
+ // console.log('controlElementID: '+controlElementID);
85
+ }
86
+
87
+ var sourceSelector = '#'+controlElementID+' #widget-'+widgetName+'-text';
88
+ var sourceTitleSelector = '#'+controlElementID+' #widget-'+widgetName+'-title';
89
+
90
+ api.editor[editor.id] = {};
91
+ api.editor[editor.id]['widgetName'] = widgetName;
92
+ api.editor[editor.id]['controls'] = controls;
93
+ api.editor[editor.id]['sourceTitleSelector'] = sourceTitleSelector;
94
+ api.editor[editor.id]['titleSelector'] = null;
95
+ api.editor[editor.id]['sourceSelector'] = sourceSelector;
96
+ api.editor[editor.id]['content'] = $(sourceSelector).val();
97
+ api.editor[editor.id]['saveSelector'] = '#'+controlElementID+' #widget-'+widgetName+'-savewidget';
98
+ api.editor[editor.id]['languageSelector'] = '#'+controlElementID+' .wpglobus-current-language';
99
+ api.editor[editor.id]['inWidgetTitleSelector'] = '#'+controlElementID+' .in-widget-title';
100
+
101
+ /**
102
+ * Set init value for tinymce editor via textarea field.
103
+ */
104
+ var ic = WPGlobusCore.TextFilter( api.editor[editor.id]['content'], WPGlobusCoreData.default_language, 'RETURN_EMPTY' );
105
+ $('#'+editor.id).val(ic);
106
+
107
+ /**
108
+ * Language items.
109
+ */
110
+ var item = '<a href="#" onclick="return false;" class="item" data-widget-id="{{widgetID}}" data-source="{{source}}" data-editor-id="{{editorID}}" data-language="{{language}}" data-widget-name="{{widgetName}}" style="text-align:center;"><span>{{item}}</span></a>';
111
+ var newItem = '', items = '';
112
+ $.each( WPGlobusCoreData.enabled_languages, function(i,l){
113
+ newItem = item;
114
+ newItem = newItem.replace('{{language}}', l);
115
+ newItem = newItem.replace('{{item}}', WPGlobusCoreData.en_language_name[l]);
116
+ newItem = newItem.replace('{{widgetName}}', widgetName);
117
+ newItem = newItem.replace('{{widgetID}}', controlElementID);
118
+ newItem = newItem.replace('{{editorID}}', editor.id);
119
+ newItem = newItem.replace('{{source}}', sourceSelector);
120
+ items += newItem;
121
+ });
122
+
123
+ /**
124
+ * Button for tinymce editor.
125
+ */
126
+ var button =
127
+ '<button ' +
128
+ 'style="z-index:200000;" ' +
129
+ 'type="button" ' +
130
+ 'id="'+editor.id+'-wpglobus-button" ' +
131
+ 'data-widget-id="'+controlElementID+'"' +
132
+ 'class="wp-switch-editor switch-wpglobus-language wpglobus-icon-globe">' +
133
+ '<span class="wpglobus-current-language" data-language="en" style="">En</span>' +
134
+ '</button>' +
135
+ '<div class="wpglobus-language-box" style="position:absolute;top:0;left:0;display:none;z-index:200100;border:1px solid #9e9e9e;border-radius:3px;background-color:#fff;padding: 2px 5px;">' +
136
+ '<div style="display:flex;flex-direction:column;">' + items + '</div>' +
137
+ '</div>';
138
+
139
+ $('#'+controlElementID+' .wp-editor-tabs').append(button);
140
+
141
+ /**
142
+ * Add WPGlobus dialog to title field.
143
+ */
144
+ if ( WPGlobusDialogApp.addElement({id:controls.fields.title[0].id, style:'width:93%;'}) ) {
145
+ api.editor[editor.id]['titleSelector'] = '#'+controls.fields.title[0].id;
146
+ }
147
+
148
+ /**
149
+ * Set widget title.
150
+ */
151
+ api.arbitraryWidgetTitle(editor.id);
152
+
153
+ },
154
+ arbitraryWidgetTitle: function(editorID) {
155
+ var title = WPGlobusCore.TextFilter(
156
+ $('#'+api.editor[editorID]['controls']['fields']['title'][0]['id']).val(),
157
+ WPGlobusCoreData.language
158
+ );
159
+ $(api.editor[editorID]['inWidgetTitleSelector']).text(': '+title);
160
+ },
161
+ setBoxTimeout: function() {
162
+ api.languageBoxTimeout = setTimeout( function(){
163
+ api.languageBoxActive = false;
164
+ $('.wpglobus-language-box').css({'display':'none'});
165
+ }, 1000);
166
+ },
167
+ arbitraryTextOrHTML: function() {
168
+ /**
169
+ * @see wp-admin\js\widgets\text-widgets.js
170
+ */
171
+
172
+ /**
173
+ * Open language selector box.
174
+ */
175
+ $(document).on('click', '.switch-wpglobus-language', function(ev) {
176
+ if ( api.languageBoxActive ) {
177
+ return;
178
+ }
179
+ api.languageBoxActive = true;
180
+ var $t = $(this);
181
+ var widgetID = $t.data('widget-id');
182
+ var pos = $t.position();
183
+ pos.top += 34;
184
+ pos.left += 10;
185
+ $('#'+widgetID+' .wpglobus-language-box').css({'display':'block','top':pos.top+'px','left':pos.left+'px'});
186
+ api.setBoxTimeout();
187
+ });
188
+
189
+ /**
190
+ * Wait then hide language selector box.
191
+ */
192
+ $(document).on('mouseenter', '.wpglobus-language-box', function(ev) {
193
+ clearTimeout(api.languageBoxTimeout);
194
+ }).on('mouseleave', '.wpglobus-language-box', function(ev) {
195
+ $('.wpglobus-language-box').css({'display':'none'});
196
+ api.languageBoxActive = false;
197
+ });
198
+
199
+ /**
200
+ * Change language code for tinymce.
201
+ */
202
+ $(document).on('click', '.wpglobus-language-box .item', function(ev) {
203
+ var $t = $(this);
204
+ var l = $t.data('language');
205
+ var widgetID = $t.data('widget-id');
206
+ var editorID = $t.data('editor-id');
207
+
208
+ $('#'+widgetID+' .wpglobus-current-language').text(l).data('language', l);
209
+
210
+ var t = WPGlobusCore.TextFilter(
211
+ api.editor[editorID].content,
212
+ l,
213
+ 'RETURN_EMPTY'
214
+ );
215
+
216
+ tinymce.get(editorID).setContent(t,{format: 'raw'});
217
+ $('textarea#'+editorID).val(t);
218
+ });
219
+
220
+ /**
221
+ * Hooked editor setup to start our setup.
222
+ */
223
+ $(document).on('tinymce-editor-setup', function(ev, editor) {
224
+ $.each(wp.textWidgets.widgetControls, function(widgetName,controls){
225
+ api.setupWidgetControl(widgetName, controls, editor);
226
+ });
227
+ });
228
+
229
+ /**
230
+ * Hooked editor init (after editor setup).
231
+ */
232
+ $(document).on( 'tinymce-editor-init', function(ev, editor) {
233
+
234
+ $(document).on('mouseenter', api.editor[editor.id]['saveSelector'], function(ev){
235
+ /**
236
+ * Sync title with hidden fields.
237
+ */
238
+ $(api.editor[editor.id]['sourceTitleSelector']).val( $(api.editor[editor.id]['titleSelector']).val() );
239
+ /**
240
+ * Sync tinymce with hidden fields.
241
+ */
242
+ $(api.editor[editor.id]['sourceSelector']).val( api.editor[editor.id]['content'] );
243
+ });
244
+
245
+ /**
246
+ * Save widget.
247
+ */
248
+ $(document).on('click', api.editor[editor.id]['saveSelector'], function(ev){
249
+ api.saveArbitraryTextOrHTML = editor.id;
250
+ });
251
+
252
+ /**
253
+ * Hook tinymce editor.
254
+ */
255
+ editor.on('nodechange keyup', _.debounce( updateEditorContent, 100 ) );
256
+
257
+ /**
258
+ * Hook textarea.
259
+ * don't use 'input' event here.
260
+ */
261
+ $('#'+editor.id).on('keyup', _.debounce( updateEditorContent, 100 ) );
262
+ } );
263
+
264
+ /**
265
+ * Update editor content.
266
+ */
267
+ function updateEditorContent(ev) {
268
+
269
+ var id = '';
270
+ if ( ev.type == 'keyup' && ev.target.id == 'tinymce' ) {
271
+ id = $(ev.target).data('id');
272
+ } else {
273
+ id = ev.target.id;
274
+ }
275
+
276
+ if ( api.editor[id] ) {
277
+ var l = $( api.editor[id]['languageSelector'] ).data('language');
278
+ var newContent = '';
279
+ if ( tinymce.get(id).isHidden() ) {
280
+ newContent = $('#'+id).val();
281
+ } else {
282
+ newContent = tinymce.get(id).getContent({format:'raw'});
283
+ }
284
+
285
+ api.editor[id]['content'] = WPGlobusCore.getString(
286
+ api.editor[id]['content'],
287
+ newContent,
288
+ l
289
+ );
290
+
291
+ /**
292
+ * Sync with widget content hidden fields.
293
+ * @see .widget-inside .widget-content
294
+ */
295
+ $(api.editor[id]['sourceSelector']).val( api.editor[id]['content'] );
296
+
297
+ }
298
+
299
+ }
300
+
301
+ },
302
+ addElements: function(get_by, coid) {
303
+ var id, elem = [], get_by_coid;
304
+ elem[0] = 'input[type="text"]';
305
+ elem[1] = 'textarea';
306
+ if ( typeof get_by === 'undefined' || get_by == 'class' ) {
307
+ get_by_coid = '.widget-liquid-right .widget .widget-content';
308
+ $.each(elem, function(i,e){
309
+ api.makeClone(get_by_coid, e);
310
+ });
311
+ } else if ( get_by == 'id' ) {
312
+ get_by_coid = '#'+coid+' .widget-content';
313
+ $.each(elem, function(i,e){
314
+ api.makeClone(get_by_coid, e);
315
+ });
316
+ }
317
+ },
318
+ makeClone: function(get_by_coid, type) {
319
+ $(get_by_coid+' '+type).each(function(i,e){
320
+ var element = $(e),
321
+ clone, name, text, id, dis = false;
322
+
323
+ id = element.attr('id');
324
+
325
+ if ( typeof id === 'undefined' || -1 != id.indexOf( '-number') || '' == id ) {
326
+ return true;
327
+ }
328
+
329
+ /**
330
+ * Check for disabled mask.
331
+ */
332
+ _.each( WPGlobusWidgets.disabledMask, function(mask){
333
+ if ( -1 != id.indexOf( mask ) ) {
334
+ dis = true;
335
+ return false;
336
+ }
337
+ });
338
+
339
+ if ( dis ) return true;
340
+
341
+ clone = $('#'+id).clone();
342
+ $(element).addClass('wpglobus-dialog-field-source hidden');
343
+ name = element.attr('name');
344
+ $(clone).attr('id', 'wpglobus-'+id);
345
+ $(clone).attr('name', 'wpglobus-'+name);
346
+ $(clone).attr('data-source-id', id);
347
+ $(clone).attr('class', 'wpglobus-dialog-field');
348
+ $(clone).attr('style', 'width:90%;');
349
+ text = WPGlobusCore.TextFilter($(element).val(), WPGlobusCoreData.language);
350
+ $(clone).val(text);
351
+ $('<div style="width:20px;" data-type="control" data-source-type="" data-source-id="'+id+'" class="wpglobus-widgets wpglobus_dialog_start wpglobus_dialog_icon"></div>').insertAfter(element);
352
+ $(clone).insertAfter(element);
353
+ if ( 'input[type="text"]' == type && '' != text ) {
354
+ var w_id = element.parents('.widget').attr('id');
355
+ $('#'+w_id+' .in-widget-title').text(': '+text);
356
+ }
357
+ });
358
+ },
359
+ attachListeners: function() {
360
+ $(document).ajaxComplete(function(event, jqxhr, settings){
361
+ if ( -1 != settings.data.indexOf( 'action=save-widget') ) {
362
+ if ( -1 != settings.data.indexOf( 'delete_widget=1' ) ) {
363
+ // deleted widget
364
+ } else {
365
+ // update or added new widget
366
+ if ( api.saveArbitraryTextOrHTML ) {
367
+ var content = WPGlobusCore.TextFilter(
368
+ api.editor[api.saveArbitraryTextOrHTML]['content'],
369
+ $( api.editor[api.saveArbitraryTextOrHTML]['languageSelector'] ).data('language'),
370
+ 'RETURN_EMPTY'
371
+ );
372
+ /**
373
+ * Set value for tinymce editor.
374
+ */
375
+ if ( tinymce.get(api.saveArbitraryTextOrHTML).isHidden() ) {
376
+ $('#'+api.saveArbitraryTextOrHTML).val(content);
377
+ $('#' + api.saveArbitraryTextOrHTML + '-tmce').click();
378
+ } else {
379
+ tinymce.get(api.saveArbitraryTextOrHTML).setContent(content, { format:'raw' });
380
+ }
381
+ /**
382
+ * Set widget title.
383
+ */
384
+ api.arbitraryWidgetTitle(api.saveArbitraryTextOrHTML);
385
+ api.saveArbitraryTextOrHTML = false;
386
+ return;
387
+ }
388
+ var s = settings.data.split('widget-id=');
389
+ s = s[1].split('&');
390
+ $('.widget-liquid-right .widget').each(function(i,e){
391
+ var id = $(e).attr('id');
392
+ if ( -1 !== id.indexOf(s[0]) ) {
393
+ api.addElements('id', id);
394
+ api.wysiwygClean();
395
+ }
396
+ });
397
+ }
398
+ }
399
+ });
400
+ $('body').on('change', '.wpglobus-dialog-field', function(){
401
+ var $t = $(this),
402
+ source_id = '#'+$t.data('source-id'),
403
+ source = '', s = '', new_value;
404
+
405
+ if ( typeof source_id == 'undefined' ) {
406
+ return;
407
+ }
408
+ source = $(source_id).val();
409
+
410
+ if ( ! /(\{:|\[:|<!--:)[a-z]{2}/.test(source) ) {
411
+ $(source_id).val($t.val());
412
+ } else {
413
+ $.each(WPGlobusCoreData.enabled_languages, function(i,l){
414
+ if ( l == WPGlobusCoreData.language ) {
415
+ new_value = $t.val();
416
+ } else {
417
+ new_value = WPGlobusCore.TextFilter(source,l,'RETURN_EMPTY');
418
+ }
419
+ if ( '' != new_value ) {
420
+ s = s + WPGlobusCore.addLocaleMarks(new_value,l);
421
+ }
422
+ });
423
+ $(source_id).val(s);
424
+ }
425
+
426
+ });
427
+ $(document).on('click','.widget-title, .widget-title-action',function(ev){
428
+ ev.preventDefault();
429
+ api.wysiwygClean();
430
+ api.imageWidget(this);
431
+ });
432
+ },
433
+ imageWidget: function(title) {
434
+ var wID = $(title).parents('.widget').attr('id');
435
+ if ( -1 == wID.indexOf('media_image') ) {
436
+ return;
437
+ }
438
+ var $title = $('#'+wID+' .in-widget-title');
439
+ var elID = $('#'+wID).find('input[type="text"]').attr('id');
440
+ if ( -1 != elID.indexOf('.') ) {
441
+ var name = 'wpg-'+elID.replace('.','_');
442
+ $('#'+wID).find('input[type="text"]').attr('name',name);
443
+ if ( WPGlobusDialogApp.addElement(name) ) {
444
+ var $el = $('#'+wID).find('input[name="'+name+'"]');
445
+ var v = WPGlobusCore.getTranslations( $el.val() )[WPGlobusCoreData['language']];
446
+ $title.text(': '+v);
447
+ setTimeout(function(){$('#wpglobus-'+name).val(v)},1000);
448
+ }
449
+ } else {
450
+ if ( WPGlobusDialogApp.addElement(elID) ) {
451
+ var v = WPGlobusCore.getTranslations( $('#'+elID).val() )[WPGlobusCoreData['language']];
452
+ $title.text(': '+v);
453
+ setTimeout(function(){$('#wpglobus-'+elID).val(v)},1000);
454
+ }
455
+ }
456
+ }
457
+ };
458
+
459
+ WPGlobusWidgets = $.extend({}, WPGlobusWidgets, api);
460
+
461
+ })(jQuery);
includes/js/wpglobus-widgets.min.js ADDED
@@ -0,0 +1 @@
 
1
+ !function(e){"use strict";if("undefined"!=typeof WPGlobusWidgets){var t={saveArbitraryTextOrHTML:!1,editor:{},languageBoxActive:!1,languageBoxTimeout:null,init:function(){t.addElements(),t.attachListeners(),t.arbitraryTextOrHTML()},wysiwygClean:function(){e(".wpglobus-dialog-field").each(function(t,i){var a=e(i).data("source-id");if(1==e("#"+a+"-tmce").size()){var o=e(i).next(".wpglobus_dialog_start");e(i).remove(),e(o).remove()}})},setupWidgetControl:function(i,a,o){var n=!1;if(e.each(t.editor,function(e,t){if(t.widgetName==i)return n=!0,!1}),!n){var r=a.$el[0].id;if(""==r){var d=a.$el[0].offsetParent;void 0===(r=e(d).attr("id"))&&e(".widget").each(function(t,a){var o=e(a).attr("id");if(-1!=o.indexOf(i))return r=o,!1})}var l="#"+r+" #widget-"+i+"-text",u="#"+r+" #widget-"+i+"-title";t.editor[o.id]={},t.editor[o.id].widgetName=i,t.editor[o.id].controls=a,t.editor[o.id].sourceTitleSelector=u,t.editor[o.id].titleSelector=null,t.editor[o.id].sourceSelector=l,t.editor[o.id].content=e(l).val(),t.editor[o.id].saveSelector="#"+r+" #widget-"+i+"-savewidget",t.editor[o.id].languageSelector="#"+r+" .wpglobus-current-language",t.editor[o.id].inWidgetTitleSelector="#"+r+" .in-widget-title";var s=WPGlobusCore.TextFilter(t.editor[o.id].content,WPGlobusCoreData.default_language,"RETURN_EMPTY");e("#"+o.id).val(s);var g="",c="";e.each(WPGlobusCoreData.enabled_languages,function(e,t){g=(g=(g=(g=(g=(g=(g='<a href="#" onclick="return false;" class="item" data-widget-id="{{widgetID}}" data-source="{{source}}" data-editor-id="{{editorID}}" data-language="{{language}}" data-widget-name="{{widgetName}}" style="text-align:center;"><span>{{item}}</span></a>').replace("{{language}}",t)).replace("{{item}}",WPGlobusCoreData.en_language_name[t])).replace("{{widgetName}}",i)).replace("{{widgetID}}",r)).replace("{{editorID}}",o.id)).replace("{{source}}",l),c+=g});var f='<button style="z-index:200000;" type="button" id="'+o.id+'-wpglobus-button" data-widget-id="'+r+'"class="wp-switch-editor switch-wpglobus-language wpglobus-icon-globe"><span class="wpglobus-current-language" data-language="en" style="">En</span></button><div class="wpglobus-language-box" style="position:absolute;top:0;left:0;display:none;z-index:200100;border:1px solid #9e9e9e;border-radius:3px;background-color:#fff;padding: 2px 5px;"><div style="display:flex;flex-direction:column;">'+c+"</div></div>";e("#"+r+" .wp-editor-tabs").append(f),WPGlobusDialogApp.addElement({id:a.fields.title[0].id,style:"width:93%;"})&&(t.editor[o.id].titleSelector="#"+a.fields.title[0].id),t.arbitraryWidgetTitle(o.id)}},arbitraryWidgetTitle:function(i){var a=WPGlobusCore.TextFilter(e("#"+t.editor[i].controls.fields.title[0].id).val(),WPGlobusCoreData.language);e(t.editor[i].inWidgetTitleSelector).text(": "+a)},setBoxTimeout:function(){t.languageBoxTimeout=setTimeout(function(){t.languageBoxActive=!1,e(".wpglobus-language-box").css({display:"none"})},1e3)},arbitraryTextOrHTML:function(){e(document).on("click",".switch-wpglobus-language",function(i){if(!t.languageBoxActive){t.languageBoxActive=!0;var a=e(this),o=a.data("widget-id"),n=a.position();n.top+=34,n.left+=10,e("#"+o+" .wpglobus-language-box").css({display:"block",top:n.top+"px",left:n.left+"px"}),t.setBoxTimeout()}}),e(document).on("mouseenter",".wpglobus-language-box",function(e){clearTimeout(t.languageBoxTimeout)}).on("mouseleave",".wpglobus-language-box",function(i){e(".wpglobus-language-box").css({display:"none"}),t.languageBoxActive=!1}),e(document).on("click",".wpglobus-language-box .item",function(i){var a=e(this),o=a.data("language"),n=a.data("widget-id"),r=a.data("editor-id");e("#"+n+" .wpglobus-current-language").text(o).data("language",o);var d=WPGlobusCore.TextFilter(t.editor[r].content,o,"RETURN_EMPTY");tinymce.get(r).setContent(d,{format:"raw"}),e("textarea#"+r).val(d)}),e(document).on("tinymce-editor-setup",function(i,a){e.each(wp.textWidgets.widgetControls,function(e,i){t.setupWidgetControl(e,i,a)})}),e(document).on("tinymce-editor-init",function(a,o){e(document).on("mouseenter",t.editor[o.id].saveSelector,function(i){e(t.editor[o.id].sourceTitleSelector).val(e(t.editor[o.id].titleSelector).val()),e(t.editor[o.id].sourceSelector).val(t.editor[o.id].content)}),e(document).on("click",t.editor[o.id].saveSelector,function(e){t.saveArbitraryTextOrHTML=o.id}),o.on("nodechange keyup",_.debounce(i,100)),e("#"+o.id).on("keyup",_.debounce(i,100))});function i(i){var a="";if(a="keyup"==i.type&&"tinymce"==i.target.id?e(i.target).data("id"):i.target.id,t.editor[a]){var o=e(t.editor[a].languageSelector).data("language"),n="";n=tinymce.get(a).isHidden()?e("#"+a).val():tinymce.get(a).getContent({format:"raw"}),t.editor[a].content=WPGlobusCore.getString(t.editor[a].content,n,o),e(t.editor[a].sourceSelector).val(t.editor[a].content)}}},addElements:function(i,a){var o,n=[];n[0]='input[type="text"]',n[1]="textarea",void 0===i||"class"==i?(o=".widget-liquid-right .widget .widget-content",e.each(n,function(e,i){t.makeClone(o,i)})):"id"==i&&(o="#"+a+" .widget-content",e.each(n,function(e,i){t.makeClone(o,i)}))},makeClone:function(t,i){e(t+" "+i).each(function(t,a){var o,n,r,d,l=e(a),u=!1;if(void 0===(d=l.attr("id"))||-1!=d.indexOf("-number")||""==d)return!0;if(_.each(WPGlobusWidgets.disabledMask,function(e){if(-1!=d.indexOf(e))return u=!0,!1}),u)return!0;if(o=e("#"+d).clone(),e(l).addClass("wpglobus-dialog-field-source hidden"),n=l.attr("name"),e(o).attr("id","wpglobus-"+d),e(o).attr("name","wpglobus-"+n),e(o).attr("data-source-id",d),e(o).attr("class","wpglobus-dialog-field"),e(o).attr("style","width:90%;"),r=WPGlobusCore.TextFilter(e(l).val(),WPGlobusCoreData.language),e(o).val(r),e('<div style="width:20px;" data-type="control" data-source-type="" data-source-id="'+d+'" class="wpglobus-widgets wpglobus_dialog_start wpglobus_dialog_icon"></div>').insertAfter(l),e(o).insertAfter(l),'input[type="text"]'==i&&""!=r){var s=l.parents(".widget").attr("id");e("#"+s+" .in-widget-title").text(": "+r)}})},attachListeners:function(){e(document).ajaxComplete(function(i,a,o){if(-1!=o.data.indexOf("action=save-widget"))if(-1!=o.data.indexOf("delete_widget=1"));else{if(t.saveArbitraryTextOrHTML){var n=WPGlobusCore.TextFilter(t.editor[t.saveArbitraryTextOrHTML].content,e(t.editor[t.saveArbitraryTextOrHTML].languageSelector).data("language"),"RETURN_EMPTY");return tinymce.get(t.saveArbitraryTextOrHTML).isHidden()?(e("#"+t.saveArbitraryTextOrHTML).val(n),e("#"+t.saveArbitraryTextOrHTML+"-tmce").click()):tinymce.get(t.saveArbitraryTextOrHTML).setContent(n,{format:"raw"}),t.arbitraryWidgetTitle(t.saveArbitraryTextOrHTML),void(t.saveArbitraryTextOrHTML=!1)}var r=o.data.split("widget-id=");r=r[1].split("&"),e(".widget-liquid-right .widget").each(function(i,a){var o=e(a).attr("id");-1!==o.indexOf(r[0])&&(t.addElements("id",o),t.wysiwygClean())})}}),e("body").on("change",".wpglobus-dialog-field",function(){var t,i=e(this),a="#"+i.data("source-id"),o="",n="";void 0!==a&&(o=e(a).val(),/(\{:|\[:|<!--:)[a-z]{2}/.test(o)?(e.each(WPGlobusCoreData.enabled_languages,function(e,a){""!=(t=a==WPGlobusCoreData.language?i.val():WPGlobusCore.TextFilter(o,a,"RETURN_EMPTY"))&&(n+=WPGlobusCore.addLocaleMarks(t,a))}),e(a).val(n)):e(a).val(i.val()))}),e(document).on("click",".widget-title, .widget-title-action",function(e){e.preventDefault(),t.wysiwygClean(),t.imageWidget(this)})},imageWidget:function(t){var i=e(t).parents(".widget").attr("id");if(-1!=i.indexOf("media_image")){var a=e("#"+i+" .in-widget-title"),o=e("#"+i).find('input[type="text"]').attr("id");if(-1!=o.indexOf(".")){var n="wpg-"+o.replace(".","_");if(e("#"+i).find('input[type="text"]').attr("name",n),WPGlobusDialogApp.addElement(n)){var r=e("#"+i).find('input[name="'+n+'"]'),d=WPGlobusCore.getTranslations(r.val())[WPGlobusCoreData.language];a.text(": "+d),setTimeout(function(){e("#wpglobus-"+n).val(d)},1e3)}}else if(WPGlobusDialogApp.addElement(o)){d=WPGlobusCore.getTranslations(e("#"+o).val())[WPGlobusCoreData.language];a.text(": "+d),setTimeout(function(){e("#wpglobus-"+o).val(d)},1e3)}}}};WPGlobusWidgets=e.extend({},WPGlobusWidgets,t)}}(jQuery);
includes/js/wpglobus-wpseo-21.js ADDED
@@ -0,0 +1,497 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*jslint browser: true*/
2
+ /*global jQuery, console, WPGlobusVendor, wpseoMetaboxL10n, yst_updateSnippet */
3
+ // don't use strict mode like original wordpress-seo\js\wp-seo-metabox.js
4
+ // "use strict";
5
+ var wpglobus_wpseo = function () {
6
+ if (typeof wpseoMetaboxL10n === "undefined") {
7
+ return;
8
+ }
9
+
10
+ function wpglobus_replaceVariables(str, language, callback) {
11
+ if (typeof str === "undefined") {
12
+ return '';
13
+ }
14
+ if ( typeof replacedVars === 'undefined' && jQuery('#title').size() == 0 ) {
15
+ // WP SEO doesn't work properly when post title is disabled
16
+ return str;
17
+ }
18
+ var post_title = '#title',
19
+ post_excerpt = '#excerpt-' + language,
20
+ post_content = '#content';
21
+ if ( language != WPGlobusAdmin.data.default_language ) {
22
+ post_title = '#title_' + language;
23
+ post_content = '#content_' + language;
24
+ }
25
+ // title
26
+ if (jQuery(post_title).length) {
27
+ str = str.replace(/%%title%%/g, jQuery(post_title).val());
28
+ }
29
+
30
+ // These are added in the head for performance reasons.
31
+ //str = str.replace(/%%sitedesc%%/g, wpseoMetaboxL10n.sitedesc);
32
+ str = str.replace(/%%sitedesc%%/g, WPGlobusAdmin.data.blogdescription[language]);
33
+ //str = str.replace(/%%sitename%%/g, wpseoMetaboxL10n.sitename);
34
+ str = str.replace(/%%sitename%%/g, WPGlobusAdmin.data.blogname[language]);
35
+ str = str.replace(/%%sep%%/g, wpseoMetaboxL10n.sep);
36
+ str = str.replace(/%%date%%/g, wpseoMetaboxL10n.date);
37
+ str = str.replace(/%%id%%/g, wpseoMetaboxL10n.id);
38
+ str = str.replace(/%%page%%/g, wpseoMetaboxL10n.page);
39
+ str = str.replace(/%%currenttime%%/g, wpseoMetaboxL10n.currenttime);
40
+ str = str.replace(/%%currentdate%%/g, wpseoMetaboxL10n.currentdate);
41
+ str = str.replace(/%%currentday%%/g, wpseoMetaboxL10n.currentday);
42
+ str = str.replace(/%%currentmonth%%/g, wpseoMetaboxL10n.currentmonth);
43
+ str = str.replace(/%%currentyear%%/g, wpseoMetaboxL10n.currentyear);
44
+
45
+ str = str.replace(/%%focuskw%%/g, jQuery('#yoast_wpseo_focuskw' + '_' + language).val() );
46
+ // excerpt
47
+ var excerpt = '';
48
+ if (jQuery(post_excerpt).length) {
49
+ excerpt = yst_clean(jQuery(post_excerpt).val());
50
+ str = str.replace(/%%excerpt_only%%/g, excerpt);
51
+ }
52
+ if ('' == excerpt && jQuery(post_content).length) {
53
+ excerpt = jQuery(post_content).val().replace(/(<([^>]+)>)/ig,"").substring(0,wpseoMetaboxL10n.wpseo_meta_desc_length-1);
54
+ }
55
+ str = str.replace(/%%excerpt%%/g, excerpt);
56
+
57
+ // parent page
58
+ if (jQuery('#parent_id').length && jQuery('#parent_id option:selected').text() != wpseoMetaboxL10n.no_parent_text ) {
59
+ str = str.replace(/%%parent_title%%/g, jQuery('#parent_id option:selected').text());
60
+ }
61
+
62
+ // remove double separators
63
+ var esc_sep = yst_escapeFocusKw(wpseoMetaboxL10n.sep);
64
+ var pattern = new RegExp(esc_sep + ' ' + esc_sep, 'g');
65
+ str = str.replace(pattern, wpseoMetaboxL10n.sep);
66
+ if (str.indexOf('%%') != -1 && str.match(/%%[a-z0-9_-]+%%/i) != null) {
67
+ regex = /%%[a-z0-9_-]+%%/gi;
68
+ matches = str.match(regex);
69
+ for (i = 0; i < matches.length; i++) {
70
+ if (replacedVars[matches[i]] != undefined) {
71
+ str = str.replace(matches[i], replacedVars[matches[i]]);
72
+ } else {
73
+ replaceableVar = matches[i];
74
+ // create the cache already, so we don't do the request twice.
75
+ replacedVars[replaceableVar] = '';
76
+ jQuery.post(ajaxurl, {
77
+ action : 'wpseo_replace_vars',
78
+ string : matches[i],
79
+ post_id : jQuery('#post_ID').val(),
80
+ _wpnonce: wpseoMetaboxL10n.wpseo_replace_vars_nonce
81
+ }, function (data) {
82
+ if (data) {
83
+ replacedVars[replaceableVar] = data;
84
+ yst_replaceVariables(str, callback);
85
+ } else {
86
+ yst_replaceVariables(str, callback);
87
+ }
88
+ }
89
+ );
90
+ }
91
+ }
92
+ }
93
+ callback(str);
94
+ }
95
+
96
+ function wpglobus_boldKeywords(str, url, language) {
97
+ var focuskw = yst_escapeFocusKw(jQuery.trim(jQuery('#' + wpseoMetaboxL10n.field_prefix + 'focuskw' + '_' + language).val()));
98
+ var keywords;
99
+
100
+ if (focuskw == '') {
101
+ return str;
102
+ }
103
+
104
+ if (focuskw.search(' ') != -1) {
105
+ keywords = focuskw.split(' ');
106
+ } else {
107
+ keywords = new Array(focuskw);
108
+ }
109
+ for (var i = 0; i < keywords.length; i++) {
110
+ var kw = yst_clean(keywords[i]);
111
+ var kwregex = '';
112
+ if (url) {
113
+ kw = kw.replace(' ', '-').toLowerCase();
114
+ kwregex = new RegExp("([-/])(" + kw + ")([-/])?");
115
+ } else {
116
+ kwregex = new RegExp("(^|[ \s\n\r\t\.,'\(\"\+;!?:\-]+)(" + kw + ")($|[ \s\n\r\t\.,'\)\"\+;!?:\-]+)", 'gim');
117
+ }
118
+ if (str != undefined) {
119
+ str = str.replace(kwregex, "$1<strong>$2</strong>$3");
120
+ }
121
+ }
122
+ return str;
123
+ }
124
+
125
+ var wpglobus_updateTitle = function(force,language) {
126
+ var title = '';
127
+ var titleElm = jQuery('#' + wpseoMetaboxL10n.field_prefix + 'title' + '_' + language);
128
+ var titleLengthError = jQuery('#' + wpseoMetaboxL10n.field_prefix + 'title-length-warning'+'_'+language);
129
+ var divHtml = jQuery('<div />');
130
+ var snippetTitle = jQuery('#wpseosnippet_title'+'_'+language);
131
+
132
+ if (titleElm.val()) {
133
+ title = titleElm.val();
134
+ } else {
135
+ title = wpseoMetaboxL10n.wpseo_title_template;
136
+ title = divHtml.html(title).text();
137
+ }
138
+ if (title == '') {
139
+ snippetTitle.html('');
140
+ titleLengthError.hide();
141
+ return;
142
+ }
143
+
144
+ title = yst_clean(title);
145
+ title = jQuery.trim(title);
146
+ title = divHtml.text(title).html();
147
+
148
+ if (force) {
149
+ titleElm.val(title);
150
+ }
151
+ // !!!!!!
152
+ title = wpglobus_replaceVariables(title, language, function (title) {
153
+ // do the placeholder
154
+ var placeholder_title = divHtml.html(title).text();
155
+ titleElm.attr('placeholder', placeholder_title);
156
+
157
+ title = yst_clean(title);
158
+
159
+ // and now the snippet preview title
160
+ title = wpglobus_boldKeywords(title, false, language);
161
+
162
+ jQuery('#wpseosnippet_title'+'_'+language).html(title);
163
+
164
+ var e = document.getElementById('wpseosnippet_title'+'_'+language);
165
+ if (e != null) {
166
+ if (e.scrollWidth > e.clientWidth) {
167
+ titleLengthError.show();
168
+ } else {
169
+ titleLengthError.hide();
170
+ }
171
+ }
172
+
173
+ wpglobus_testFocusKw(language);
174
+ });
175
+ };
176
+
177
+ function wpglobus_updateDesc(language) {
178
+ var desc = jQuery.trim(yst_clean(jQuery('#' + wpseoMetaboxL10n.field_prefix + 'metadesc' + '_' + language).val()));
179
+ var divHtml = jQuery('<div />');
180
+ var snippet = jQuery('#wpseosnippet'+'_'+language);
181
+
182
+ if (desc == '' && wpseoMetaboxL10n.wpseo_metadesc_template != '') {
183
+ desc = wpseoMetaboxL10n.wpseo_metadesc_template;
184
+ }
185
+ if (desc != '') {
186
+ desc = yst_replaceVariables(desc, function (desc) {
187
+ desc = divHtml.text(desc).html();
188
+ desc = yst_clean(desc);
189
+
190
+
191
+ var len;
192
+ len = wpseoMetaboxL10n.wpseo_meta_desc_length - desc.length;
193
+
194
+ if (len < 0) {
195
+ len = '<span class="wrong">' + len + '</span>';
196
+ }
197
+ else {
198
+ len = '<span class="good">' + len + '</span>';
199
+ }
200
+
201
+ jQuery('#' + wpseoMetaboxL10n.field_prefix + 'metadesc-length' + '_' + language).html(len);
202
+
203
+ desc = yst_trimDesc(desc);
204
+ desc = wpglobus_boldKeywords(desc, false);
205
+ // Clear the autogen description.
206
+ snippet.find('.desc span.autogen').html('');
207
+ // Set our new one.
208
+ snippet.find('.desc span.content').html(desc);
209
+
210
+ wpglobus_testFocusKw(language);
211
+ });
212
+ } else {
213
+ jQuery('#' + wpseoMetaboxL10n.field_prefix + 'metadesc-length' + '_' + language).html(wpseoMetaboxL10n.wpseo_meta_desc_length);
214
+ // Clear the generated description
215
+ snippet.find('.desc span.content').html('');
216
+ wpglobus_testFocusKw(language);
217
+
218
+ var post_content = '#content';
219
+ if ( language != WPGlobusAdmin.data.default_language ) {
220
+ post_content = '#content_' + language;
221
+ }
222
+ if (jQuery(post_content).length) {
223
+ desc = jQuery(post_content).val();
224
+ desc = yst_clean(desc);
225
+ }
226
+
227
+ var focuskw = yst_escapeFocusKw(jQuery.trim(jQuery('#' + wpseoMetaboxL10n.field_prefix + 'focuskw' + '_' + language).val()));
228
+ if (focuskw != '') {
229
+ var descsearch = new RegExp(focuskw, 'gim');
230
+ if (desc.search(descsearch) != -1 && desc.length > wpseoMetaboxL10n.wpseo_meta_desc_length) {
231
+ desc = desc.substr(desc.search(descsearch), wpseoMetaboxL10n.wpseo_meta_desc_length);
232
+ } else {
233
+ desc = desc.substr(0, wpseoMetaboxL10n.wpseo_meta_desc_length);
234
+ }
235
+ } else {
236
+ desc = desc.substr(0, wpseoMetaboxL10n.wpseo_meta_desc_length);
237
+ }
238
+
239
+ desc = wpglobus_boldKeywords(desc, false);
240
+ desc = yst_trimDesc(desc);
241
+ snippet.find('.desc span.autogen').html(desc);
242
+ }
243
+ }
244
+
245
+ function wpglobus_testFocusKw(language) {
246
+ // Retrieve focus keyword and trim
247
+ var focuskw = jQuery.trim(jQuery('#' + wpseoMetaboxL10n.field_prefix + 'focuskw' + '_' + language).val());
248
+ focuskw = yst_escapeFocusKw(focuskw).toLowerCase();
249
+
250
+ var post_title = '#title';
251
+ var post_content = '#content';
252
+ if ( language != WPGlobusAdmin.data.default_language ) {
253
+ post_title = '#title_' + language;
254
+ post_content = '#content_' + language;
255
+ }
256
+
257
+ var postnamefull = jQuery(document).triggerHandler('wpglobus_post_name_full', {postnamefull:'#editable-post-name-full',language:language}) || '#editable-post-name-full';
258
+ if (jQuery(postnamefull).length) {
259
+ var postname = jQuery(postnamefull).text();
260
+ var url = wpseoMetaboxL10n.wpseo_permalink_template.replace('%postname%', postname).replace('http://', '');
261
+ }
262
+ var p = new RegExp("(^|[ \s\n\r\t\.,'\(\"\+;!?:\-])" + focuskw + "($|[ \s\n\r\t.,'\)\"\+!?:;\-])", 'gim');
263
+ //remove diacritics of a lower cased focuskw for url matching in foreign lang
264
+ var focuskwNoDiacritics = removeLowerCaseDiacritics(focuskw);
265
+ var p2 = new RegExp(focuskwNoDiacritics.replace(/\s+/g, "[-_\\\//]"), 'gim');
266
+
267
+ var focuskwresults = jQuery('#focuskwresults'+'_'+language);
268
+ var metadesc = jQuery('#wpseosnippet'+'_'+language).find('.desc span.content').text();
269
+
270
+ if (focuskw != '') {
271
+ var html = '<p>' + wpseoMetaboxL10n.keyword_header + '</p>';
272
+ html += '<ul>';
273
+ if (jQuery(post_title).length) {
274
+ html += '<li>' + wpseoMetaboxL10n.article_header_text + ptest(jQuery(post_title).val(), p) + '</li>';
275
+ }
276
+ html += '<li>' + wpseoMetaboxL10n.page_title_text + ptest(jQuery('#wpseosnippet_title'+'_'+language).text(), p) + '</li>';
277
+ html += '<li>' + wpseoMetaboxL10n.page_url_text + ptest(url, p2) + '</li>';
278
+ if (jQuery(post_content).length) {
279
+ html += '<li>' + wpseoMetaboxL10n.content_text + ptest(jQuery(post_content).val(), p) + '</li>';
280
+ }
281
+ html += '<li>' + wpseoMetaboxL10n.meta_description_text + ptest(metadesc, p) + '</li>';
282
+ html += '</ul>';
283
+ focuskwresults.html(html);
284
+ } else {
285
+ focuskwresults.html('');
286
+ }
287
+ }
288
+
289
+ var wpglobus_updateSnippet = function(language) {
290
+ //yst_updateURL();
291
+ wpglobus_updateTitle(false,language);
292
+ wpglobus_updateDesc(language);
293
+ };
294
+
295
+ var wpglobus_qtip = function() {
296
+ jQuery(".yoast_help").qtip(
297
+ {
298
+ content: {
299
+ attr: 'alt'
300
+ },
301
+ position: {
302
+ my: 'bottom left',
303
+ at: 'top center'
304
+ },
305
+ style : {
306
+ tip: {
307
+ corner: true
308
+ },
309
+ classes : 'yoast-qtip qtip-rounded qtip-blue'
310
+ },
311
+ show : {
312
+ when: {
313
+ event: 'mouseover'
314
+ }
315
+ },
316
+ hide : {
317
+ fixed: true,
318
+ when : {
319
+ event: 'mouseout'
320
+ }
321
+ }
322
+ }
323
+ );
324
+ };
325
+
326
+ // start
327
+
328
+ // tabs on
329
+ jQuery('#wpglobus-wpseo-tabs').tabs();
330
+
331
+ var attrs = jQuery('#wpglobus-wpseo-attr');
332
+ var t = jQuery('.wpseotab.general .form-table');
333
+ var ids = attrs.data('ids');
334
+ var names = attrs.data('names');
335
+ var wpseosnippet_url = '';
336
+
337
+ ids = ids+',' + attrs.data('qtip');
338
+ ids = ids.split(',');
339
+ names = names.split(',');
340
+
341
+ jQuery('#wpglobus-wpseo-tabs').insertBefore(t);
342
+
343
+ jQuery('.wpglobus-wpseo-general').each(function(i,e){
344
+ var $e = jQuery(e);
345
+ var l = $e.data('language');
346
+ $e.html('<table class="form-table wpglobus-table-'+l+'" data-language="'+l+'">' + t.html() + '</table>');
347
+ jQuery.each(names,function(i,name){
348
+ jQuery('#'+name).attr('name',name+'_'+l);
349
+ });
350
+ jQuery.each(ids,function(i,id){
351
+ var $id = jQuery('#'+id);
352
+ if ( 'wpseosnippet' == id ) {
353
+ $id.addClass('wpglobus-wpseosnippet');
354
+ }
355
+ if ( 'focuskwresults' == id ) {
356
+ $id.addClass('wpglobus-focuskwresults');
357
+ }
358
+ if ( wpseoMetaboxL10n.field_prefix + 'metadesc' == id ) {
359
+ $id.addClass('wpglobus-wpseo_metadesc').text($e.data('metadesc'));
360
+ }
361
+ if ( wpseoMetaboxL10n.field_prefix + 'title' == id ) {
362
+ $id.addClass('wpglobus-wpseo_title').val($e.data('wpseotitle'));
363
+ }
364
+ if ( wpseoMetaboxL10n.field_prefix + 'focuskw' == id ) {
365
+ $id.addClass('wpglobus-wpseo_focuskw').val($e.data('focuskw'));
366
+ }
367
+ $id.attr('id',id+'_'+l);
368
+ jQuery('#'+id+'_'+l).attr('data-language',l);
369
+ });
370
+ if ( 'complete' == $e.data('permalink') ) {
371
+ wpseosnippet_url = $e.data('url-'+l);
372
+ } else {
373
+ wpseosnippet_url = $e.data('url-'+l)+jQuery('#editable-post-name-full').text()+'/';
374
+ }
375
+ jQuery('#wpseosnippet_'+l+' .url').text(wpseosnippet_url);
376
+ wpglobus_updateSnippet(l);
377
+
378
+ if ( typeof jQuery().autocomplete != 'undefined' ) {
379
+ //
380
+ var cache = {}, lastXhr;
381
+ jQuery('#' + wpseoMetaboxL10n.field_prefix + 'focuskw' + '_' + l).autocomplete({
382
+ minLength : 3,
383
+ formatResult: function (row) {
384
+ return jQuery('<div/>').html(row).html();
385
+ },
386
+ source : function (request, response) {
387
+ var term = request.term;
388
+ if (term in cache) {
389
+ response(cache[term]);
390
+ return;
391
+ }
392
+ request._ajax_nonce = wpseoMetaboxL10n.wpseo_keyword_suggest_nonce;
393
+ request.action = 'wpseo_get_suggest';
394
+
395
+ lastXhr = jQuery.getJSON(ajaxurl, request, function (data, status, xhr) {
396
+ cache[term] = data;
397
+ if (xhr === lastXhr) {
398
+ response(data);
399
+ }
400
+ });
401
+ }
402
+ });
403
+ }
404
+
405
+ jQuery('#' + wpseoMetaboxL10n.field_prefix + 'title' + '_' + l).keyup(function () {
406
+ wpglobus_updateTitle(false, jQuery(this).data('language'));
407
+ });
408
+ jQuery('#title'+'_'+l).keyup(function () {
409
+ var l = jQuery(this).data('language') ? jQuery(this).data('language') : WPGlobusAdmin.data.default_language;
410
+ wpglobus_updateTitle(false, l);
411
+ wpglobus_updateDesc(l);
412
+ });
413
+ if ( i == 0 ) {
414
+ jQuery('#title').keyup(function () {
415
+ wpglobus_updateTitle(false, WPGlobusAdmin.data.default_language);
416
+ wpglobus_updateDesc(WPGlobusAdmin.data.default_language);
417
+ });
418
+ }
419
+ if ( i == 0 ) {
420
+ jQuery('body').on('change', '#parent_id', function () {
421
+ jQuery.each(WPGlobusAdmin.data.enabled_languages, function(i,l){
422
+ wpglobus_updateTitle(false, l);
423
+ wpglobus_updateDesc(l);
424
+ });
425
+ });
426
+ }
427
+ jQuery('#' + wpseoMetaboxL10n.field_prefix + 'metadesc' + '_' + l).keyup(function () {
428
+ wpglobus_updateDesc(jQuery(this).data('language'));
429
+ });
430
+ jQuery('body').on('keyup', '#excerpt-'+l, function () {
431
+ wpglobus_updateDesc(jQuery(this).data('language') ? jQuery(this).data('language') : WPGlobusAdmin.data.default_language);
432
+ });
433
+ if ( i == 0 ) {
434
+ // #content,#content_{lang_code}
435
+ jQuery('.wpglobus-editor').focusout(function () {
436
+ wpglobus_updateDesc(jQuery(this).data('language'));
437
+ });
438
+ }
439
+ var focuskwhelptriggered = false;
440
+ jQuery(document).on('change', '#' + wpseoMetaboxL10n.field_prefix + 'focuskw' + '_' + l, function () {
441
+ var l = jQuery(this).data('language');
442
+ var focuskwhelpElm = jQuery('#focuskwhelp'+'_'+l);
443
+ if (jQuery('#' + wpseoMetaboxL10n.field_prefix + 'focuskw' + '_' + l).val().search(',') != -1) {
444
+ focuskwhelpElm.click();
445
+ focuskwhelptriggered = true;
446
+ } else if (focuskwhelptriggered) {
447
+ focuskwhelpElm.qtip("hide");
448
+ focuskwhelptriggered = false;
449
+ }
450
+ wpglobus_updateSnippet( l );
451
+ });
452
+
453
+ }); // end each .wpglobus-wpseo-general
454
+ t.addClass('hidden');
455
+
456
+ // description
457
+ jQuery( 'body' ).on('change', '.wpglobus-wpseo_metadesc', function(event){
458
+ var save_to = '#' + wpseoMetaboxL10n.field_prefix + 'metadesc',
459
+ $t = jQuery(this);
460
+
461
+ jQuery(save_to).val( WPGlobusCore.getString( jQuery(save_to).val(), $t.val(), $t.data('language')) );
462
+ });
463
+
464
+ // title
465
+ jQuery('body').on('change', '.wpglobus-wpseo_title', function(event){
466
+ var save_to = '#' + wpseoMetaboxL10n.field_prefix + 'title',
467
+ $t = jQuery(this);
468
+
469
+ jQuery(save_to).val( WPGlobusCore.getString( jQuery(save_to).val(), $t.val(), $t.data('language')) );
470
+
471
+ });
472
+
473
+ // keywords
474
+ jQuery('body').on('change', '.wpglobus-wpseo_focuskw', function(event){
475
+ var save_to = '#' + wpseoMetaboxL10n.field_prefix + 'focuskw',
476
+ $t = jQuery(this);
477
+
478
+ jQuery(save_to).val( WPGlobusCore.getString( jQuery(save_to).val(), $t.val(), $t.data('language')) );
479
+ });
480
+
481
+ jQuery('body').on('click', '.wpglobus-post-body-tabs-list li', function(event){
482
+ $this = jQuery(this);
483
+ if ( $this.hasClass('wpglobus-post-tab') ) {
484
+ jQuery('#wpglobus-wpseo-tabs').tabs('option','active',jQuery(this).data('order'));
485
+ }
486
+ });
487
+
488
+ wpglobus_qtip();
489
+ yst_updateSnippet();
490
+ /*
491
+ jQuery('body').on('keyup', '.wpglobus-excerpt', function () {
492
+ var l = jQuery(this).data('language') ? jQuery(this).data('language') : WPGlobusAdmin.data.default_language;
493
+ console.log(l);
494
+ //wpglobus_updateDesc(l);
495
+ }); */
496
+
497
+ };
includes/js/wpglobus-wpseo-21.min.js ADDED
@@ -0,0 +1 @@
 
1
+ var wpglobus_wpseo=function(){if("undefined"!=typeof wpseoMetaboxL10n){var e=function(e,t){var a="",s=jQuery("#"+wpseoMetaboxL10n.field_prefix+"title_"+t),o=jQuery("#"+wpseoMetaboxL10n.field_prefix+"title-length-warning_"+t),n=jQuery("<div />"),r=jQuery("#wpseosnippet_title_"+t);if(s.val()?a=s.val():(a=wpseoMetaboxL10n.wpseo_title_template,a=n.html(a).text()),""==a)return r.html(""),void o.hide();a=yst_clean(a),a=jQuery.trim(a),a=n.text(a).html(),e&&s.val(a),a=function(e,t,a){if(void 0===e)return"";if("undefined"==typeof replacedVars&&0==jQuery("#title").size())return e;var s="#title",o="#excerpt-"+t,n="#content";t!=WPGlobusAdmin.data.default_language&&(s="#title_"+t,n="#content_"+t),jQuery(s).length&&(e=e.replace(/%%title%%/g,jQuery(s).val())),e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replace(/%%sitedesc%%/g,WPGlobusAdmin.data.blogdescription[t])).replace(/%%sitename%%/g,WPGlobusAdmin.data.blogname[t])).replace(/%%sep%%/g,wpseoMetaboxL10n.sep)).replace(/%%date%%/g,wpseoMetaboxL10n.date)).replace(/%%id%%/g,wpseoMetaboxL10n.id)).replace(/%%page%%/g,wpseoMetaboxL10n.page)).replace(/%%currenttime%%/g,wpseoMetaboxL10n.currenttime)).replace(/%%currentdate%%/g,wpseoMetaboxL10n.currentdate)).replace(/%%currentday%%/g,wpseoMetaboxL10n.currentday)).replace(/%%currentmonth%%/g,wpseoMetaboxL10n.currentmonth)).replace(/%%currentyear%%/g,wpseoMetaboxL10n.currentyear)).replace(/%%focuskw%%/g,jQuery("#yoast_wpseo_focuskw_"+t).val());var r="";jQuery(o).length&&(r=yst_clean(jQuery(o).val()),e=e.replace(/%%excerpt_only%%/g,r)),""==r&&jQuery(n).length&&(r=jQuery(n).val().replace(/(<([^>]+)>)/gi,"").substring(0,wpseoMetaboxL10n.wpseo_meta_desc_length-1)),e=e.replace(/%%excerpt%%/g,r),jQuery("#parent_id").length&&jQuery("#parent_id option:selected").text()!=wpseoMetaboxL10n.no_parent_text&&(e=e.replace(/%%parent_title%%/g,jQuery("#parent_id option:selected").text()));var l=yst_escapeFocusKw(wpseoMetaboxL10n.sep),p=new RegExp(l+" "+l,"g");if(-1!=(e=e.replace(p,wpseoMetaboxL10n.sep)).indexOf("%%")&&null!=e.match(/%%[a-z0-9_-]+%%/i))for(regex=/%%[a-z0-9_-]+%%/gi,matches=e.match(regex),i=0;i<matches.length;i++)void 0!=replacedVars[matches[i]]?e=e.replace(matches[i],replacedVars[matches[i]]):(replaceableVar=matches[i],replacedVars[replaceableVar]="",jQuery.post(ajaxurl,{action:"wpseo_replace_vars",string:matches[i],post_id:jQuery("#post_ID").val(),_wpnonce:wpseoMetaboxL10n.wpseo_replace_vars_nonce},function(t){t?(replacedVars[replaceableVar]=t,yst_replaceVariables(e,a)):yst_replaceVariables(e,a)}));a(e)}(a,t,function(e){var a=n.html(e).text();s.attr("placeholder",a),e=l(e=yst_clean(e),!1,t),jQuery("#wpseosnippet_title_"+t).html(e);var r=document.getElementById("wpseosnippet_title_"+t);null!=r&&(r.scrollWidth>r.clientWidth?o.show():o.hide()),u(t)})},t=function(t){e(!1,t),p(t)};jQuery("#wpglobus-wpseo-tabs").tabs();var a=jQuery("#wpglobus-wpseo-attr"),s=jQuery(".wpseotab.general .form-table"),o=a.data("ids"),n=a.data("names"),r="";o=(o=o+","+a.data("qtip")).split(","),n=n.split(","),jQuery("#wpglobus-wpseo-tabs").insertBefore(s),jQuery(".wpglobus-wpseo-general").each(function(a,l){var u=jQuery(l),i=u.data("language");if(u.html('<table class="form-table wpglobus-table-'+i+'" data-language="'+i+'">'+s.html()+"</table>"),jQuery.each(n,function(e,t){jQuery("#"+t).attr("name",t+"_"+i)}),jQuery.each(o,function(e,t){var a=jQuery("#"+t);"wpseosnippet"==t&&a.addClass("wpglobus-wpseosnippet"),"focuskwresults"==t&&a.addClass("wpglobus-focuskwresults"),wpseoMetaboxL10n.field_prefix+"metadesc"==t&&a.addClass("wpglobus-wpseo_metadesc").text(u.data("metadesc")),wpseoMetaboxL10n.field_prefix+"title"==t&&a.addClass("wpglobus-wpseo_title").val(u.data("wpseotitle")),wpseoMetaboxL10n.field_prefix+"focuskw"==t&&a.addClass("wpglobus-wpseo_focuskw").val(u.data("focuskw")),a.attr("id",t+"_"+i),jQuery("#"+t+"_"+i).attr("data-language",i)}),r="complete"==u.data("permalink")?u.data("url-"+i):u.data("url-"+i)+jQuery("#editable-post-name-full").text()+"/",jQuery("#wpseosnippet_"+i+" .url").text(r),t(i),void 0!==jQuery().autocomplete){var c,d={};jQuery("#"+wpseoMetaboxL10n.field_prefix+"focuskw_"+i).autocomplete({minLength:3,formatResult:function(e){return jQuery("<div/>").html(e).html()},source:function(e,t){var a=e.term;a in d?t(d[a]):(e._ajax_nonce=wpseoMetaboxL10n.wpseo_keyword_suggest_nonce,e.action="wpseo_get_suggest",c=jQuery.getJSON(ajaxurl,e,function(e,s,o){d[a]=e,o===c&&t(e)}))}})}jQuery("#"+wpseoMetaboxL10n.field_prefix+"title_"+i).keyup(function(){e(!1,jQuery(this).data("language"))}),jQuery("#title_"+i).keyup(function(){var t=jQuery(this).data("language")?jQuery(this).data("language"):WPGlobusAdmin.data.default_language;e(!1,t),p(t)}),0==a&&jQuery("#title").keyup(function(){e(!1,WPGlobusAdmin.data.default_language),p(WPGlobusAdmin.data.default_language)}),0==a&&jQuery("body").on("change","#parent_id",function(){jQuery.each(WPGlobusAdmin.data.enabled_languages,function(t,a){e(!1,a),p(a)})}),jQuery("#"+wpseoMetaboxL10n.field_prefix+"metadesc_"+i).keyup(function(){p(jQuery(this).data("language"))}),jQuery("body").on("keyup","#excerpt-"+i,function(){p(jQuery(this).data("language")?jQuery(this).data("language"):WPGlobusAdmin.data.default_language)}),0==a&&jQuery(".wpglobus-editor").focusout(function(){p(jQuery(this).data("language"))});var _=!1;jQuery(document).on("change","#"+wpseoMetaboxL10n.field_prefix+"focuskw_"+i,function(){var e=jQuery(this).data("language"),a=jQuery("#focuskwhelp_"+e);-1!=jQuery("#"+wpseoMetaboxL10n.field_prefix+"focuskw_"+e).val().search(",")?(a.click(),_=!0):_&&(a.qtip("hide"),_=!1),t(e)})}),s.addClass("hidden"),jQuery("body").on("change",".wpglobus-wpseo_metadesc",function(e){var t="#"+wpseoMetaboxL10n.field_prefix+"metadesc",a=jQuery(this);jQuery(t).val(WPGlobusCore.getString(jQuery(t).val(),a.val(),a.data("language")))}),jQuery("body").on("change",".wpglobus-wpseo_title",function(e){var t="#"+wpseoMetaboxL10n.field_prefix+"title",a=jQuery(this);jQuery(t).val(WPGlobusCore.getString(jQuery(t).val(),a.val(),a.data("language")))}),jQuery("body").on("change",".wpglobus-wpseo_focuskw",function(e){var t="#"+wpseoMetaboxL10n.field_prefix+"focuskw",a=jQuery(this);jQuery(t).val(WPGlobusCore.getString(jQuery(t).val(),a.val(),a.data("language")))}),jQuery("body").on("click",".wpglobus-post-body-tabs-list li",function(e){$this=jQuery(this),$this.hasClass("wpglobus-post-tab")&&jQuery("#wpglobus-wpseo-tabs").tabs("option","active",jQuery(this).data("order"))}),jQuery(".yoast_help").qtip({content:{attr:"alt"},position:{my:"bottom left",at:"top center"},style:{tip:{corner:!0},classes:"yoast-qtip qtip-rounded qtip-blue"},show:{when:{event:"mouseover"}},hide:{fixed:!0,when:{event:"mouseout"}}}),yst_updateSnippet()}function l(e,t,a){var s,o=yst_escapeFocusKw(jQuery.trim(jQuery("#"+wpseoMetaboxL10n.field_prefix+"focuskw_"+a).val()));if(""==o)return e;s=-1!=o.search(" ")?o.split(" "):new Array(o);for(var n=0;n<s.length;n++){var r=yst_clean(s[n]),l="";t?(r=r.replace(" ","-").toLowerCase(),l=new RegExp("([-/])("+r+")([-/])?")):l=new RegExp("(^|[ s\n\r\t.,'(\"+;!?:-]+)("+r+")($|[ s\n\r\t.,')\"+;!?:-]+)","gim"),void 0!=e&&(e=e.replace(l,"$1<strong>$2</strong>$3"))}return e}function p(e){var t=jQuery.trim(yst_clean(jQuery("#"+wpseoMetaboxL10n.field_prefix+"metadesc_"+e).val())),a=jQuery("<div />"),s=jQuery("#wpseosnippet_"+e);if(""==t&&""!=wpseoMetaboxL10n.wpseo_metadesc_template&&(t=wpseoMetaboxL10n.wpseo_metadesc_template),""!=t)t=yst_replaceVariables(t,function(t){t=a.text(t).html(),t=yst_clean(t);var o;o=(o=wpseoMetaboxL10n.wpseo_meta_desc_length-t.length)<0?'<span class="wrong">'+o+"</span>":'<span class="good">'+o+"</span>",jQuery("#"+wpseoMetaboxL10n.field_prefix+"metadesc-length_"+e).html(o),t=l(t=yst_trimDesc(t),!1),s.find(".desc span.autogen").html(""),s.find(".desc span.content").html(t),u(e)});else{jQuery("#"+wpseoMetaboxL10n.field_prefix+"metadesc-length_"+e).html(wpseoMetaboxL10n.wpseo_meta_desc_length),s.find(".desc span.content").html(""),u(e);var o="#content";e!=WPGlobusAdmin.data.default_language&&(o="#content_"+e),jQuery(o).length&&(t=jQuery(o).val(),t=yst_clean(t));var n=yst_escapeFocusKw(jQuery.trim(jQuery("#"+wpseoMetaboxL10n.field_prefix+"focuskw_"+e).val()));if(""!=n){var r=new RegExp(n,"gim");t=-1!=t.search(r)&&t.length>wpseoMetaboxL10n.wpseo_meta_desc_length?t.substr(t.search(r),wpseoMetaboxL10n.wpseo_meta_desc_length):t.substr(0,wpseoMetaboxL10n.wpseo_meta_desc_length)}else t=t.substr(0,wpseoMetaboxL10n.wpseo_meta_desc_length);t=l(t,!1),t=yst_trimDesc(t),s.find(".desc span.autogen").html(t)}}function u(e){var t=jQuery.trim(jQuery("#"+wpseoMetaboxL10n.field_prefix+"focuskw_"+e).val());t=yst_escapeFocusKw(t).toLowerCase();var a="#title",s="#content";e!=WPGlobusAdmin.data.default_language&&(a="#title_"+e,s="#content_"+e);var o=jQuery(document).triggerHandler("wpglobus_post_name_full",{postnamefull:"#editable-post-name-full",language:e})||"#editable-post-name-full";if(jQuery(o).length)var n=jQuery(o).text(),r=wpseoMetaboxL10n.wpseo_permalink_template.replace("%postname%",n).replace("http://","");var l=new RegExp("(^|[ s\n\r\t.,'(\"+;!?:-])"+t+"($|[ s\n\r\t.,')\"+!?:;-])","gim"),p=removeLowerCaseDiacritics(t),u=new RegExp(p.replace(/\s+/g,"[-_\\//]"),"gim"),i=jQuery("#focuskwresults_"+e),c=jQuery("#wpseosnippet_"+e).find(".desc span.content").text();if(""!=t){var d="<p>"+wpseoMetaboxL10n.keyword_header+"</p>";d+="<ul>",jQuery(a).length&&(d+="<li>"+wpseoMetaboxL10n.article_header_text+ptest(jQuery(a).val(),l)+"</li>"),d+="<li>"+wpseoMetaboxL10n.page_title_text+ptest(jQuery("#wpseosnippet_title_"+e).text(),l)+"</li>",d+="<li>"+wpseoMetaboxL10n.page_url_text+ptest(r,u)+"</li>",jQuery(s).length&&(d+="<li>"+wpseoMetaboxL10n.content_text+ptest(jQuery(s).val(),l)+"</li>"),d+="<li>"+wpseoMetaboxL10n.meta_description_text+ptest(c,l)+"</li>",d+="</ul>",i.html(d)}else i.html("")}};
includes/js/wpglobus-wpseo-22.js ADDED
@@ -0,0 +1,526 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*jslint browser: true*/
2
+ /*global jQuery, console, WPGlobusVendor, wpseoMetaboxL10n, ystUpdateSnippet */
3
+
4
+ 'use strict';
5
+ var wpglobus_wpseo = function () {
6
+
7
+ if (typeof wpseoMetaboxL10n === "undefined") {
8
+ return;
9
+ }
10
+
11
+ // @see ystReplaceVariables()
12
+ function wpglobus_replaceVariables(str, language, callback) {
13
+ if (typeof str === 'undefined') {
14
+ return;
15
+ }
16
+ if ( typeof replacedVars === 'undefined' && jQuery('#title').size() == 0 ) {
17
+ // WP SEO doesn't work properly when post title is disabled
18
+ return str;
19
+ }
20
+ var post_title = '#title',
21
+ post_excerpt = '#excerpt-' + language,
22
+ post_content = '#content';
23
+ if ( language != WPGlobusAdmin.data.default_language ) {
24
+ post_title = '#title_' + language;
25
+ post_content = '#content_' + language;
26
+ }
27
+ // title
28
+ if (jQuery(post_title).length) {
29
+ str = str.replace( /%%title%%/g, jQuery( post_title ).val().replace( /(<([^>]+)>)/ig, '' ) );
30
+ }
31
+
32
+ // These are added in the head for performance reasons.
33
+ //str = str.replace( /%%sitedesc%%/g, wpseoMetaboxL10n.sitedesc );
34
+ str = str.replace( /%%sitedesc%%/g, WPGlobusAdmin.data.blogdescription[language] );
35
+ //str = str.replace( /%%sitename%%/g, wpseoMetaboxL10n.sitename );
36
+ str = str.replace( /%%sitename%%/g, WPGlobusAdmin.data.blogname[language] );
37
+ str = str.replace( /%%sep%%/g, wpseoMetaboxL10n.sep );
38
+ str = str.replace( /%%date%%/g, wpseoMetaboxL10n.date );
39
+ str = str.replace( /%%id%%/g, wpseoMetaboxL10n.id );
40
+ str = str.replace( /%%page%%/g, wpseoMetaboxL10n.page );
41
+ str = str.replace( /%%currenttime%%/g, wpseoMetaboxL10n.currenttime );
42
+ str = str.replace( /%%currentdate%%/g, wpseoMetaboxL10n.currentdate );
43
+ str = str.replace( /%%currentday%%/g, wpseoMetaboxL10n.currentday );
44
+ str = str.replace( /%%currentmonth%%/g, wpseoMetaboxL10n.currentmonth );
45
+ str = str.replace( /%%currentyear%%/g, wpseoMetaboxL10n.currentyear );
46
+
47
+ str = str.replace( /%%focuskw%%/g, jQuery( '#yoast_wpseo_focuskw' + '_' + language ).val().replace( /(<([^>]+)>)/ig, '' ) );
48
+ // excerpt
49
+ var excerpt = '';
50
+ if ( jQuery( post_excerpt ).length ) {
51
+ excerpt = ystClean( jQuery( post_excerpt ).val().replace( /(<([^>]+)>)/ig, '' ) );
52
+ str = str.replace( /%%excerpt_only%%/g, excerpt );
53
+ }
54
+ if ( '' === excerpt && jQuery(post_content).length ) {
55
+ excerpt = jQuery(post_content).val().replace(/(<([^>]+)>)/ig,"").substring(0,wpseoMetaboxL10n.wpseo_meta_desc_length-1);
56
+ }
57
+ str = str.replace( /%%excerpt%%/g, excerpt );
58
+
59
+ // parent page
60
+ if (jQuery('#parent_id').length && jQuery('#parent_id option:selected').text() !== wpseoMetaboxL10n.no_parent_text ) {
61
+ str = str.replace(/%%parent_title%%/g, jQuery('#parent_id option:selected').text());
62
+ }
63
+
64
+ // remove double separators
65
+ var esc_sep = ystEscapeFocusKw( wpseoMetaboxL10n.sep );
66
+ var pattern = new RegExp( esc_sep + ' ' + esc_sep, 'g' );
67
+ str = str.replace( pattern, wpseoMetaboxL10n.sep );
68
+
69
+ if ( str.indexOf('%%') !== -1 && str.match( /%%[a-z0-9_-]+%%/i) !== null ) {
70
+ var regex = /%%[a-z0-9_-]+%%/gi;
71
+ var matches = str.match(regex);
72
+ for ( var i = 0; i < matches.length; i++ ) {
73
+ if ( typeof( replacedVars[matches[i]] ) === 'undefined' ) {
74
+ str = str.replace( matches[i], replacedVars[matches[i]] );
75
+ }
76
+ else {
77
+ var replaceableVar = matches[i];
78
+
79
+ // create the cache already, so we don't do the request twice.
80
+ replacedVars[replaceableVar] = '';
81
+ ystAjaxReplaceVariables( replaceableVar, callback );
82
+ /*
83
+ jQuery.post(ajaxurl, {
84
+ action : 'wpseo_replace_vars',
85
+ string : matches[i],
86
+ post_id : jQuery('#post_ID').val(),
87
+ _wpnonce: wpseoMetaboxL10n.wpseo_replace_vars_nonce
88
+ }, function (data) {
89
+ if (data) {
90
+ replacedVars[replaceableVar] = data;
91
+ yst_replaceVariables(str, callback);
92
+ } else {
93
+ yst_replaceVariables(str, callback);
94
+ }
95
+ }
96
+ ); //*/
97
+ }
98
+ }
99
+ }
100
+ callback( str );
101
+ }
102
+
103
+ // @see ystBoldKeywords()
104
+ function wpglobus_boldKeywords( str, url, language ) {
105
+ var focuskw = ystEscapeFocusKw( jQuery.trim( jQuery( '#' + wpseoMetaboxL10n.field_prefix + 'focuskw' + '_' + language ).val() ) );
106
+ var keywords;
107
+
108
+ if ( focuskw === '' ) {
109
+ return str;
110
+ }
111
+
112
+ if ( focuskw.search(' ') !== -1 ) {
113
+ keywords = focuskw.split(' ');
114
+ }
115
+ else {
116
+ keywords = new Array( focuskw );
117
+ }
118
+ for ( var i = 0; i < keywords.length; i++ ) {
119
+ var kw = ystClean( keywords[i] );
120
+ var kwregex = '';
121
+ if ( url ) {
122
+ kw = kw.replace( ' ', '-' ).toLowerCase();
123
+ kwregex = new RegExp( '([-/])(' + kw + ')([-/])?' );
124
+ }
125
+ else {
126
+ kwregex = new RegExp( '(^|[ \\s\n\r\t\\.,\'\\("\\+;!?:\\-]+)(' + kw + ')($|[ \\s\n\r\t\\.,\'\\)"\\+;!?:\\-]+)', 'gim' );
127
+ }
128
+ if ( str !== undefined ) {
129
+ str = str.replace( kwregex, '$1<strong>$2</strong>$3' );
130
+ }
131
+ }
132
+ return str;
133
+ }
134
+
135
+ // @see ystUpdateTitle()
136
+ var wpglobus_updateTitle = function( force,language ) {
137
+ var title = '';
138
+ var titleElm = jQuery( '#' + wpseoMetaboxL10n.field_prefix + 'title' + '_' + language );
139
+ var titleLengthError = jQuery( '#' + wpseoMetaboxL10n.field_prefix + 'title-length-warning'+'_'+language );
140
+ var divHtml = jQuery( '<div />' );
141
+ var snippetTitle = jQuery( '#wpseosnippet_title'+'_'+language );
142
+
143
+ if ( titleElm.val() ) {
144
+ title = titleElm.val().replace( /(<([^>]+)>)/ig, '' );
145
+ }
146
+ else {
147
+ title = wpseoMetaboxL10n.wpseo_title_template;
148
+ title = divHtml.html( title ).text();
149
+ }
150
+ if ( title === '' ) {
151
+ snippetTitle.html( '' );
152
+ titleLengthError.hide();
153
+ return;
154
+ }
155
+
156
+ title = ystClean( title );
157
+ title = jQuery.trim( title );
158
+ title = divHtml.text( title ).html();
159
+
160
+ if ( force ) {
161
+ titleElm.val( title );
162
+ }
163
+
164
+ title = wpglobus_replaceVariables( title, language, function ( title ) {
165
+ title = ystSanitizeTitle( title );
166
+
167
+ jQuery( '#wpseosnippet_title'+'_'+language ).html( title );
168
+
169
+ // do the placeholder
170
+ var placeholder_title = divHtml.html( title ).text();
171
+ titleElm.attr( 'placeholder', placeholder_title );
172
+
173
+ var titleElement = document.getElementById( 'wpseosnippet_title'+'_'+language );
174
+ if ( titleElement !== null ) {
175
+ if ( titleElement.scrollWidth > titleElement.clientWidth ) {
176
+ titleLengthError.show();
177
+ }
178
+ else {
179
+ titleLengthError.hide();
180
+ }
181
+ }
182
+
183
+ wpglobus_testFocusKw(language);
184
+ }
185
+ )
186
+ };
187
+
188
+ // @see ystUpdateDesc()
189
+ function wpglobus_updateDesc( language ) {
190
+ var desc = jQuery.trim( ystClean( jQuery( '#' + wpseoMetaboxL10n.field_prefix + 'metadesc' + '_' + language ).val() ) );
191
+ var divHtml = jQuery( '<div />' );
192
+ var snippet = jQuery( '#wpseosnippet'+'_'+language );
193
+
194
+ if ( desc === '' && wpseoMetaboxL10n.wpseo_metadesc_template !== '' ) {
195
+ desc = wpseoMetaboxL10n.wpseo_metadesc_template;
196
+ }
197
+ if ( desc !== '' ) {
198
+ desc = ystReplaceVariables( desc, function ( desc ) {
199
+ desc = divHtml.text( desc ).html();
200
+ desc = ystClean( desc );
201
+
202
+ var len = wpseoMetaboxL10n.wpseo_meta_desc_length - desc.length;
203
+
204
+ if ( len < 0 ) {
205
+ len = '<span class="wrong">' + len + '</span>';
206
+ }
207
+ else {
208
+ len = '<span class="good">' + len + '</span>';
209
+ }
210
+
211
+ jQuery( '#' + wpseoMetaboxL10n.field_prefix + 'metadesc-length' + '_' + language ).html( len );
212
+
213
+ desc = ystSanitizeDesc( desc );
214
+ desc = wpglobus_boldKeywords( desc, false ); // @todo check for workability
215
+ // Clear the autogen description.
216
+ snippet.find( '.desc span.autogen' ).html( '' );
217
+ // Set our new one.
218
+ snippet.find( '.desc span.content' ).html( desc );
219
+
220
+ wpglobus_testFocusKw( language );
221
+ }
222
+ );
223
+ }
224
+ else {
225
+ jQuery( '#' + wpseoMetaboxL10n.field_prefix + 'metadesc-length' + '_' + language ).html( wpseoMetaboxL10n.wpseo_meta_desc_length );
226
+ // Clear the generated description
227
+ snippet.find( '.desc span.content' ).html( '' );
228
+ wpglobus_testFocusKw( language );
229
+
230
+ var post_content = '#content';
231
+ if ( language != WPGlobusAdmin.data.default_language ) {
232
+ post_content = '#content_' + language;
233
+ }
234
+ /*
235
+ if ( jQuery( post_content ).length ) {
236
+ desc = jQuery( post_content ).val();
237
+ desc = ystClean( desc );
238
+ } */
239
+
240
+ if ( typeof tinyMCE !== 'undefined' && tinyMCE.get( 'excerpt' + '-' + language ) !== null ) {
241
+ desc = tinyMCE.get( 'excerpt' + '-' + language ).getContent();
242
+ desc = ystClean( desc );
243
+ }
244
+
245
+ if ( typeof tinyMCE !== 'undefined' && tinyMCE.get( post_content ) !== null && desc.length === 0 ) {
246
+ desc = tinyMCE.get( post_content ).getContent();
247
+
248
+ desc = ystClean( desc );
249
+ }
250
+
251
+ var focuskw = ystEscapeFocusKw( jQuery.trim( jQuery( '#' + wpseoMetaboxL10n.field_prefix + 'focuskw' + '_' + language ).val() ) );
252
+ if ( focuskw !== '' ) {
253
+ var descsearch = new RegExp( focuskw, 'gim' );
254
+ if ( desc.search(descsearch) !== -1 && desc.length > wpseoMetaboxL10n.wpseo_meta_desc_length ) {
255
+ desc = desc.substr( desc.search( descsearch ), wpseoMetaboxL10n.wpseo_meta_desc_length );
256
+ }
257
+ else {
258
+ desc = desc.substr( 0, wpseoMetaboxL10n.wpseo_meta_desc_length );
259
+ }
260
+ }
261
+ else {
262
+ desc = desc.substr( 0, wpseoMetaboxL10n.wpseo_meta_desc_length );
263
+ }
264
+
265
+ desc = wpglobus_boldKeywords( desc, false ); // @todo check for workability
266
+ desc = ystSanitizeDesc( desc );
267
+
268
+ snippet.find( '.desc span.autogen' ).html( desc );
269
+ }
270
+ }
271
+
272
+ // @see ystTestFocusKw()
273
+ function wpglobus_testFocusKw( language ) {
274
+ // Retrieve focus keyword and trim
275
+ var focuskw = jQuery.trim( jQuery( '#' + wpseoMetaboxL10n.field_prefix + 'focuskw' + '_' + language ).val() );
276
+ focuskw = ystEscapeFocusKw( focuskw ).toLowerCase();
277
+
278
+ var post_title = '#title';
279
+ var post_content = '#content';
280
+ if ( language != WPGlobusAdmin.data.default_language ) {
281
+ post_title = '#title_' + language;
282
+ post_content = '#content_' + language;
283
+ }
284
+
285
+ var postname;
286
+ var url;
287
+ var postnamefull = jQuery(document).triggerHandler('wpglobus_post_name_full', {postnamefull:'#editable-post-name-full',language:language}) || '#editable-post-name-full';
288
+ if ( jQuery( postnamefull ).length ) {
289
+ postname = jQuery( postnamefull ).text();
290
+ url = wpseoMetaboxL10n.wpseo_permalink_template.replace( '%postname%', postname ).replace( 'http://', '' );
291
+ }
292
+ var p = new RegExp( '(^|[ \\s\n\r\t\\.,\'\\("\\+;!?:\\-])' + ystRemoveLowerCaseDiacritics( focuskw ) + '($|[\\s\n\r\t.,\'\\)"\\+!?:;\\-])', 'gim' );
293
+
294
+ //remove diacritics of a lower cased focuskw for url matching in foreign lang
295
+ var focuskwNoDiacritics = ystRemoveLowerCaseDiacritics( focuskw );
296
+ var p2 = new RegExp( focuskwNoDiacritics.replace( /\s+/g, '[-_\\\//]' ), 'gim' );
297
+
298
+ var focuskwresults = jQuery( '#focuskwresults'+'_'+language );
299
+ var metadesc = jQuery( '#wpseosnippet'+'_'+language ).find( '.desc span.content' ).text();
300
+
301
+ if ( focuskw !== '' ) {
302
+ var html = '<p>' + wpseoMetaboxL10n.keyword_header + '</p>';
303
+ html += '<ul>';
304
+ if ( jQuery( post_title ).length ) {
305
+ html += '<li>' + wpseoMetaboxL10n.article_header_text + ystFocusKwTest( jQuery( post_title ).val(), p ) + '</li>';
306
+ }
307
+ html += '<li>' + wpseoMetaboxL10n.page_title_text + ystFocusKwTest( jQuery( '#wpseosnippet_title'+'_'+language ).text(), p ) + '</li>';
308
+ html += '<li>' + wpseoMetaboxL10n.page_url_text + ystFocusKwTest( url, p2 ) + '</li>';
309
+ if ( jQuery( post_content ).length ) {
310
+ html += '<li>' + wpseoMetaboxL10n.content_text + ystFocusKwTest( jQuery( post_content ).val(), p ) + '</li>';
311
+ }
312
+ html += '<li>' + wpseoMetaboxL10n.meta_description_text + ystFocusKwTest( metadesc, p ) + '</li>';
313
+ html += '</ul>';
314
+ focuskwresults.html( html );
315
+ }
316
+ else {
317
+ focuskwresults.html( '' );
318
+ }
319
+ }
320
+
321
+ // @see ystUpdateSnippet()
322
+ var wpglobus_updateSnippet = function(language) {
323
+ //yst_updateURL();
324
+ wpglobus_updateTitle(false,language);
325
+ wpglobus_updateDesc(language);
326
+ };
327
+
328
+ // @see jQuery( '.yoast_help' ).qtip()
329
+ var wpglobus_qtip = function() {
330
+ jQuery( '.yoast_help' ).qtip(
331
+ {
332
+ content: {
333
+ attr: 'alt'
334
+ },
335
+ position: {
336
+ my: 'bottom left',
337
+ at: 'top center'
338
+ },
339
+ style : {
340
+ tip: {
341
+ corner: true
342
+ },
343
+ classes : 'yoast-qtip qtip-rounded qtip-blue'
344
+ },
345
+ show : 'click',
346
+ hide : {
347
+ fixed: true,
348
+ delay: 500
349
+ }
350
+ }
351
+ );
352
+ };
353
+
354
+ // start
355
+
356
+ // tabs on
357
+ jQuery('#wpglobus-wpseo-tabs').tabs();
358
+
359
+ var attrs = jQuery('#wpglobus-wpseo-attr');
360
+ var t = jQuery('.wpseotab.general .form-table');
361
+ var ids = attrs.data('ids');
362
+ var names = attrs.data('names');
363
+ var wpseosnippet_url = '';
364
+
365
+ ids = ids+',' + attrs.data('qtip');
366
+ ids = ids.split(',');
367
+ names = names.split(',');
368
+
369
+ jQuery('#wpglobus-wpseo-tabs').insertBefore(t);
370
+
371
+ jQuery('.wpglobus-wpseo-general').each(function(i,e){
372
+ var $e = jQuery(e);
373
+ var l = $e.data('language');
374
+ $e.html('<table class="form-table wpglobus-table-'+l+'" data-language="'+l+'">' + t.html() + '</table>');
375
+ jQuery.each(names,function(i,name){
376
+ jQuery('#'+name).attr('name',name+'_'+l);
377
+ });
378
+ jQuery.each(ids,function(i,id){
379
+ var $id = jQuery('#'+id);
380
+ if ( 'wpseosnippet' == id ) {
381
+ $id.addClass('wpglobus-wpseosnippet');
382
+ }
383
+ if ( 'focuskwresults' == id ) {
384
+ $id.addClass('wpglobus-focuskwresults');
385
+ }
386
+ if ( wpseoMetaboxL10n.field_prefix + 'metadesc' == id ) {
387
+ $id.addClass('wpglobus-wpseo_metadesc').text($e.data('metadesc'));
388
+ }
389
+ if ( wpseoMetaboxL10n.field_prefix + 'title' == id ) {
390
+ $id.addClass('wpglobus-wpseo_title').val($e.data('wpseotitle'));
391
+ }
392
+ if ( wpseoMetaboxL10n.field_prefix + 'focuskw' == id ) {
393
+ $id.addClass('wpglobus-wpseo_focuskw').val($e.data('focuskw'));
394
+ }
395
+ $id.attr('id',id+'_'+l);
396
+ jQuery('#'+id+'_'+l).attr('data-language',l);
397
+ });
398
+ if ( 'complete' == $e.data( 'permalink' ) ) {
399
+ wpseosnippet_url = $e.data( 'url-' + l );
400
+ } else {
401
+ wpseosnippet_url = $e.data( 'url-' + l )+jQuery( '#editable-post-name-full' ).text()+'/';
402
+ }
403
+ jQuery( '#wpseosnippet_'+l+' .url' ).text( wpseosnippet_url );
404
+ wpglobus_updateSnippet(l);
405
+
406
+ if ( typeof jQuery().autocomplete != 'u