From afb4069e27955cebb6f90b24378f7de4613a9952 Mon Sep 17 00:00:00 2001 From: yivi Date: Fri, 8 May 2015 09:35:55 +0200 Subject: [PATCH 01/20] updated Spanish translations --- languages/cmb2-es_ES.mo | Bin 7271 -> 7199 bytes languages/cmb2-es_ES.po | 371 +++++++++++++++++++++++----------------- 2 files changed, 214 insertions(+), 157 deletions(-) mode change 100755 => 100644 languages/cmb2-es_ES.po diff --git a/languages/cmb2-es_ES.mo b/languages/cmb2-es_ES.mo index 6508e375e1badad344988a384ada53893dda83a4..0441630d9aa6189cb0ecd2c8f5c376e8e867ac57 100644 GIT binary patch delta 2721 zcmYk-X>1f_9LMnoXrc6=w55kuWU8W|-5!A2mP61M7A>|y!72!y?hfs0cc;$I7MqAG zG4TZwzPj9z>Z+wmZ32B&crPNH5cqm@>yL=B`9b$=bQXl6Z9 z)oenwXNTn!&Zaz$s=pi6{$4B%GE>U4x!zUc?m?`^4^g!zP_>VT_kTmxo61G?%JE#B zj}5pISKuIOIiEo7+Y6{syp5{&1vcWJrL2L5-9T;bnMPE(9krpIVYwgGPz)J^$)FC* zE>yjJI0yG5OK#prE#K$i{Ryn4{1?2E&VC{ zeX22k<2jU%@ja-4NmRpCOkV?Sz&dOSU4wdm0M+pjG8W^Z-rI%hFT0nFDn5c*q9;)+ z@OoI`V^jx6P%}M_n)$EzGX8~X=vhXk0ltEa)qI9JsS|h^{*0_&BT61(vq)WD)O`38GX9dE;{F@f5{=TP75LDT>bqdNKs)!sK@`4}=*^9O2R1S!d?M~m{EsP`X5?fna=ui{f=4(1oU3bj8Mz)I9v zieVl7n=F}y_#iI9cTfX4jT%T1>#A}sUWf}&1M5cq%$Be`hAouu#ku$@@@Kx{qWY(h zCe6QiKGreH>;f`Zl3`WM05Vv!12yBlp-+Xridxc-P%}G%7vV|No>nm}J+DLkD$Pet zU?Ee2v=6AH#~r(V~1BbtdZgM5drtqlr-Cnz7RL zd2*kh&WTc6p4?Rvyq3^P==|k=u{4`?#ByRip;_EaDCzT2(kWg_Y$LjfMMN*5fiETo ziJJ(%%-rC6kn!ezxBKu+T1iHqU_WuC_J1{D5o?Jv=|(bF5!al#5z0!NO<}$n`Koeh z9@pHzP}Ejxd9{*f(uOdja}Xu8|JtIg4&2#E2W={$PiTPHO58#yX^)jQ6034K{?p(V zLMK~ahqgyss&rkR+;9F3XbCUj_&beh)?I%N9xmD-8< zM28At>Iw>rdd`W*E!VR)j*hr?+*+L&anfehnC;tM@J7)E#lxCV%z7ZZ z$sS3>t?jOtwEa%ocdWGUB~nAWW8Hdt#_`4@nS>SR$!H>Wo8uKElg;sX^Z2+q`%Pc3 zgx;6Ex$C_Q=YLekF@Z2g|(=qqqX(2me!V*;@+OfdS@(=W}XoZw}XeRXV+Vjuh(s- z{Yal@r_v*~?|L29+A%w2ElY4+Ii47Ew{O=#g5>Ni<=u8_C}R)Nl#|}pwITRm_U2%5 zMO%5V>%;LD1A!Jf+Yy8cN1X=HUwr?sA@%NXMX=;i9-ic`{yj5!Upo> z@#;0fJ=Nb$U#DGkgRM0?3Rey5!Iw496%J)mareN^+6SlQE6=HaYZg1h{;)aGC~Fx^ O)GwLgb|nX$xcLts&T~!x delta 2868 zcmbuAX>3$g6vr={mO?3QDIlO+aY2xo>69Yv2m&pO3!6+8L7}|qJlfHjd3D~KE=C=f zFKUcQ^VAP&qG((a<3b=NM57=H`M7@KeTLSB%tK~OFs1^hp2CM#Rb@;)oDA#WJUAJ~;i<4S8ea`rYSK_k zx5FuLH@qBP3$^a0sDI?7T`_N=Ok&_8SPMUcHShOPbqnatOqK?@p4e%@|dpVS&cF3Nl6RI}$K+U@e z&Va*^tePjFGWUGc{|cOi{WjE<9)k+#L}b@6S?f-pM*g+YLOK*t8&oFN!@2O9XyPE$ zo!$l&&>c{BdoNrJ4?=vKPoNI)EmVNNMEx~Hp>=bi4zdu=hHGod|2ZhT=+GVC4s~aD z!)D4kgr{MT@C4-WQ>cx8f(m#7>5!x8PysH2TAzU0@B+94wnGK>5F{q^B$S^QDkxg; z8dS;-LuKT1CfO7Z_l!K#@eH;?2`3)+7X`Du!1$7_`<);}c z109h4DrOss7G|I}=!X{G47KoKsJq?|RsC;5f;Y$DDmb3}FM#b(HRD2E$*p`A!3SUq zd<`mqU!el1CT-L8{!c?Wi;l%m8Q2W@nca~+2%E6)fTzPlke_*%kLG_5@oB~p-5GEW zJP)=(l3_BCSj`aBL5CwgF0#KlgrZcw0d=wu;MwrIsK1e8QHy2)ROIKvg>V^M26sVa zDumkLai{N3QeqL~PHXs-3{#T=@wIV9OlnmPC$P(lN88n{!XxgN& z)rYnn89%C>{2!uwPe!(0Q5T}C8f&T-wRS{*y3f`9kF~2&5|N?%RJC3j*;^wDtB^F( zflwlUw)tp!a_bNktp1nmMm8d<3)R%ch??r-3Z(HeJ}VJwVzgbOZ@8{%OHV#;*7Q4p zQ!*W!+MDfp88>hiozw?%`Mm8exlZ8P0^J#J(DkiT%-X$Pso>jzT+nN~%YNV$?B1N4 z&-ym#bprZXm&tnrcE~H2Y#~?7#=~c-7K9&GEeRVYp9p7Ee-Zv(oer;@GJN3pl;_5W zk4_t|+3sf6y8Y>(oXvTD_qp{-t4+^kIp9LW#Ase5Y9 zg@4UTyH2UQcPl<)O?VB5>)XQ5>$8-AVoqX;F2aoppvTJ*_wrKl3X4{}_H@U^YjhjtQNu%YWV>&{=VP5!P!^#6+ zHmn#I-qpB1%r|}%ZkgF19-jI1ftzRDHzAxo_vL?;$rp25(*L_mY{F)qGk>k1h+ GYyJS;7OO%4 diff --git a/languages/cmb2-es_ES.po b/languages/cmb2-es_ES.po old mode 100755 new mode 100644 index b43d81c72..ce8bae6f4 --- a/languages/cmb2-es_ES.po +++ b/languages/cmb2-es_ES.po @@ -2,433 +2,490 @@ # This file is distributed under the same license as the CMB2 (beta) package. # Translators: # Justin Sternberg , 2014 +# Iván Yivoff , 2015 msgid "" msgstr "" "Project-Id-Version: CMB2\n" "Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/cmb2\n" -"POT-Creation-Date: 2014-12-23 14:37:49+00:00\n" -"PO-Revision-Date: 2014-12-23 21:54+0000\n" -"Last-Translator: FxB \n" -"Language-Team: Spanish (Spain) (http://www.transifex.com/projects/p/cmb2/language/es_ES/)\n" +"POT-Creation-Date: 2015-05-06 20:11+0100\n" +"PO-Revision-Date: 2015-05-06 20:14+0100\n" +"Last-Translator: Ivan \n" +"Language-Team: Spanish (Spain) (http://www.transifex.com/projects/p/cmb2/" +"language/es_ES/)\n" +"Language: es_ES\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Language: es_ES\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -"X-Generator: grunt-wp-i18n 0.4.9\n" +"X-Generator: Poedit 1.8beta2\n" "X-Poedit-Basepath: ../\n" -"X-Poedit-Bookmarks: \n" -"X-Poedit-Country: United States\n" -"X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;esc_html_x:1,2c;\n" -"X-Poedit-SearchPath-0: .\n" +"X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;" +"_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;" +"esc_html_x:1,2c\n" "X-Poedit-SourceCharset: UTF-8\n" "X-Textdomain-Support: yes\n" +"X-Poedit-SearchPath-0: .\n" -#: CMB2.php:100 -msgid "Metabox configuration is required to have an ID parameter" -msgstr "Se requiere de configuración Metabox tener un parámetro de identificación" - -#: CMB2.php:287 -msgid "Click to toggle" -msgstr "Haga clic para alternar" - -#: example-functions.php:53 +#: example-functions.php:82 msgid "Test Metabox" msgstr "Prueba Metabox" -#: example-functions.php:61 example-functions.php:295 +#: example-functions.php:93 example-functions.php:380 msgid "Test Text" msgstr "Texto de prueba" -#: example-functions.php:62 example-functions.php:73 example-functions.php:80 -#: example-functions.php:87 example-functions.php:95 example-functions.php:102 -#: example-functions.php:114 example-functions.php:120 -#: example-functions.php:127 example-functions.php:142 -#: example-functions.php:150 example-functions.php:157 -#: example-functions.php:163 example-functions.php:169 -#: example-functions.php:181 example-functions.php:192 -#: example-functions.php:203 example-functions.php:214 -#: example-functions.php:222 example-functions.php:229 -#: example-functions.php:237 example-functions.php:243 -#: example-functions.php:255 example-functions.php:296 -#: example-functions.php:362 example-functions.php:369 -#: example-functions.php:375 example-functions.php:381 -#: example-functions.php:387 example-functions.php:393 -#: example-functions.php:399 example-functions.php:417 +#: example-functions.php:94 example-functions.php:106 +#: example-functions.php:114 example-functions.php:122 +#: example-functions.php:131 example-functions.php:139 +#: example-functions.php:153 example-functions.php:160 +#: example-functions.php:168 example-functions.php:185 +#: example-functions.php:194 example-functions.php:202 +#: example-functions.php:209 example-functions.php:216 +#: example-functions.php:230 example-functions.php:243 +#: example-functions.php:256 example-functions.php:268 +#: example-functions.php:277 example-functions.php:285 +#: example-functions.php:294 example-functions.php:301 +#: example-functions.php:315 example-functions.php:381 +#: example-functions.php:475 example-functions.php:483 +#: example-functions.php:490 example-functions.php:497 +#: example-functions.php:504 example-functions.php:511 +#: example-functions.php:518 example-functions.php:556 msgid "field description (optional)" msgstr "campo de descripción (opcional)" -#: example-functions.php:72 +#: example-functions.php:105 msgid "Test Text Small" msgstr "Test Texto Pequeño" -#: example-functions.php:79 +#: example-functions.php:113 msgid "Test Text Medium" msgstr "Prueba de texto mediano" -#: example-functions.php:86 +#: example-functions.php:121 msgid "Website URL" msgstr "URL del sitio web" -#: example-functions.php:94 +#: example-functions.php:130 msgid "Test Text Email" msgstr "Prueba de texto Enviar" -#: example-functions.php:101 +#: example-functions.php:138 msgid "Test Time" msgstr "El tiempo de prueba" -#: example-functions.php:107 example-functions.php:108 +#: example-functions.php:145 example-functions.php:146 msgid "Time zone" msgstr "Zona horaria" -#: example-functions.php:113 +#: example-functions.php:152 msgid "Test Date Picker" msgstr "Prueba Selector de fecha" -#: example-functions.php:119 +#: example-functions.php:159 msgid "Test Date Picker (UNIX timestamp)" msgstr "Prueba Selector de fecha (UNIX timestamp)" -#: example-functions.php:126 +#: example-functions.php:167 msgid "Test Date/Time Picker Combo (UNIX timestamp)" msgstr "Fecha de Prueba / Hora Picker Combo (UNIX timestamp)" -#: example-functions.php:141 +#: example-functions.php:184 msgid "Test Money" msgstr "Prueba de dinero" -#: example-functions.php:149 +#: example-functions.php:193 msgid "Test Color Picker" msgstr "Selector de color de prueba" -#: example-functions.php:156 +#: example-functions.php:201 msgid "Test Text Area" msgstr "Área de texto de prueba" -#: example-functions.php:162 +#: example-functions.php:208 msgid "Test Text Area Small" msgstr "Prueba de Texto Área Pequeño" -#: example-functions.php:168 +#: example-functions.php:215 msgid "Test Text Area for Code" msgstr "Área de texto de prueba para el código" -#: example-functions.php:174 +#: example-functions.php:222 msgid "Test Title Weeeee" msgstr "Test Título Weeeee" -#: example-functions.php:175 +#: example-functions.php:223 msgid "This is a title description" msgstr "Esta es una descripción del título" -#: example-functions.php:180 +#: example-functions.php:229 msgid "Test Select" msgstr "Test Seleccione" -#: example-functions.php:185 example-functions.php:196 -#: example-functions.php:207 +#: example-functions.php:235 example-functions.php:248 +#: example-functions.php:260 msgid "Option One" msgstr "Una Opción" -#: example-functions.php:186 example-functions.php:197 -#: example-functions.php:208 +#: example-functions.php:236 example-functions.php:249 +#: example-functions.php:261 msgid "Option Two" msgstr "Opción dos" -#: example-functions.php:187 example-functions.php:198 -#: example-functions.php:209 +#: example-functions.php:237 example-functions.php:250 +#: example-functions.php:262 msgid "Option Three" msgstr "Opción Tres" -#: example-functions.php:191 +#: example-functions.php:242 msgid "Test Radio inline" msgstr "Radio de prueba en línea" -#: example-functions.php:202 +#: example-functions.php:255 msgid "Test Radio" msgstr "Prueba de Radio" -#: example-functions.php:213 +#: example-functions.php:267 msgid "Test Taxonomy Radio" msgstr "Prueba de Taxonomía de Radio" -#: example-functions.php:221 +#: example-functions.php:276 msgid "Test Taxonomy Select" msgstr "Prueba fields Seleccionar" -#: example-functions.php:228 +#: example-functions.php:284 msgid "Test Taxonomy Multi Checkbox" msgstr "Prueba Taxonomía Multi Casilla de verificación" -#: example-functions.php:236 +#: example-functions.php:293 msgid "Test Checkbox" msgstr "Prueba de Casilla de verificación" -#: example-functions.php:242 +#: example-functions.php:300 msgid "Test Multi Checkbox" msgstr "Test Multi Casilla de verificación" -#: example-functions.php:247 +#: example-functions.php:306 msgid "Check One" msgstr "Marque una" -#: example-functions.php:248 +#: example-functions.php:307 msgid "Check Two" msgstr "Comprobar Dos" -#: example-functions.php:249 +#: example-functions.php:308 msgid "Check Three" msgstr "Comprobar Tres" -#: example-functions.php:254 +#: example-functions.php:314 msgid "Test wysiwyg" msgstr "wysiwyg Test" -#: example-functions.php:261 +#: example-functions.php:322 msgid "Test Image" msgstr "Prueba de imagen" -#: example-functions.php:262 +#: example-functions.php:323 msgid "Upload an image or enter a URL." msgstr "Cargar una imagen o introducir una URL." -#: example-functions.php:267 +#: example-functions.php:329 msgid "Multiple Files" msgstr "varios archivos" -#: example-functions.php:268 +#: example-functions.php:330 msgid "Upload or add multiple images/attachments." msgstr "Subir o añadir varias imágenes / archivos adjuntos." -#: example-functions.php:274 +#: example-functions.php:337 msgid "oEmbed" msgstr "oEmbed" -#: example-functions.php:275 +#: example-functions.php:338 msgid "" "Enter a youtube, twitter, or instagram URL. Supports services listed at http://codex.wordpress.org/Embeds." -msgstr "Introduzca un YouTube, Twitter, Instagram o URL. Es compatible con los servicios enumerados en el http://codex.wordpress.org/Embeds." +"href=\"http://codex.wordpress.org/Embeds\">http://codex.wordpress.org/" +"Embeds." +msgstr "" +"Introduzca un YouTube, Twitter, Instagram o URL. Es compatible con los " +"servicios enumerados en el http://codex.wordpress.org/Embeds." -#: example-functions.php:287 +#: example-functions.php:371 msgid "About Page Metabox" msgstr "Acerca de Página Metabox" -#: example-functions.php:308 +#: example-functions.php:402 msgid "Repeating Field Group" msgstr "Repetir Grupo Campo" -#: example-functions.php:314 +#: example-functions.php:410 msgid "Generates reusable form entries" msgstr "Genera entradas de formulario reutilizables" -#: example-functions.php:316 +#: example-functions.php:412 msgid "Entry {#}" msgstr "Entrada {#}" -#: example-functions.php:317 +#: example-functions.php:413 msgid "Add Another Entry" msgstr "Añadir otra entrada" -#: example-functions.php:318 +#: example-functions.php:414 msgid "Remove Entry" msgstr "Eliminar entrada" -#: example-functions.php:355 +#: example-functions.php:426 +#, fuzzy +msgid "Entry Title" +msgstr "Entrada {#}" + +#: example-functions.php:433 +msgid "Description" +msgstr "Descripción" + +#: example-functions.php:434 +msgid "Write a short description for this entry" +msgstr "" + +#: example-functions.php:440 +msgid "Entry Image" +msgstr "" + +#: example-functions.php:446 +msgid "Image Caption" +msgstr "" + +#: example-functions.php:467 msgid "User Profile Metabox" msgstr "Perfil de Usuario Metabox" -#: example-functions.php:361 +#: example-functions.php:474 msgid "Extra Info" msgstr "Perfil de Usuario Metabox" -#: example-functions.php:368 +#: example-functions.php:482 msgid "Avatar" msgstr "Avatar" -#: example-functions.php:374 +#: example-functions.php:489 msgid "Facebook URL" msgstr "URL de Facebook" -#: example-functions.php:380 +#: example-functions.php:496 msgid "Twitter URL" msgstr "URL de Twitter" -#: example-functions.php:386 +#: example-functions.php:503 msgid "Google+ URL" msgstr "Google+ URL" -#: example-functions.php:392 +#: example-functions.php:510 msgid "Linkedin URL" msgstr "Linkedin URL" -#: example-functions.php:398 +#: example-functions.php:517 msgid "User Field" msgstr "El campo de usuario" -#: example-functions.php:412 +#: example-functions.php:540 msgid "Theme Options Metabox" msgstr "Tema Opciones Metabox" -#: example-functions.php:416 +#: example-functions.php:555 msgid "Site Background Color" msgstr "Antecedentes del sitio de color" -#: includes/CMB2_Ajax.php:37 +#: includes/CMB2.php:119 +msgid "Metabox configuration is required to have an ID parameter" +msgstr "" +"Se requiere de configuración Metabox tener un parámetro de identificación" + +#: includes/CMB2.php:316 +msgid "Click to toggle" +msgstr "Haga clic para alternar" + +#: includes/CMB2_Ajax.php:40 msgid "Please Try Again" msgstr "Vuelva a intentarlo" -#: includes/CMB2_Ajax.php:133 tests/test-cmb-types.php:734 +#: includes/CMB2_Ajax.php:135 msgid "Remove Embed" msgstr "Eliminar Insertar" -#: includes/CMB2_Ajax.php:137 +#: includes/CMB2_Ajax.php:139 +#, php-format msgid "No oEmbed Results Found for %s. View more info at" msgstr "No oEmbed resultados encontrados por% s. Ver más información en " -#: includes/CMB2_Field.php:765 +#: includes/CMB2_Field.php:893 msgid "Add Group" msgstr "Agregar grupo" -#: includes/CMB2_Field.php:766 +#: includes/CMB2_Field.php:894 msgid "Remove Group" msgstr "Eliminar grupo" -#: includes/CMB2_Field.php:787 +#: includes/CMB2_Field.php:916 includes/CMB2_Field.php:920 msgid "None" msgstr "Ninguno" -#: includes/CMB2_Field.php:788 -msgid "All" -msgstr "Todos" - -#: includes/CMB2_Types.php:290 +#: includes/CMB2_Types.php:297 msgid "Add Row" msgstr "Añadir fila" -#: includes/CMB2_Types.php:349 includes/CMB2_Types.php:805 -#: includes/CMB2_Types.php:882 includes/CMB2_hookup.php:173 -#: tests/test-cmb-types.php:147 tests/test-cmb-types.php:155 -#: tests/test-cmb-types.php:683 tests/test-cmb-types.php:708 +#: includes/CMB2_Types.php:356 includes/CMB2_Types.php:989 +#: includes/CMB2_hookup.php:194 msgid "Remove" msgstr "Eliminar" -#: includes/CMB2_Types.php:683 includes/CMB2_Types.php:731 +#: includes/CMB2_Types.php:725 includes/CMB2_Types.php:773 msgid "No terms" msgstr "No hay términos" -#: includes/CMB2_Types.php:775 includes/CMB2_Types.php:830 -#: tests/test-cmb-types.php:659 tests/test-cmb-types.php:685 -#: tests/test-cmb-types.php:695 tests/test-cmb-types.php:710 +#: includes/CMB2_Types.php:838 +msgid "Add or Upload Files" +msgstr "Añadir o Subir archivos" + +#: includes/CMB2_Types.php:896 msgid "Add or Upload File" msgstr "Añadir o Cargar archivo" -#: includes/CMB2_Types.php:796 includes/CMB2_Types.php:877 -#: includes/CMB2_hookup.php:172 +#: includes/CMB2_Types.php:970 includes/CMB2_hookup.php:193 msgid "Remove Image" msgstr "Eliminar imagen" -#: includes/CMB2_Types.php:805 includes/CMB2_Types.php:882 -#: includes/CMB2_hookup.php:174 tests/test-cmb-types.php:684 -#: tests/test-cmb-types.php:709 +#: includes/CMB2_Types.php:984 includes/CMB2_hookup.php:195 msgid "File:" msgstr "Archivo:" -#: includes/CMB2_Types.php:805 includes/CMB2_Types.php:882 -#: includes/CMB2_hookup.php:175 tests/test-cmb-types.php:682 -#: tests/test-cmb-types.php:707 +#: includes/CMB2_Types.php:987 includes/CMB2_hookup.php:196 msgid "Download" msgstr "Descargar" -#: includes/CMB2_hookup.php:123 includes/CMB2_hookup.php:160 +#: includes/CMB2_hookup.php:139 includes/CMB2_hookup.php:176 msgid "Clear" msgstr "Borrar" -#: includes/CMB2_hookup.php:124 +#: includes/CMB2_hookup.php:140 msgid "Default" msgstr "Por defecto" -#: includes/CMB2_hookup.php:125 +#: includes/CMB2_hookup.php:141 msgid "Select Color" msgstr "Seleccionar color" -#: includes/CMB2_hookup.php:126 +#: includes/CMB2_hookup.php:142 msgid "Current Color" msgstr "Seleccionar color" -#: includes/CMB2_hookup.php:150 +#: includes/CMB2_hookup.php:166 +msgctxt "Valid formatDate string for jquery-ui datepicker" msgid "mm/dd/yy" -msgstr "mm / dd / aa" +msgstr "dd/mm/yy" -#: includes/CMB2_hookup.php:151 +#: includes/CMB2_hookup.php:167 msgid "Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday" msgstr "El domingo, lunes, martes, miércoles, jueves, viernes, sábado" -#: includes/CMB2_hookup.php:152 +#: includes/CMB2_hookup.php:168 msgid "Su, Mo, Tu, We, Th, Fr, Sa" msgstr "Do, Lu, Ma, Mi, Ju, Vi, Sa" -#: includes/CMB2_hookup.php:153 +#: includes/CMB2_hookup.php:169 msgid "Sun, Mon, Tue, Wed, Thu, Fri, Sat" msgstr "Sun, L, M, X, J, V, S" -#: includes/CMB2_hookup.php:154 +#: includes/CMB2_hookup.php:170 msgid "" "January, February, March, April, May, June, July, August, September, " "October, November, December" -msgstr "Enero, febrero, marzo, abril, mayo, junio, julio, agosto, septiembre, Octubre, Noviembre, Diciembre" +msgstr "" +"Enero, febrero, marzo, abril, mayo, junio, julio, agosto, septiembre, " +"Octubre, Noviembre, Diciembre" -#: includes/CMB2_hookup.php:155 +#: includes/CMB2_hookup.php:171 msgid "Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec" -msgstr "Enero, febrero, marzo, abril, mayo, junio, julio, agosto, septiembre, octubre, noviembre, diciembre" +msgstr "" +"Enero, febrero, marzo, abril, mayo, junio, julio, agosto, septiembre, " +"octubre, noviembre, diciembre" -#: includes/CMB2_hookup.php:156 +#: includes/CMB2_hookup.php:172 msgid "Next" msgstr "Siguiente" -#: includes/CMB2_hookup.php:157 +#: includes/CMB2_hookup.php:173 msgid "Prev" msgstr "Anterior" -#: includes/CMB2_hookup.php:158 +#: includes/CMB2_hookup.php:174 msgid "Today" msgstr "Hoy" -#: includes/CMB2_hookup.php:159 +#: includes/CMB2_hookup.php:175 includes/CMB2_hookup.php:185 msgid "Done" msgstr "Hecho" -#: includes/CMB2_hookup.php:171 +#: includes/CMB2_hookup.php:179 +msgid "Choose Time" +msgstr "Elegir Hora" + +#: includes/CMB2_hookup.php:180 +msgid "Time" +msgstr "Hora" + +#: includes/CMB2_hookup.php:181 +msgid "Hour" +msgstr "Hora" + +#: includes/CMB2_hookup.php:182 +msgid "Minute" +msgstr "Minuto" + +#: includes/CMB2_hookup.php:183 +msgid "Second" +msgstr "Segundo" + +#: includes/CMB2_hookup.php:184 +msgid "Now" +msgstr "Ahora" + +#: includes/CMB2_hookup.php:186 +msgctxt "" +"Valid formatting string, as per http://trentrichardson.com/examples/" +"timepicker/" +msgid "hh:mm TT" +msgstr "HH:mm" + +#: includes/CMB2_hookup.php:192 msgid "Use this file" msgstr "Usar este archivo" -#: includes/CMB2_hookup.php:176 +#: includes/CMB2_hookup.php:197 msgid "Select / Deselect All" msgstr "Seleccionar / Deseleccionar todo" -#: includes/helper-functions.php:243 +#: includes/helper-functions.php:249 msgid "Save" msgstr "Guardar" -#. Plugin Name of the plugin/theme -msgid "CMB2 (beta)" -msgstr "CMB2 (beta)" +#~ msgid "All" +#~ msgstr "Todos" -#. Plugin URI of the plugin/theme -msgid "https://github.com/WebDevStudios/CMB2" -msgstr "https://github.com/WebDevStudios/CMB2" +#~ msgid "CMB2 (beta)" +#~ msgstr "CMB2 (beta)" -#. Description of the plugin/theme -msgid "" -"CMB2 will create metaboxes and forms with custom fields that will blow your " -"mind." -msgstr "CMB2 creará metaboxes y formularios con campos personalizados que harán volar tu Mente." +#~ msgid "https://github.com/WebDevStudios/CMB2" +#~ msgstr "https://github.com/WebDevStudios/CMB2" + +#~ msgid "" +#~ "CMB2 will create metaboxes and forms with custom fields that will blow " +#~ "your mind." +#~ msgstr "" +#~ "CMB2 creará metaboxes y formularios con campos personalizados que harán " +#~ "volar tu Mente." -#. Author of the plugin/theme -msgid "WebDevStudios" -msgstr "WebDevStudios" +#~ msgid "WebDevStudios" +#~ msgstr "WebDevStudios" -#. Author URI of the plugin/theme -msgid "http://webdevstudios.com" -msgstr "http://webdevstudios.com" +#~ msgid "http://webdevstudios.com" +#~ msgstr "http://webdevstudios.com" From a286f03b958c1aa807c6d22d1e356f870a27c869 Mon Sep 17 00:00:00 2001 From: yivi Date: Fri, 8 May 2015 09:38:42 +0200 Subject: [PATCH 02/20] Fixes text_date_timestamp validation so it uses 'date_format', instead of just trying strtotime directly --- includes/CMB2_Sanitize.php | 94 ++++++++++++++++++++++++++++---------- 1 file changed, 70 insertions(+), 24 deletions(-) diff --git a/includes/CMB2_Sanitize.php b/includes/CMB2_Sanitize.php index 8f996940d..d1311f0ed 100644 --- a/includes/CMB2_Sanitize.php +++ b/includes/CMB2_Sanitize.php @@ -2,26 +2,31 @@ /** * CMB field validation + * * @since 0.0.4 - * @method string _id() + * @method string _id() */ class CMB2_Sanitize { /** * A CMB field object + * * @var CMB2_Field object */ public $field; /** * Field's value + * * @var mixed */ public $value; /** * Setup our class vars + * * @since 1.1.0 + * * @param CMB2_Field $field A CMB field object * @param mixed $value Field value */ @@ -32,9 +37,12 @@ public function __construct( CMB2_Field $field, $value ) { /** * Catchall method if field's 'sanitization_cb' is NOT defined, or field type does not have a corresponding validation method + * * @since 1.0.0 + * * @param string $name Non-existent method name * @param array $arguments All arguments passed to the method + * @return mixed */ public function __call( $name, $arguments ) { return $this->default_sanitization( $this->value ); @@ -42,6 +50,7 @@ public function __call( $name, $arguments ) { /** * Default fallback sanitization method. Applies filters. + * * @since 1.0.2 */ public function default_sanitization() { @@ -56,16 +65,18 @@ public function default_sanitization() { * * @param bool|mixed $override_value Sanitization/Validation override value to return. * Default false to skip it. - * @param mixed $value The value to be saved to this field. - * @param int $object_id The ID of the object where the value will be saved - * @param array $field_args The current field's arguments - * @param object $sanitizer This `CMB2_Sanitize` object + * @param mixed $value The value to be saved to this field. + * @param int $object_id The ID of the object where the value will be saved + * @param array $field_args The current field's arguments + * @param object $sanitizer This `CMB2_Sanitize` object */ - $override_value = apply_filters( "cmb2_sanitize_{$this->field->type()}", null, $this->value, $this->field->object_id, $this->field->args(), $this ); + $override_value = apply_filters( "cmb2_sanitize_{$this->field->type()}", null, $this->value, + $this->field->object_id, $this->field->args(), $this ); /** * DEPRECATED. See documentation above. */ - $override_value = apply_filters( "cmb2_validate_{$this->field->type()}", $override_value, $this->value, $this->field->object_id, $this->field->args(), $this ); + $override_value = apply_filters( "cmb2_validate_{$this->field->type()}", $override_value, $this->value, + $this->field->object_id, $this->field->args(), $this ); if ( null !== $override_value ) { return $override_value; @@ -95,7 +106,8 @@ public function default_sanitization() { default: // Handle repeatable fields array // We'll fallback to 'sanitize_text_field' - $sanitized_value = is_array( $this->value ) ? array_map( 'sanitize_text_field', $this->value ) : call_user_func( 'sanitize_text_field', $this->value ); + $sanitized_value = is_array( $this->value ) ? array_map( 'sanitize_text_field', $this->value ) + : call_user_func( 'sanitize_text_field', $this->value ); break; } @@ -104,6 +116,7 @@ public function default_sanitization() { /** * Simple checkbox validation + * * @since 1.0.1 * @return string|false 'on' or false */ @@ -113,6 +126,7 @@ public function checkbox() { /** * Validate url in a meta value + * * @since 1.0.1 * @return string Empty string or escaped url */ @@ -133,8 +147,8 @@ public function text_url() { public function colorpicker() { // for repeatable if ( is_array( $this->value ) ) { - $check = $this->value; - $this->value = array(); + $check = $this->value; + $this->value = [ ]; foreach ( $check as $key => $val ) { if ( $val && '#' != $val ) { $this->value[ $key ] = esc_attr( $val ); @@ -143,11 +157,13 @@ public function colorpicker() { } else { $this->value = ! $this->value || '#' == $this->value ? '' : esc_attr( $this->value ); } + return $this->value; } /** * Validate email in a meta value + * * @since 1.0.1 * @return string Empty string or sanitized email */ @@ -155,7 +171,7 @@ public function text_email() { // for repeatable if ( is_array( $this->value ) ) { foreach ( $this->value as $key => $val ) { - $val = trim( $val ); + $val = trim( $val ); $this->value[ $key ] = is_email( $val ) ? $val : ''; } } else { @@ -168,6 +184,7 @@ public function text_email() { /** * Validate money in a meta value + * * @since 1.0.1 * @return string Empty string or sanitized money value */ @@ -175,8 +192,8 @@ public function text_money() { global $wp_locale; - $search = array( $wp_locale->number_format['thousands_sep'], $wp_locale->number_format['decimal_point'] ); - $replace = array( '', '.' ); + $search = [ $wp_locale->number_format['thousands_sep'], $wp_locale->number_format['decimal_point'] ]; + $replace = [ '', '.' ]; // for repeatable if ( is_array( $this->value ) ) { @@ -192,15 +209,30 @@ public function text_money() { /** * Converts text date to timestamp + * * @since 1.0.2 - * @return string Timestring + * @return array/int Timestring */ public function text_date_timestamp() { - return is_array( $this->value ) ? array_map( 'strtotime', $this->value ) : strtotime( $this->value ); + if ( is_array( $this->value ) ) { + $returnee = [ ]; + foreach ( $this->value as $value ) { + $date_object = DateTime::createFromFormat( $this->field->args['date_format'], $value ); + $returnee[] = $date_object ? $date_object->setTime( 0, 0, 0 )->getTimeStamp() : ''; + + } + } else { + $date_object = DateTime::createFromFormat( $this->field->args['date_format'], $this->value ); + $returnee = $date_object ? $date_object->setTime( 0, 0, 0 )->getTimeStamp() : ''; + } + + return $returnee; + } /** * Datetime to timestamp + * * @since 1.0.1 * @return string Timestring */ @@ -225,7 +257,8 @@ public function text_datetime_timestamp( $repeat = false ) { } /** - * Datetime to imestamp with timezone + * Datetime to timestamp with timezone + * * @since 1.0.1 * @return string Timestring */ @@ -264,6 +297,7 @@ public function text_datetime_timestamp_timezone( $repeat = false ) { /** * Sanitize textareas and wysiwyg fields + * * @since 1.0.1 * @return string Sanitized data */ @@ -273,6 +307,7 @@ public function textarea() { /** * Sanitize code textareas + * * @since 1.0.2 * @return string Sanitized data */ @@ -286,6 +321,7 @@ public function textarea_code( $repeat = false ) { /** * Peforms saving of `file` attachement's ID + * * @since 1.1.0 */ public function _save_file_id() { @@ -295,12 +331,12 @@ public function _save_file_id() { unset( $args['_id'], $args['_name'] ); // And get new field object - $field = new CMB2_Field( array( + $field = new CMB2_Field( [ 'field_args' => $args, 'group_field' => $group, 'object_id' => $this->field->object_id, 'object_type' => $this->field->object_type, - ) ); + ] ); $id_key = $field->_id(); $id_val_old = $field->escaped_value( 'absint' ); @@ -322,10 +358,10 @@ public function _save_file_id() { } if ( $group ) { - return array( + return [ 'attach_id' => $id_val, 'field_id' => $id_key, - ); + ]; } if ( $id_val && $id_val != $id_val_old ) { @@ -337,46 +373,56 @@ public function _save_file_id() { /** * Handles saving of attachment post ID and sanitizing file url + * * @since 1.1.0 * @return string Sanitized url */ public function file() { $id_value = $this->_save_file_id( $this->value ); - $clean = $this->text_url( $this->value ); + $clean = $this->text_url( $this->value ); // Return an array with url/id if saving a group field - return $this->field->group ? array_merge( array( 'url' => $clean ), $id_value ) : $clean; + return $this->field->group ? array_merge( [ 'url' => $clean ], $id_value ) : $clean; } /** * If repeating, loop through and re-apply sanitization method + * * @since 1.1.0 + * * @param string $method Class method * @param bool $repeat Whether repeating or not + * * @return mixed Sanitized value */ public function _check_repeat( $method, $repeat ) { if ( $repeat || ! $this->field->args( 'repeatable' ) ) { return; } - $new_value = array(); + $new_value = [ ]; foreach ( $this->value as $iterator => $val ) { $new_value[] = $this->$method( $val, true ); } + return $new_value; } /** * Determine if passed value is an empty array + * * @since 2.0.6 - * @param mixed $to_check Value to check + * + * @param mixed $to_check Value to check + * * @return boolean Whether value is an array that's empty */ public function _is_empty_array( $to_check ) { if ( is_array( $to_check ) ) { $cleaned_up = array_filter( $to_check ); + return empty( $cleaned_up ); } + return false; } From 26a9b7309670b96f847b6cf2cee57e60ac7b3966 Mon Sep 17 00:00:00 2001 From: yivi Date: Fri, 8 May 2015 17:56:12 +0200 Subject: [PATCH 03/20] Outputs data-datepicker into date_text, so each datepicker can be initialized with its own date-format The js initializer reads data-datepicker to set each datepicker properly --- includes/CMB2_Types.php | 5 ++++- js/cmb2.js | 9 +++++++-- js/cmb2.min.js | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/includes/CMB2_Types.php b/includes/CMB2_Types.php index 270b9db98..8448ed4c3 100644 --- a/includes/CMB2_Types.php +++ b/includes/CMB2_Types.php @@ -5,7 +5,7 @@ * * @todo test taxonomy methods with non-post objects * @todo test all methods with non-post objects - * @todo Date/Time fields should store date format as data attribute for JS + * @todo Time fields should store date format as data attribute for JS * * @since 1.0.0 */ @@ -496,10 +496,13 @@ public function wysiwyg( $args = array() ) { } public function text_date( $args = array() ) { + $dateFormat = cmb2_utils()->php_to_js_dateformat( $this->field->args( 'date_format' ) ); + $args = wp_parse_args( $args, array( 'class' => 'cmb2-text-small cmb2-datepicker', 'value' => $this->field->get_timestamp_format(), 'desc' => $this->_desc(), + 'data-datepicker' => '{ "dateFormat": "' . $dateFormat . '" }' ) ); return $this->input( $args ); diff --git a/js/cmb2.js b/js/cmb2.js index a848a3b4e..686c6b02e 100755 --- a/js/cmb2.js +++ b/js/cmb2.js @@ -679,8 +679,13 @@ window.CMB2 = (function(window, document, $, undefined){ return; } - $selector.datepicker( 'destroy' ); - $selector.datepicker( cmb.defaults.date_picker ); + $selector.each(function() { + var options = cmb.defaults.date_picker; + $(this).datepicker( 'destroy' ); + var additionalOptions = $(this).data("datepicker"); + $.extend( options, additionalOptions ); + $(this).datepicker( options ); + }); }; cmb.initColorPickers = function( $selector ) { diff --git a/js/cmb2.min.js b/js/cmb2.min.js index f05faa69e..d790f0285 100644 --- a/js/cmb2.min.js +++ b/js/cmb2.min.js @@ -1 +1 @@ -window.CMB2=function(window,document,$){"use strict";var l10n=window.cmb2_l10,setTimeout=window.setTimeout,cmb={formfield:"",idNumber:!1,file_frames:{},repeatEls:'input:not([type="button"]),select,textarea,.cmb2-media-status',styleBreakPoint:450,mediaHandlers:{},neweditor_id:[],defaults:{time_picker:l10n.defaults.time_picker,date_picker:l10n.defaults.date_picker,color_picker:l10n.defaults.color_picker||{}}},$id=function(selector){return $(document.getElementById(selector))};return cmb.metabox=function(){return cmb.$metabox?cmb.$metabox:(cmb.$metabox=$(".cmb2-wrap > .cmb2-metabox"),cmb.$metabox)},cmb.init=function(){cmb.log("CMB2 localized data",l10n);var $metabox=cmb.metabox(),$repeatGroup=$metabox.find(".cmb-repeatable-group");cmb.initPickers($metabox.find('input[type="text"].cmb2-timepicker'),$metabox.find('input[type="text"].cmb2-datepicker'),$metabox.find('input[type="text"].cmb2-colorpicker')),$id("ui-datepicker-div").wrap('
'),$('

'+l10n.strings.check_toggle+"

").insertBefore(".cmb2-checkbox-list:not(.no-select-all)"),cmb.makeListSortable(),$metabox.on("change",".cmb2_upload_file",function(){cmb.formfield=$(this).attr("id"),$id(cmb.formfield+"_id").val("")}).on("click",".cmb-multicheck-toggle",cmb.toggleCheckBoxes).on("click",".cmb2-upload-button",cmb.handleMedia).on("click",".cmb-attach-list li, .cmb2-media-status .img-status img, .cmb2-media-status .file-status > span",cmb.handleFileClick).on("click",".cmb2-remove-file-button",cmb.handleRemoveMedia).on("click",".cmb-add-group-row",cmb.addGroupRow).on("click",".cmb-add-row-button",cmb.addAjaxRow).on("click",".cmb-remove-group-row",cmb.removeGroupRow).on("click",".cmb-remove-row-button",cmb.removeAjaxRow).on("keyup paste focusout",".cmb2-oembed",cmb.maybeOembed).on("cmb2_remove_row",".cmb-repeatable-group",cmb.resetTitlesAndIterator).on("click",".cmbhandle, .cmbhandle + .cmbhandle-title",cmb.toggleHandle),$repeatGroup.length&&$repeatGroup.filter(".sortable").each(function(){$(this).find(".button.cmb-remove-group-row").before(' ')}).on("click",".cmb-shift-rows",cmb.shiftRows).on("cmb2_add_row",cmb.emptyValue),setTimeout(cmb.resizeoEmbeds,500),$(window).on("resize",cmb.resizeoEmbeds)},cmb.resetTitlesAndIterator=function(){$(".cmb-repeatable-group").each(function(){var $table=$(this);$table.find(".cmb-repeatable-grouping").each(function(rowindex){var $row=$(this);$row.data("iterator",rowindex),$row.find(".cmb-group-title h4").text($table.find(".cmb-add-group-row").data("grouptitle").replace("{#}",rowindex+1))})})},cmb.toggleHandle=function(evt){evt.preventDefault(),$(document).trigger("postbox-toggled",$(this).parent(".postbox").toggleClass("closed"))},cmb.toggleCheckBoxes=function(evt){evt.preventDefault();var $self=$(this),$multicheck=$self.closest(".cmb-td").find("input[type=checkbox]");$self.data("checked")?($multicheck.prop("checked",!1),$self.data("checked",!1)):($multicheck.prop("checked",!0),$self.data("checked",!0))},cmb.handleMedia=function(evt){evt.preventDefault();var $el=$(this);cmb.attach_id=$el.hasClass("cmb2-upload-list")?!1:$el.closest(".cmb-td").find(".cmb2-upload-file-id").val(),cmb.attach_id="0"!==cmb.attach_id?cmb.attach_id:!1,cmb._handleMedia($el.prev("input.cmb2-upload-file").attr("id"),$el.hasClass("cmb2-upload-list"))},cmb.handleFileClick=function(evt){evt.preventDefault();var $el=$(this),$td=$el.closest(".cmb-td"),isList=$td.find(".cmb2-upload-button").hasClass("cmb2-upload-list");cmb.attach_id=isList?$el.find('input[type="hidden"]').data("id"):$td.find(".cmb2-upload-file-id").val(),cmb.attach_id&&cmb._handleMedia($td.find("input.cmb2-upload-file").attr("id"),isList,cmb.attach_id)},cmb._handleMedia=function(formfield,isList){if(wp){var $metabox=cmb.metabox();cmb.formfield=formfield;var $formfield=$id(cmb.formfield),previewSize=$formfield.data("previewsize"),formName=$formfield.attr("name"),uploadStatus=!0,attachment=!0;if(cmb.formfield in cmb.file_frames)return void cmb.file_frames[cmb.formfield].open();cmb.file_frames[cmb.formfield]=wp.media({title:$metabox.find("label[for="+cmb.formfield+"]").text(),button:{text:l10n.strings.upload_file},multiple:isList?!0:!1}),cmb.mediaHandlers.list=function(selection,returnIt){attachment=selection.toJSON(),$formfield.val(attachment.url),$id(cmb.formfield+"_id").val(attachment.id);var fileGroup=[];return $(attachment).each(function(){if(this.type&&"image"===this.type){var width=previewSize[0]?previewSize[0]:50,height=previewSize[1]?previewSize[1]:50;uploadStatus='
  • '+this.filename+'

    '+l10n.strings.remove_image+'

  • '}else uploadStatus='
  • '+l10n.strings.file+" "+this.filename+'   ('+l10n.strings.download+' / '+l10n.strings.remove_file+')
  • ';fileGroup.push(uploadStatus)}),returnIt?fileGroup:void $(fileGroup).each(function(){$formfield.siblings(".cmb2-media-status").slideDown().append(this)})},cmb.mediaHandlers.single=function(selection){if(attachment=selection.first().toJSON(),$formfield.val(attachment.url),$id(cmb.formfield+"_id").val(attachment.id),attachment.type&&"image"===attachment.type){var width=previewSize[0]?previewSize[0]:350;uploadStatus='"}else uploadStatus='
    '+l10n.strings.file+" "+attachment.filename+'   ('+l10n.strings.download+' / '+l10n.strings.remove_file+")
    ";$formfield.siblings(".cmb2-media-status").slideDown().html(uploadStatus)},cmb.mediaHandlers.selectFile=function(){var selection=cmb.file_frames[cmb.formfield].state().get("selection"),type=isList?"list":"single";return cmb.attach_id&&isList?void $('[data-id="'+cmb.attach_id+'"]').parents("li").replaceWith(cmb.mediaHandlers.list(selection,!0)):void cmb.mediaHandlers[type](selection)},cmb.mediaHandlers.openModal=function(){var selection=cmb.file_frames[cmb.formfield].state().get("selection");if(!cmb.attach_id)return selection.reset();var attach=wp.media.attachment(cmb.attach_id);attach.fetch(),selection.set(attach?[attach]:[])},cmb.file_frames[cmb.formfield].on("select",cmb.mediaHandlers.selectFile).on("open",cmb.mediaHandlers.openModal),cmb.file_frames[cmb.formfield].open()}},cmb.handleRemoveMedia=function(evt){evt.preventDefault();var $self=$(this);return $self.is(".cmb-attach-list .cmb2-remove-file-button")?($self.parents("li").remove(),!1):(cmb.formfield=$self.attr("rel"),cmb.metabox().find("input#"+cmb.formfield).val(""),cmb.metabox().find("input#"+cmb.formfield+"_id").val(""),$self.parents(".cmb2-media-status").html(""),!1)},cmb.cleanRow=function($row,prevNum,group){var $inputs=$row.find('input:not([type="button"]), select, textarea, label'),$other=$row.find("[id]").not('input:not([type="button"]), select, textarea, label');return group&&($row.find(".cmb-repeat-table .cmb-repeat-row:not(:first-child)").remove(),$other.length&&$other.each(function(){var $_this=$(this),oldID=$_this.attr("id"),newID=oldID.replace("_"+prevNum,"_"+cmb.idNumber),$buttons=$row.find('[data-selector="'+oldID+'"]');$_this.attr("id",newID),$buttons.length&&$buttons.attr("data-selector",newID).data("selector",newID)})),cmb.neweditor_id=[],$inputs.filter(":checked").prop("checked",!1),$inputs.filter(":selected").prop("selected",!1),$row.find("h3.cmb-group-title").length&&$row.find("h3.cmb-group-title").text($row.data("title").replace("{#}",cmb.idNumber+1)),$inputs.each(function(){var newID,oldID,$newInput=$(this),isEditor=$newInput.hasClass("wp-editor-area"),oldFor=$newInput.attr("for"),attrs={};if(oldFor)attrs={"for":oldFor.replace("_"+prevNum,"_"+cmb.idNumber)};else{var oldName=$newInput.attr("name"),newName=oldName?oldName.replace("["+prevNum+"]","["+cmb.idNumber+"]"):"";oldID=$newInput.attr("id"),newID=oldID?oldID.replace("_"+prevNum,"_"+cmb.idNumber):"",attrs={id:newID,name:newName,"data-iterator":cmb.idNumber}}if($newInput.removeClass("hasDatepicker").attr(attrs).val(""),isEditor){newID=newID?oldID.replace("zx"+prevNum,"zx"+cmb.idNumber):"",$newInput.html("");var $wysiwyg=$newInput.parents(".cmb-type-wysiwyg");$wysiwyg.find(".mce-tinymce:not(:first-child)").remove();var html=$wysiwyg.html().replace(new RegExp(oldID,"g"),newID);$wysiwyg.html(html),cmb.neweditor_id.push({id:newID,old:oldID})}}),cmb},cmb.newRowHousekeeping=function($row){var $colorPicker=$row.find(".wp-picker-container"),$list=$row.find(".cmb2-media-status");return $colorPicker.length&&$colorPicker.each(function(){var $td=$(this).parent();$td.html($td.find('input[type="text"].cmb2-colorpicker').attr("style",""))}),$list.length&&$list.empty(),cmb},cmb.afterRowInsert=function($row){var _prop;if(cmb.neweditor_id.length){var i;for(i=cmb.neweditor_id.length-1;i>=0;i--){var id=cmb.neweditor_id[i].id,old=cmb.neweditor_id[i].old;if("undefined"==typeof tinyMCEPreInit.mceInit[id]){var newSettings=jQuery.extend({},tinyMCEPreInit.mceInit[old]);for(_prop in newSettings)"string"==typeof newSettings[_prop]&&(newSettings[_prop]=newSettings[_prop].replace(new RegExp(old,"g"),id));tinyMCEPreInit.mceInit[id]=newSettings}if("undefined"==typeof tinyMCEPreInit.qtInit[id]){var newQTS=jQuery.extend({},tinyMCEPreInit.qtInit[old]);for(_prop in newQTS)"string"==typeof newQTS[_prop]&&(newQTS[_prop]=newQTS[_prop].replace(new RegExp(old,"g"),id));tinyMCEPreInit.qtInit[id]=newQTS}tinyMCE.init({id:tinyMCEPreInit.mceInit[id]})}}cmb.initPickers($row.find('input[type="text"].cmb2-timepicker'),$row.find('input[type="text"].cmb2-datepicker'),$row.find('input[type="text"].cmb2-colorpicker'))},cmb.updateNameAttr=function(){var $this=$(this),name=$this.attr("name");if("undefined"==typeof name)return!1;var prevNum=parseInt($this.parents(".cmb-repeatable-grouping").data("iterator")),newNum=prevNum-1,$newName=name.replace("["+prevNum+"]","["+newNum+"]");$this.attr("name",$newName)},cmb.emptyValue=function(evt,row){$('input:not([type="button"]), textarea',row).val("")},cmb.addGroupRow=function(evt){evt.preventDefault();var $self=$(this);$self.trigger("cmb2_add_group_row_start",$self);var $table=$id($self.data("selector")),$oldRow=$table.find(".cmb-repeatable-grouping").last(),prevNum=parseInt($oldRow.data("iterator"));cmb.idNumber=prevNum+1;var $row=$oldRow.clone();cmb.newRowHousekeeping($row.data("title",$self.data("grouptitle"))).cleanRow($row,prevNum,!0),$row.find(".cmb-add-row-button").prop("disabled",!1);var $newRow=$('
    '+$row.html()+"
    ");$oldRow.after($newRow),cmb.afterRowInsert($newRow),$table.find(".cmb-repeatable-grouping").length<=1?$table.find(".cmb-remove-group-row").prop("disabled",!0):$table.find(".cmb-remove-group-row").prop("disabled",!1),$table.trigger("cmb2_add_row",$newRow)},cmb.addAjaxRow=function(evt){evt.preventDefault();var $self=$(this),$table=$id($self.data("selector")),$emptyrow=$table.find(".empty-row"),prevNum=parseInt($emptyrow.find("[data-iterator]").data("iterator"));cmb.idNumber=prevNum+1;var $row=$emptyrow.clone();cmb.newRowHousekeeping($row).cleanRow($row,prevNum),$emptyrow.removeClass("empty-row hidden").addClass("cmb-repeat-row"),$emptyrow.after($row),cmb.afterRowInsert($row),$table.trigger("cmb2_add_row",$row),$table.find(".cmb-remove-row-button").removeClass("button-disabled")},cmb.removeGroupRow=function(evt){evt.preventDefault();var $self=$(this),$table=$id($self.data("selector")),$parent=$self.parents(".cmb-repeatable-grouping"),number=$table.find(".cmb-repeatable-grouping").length;number>1&&($table.trigger("cmb2_remove_group_row_start",$self),$parent.nextAll(".cmb-repeatable-grouping").find(cmb.repeatEls).each(cmb.updateNameAttr),$parent.remove(),2>=number?$table.find(".cmb-remove-group-row").prop("disabled",!0):$table.find(".cmb-remove-group-row").prop("disabled",!1),$table.trigger("cmb2_remove_row"))},cmb.removeAjaxRow=function(evt){evt.preventDefault();var $self=$(this);if(!$self.hasClass("button-disabled")){var $parent=$self.parents(".cmb-row"),$table=$self.parents(".cmb-repeat-table"),number=$table.find(".cmb-row").length;number>2?($parent.hasClass("empty-row")&&$parent.prev().addClass("empty-row").removeClass("cmb-repeat-row"),$self.parents(".cmb-repeat-table .cmb-row").remove(),3===number&&$table.find(".cmb-remove-row-button").addClass("button-disabled"),$table.trigger("cmb2_remove_row")):$self.addClass("button-disabled")}},cmb.shiftRows=function(evt){evt.preventDefault();var $self=$(this);$self.trigger("cmb2_shift_rows_enter",$self);var $parent=$self.parents(".cmb-repeatable-grouping"),$goto=$self.hasClass("move-up")?$parent.prev(".cmb-repeatable-grouping"):$parent.next(".cmb-repeatable-grouping");if($goto.length){$self.trigger("cmb2_shift_rows_start",$self);var inputVals=[];$parent.find(cmb.repeatEls).each(function(){var val,$element=$(this);val=$element.hasClass("cmb2-media-status")?$element.html():"checkbox"===$element.attr("type")||"radio"===$element.attr("type")?$element.is(":checked"):"select"===$element.prop("tagName")?$element.is(":selected"):$element.val(),inputVals.push({val:val,$:$element})}),$goto.find(cmb.repeatEls).each(function(index){var val,$element=$(this);$element.hasClass("cmb2-media-status")?(val=$element.html(),$element.html(inputVals[index].val),inputVals[index].$.html(val)):"checkbox"===$element.attr("type")||"radio"===$element.attr("type")?(inputVals[index].$.prop("checked",$element.is(":checked")),$element.prop("checked",inputVals[index].val)):"select"===$element.prop("tagName")?(inputVals[index].$.prop("selected",$element.is(":selected")),$element.prop("selected",inputVals[index].val)):(inputVals[index].$.val($element.val()),$element.val(inputVals[index].val))}),$self.trigger("cmb2_shift_rows_complete",$self)}},cmb.initPickers=function($timePickers,$datePickers,$colorPickers){cmb.initTimePickers($timePickers),cmb.initDatePickers($datePickers),cmb.initColorPickers($colorPickers)},cmb.initTimePickers=function($selector){$selector.length&&($selector.timepicker("destroy"),$selector.timepicker(cmb.defaults.time_picker))},cmb.initDatePickers=function($selector){$selector.length&&($selector.datepicker("destroy"),$selector.datepicker(cmb.defaults.date_picker))},cmb.initColorPickers=function($selector){$selector.length&&("object"==typeof jQuery.wp&&"function"==typeof jQuery.wp.wpColorPicker?$selector.wpColorPicker(cmb.defaults.color_picker):$selector.each(function(i){$(this).after('
    '),$id("picker-"+i).hide().farbtastic($(this))}).focus(function(){$(this).next().show()}).blur(function(){$(this).next().hide()}))},cmb.makeListSortable=function(){var $filelist=cmb.metabox().find(".cmb2-media-status.cmb-attach-list");$filelist.length&&$filelist.sortable({cursor:"move"}).disableSelection()},cmb.maybeOembed=function(evt){var $self=$(this),type=evt.type,m={focusout:function(){setTimeout(function(){cmb.spinner(".postbox .cmb2-metabox",!0)},2e3)},keyup:function(){var betw=function(min,max){return evt.which<=max&&evt.which>=min};(betw(48,90)||betw(96,111)||betw(8,9)||187===evt.which||190===evt.which)&&cmb.doAjax($self,evt)},paste:function(){setTimeout(function(){cmb.doAjax($self)},100)}};m[type]()},cmb.resizeoEmbeds=function(){cmb.metabox().each(function(){var $self=$(this),$tableWrap=$self.parents(".inside"),isSide=$self.parents(".inner-sidebar").length||$self.parents("#side-sortables").length,isSmall=isSide,isSmallest=!1;if(!$tableWrap.length)return!0;var tableW=$tableWrap.width();cmb.styleBreakPoint>tableW&&(isSmall=!0,isSmallest=cmb.styleBreakPoint-62>tableW),tableW=isSmall?tableW:Math.round(.82*$tableWrap.width()*.97);var newWidth=tableW-30;if(!isSmall||isSide||isSmallest||(newWidth-=75),newWidth>639)return!0;var $embeds=$self.find(".cmb-type-oembed .embed-status"),$children=$embeds.children().not(".cmb2-remove-wrapper");return $children.length?void $children.each(function(){var $self=$(this),iwidth=$self.width(),iheight=$self.height(),_newWidth=newWidth;$self.parents(".cmb-repeat-row").length&&!isSmall&&(_newWidth=newWidth-91,_newWidth=785>tableW?_newWidth-15:_newWidth);var newHeight=Math.round(_newWidth*iheight/iwidth);$self.width(_newWidth).height(newHeight)}):!0})},cmb.log=function(){l10n.script_debug&&console&&"function"==typeof console.log&&console.log.apply(console,arguments)},cmb.spinner=function($context,hide){hide?$(".cmb-spinner",$context).hide():$(".cmb-spinner",$context).show()},cmb.doAjax=function($obj){var oembed_url=$obj.val();if(!(oembed_url.length<6)){var field_id=$obj.attr("id"),$context=$obj.closest(".cmb-td"),$embed_container=$context.find(".embed-status"),$embed_wrap=$context.find(".embed_wrap"),$child_el=$embed_container.find(":first-child"),oembed_width=$embed_container.length&&$child_el.length?$child_el.width():$obj.width();cmb.log("oembed_url",oembed_url,field_id),cmb.spinner($context),$embed_wrap.html(""),setTimeout(function(){$(".cmb2-oembed:focus").val()===oembed_url&&$.ajax({type:"post",dataType:"json",url:l10n.ajaxurl,data:{action:"cmb2_oembed_handler",oembed_url:oembed_url,oembed_width:oembed_width>300?oembed_width:300,field_id:field_id,object_id:$obj.data("objectid"),object_type:$obj.data("objecttype"),cmb2_ajax_nonce:l10n.ajax_nonce},success:function(response){cmb.log(response),cmb.spinner($context,!0),$embed_wrap.html(response.data)}})},500)}},$(document).ready(cmb.init),cmb}(window,document,jQuery); \ No newline at end of file +window.CMB2=function(e,t,i){"use strict";var a=e.cmb2_l10,r=e.setTimeout,n={formfield:"",idNumber:!1,file_frames:{},repeatEls:'input:not([type="button"]),select,textarea,.cmb2-media-status',styleBreakPoint:450,mediaHandlers:{},neweditor_id:[],defaults:{time_picker:a.defaults.time_picker,date_picker:a.defaults.date_picker,color_picker:a.defaults.color_picker||{}}},o=function(e){return i(t.getElementById(e))};return n.metabox=function(){return n.$metabox?n.$metabox:(n.$metabox=i(".cmb2-wrap > .cmb2-metabox"),n.$metabox)},n.init=function(){n.log("CMB2 localized data",a);var t=n.metabox(),l=t.find(".cmb-repeatable-group");n.initPickers(t.find('input[type="text"].cmb2-timepicker'),t.find('input[type="text"].cmb2-datepicker'),t.find('input[type="text"].cmb2-colorpicker')),o("ui-datepicker-div").wrap('
    '),i('

    '+a.strings.check_toggle+"

    ").insertBefore(".cmb2-checkbox-list:not(.no-select-all)"),n.makeListSortable(),t.on("change",".cmb2_upload_file",function(){n.formfield=i(this).attr("id"),o(n.formfield+"_id").val("")}).on("click",".cmb-multicheck-toggle",n.toggleCheckBoxes).on("click",".cmb2-upload-button",n.handleMedia).on("click",".cmb-attach-list li, .cmb2-media-status .img-status img, .cmb2-media-status .file-status > span",n.handleFileClick).on("click",".cmb2-remove-file-button",n.handleRemoveMedia).on("click",".cmb-add-group-row",n.addGroupRow).on("click",".cmb-add-row-button",n.addAjaxRow).on("click",".cmb-remove-group-row",n.removeGroupRow).on("click",".cmb-remove-row-button",n.removeAjaxRow).on("keyup paste focusout",".cmb2-oembed",n.maybeOembed).on("cmb2_remove_row",".cmb-repeatable-group",n.resetTitlesAndIterator).on("click",".cmbhandle, .cmbhandle + .cmbhandle-title",n.toggleHandle),l.length&&l.filter(".sortable").each(function(){i(this).find(".button.cmb-remove-group-row").before(' ')}).on("click",".cmb-shift-rows",n.shiftRows).on("cmb2_add_row",n.emptyValue),r(n.resizeoEmbeds,500),i(e).on("resize",n.resizeoEmbeds)},n.resetTitlesAndIterator=function(){i(".cmb-repeatable-group").each(function(){var e=i(this);e.find(".cmb-repeatable-grouping").each(function(t){var a=i(this);a.data("iterator",t),a.find(".cmb-group-title h4").text(e.find(".cmb-add-group-row").data("grouptitle").replace("{#}",t+1))})})},n.toggleHandle=function(e){e.preventDefault(),i(t).trigger("postbox-toggled",i(this).parent(".postbox").toggleClass("closed"))},n.toggleCheckBoxes=function(e){e.preventDefault();var t=i(this),a=t.closest(".cmb-td").find("input[type=checkbox]");t.data("checked")?(a.prop("checked",!1),t.data("checked",!1)):(a.prop("checked",!0),t.data("checked",!0))},n.handleMedia=function(e){e.preventDefault();var t=i(this);n.attach_id=t.hasClass("cmb2-upload-list")?!1:t.closest(".cmb-td").find(".cmb2-upload-file-id").val(),n.attach_id="0"!==n.attach_id?n.attach_id:!1,n._handleMedia(t.prev("input.cmb2-upload-file").attr("id"),t.hasClass("cmb2-upload-list"))},n.handleFileClick=function(e){e.preventDefault();var t=i(this),a=t.closest(".cmb-td"),r=a.find(".cmb2-upload-button").hasClass("cmb2-upload-list");n.attach_id=r?t.find('input[type="hidden"]').data("id"):a.find(".cmb2-upload-file-id").val(),n.attach_id&&n._handleMedia(a.find("input.cmb2-upload-file").attr("id"),r,n.attach_id)},n._handleMedia=function(e,t){if(wp){var r=n.metabox();n.formfield=e;var l=o(n.formfield),d=l.data("previewsize"),s=l.attr("name"),c=!0,m=!0;if(n.formfield in n.file_frames)return void n.file_frames[n.formfield].open();n.file_frames[n.formfield]=wp.media({title:r.find("label[for="+n.formfield+"]").text(),button:{text:a.strings.upload_file},multiple:t?!0:!1}),n.mediaHandlers.list=function(e,t){m=e.toJSON(),l.val(m.url),o(n.formfield+"_id").val(m.id);var r=[];return i(m).each(function(){if(this.type&&"image"===this.type){var e=d[0]?d[0]:50,t=d[1]?d[1]:50;c='
  • '+this.filename+'

    '+a.strings.remove_image+'

  • '}else c='
  • '+a.strings.file+" "+this.filename+'   ('+a.strings.download+' / '+a.strings.remove_file+')
  • ';r.push(c)}),t?r:void i(r).each(function(){l.siblings(".cmb2-media-status").slideDown().append(this)})},n.mediaHandlers.single=function(e){if(m=e.first().toJSON(),l.val(m.url),o(n.formfield+"_id").val(m.id),m.type&&"image"===m.type){var t=d[0]?d[0]:350;c='"}else c='
    '+a.strings.file+" "+m.filename+'   ('+a.strings.download+' / '+a.strings.remove_file+")
    ";l.siblings(".cmb2-media-status").slideDown().html(c)},n.mediaHandlers.selectFile=function(){var e=n.file_frames[n.formfield].state().get("selection"),a=t?"list":"single";return n.attach_id&&t?void i('[data-id="'+n.attach_id+'"]').parents("li").replaceWith(n.mediaHandlers.list(e,!0)):void n.mediaHandlers[a](e)},n.mediaHandlers.openModal=function(){var e=n.file_frames[n.formfield].state().get("selection");if(!n.attach_id)return e.reset();var t=wp.media.attachment(n.attach_id);t.fetch(),e.set(t?[t]:[])},n.file_frames[n.formfield].on("select",n.mediaHandlers.selectFile).on("open",n.mediaHandlers.openModal),n.file_frames[n.formfield].open()}},n.handleRemoveMedia=function(e){e.preventDefault();var t=i(this);return t.is(".cmb-attach-list .cmb2-remove-file-button")?(t.parents("li").remove(),!1):(n.formfield=t.attr("rel"),n.metabox().find("input#"+n.formfield).val(""),n.metabox().find("input#"+n.formfield+"_id").val(""),t.parents(".cmb2-media-status").html(""),!1)},n.cleanRow=function(e,t,a){var r=e.find('input:not([type="button"]), select, textarea, label'),o=e.find("[id]").not('input:not([type="button"]), select, textarea, label');return a&&(e.find(".cmb-repeat-table .cmb-repeat-row:not(:first-child)").remove(),o.length&&o.each(function(){var a=i(this),r=a.attr("id"),o=r.replace("_"+t,"_"+n.idNumber),l=e.find('[data-selector="'+r+'"]');a.attr("id",o),l.length&&l.attr("data-selector",o).data("selector",o)})),n.neweditor_id=[],r.filter(":checked").prop("checked",!1),r.filter(":selected").prop("selected",!1),e.find("h3.cmb-group-title").length&&e.find("h3.cmb-group-title").text(e.data("title").replace("{#}",n.idNumber+1)),r.each(function(){var e,a,r=i(this),o=r.hasClass("wp-editor-area"),l=r.attr("for"),d={};if(l)d={"for":l.replace("_"+t,"_"+n.idNumber)};else{var s=r.attr("name"),c=s?s.replace("["+t+"]","["+n.idNumber+"]"):"";a=r.attr("id"),e=a?a.replace("_"+t,"_"+n.idNumber):"",d={id:e,name:c,"data-iterator":n.idNumber}}if(r.removeClass("hasDatepicker").attr(d).val(""),o){e=e?a.replace("zx"+t,"zx"+n.idNumber):"",r.html("");var m=r.parents(".cmb-type-wysiwyg");m.find(".mce-tinymce:not(:first-child)").remove();var p=m.html().replace(new RegExp(a,"g"),e);m.html(p),n.neweditor_id.push({id:e,old:a})}}),n},n.newRowHousekeeping=function(e){var t=e.find(".wp-picker-container"),a=e.find(".cmb2-media-status");return t.length&&t.each(function(){var e=i(this).parent();e.html(e.find('input[type="text"].cmb2-colorpicker').attr("style",""))}),a.length&&a.empty(),n},n.afterRowInsert=function(e){var t;if(n.neweditor_id.length){var i;for(i=n.neweditor_id.length-1;i>=0;i--){var a=n.neweditor_id[i].id,r=n.neweditor_id[i].old;if("undefined"==typeof tinyMCEPreInit.mceInit[a]){var o=jQuery.extend({},tinyMCEPreInit.mceInit[r]);for(t in o)"string"==typeof o[t]&&(o[t]=o[t].replace(new RegExp(r,"g"),a));tinyMCEPreInit.mceInit[a]=o}if("undefined"==typeof tinyMCEPreInit.qtInit[a]){var l=jQuery.extend({},tinyMCEPreInit.qtInit[r]);for(t in l)"string"==typeof l[t]&&(l[t]=l[t].replace(new RegExp(r,"g"),a));tinyMCEPreInit.qtInit[a]=l}tinyMCE.init({id:tinyMCEPreInit.mceInit[a]})}}n.initPickers(e.find('input[type="text"].cmb2-timepicker'),e.find('input[type="text"].cmb2-datepicker'),e.find('input[type="text"].cmb2-colorpicker'))},n.updateNameAttr=function(){var e=i(this),t=e.attr("name");if("undefined"==typeof t)return!1;var a=parseInt(e.parents(".cmb-repeatable-grouping").data("iterator")),r=a-1,n=t.replace("["+a+"]","["+r+"]");e.attr("name",n)},n.emptyValue=function(e,t){i('input:not([type="button"]), textarea',t).val("")},n.addGroupRow=function(e){e.preventDefault();var t=i(this);t.trigger("cmb2_add_group_row_start",t);var a=o(t.data("selector")),r=a.find(".cmb-repeatable-grouping").last(),l=parseInt(r.data("iterator"));n.idNumber=l+1;var d=r.clone();n.newRowHousekeeping(d.data("title",t.data("grouptitle"))).cleanRow(d,l,!0),d.find(".cmb-add-row-button").prop("disabled",!1);var s=i('
    '+d.html()+"
    ");r.after(s),n.afterRowInsert(s),a.find(".cmb-repeatable-grouping").length<=1?a.find(".cmb-remove-group-row").prop("disabled",!0):a.find(".cmb-remove-group-row").prop("disabled",!1),a.trigger("cmb2_add_row",s)},n.addAjaxRow=function(e){e.preventDefault();var t=i(this),a=o(t.data("selector")),r=a.find(".empty-row"),l=parseInt(r.find("[data-iterator]").data("iterator"));n.idNumber=l+1;var d=r.clone();n.newRowHousekeeping(d).cleanRow(d,l),r.removeClass("empty-row hidden").addClass("cmb-repeat-row"),r.after(d),n.afterRowInsert(d),a.trigger("cmb2_add_row",d),a.find(".cmb-remove-row-button").removeClass("button-disabled")},n.removeGroupRow=function(e){e.preventDefault();var t=i(this),a=o(t.data("selector")),r=t.parents(".cmb-repeatable-grouping"),l=a.find(".cmb-repeatable-grouping").length;l>1&&(a.trigger("cmb2_remove_group_row_start",t),r.nextAll(".cmb-repeatable-grouping").find(n.repeatEls).each(n.updateNameAttr),r.remove(),2>=l?a.find(".cmb-remove-group-row").prop("disabled",!0):a.find(".cmb-remove-group-row").prop("disabled",!1),a.trigger("cmb2_remove_row"))},n.removeAjaxRow=function(e){e.preventDefault();var t=i(this);if(!t.hasClass("button-disabled")){var a=t.parents(".cmb-row"),r=t.parents(".cmb-repeat-table"),n=r.find(".cmb-row").length;n>2?(a.hasClass("empty-row")&&a.prev().addClass("empty-row").removeClass("cmb-repeat-row"),t.parents(".cmb-repeat-table .cmb-row").remove(),3===n&&r.find(".cmb-remove-row-button").addClass("button-disabled"),r.trigger("cmb2_remove_row")):t.addClass("button-disabled")}},n.shiftRows=function(e){e.preventDefault();var t=i(this);t.trigger("cmb2_shift_rows_enter",t);var a=t.parents(".cmb-repeatable-grouping"),r=t.hasClass("move-up")?a.prev(".cmb-repeatable-grouping"):a.next(".cmb-repeatable-grouping");if(r.length){t.trigger("cmb2_shift_rows_start",t);var o=[];a.find(n.repeatEls).each(function(){var e,t=i(this);e=t.hasClass("cmb2-media-status")?t.html():"checkbox"===t.attr("type")||"radio"===t.attr("type")?t.is(":checked"):"select"===t.prop("tagName")?t.is(":selected"):t.val(),o.push({val:e,$:t})}),r.find(n.repeatEls).each(function(e){var t,a=i(this);a.hasClass("cmb2-media-status")?(t=a.html(),a.html(o[e].val),o[e].$.html(t)):"checkbox"===a.attr("type")||"radio"===a.attr("type")?(o[e].$.prop("checked",a.is(":checked")),a.prop("checked",o[e].val)):"select"===a.prop("tagName")?(o[e].$.prop("selected",a.is(":selected")),a.prop("selected",o[e].val)):(o[e].$.val(a.val()),a.val(o[e].val))}),t.trigger("cmb2_shift_rows_complete",t)}},n.initPickers=function(e,t,i){n.initTimePickers(e),n.initDatePickers(t),n.initColorPickers(i)},n.initTimePickers=function(e){e.length&&(e.timepicker("destroy"),e.timepicker(n.defaults.time_picker))},n.initDatePickers=function(e){e.length&&e.each(function(){var e=n.defaults.date_picker;i(this).datepicker("destroy");var t=i(this).data("datepicker");i.extend(e,t),i(this).datepicker(e)})},n.initColorPickers=function(e){e.length&&("object"==typeof jQuery.wp&&"function"==typeof jQuery.wp.wpColorPicker?e.wpColorPicker(n.defaults.color_picker):e.each(function(e){i(this).after('
    '),o("picker-"+e).hide().farbtastic(i(this))}).focus(function(){i(this).next().show()}).blur(function(){i(this).next().hide()}))},n.makeListSortable=function(){var e=n.metabox().find(".cmb2-media-status.cmb-attach-list");e.length&&e.sortable({cursor:"move"}).disableSelection()},n.maybeOembed=function(e){var t=i(this),a=e.type,o={focusout:function(){r(function(){n.spinner(".postbox .cmb2-metabox",!0)},2e3)},keyup:function(){var i=function(t,i){return e.which<=i&&e.which>=t};(i(48,90)||i(96,111)||i(8,9)||187===e.which||190===e.which)&&n.doAjax(t,e)},paste:function(){r(function(){n.doAjax(t)},100)}};o[a]()},n.resizeoEmbeds=function(){n.metabox().each(function(){var e=i(this),t=e.parents(".inside"),a=e.parents(".inner-sidebar").length||e.parents("#side-sortables").length,r=a,o=!1;if(!t.length)return!0;var l=t.width();n.styleBreakPoint>l&&(r=!0,o=n.styleBreakPoint-62>l),l=r?l:Math.round(.82*t.width()*.97);var d=l-30;if(!r||a||o||(d-=75),d>639)return!0;var s=e.find(".cmb-type-oembed .embed-status"),c=s.children().not(".cmb2-remove-wrapper");return c.length?void c.each(function(){var e=i(this),t=e.width(),a=e.height(),n=d;e.parents(".cmb-repeat-row").length&&!r&&(n=d-91,n=785>l?n-15:n);var o=Math.round(n*a/t);e.width(n).height(o)}):!0})},n.log=function(){a.script_debug&&console&&"function"==typeof console.log&&console.log.apply(console,arguments)},n.spinner=function(e,t){t?i(".cmb-spinner",e).hide():i(".cmb-spinner",e).show()},n.doAjax=function(e){var t=e.val();if(!(t.length<6)){var o=e.attr("id"),l=e.closest(".cmb-td"),d=l.find(".embed-status"),s=l.find(".embed_wrap"),c=d.find(":first-child"),m=d.length&&c.length?c.width():e.width();n.log("oembed_url",t,o),n.spinner(l),s.html(""),r(function(){i(".cmb2-oembed:focus").val()===t&&i.ajax({type:"post",dataType:"json",url:a.ajaxurl,data:{action:"cmb2_oembed_handler",oembed_url:t,oembed_width:m>300?m:300,field_id:o,object_id:e.data("objectid"),object_type:e.data("objecttype"),cmb2_ajax_nonce:a.ajax_nonce},success:function(e){n.log(e),n.spinner(l,!0),s.html(e.data)}})},500)}},i(t).ready(n.init),n}(window,document,jQuery); \ No newline at end of file From 128cecb8035cf55335d25a78ea3cf82609b7fb5c Mon Sep 17 00:00:00 2001 From: yivi Date: Fri, 8 May 2015 17:57:15 +0200 Subject: [PATCH 04/20] function to convert between php date-format options, and js date-format options for the datepickers --- includes/CMB2_Utils.php | 47 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/includes/CMB2_Utils.php b/includes/CMB2_Utils.php index 6fe323202..bc7f82770 100644 --- a/includes/CMB2_Utils.php +++ b/includes/CMB2_Utils.php @@ -178,4 +178,51 @@ public function url( $path = '' ) { return $this->url . $path; } + + /** + * Takes a php date() format string and returns a string formatted to suit for the date/time pickers + * It will work with only with the following subset ot date() options: + * + * d, j, z, m, n, y, and Y. + * + * A slight effort is made to deal with escaped characters. + * + * Other options are ignored, because they would either bring compatibility problems between PHP and JS, or + * bring even more translation troubles. + * + * @since 2.0.6 + * + * @param string $format php date format + * + * @return string reformatted string + */ + public function php_to_js_dateformat( $format ) { + + // order is relevant here, since the replacement will be done sequentially. + $supported_options = [ + 'd' => 'dd', // Day, leading 0 + 'j' => 'd', // Day, no 0 + 'z' => 'o', // Day of the year, no leading zeroes, + // 'D' => 'D', // Day name short, not sure how it'll work with translations + // 'l' => 'DD', // Day name full, idem before + 'm' => 'mm', // Month of the year, leading 0 + 'n' => 'm', // Month of the year, no leading 0 + // 'M' => 'M', // Month, Short name + // 'F' => 'MM', // Month, full name, + 'y' => 'y', // Year, two digit + 'Y' => 'yy', // Year, full + ]; + + foreach ( $supported_options as $php => $js ) { + // replaces every instance of a supported option, but skips escaped characters + $format = preg_replace( "~(? Date: Fri, 8 May 2015 17:58:08 +0200 Subject: [PATCH 05/20] stripslashes in format_timestamp made it so you couldn't insert escape characters into your date-format string --- includes/CMB2_Field.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/CMB2_Field.php b/includes/CMB2_Field.php index 9afeb7fec..914dc7209 100644 --- a/includes/CMB2_Field.php +++ b/includes/CMB2_Field.php @@ -631,7 +631,7 @@ public function field_timezone() { * @return string Formatted date */ public function format_timestamp( $meta_value, $format = 'date_format' ) { - return date( stripslashes( $this->args( $format ) ), $meta_value ); + return date( $this->args( $format ) , $meta_value ); } /** From d3d8c2383acdaae9b2cf209baf8b62251c481e0e Mon Sep 17 00:00:00 2001 From: yivi Date: Fri, 8 May 2015 18:42:46 +0200 Subject: [PATCH 06/20] Aditional options to convert time formats from php to js --- includes/CMB2_Utils.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/includes/CMB2_Utils.php b/includes/CMB2_Utils.php index bc7f82770..4db709865 100644 --- a/includes/CMB2_Utils.php +++ b/includes/CMB2_Utils.php @@ -211,6 +211,14 @@ public function php_to_js_dateformat( $format ) { // 'F' => 'MM', // Month, full name, 'y' => 'y', // Year, two digit 'Y' => 'yy', // Year, full + 'H' => 'HH', // Hour with leading 0 (24 hour) + 'G' => 'H', // Hour with no leading 0 (24 hour) + 'h' => 'hh', // Hour with leading 0 (12 hour) + 'g' => 'h', // Hour with no leading 0 (12 hour), + 'i' => 'mm', // Minute with leading 0, + 's' => 'ss', // Second with leading 0, + 'a' => 'tt', // am/pm + 'A' => 'TT' // AM/PM ]; foreach ( $supported_options as $php => $js ) { From 35bb37fed77ae5f440ddd75c79e47d29aee62669 Mon Sep 17 00:00:00 2001 From: yivi Date: Fri, 8 May 2015 18:52:57 +0200 Subject: [PATCH 07/20] time-format options are recognized by the time-picker (using a data attribute as in date-picker) --- includes/CMB2_Types.php | 5 ++++- js/cmb2.js | 20 +++++++++++++------- js/cmb2.min.js | 2 +- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/includes/CMB2_Types.php b/includes/CMB2_Types.php index 8448ed4c3..07f57ce85 100644 --- a/includes/CMB2_Types.php +++ b/includes/CMB2_Types.php @@ -514,10 +514,13 @@ public function text_date_timestamp( $args = array() ) { } public function text_time( $args = array() ) { + $timeFormat = cmb2_utils()->php_to_js_dateformat( $this->field->args( 'time_format' ) ); + $args = wp_parse_args( $args, array( 'class' => 'cmb2-timepicker text-time', - 'value' => $this->field->get_timestamp_format( 'time_format' ), + 'value' => $this->field->escaped_value(), 'desc' => $this->_desc(), + 'data-timepicker' => '{ "timeFormat": "' . $timeFormat . '" }' ) ); return $this->input( $args ); diff --git a/js/cmb2.js b/js/cmb2.js index 686c6b02e..4858071e7 100755 --- a/js/cmb2.js +++ b/js/cmb2.js @@ -665,14 +665,20 @@ window.CMB2 = (function(window, document, $, undefined){ cmb.initColorPickers( $colorPickers ); }; - cmb.initTimePickers = function( $selector ) { - if ( ! $selector.length ) { - return; - } + cmb.initTimePickers = function( $selector ) { + if ( ! $selector.length ) { + return; + } - $selector.timepicker( 'destroy' ); - $selector.timepicker( cmb.defaults.time_picker ); - }; + $selector.each(function() { + var options = cmb.defaults.time_picker; + $(this).timepicker( 'destroy' ); + var additionalOptions = $(this).data("timepicker"); + $.extend( options, additionalOptions ); + $(this).timepicker( options ); + }); + + }; cmb.initDatePickers = function( $selector ) { if ( ! $selector.length ) { diff --git a/js/cmb2.min.js b/js/cmb2.min.js index d790f0285..c204ae946 100644 --- a/js/cmb2.min.js +++ b/js/cmb2.min.js @@ -1 +1 @@ -window.CMB2=function(e,t,i){"use strict";var a=e.cmb2_l10,r=e.setTimeout,n={formfield:"",idNumber:!1,file_frames:{},repeatEls:'input:not([type="button"]),select,textarea,.cmb2-media-status',styleBreakPoint:450,mediaHandlers:{},neweditor_id:[],defaults:{time_picker:a.defaults.time_picker,date_picker:a.defaults.date_picker,color_picker:a.defaults.color_picker||{}}},o=function(e){return i(t.getElementById(e))};return n.metabox=function(){return n.$metabox?n.$metabox:(n.$metabox=i(".cmb2-wrap > .cmb2-metabox"),n.$metabox)},n.init=function(){n.log("CMB2 localized data",a);var t=n.metabox(),l=t.find(".cmb-repeatable-group");n.initPickers(t.find('input[type="text"].cmb2-timepicker'),t.find('input[type="text"].cmb2-datepicker'),t.find('input[type="text"].cmb2-colorpicker')),o("ui-datepicker-div").wrap('
    '),i('

    '+a.strings.check_toggle+"

    ").insertBefore(".cmb2-checkbox-list:not(.no-select-all)"),n.makeListSortable(),t.on("change",".cmb2_upload_file",function(){n.formfield=i(this).attr("id"),o(n.formfield+"_id").val("")}).on("click",".cmb-multicheck-toggle",n.toggleCheckBoxes).on("click",".cmb2-upload-button",n.handleMedia).on("click",".cmb-attach-list li, .cmb2-media-status .img-status img, .cmb2-media-status .file-status > span",n.handleFileClick).on("click",".cmb2-remove-file-button",n.handleRemoveMedia).on("click",".cmb-add-group-row",n.addGroupRow).on("click",".cmb-add-row-button",n.addAjaxRow).on("click",".cmb-remove-group-row",n.removeGroupRow).on("click",".cmb-remove-row-button",n.removeAjaxRow).on("keyup paste focusout",".cmb2-oembed",n.maybeOembed).on("cmb2_remove_row",".cmb-repeatable-group",n.resetTitlesAndIterator).on("click",".cmbhandle, .cmbhandle + .cmbhandle-title",n.toggleHandle),l.length&&l.filter(".sortable").each(function(){i(this).find(".button.cmb-remove-group-row").before(' ')}).on("click",".cmb-shift-rows",n.shiftRows).on("cmb2_add_row",n.emptyValue),r(n.resizeoEmbeds,500),i(e).on("resize",n.resizeoEmbeds)},n.resetTitlesAndIterator=function(){i(".cmb-repeatable-group").each(function(){var e=i(this);e.find(".cmb-repeatable-grouping").each(function(t){var a=i(this);a.data("iterator",t),a.find(".cmb-group-title h4").text(e.find(".cmb-add-group-row").data("grouptitle").replace("{#}",t+1))})})},n.toggleHandle=function(e){e.preventDefault(),i(t).trigger("postbox-toggled",i(this).parent(".postbox").toggleClass("closed"))},n.toggleCheckBoxes=function(e){e.preventDefault();var t=i(this),a=t.closest(".cmb-td").find("input[type=checkbox]");t.data("checked")?(a.prop("checked",!1),t.data("checked",!1)):(a.prop("checked",!0),t.data("checked",!0))},n.handleMedia=function(e){e.preventDefault();var t=i(this);n.attach_id=t.hasClass("cmb2-upload-list")?!1:t.closest(".cmb-td").find(".cmb2-upload-file-id").val(),n.attach_id="0"!==n.attach_id?n.attach_id:!1,n._handleMedia(t.prev("input.cmb2-upload-file").attr("id"),t.hasClass("cmb2-upload-list"))},n.handleFileClick=function(e){e.preventDefault();var t=i(this),a=t.closest(".cmb-td"),r=a.find(".cmb2-upload-button").hasClass("cmb2-upload-list");n.attach_id=r?t.find('input[type="hidden"]').data("id"):a.find(".cmb2-upload-file-id").val(),n.attach_id&&n._handleMedia(a.find("input.cmb2-upload-file").attr("id"),r,n.attach_id)},n._handleMedia=function(e,t){if(wp){var r=n.metabox();n.formfield=e;var l=o(n.formfield),d=l.data("previewsize"),s=l.attr("name"),c=!0,m=!0;if(n.formfield in n.file_frames)return void n.file_frames[n.formfield].open();n.file_frames[n.formfield]=wp.media({title:r.find("label[for="+n.formfield+"]").text(),button:{text:a.strings.upload_file},multiple:t?!0:!1}),n.mediaHandlers.list=function(e,t){m=e.toJSON(),l.val(m.url),o(n.formfield+"_id").val(m.id);var r=[];return i(m).each(function(){if(this.type&&"image"===this.type){var e=d[0]?d[0]:50,t=d[1]?d[1]:50;c='
  • '+this.filename+'

    '+a.strings.remove_image+'

  • '}else c='
  • '+a.strings.file+" "+this.filename+'   ('+a.strings.download+' / '+a.strings.remove_file+')
  • ';r.push(c)}),t?r:void i(r).each(function(){l.siblings(".cmb2-media-status").slideDown().append(this)})},n.mediaHandlers.single=function(e){if(m=e.first().toJSON(),l.val(m.url),o(n.formfield+"_id").val(m.id),m.type&&"image"===m.type){var t=d[0]?d[0]:350;c='"}else c='
    '+a.strings.file+" "+m.filename+'   ('+a.strings.download+' / '+a.strings.remove_file+")
    ";l.siblings(".cmb2-media-status").slideDown().html(c)},n.mediaHandlers.selectFile=function(){var e=n.file_frames[n.formfield].state().get("selection"),a=t?"list":"single";return n.attach_id&&t?void i('[data-id="'+n.attach_id+'"]').parents("li").replaceWith(n.mediaHandlers.list(e,!0)):void n.mediaHandlers[a](e)},n.mediaHandlers.openModal=function(){var e=n.file_frames[n.formfield].state().get("selection");if(!n.attach_id)return e.reset();var t=wp.media.attachment(n.attach_id);t.fetch(),e.set(t?[t]:[])},n.file_frames[n.formfield].on("select",n.mediaHandlers.selectFile).on("open",n.mediaHandlers.openModal),n.file_frames[n.formfield].open()}},n.handleRemoveMedia=function(e){e.preventDefault();var t=i(this);return t.is(".cmb-attach-list .cmb2-remove-file-button")?(t.parents("li").remove(),!1):(n.formfield=t.attr("rel"),n.metabox().find("input#"+n.formfield).val(""),n.metabox().find("input#"+n.formfield+"_id").val(""),t.parents(".cmb2-media-status").html(""),!1)},n.cleanRow=function(e,t,a){var r=e.find('input:not([type="button"]), select, textarea, label'),o=e.find("[id]").not('input:not([type="button"]), select, textarea, label');return a&&(e.find(".cmb-repeat-table .cmb-repeat-row:not(:first-child)").remove(),o.length&&o.each(function(){var a=i(this),r=a.attr("id"),o=r.replace("_"+t,"_"+n.idNumber),l=e.find('[data-selector="'+r+'"]');a.attr("id",o),l.length&&l.attr("data-selector",o).data("selector",o)})),n.neweditor_id=[],r.filter(":checked").prop("checked",!1),r.filter(":selected").prop("selected",!1),e.find("h3.cmb-group-title").length&&e.find("h3.cmb-group-title").text(e.data("title").replace("{#}",n.idNumber+1)),r.each(function(){var e,a,r=i(this),o=r.hasClass("wp-editor-area"),l=r.attr("for"),d={};if(l)d={"for":l.replace("_"+t,"_"+n.idNumber)};else{var s=r.attr("name"),c=s?s.replace("["+t+"]","["+n.idNumber+"]"):"";a=r.attr("id"),e=a?a.replace("_"+t,"_"+n.idNumber):"",d={id:e,name:c,"data-iterator":n.idNumber}}if(r.removeClass("hasDatepicker").attr(d).val(""),o){e=e?a.replace("zx"+t,"zx"+n.idNumber):"",r.html("");var m=r.parents(".cmb-type-wysiwyg");m.find(".mce-tinymce:not(:first-child)").remove();var p=m.html().replace(new RegExp(a,"g"),e);m.html(p),n.neweditor_id.push({id:e,old:a})}}),n},n.newRowHousekeeping=function(e){var t=e.find(".wp-picker-container"),a=e.find(".cmb2-media-status");return t.length&&t.each(function(){var e=i(this).parent();e.html(e.find('input[type="text"].cmb2-colorpicker').attr("style",""))}),a.length&&a.empty(),n},n.afterRowInsert=function(e){var t;if(n.neweditor_id.length){var i;for(i=n.neweditor_id.length-1;i>=0;i--){var a=n.neweditor_id[i].id,r=n.neweditor_id[i].old;if("undefined"==typeof tinyMCEPreInit.mceInit[a]){var o=jQuery.extend({},tinyMCEPreInit.mceInit[r]);for(t in o)"string"==typeof o[t]&&(o[t]=o[t].replace(new RegExp(r,"g"),a));tinyMCEPreInit.mceInit[a]=o}if("undefined"==typeof tinyMCEPreInit.qtInit[a]){var l=jQuery.extend({},tinyMCEPreInit.qtInit[r]);for(t in l)"string"==typeof l[t]&&(l[t]=l[t].replace(new RegExp(r,"g"),a));tinyMCEPreInit.qtInit[a]=l}tinyMCE.init({id:tinyMCEPreInit.mceInit[a]})}}n.initPickers(e.find('input[type="text"].cmb2-timepicker'),e.find('input[type="text"].cmb2-datepicker'),e.find('input[type="text"].cmb2-colorpicker'))},n.updateNameAttr=function(){var e=i(this),t=e.attr("name");if("undefined"==typeof t)return!1;var a=parseInt(e.parents(".cmb-repeatable-grouping").data("iterator")),r=a-1,n=t.replace("["+a+"]","["+r+"]");e.attr("name",n)},n.emptyValue=function(e,t){i('input:not([type="button"]), textarea',t).val("")},n.addGroupRow=function(e){e.preventDefault();var t=i(this);t.trigger("cmb2_add_group_row_start",t);var a=o(t.data("selector")),r=a.find(".cmb-repeatable-grouping").last(),l=parseInt(r.data("iterator"));n.idNumber=l+1;var d=r.clone();n.newRowHousekeeping(d.data("title",t.data("grouptitle"))).cleanRow(d,l,!0),d.find(".cmb-add-row-button").prop("disabled",!1);var s=i('
    '+d.html()+"
    ");r.after(s),n.afterRowInsert(s),a.find(".cmb-repeatable-grouping").length<=1?a.find(".cmb-remove-group-row").prop("disabled",!0):a.find(".cmb-remove-group-row").prop("disabled",!1),a.trigger("cmb2_add_row",s)},n.addAjaxRow=function(e){e.preventDefault();var t=i(this),a=o(t.data("selector")),r=a.find(".empty-row"),l=parseInt(r.find("[data-iterator]").data("iterator"));n.idNumber=l+1;var d=r.clone();n.newRowHousekeeping(d).cleanRow(d,l),r.removeClass("empty-row hidden").addClass("cmb-repeat-row"),r.after(d),n.afterRowInsert(d),a.trigger("cmb2_add_row",d),a.find(".cmb-remove-row-button").removeClass("button-disabled")},n.removeGroupRow=function(e){e.preventDefault();var t=i(this),a=o(t.data("selector")),r=t.parents(".cmb-repeatable-grouping"),l=a.find(".cmb-repeatable-grouping").length;l>1&&(a.trigger("cmb2_remove_group_row_start",t),r.nextAll(".cmb-repeatable-grouping").find(n.repeatEls).each(n.updateNameAttr),r.remove(),2>=l?a.find(".cmb-remove-group-row").prop("disabled",!0):a.find(".cmb-remove-group-row").prop("disabled",!1),a.trigger("cmb2_remove_row"))},n.removeAjaxRow=function(e){e.preventDefault();var t=i(this);if(!t.hasClass("button-disabled")){var a=t.parents(".cmb-row"),r=t.parents(".cmb-repeat-table"),n=r.find(".cmb-row").length;n>2?(a.hasClass("empty-row")&&a.prev().addClass("empty-row").removeClass("cmb-repeat-row"),t.parents(".cmb-repeat-table .cmb-row").remove(),3===n&&r.find(".cmb-remove-row-button").addClass("button-disabled"),r.trigger("cmb2_remove_row")):t.addClass("button-disabled")}},n.shiftRows=function(e){e.preventDefault();var t=i(this);t.trigger("cmb2_shift_rows_enter",t);var a=t.parents(".cmb-repeatable-grouping"),r=t.hasClass("move-up")?a.prev(".cmb-repeatable-grouping"):a.next(".cmb-repeatable-grouping");if(r.length){t.trigger("cmb2_shift_rows_start",t);var o=[];a.find(n.repeatEls).each(function(){var e,t=i(this);e=t.hasClass("cmb2-media-status")?t.html():"checkbox"===t.attr("type")||"radio"===t.attr("type")?t.is(":checked"):"select"===t.prop("tagName")?t.is(":selected"):t.val(),o.push({val:e,$:t})}),r.find(n.repeatEls).each(function(e){var t,a=i(this);a.hasClass("cmb2-media-status")?(t=a.html(),a.html(o[e].val),o[e].$.html(t)):"checkbox"===a.attr("type")||"radio"===a.attr("type")?(o[e].$.prop("checked",a.is(":checked")),a.prop("checked",o[e].val)):"select"===a.prop("tagName")?(o[e].$.prop("selected",a.is(":selected")),a.prop("selected",o[e].val)):(o[e].$.val(a.val()),a.val(o[e].val))}),t.trigger("cmb2_shift_rows_complete",t)}},n.initPickers=function(e,t,i){n.initTimePickers(e),n.initDatePickers(t),n.initColorPickers(i)},n.initTimePickers=function(e){e.length&&(e.timepicker("destroy"),e.timepicker(n.defaults.time_picker))},n.initDatePickers=function(e){e.length&&e.each(function(){var e=n.defaults.date_picker;i(this).datepicker("destroy");var t=i(this).data("datepicker");i.extend(e,t),i(this).datepicker(e)})},n.initColorPickers=function(e){e.length&&("object"==typeof jQuery.wp&&"function"==typeof jQuery.wp.wpColorPicker?e.wpColorPicker(n.defaults.color_picker):e.each(function(e){i(this).after('
    '),o("picker-"+e).hide().farbtastic(i(this))}).focus(function(){i(this).next().show()}).blur(function(){i(this).next().hide()}))},n.makeListSortable=function(){var e=n.metabox().find(".cmb2-media-status.cmb-attach-list");e.length&&e.sortable({cursor:"move"}).disableSelection()},n.maybeOembed=function(e){var t=i(this),a=e.type,o={focusout:function(){r(function(){n.spinner(".postbox .cmb2-metabox",!0)},2e3)},keyup:function(){var i=function(t,i){return e.which<=i&&e.which>=t};(i(48,90)||i(96,111)||i(8,9)||187===e.which||190===e.which)&&n.doAjax(t,e)},paste:function(){r(function(){n.doAjax(t)},100)}};o[a]()},n.resizeoEmbeds=function(){n.metabox().each(function(){var e=i(this),t=e.parents(".inside"),a=e.parents(".inner-sidebar").length||e.parents("#side-sortables").length,r=a,o=!1;if(!t.length)return!0;var l=t.width();n.styleBreakPoint>l&&(r=!0,o=n.styleBreakPoint-62>l),l=r?l:Math.round(.82*t.width()*.97);var d=l-30;if(!r||a||o||(d-=75),d>639)return!0;var s=e.find(".cmb-type-oembed .embed-status"),c=s.children().not(".cmb2-remove-wrapper");return c.length?void c.each(function(){var e=i(this),t=e.width(),a=e.height(),n=d;e.parents(".cmb-repeat-row").length&&!r&&(n=d-91,n=785>l?n-15:n);var o=Math.round(n*a/t);e.width(n).height(o)}):!0})},n.log=function(){a.script_debug&&console&&"function"==typeof console.log&&console.log.apply(console,arguments)},n.spinner=function(e,t){t?i(".cmb-spinner",e).hide():i(".cmb-spinner",e).show()},n.doAjax=function(e){var t=e.val();if(!(t.length<6)){var o=e.attr("id"),l=e.closest(".cmb-td"),d=l.find(".embed-status"),s=l.find(".embed_wrap"),c=d.find(":first-child"),m=d.length&&c.length?c.width():e.width();n.log("oembed_url",t,o),n.spinner(l),s.html(""),r(function(){i(".cmb2-oembed:focus").val()===t&&i.ajax({type:"post",dataType:"json",url:a.ajaxurl,data:{action:"cmb2_oembed_handler",oembed_url:t,oembed_width:m>300?m:300,field_id:o,object_id:e.data("objectid"),object_type:e.data("objecttype"),cmb2_ajax_nonce:a.ajax_nonce},success:function(e){n.log(e),n.spinner(l,!0),s.html(e.data)}})},500)}},i(t).ready(n.init),n}(window,document,jQuery); \ No newline at end of file +window.CMB2=function(e,t,i){"use strict";var a=e.cmb2_l10,r=e.setTimeout,n={formfield:"",idNumber:!1,file_frames:{},repeatEls:'input:not([type="button"]),select,textarea,.cmb2-media-status',styleBreakPoint:450,mediaHandlers:{},neweditor_id:[],defaults:{time_picker:a.defaults.time_picker,date_picker:a.defaults.date_picker,color_picker:a.defaults.color_picker||{}}},o=function(e){return i(t.getElementById(e))};return n.metabox=function(){return n.$metabox?n.$metabox:(n.$metabox=i(".cmb2-wrap > .cmb2-metabox"),n.$metabox)},n.init=function(){n.log("CMB2 localized data",a);var t=n.metabox(),l=t.find(".cmb-repeatable-group");n.initPickers(t.find('input[type="text"].cmb2-timepicker'),t.find('input[type="text"].cmb2-datepicker'),t.find('input[type="text"].cmb2-colorpicker')),o("ui-datepicker-div").wrap('
    '),i('

    '+a.strings.check_toggle+"

    ").insertBefore(".cmb2-checkbox-list:not(.no-select-all)"),n.makeListSortable(),t.on("change",".cmb2_upload_file",function(){n.formfield=i(this).attr("id"),o(n.formfield+"_id").val("")}).on("click",".cmb-multicheck-toggle",n.toggleCheckBoxes).on("click",".cmb2-upload-button",n.handleMedia).on("click",".cmb-attach-list li, .cmb2-media-status .img-status img, .cmb2-media-status .file-status > span",n.handleFileClick).on("click",".cmb2-remove-file-button",n.handleRemoveMedia).on("click",".cmb-add-group-row",n.addGroupRow).on("click",".cmb-add-row-button",n.addAjaxRow).on("click",".cmb-remove-group-row",n.removeGroupRow).on("click",".cmb-remove-row-button",n.removeAjaxRow).on("keyup paste focusout",".cmb2-oembed",n.maybeOembed).on("cmb2_remove_row",".cmb-repeatable-group",n.resetTitlesAndIterator).on("click",".cmbhandle, .cmbhandle + .cmbhandle-title",n.toggleHandle),l.length&&l.filter(".sortable").each(function(){i(this).find(".button.cmb-remove-group-row").before(' ')}).on("click",".cmb-shift-rows",n.shiftRows).on("cmb2_add_row",n.emptyValue),r(n.resizeoEmbeds,500),i(e).on("resize",n.resizeoEmbeds)},n.resetTitlesAndIterator=function(){i(".cmb-repeatable-group").each(function(){var e=i(this);e.find(".cmb-repeatable-grouping").each(function(t){var a=i(this);a.data("iterator",t),a.find(".cmb-group-title h4").text(e.find(".cmb-add-group-row").data("grouptitle").replace("{#}",t+1))})})},n.toggleHandle=function(e){e.preventDefault(),i(t).trigger("postbox-toggled",i(this).parent(".postbox").toggleClass("closed"))},n.toggleCheckBoxes=function(e){e.preventDefault();var t=i(this),a=t.closest(".cmb-td").find("input[type=checkbox]");t.data("checked")?(a.prop("checked",!1),t.data("checked",!1)):(a.prop("checked",!0),t.data("checked",!0))},n.handleMedia=function(e){e.preventDefault();var t=i(this);n.attach_id=t.hasClass("cmb2-upload-list")?!1:t.closest(".cmb-td").find(".cmb2-upload-file-id").val(),n.attach_id="0"!==n.attach_id?n.attach_id:!1,n._handleMedia(t.prev("input.cmb2-upload-file").attr("id"),t.hasClass("cmb2-upload-list"))},n.handleFileClick=function(e){e.preventDefault();var t=i(this),a=t.closest(".cmb-td"),r=a.find(".cmb2-upload-button").hasClass("cmb2-upload-list");n.attach_id=r?t.find('input[type="hidden"]').data("id"):a.find(".cmb2-upload-file-id").val(),n.attach_id&&n._handleMedia(a.find("input.cmb2-upload-file").attr("id"),r,n.attach_id)},n._handleMedia=function(e,t){if(wp){var r=n.metabox();n.formfield=e;var l=o(n.formfield),s=l.data("previewsize"),d=l.attr("name"),c=!0,m=!0;if(n.formfield in n.file_frames)return void n.file_frames[n.formfield].open();n.file_frames[n.formfield]=wp.media({title:r.find("label[for="+n.formfield+"]").text(),button:{text:a.strings.upload_file},multiple:t?!0:!1}),n.mediaHandlers.list=function(e,t){m=e.toJSON(),l.val(m.url),o(n.formfield+"_id").val(m.id);var r=[];return i(m).each(function(){if(this.type&&"image"===this.type){var e=s[0]?s[0]:50,t=s[1]?s[1]:50;c='
  • '+this.filename+'

    '+a.strings.remove_image+'

  • '}else c='
  • '+a.strings.file+" "+this.filename+'   ('+a.strings.download+' / '+a.strings.remove_file+')
  • ';r.push(c)}),t?r:void i(r).each(function(){l.siblings(".cmb2-media-status").slideDown().append(this)})},n.mediaHandlers.single=function(e){if(m=e.first().toJSON(),l.val(m.url),o(n.formfield+"_id").val(m.id),m.type&&"image"===m.type){var t=s[0]?s[0]:350;c='"}else c='
    '+a.strings.file+" "+m.filename+'   ('+a.strings.download+' / '+a.strings.remove_file+")
    ";l.siblings(".cmb2-media-status").slideDown().html(c)},n.mediaHandlers.selectFile=function(){var e=n.file_frames[n.formfield].state().get("selection"),a=t?"list":"single";return n.attach_id&&t?void i('[data-id="'+n.attach_id+'"]').parents("li").replaceWith(n.mediaHandlers.list(e,!0)):void n.mediaHandlers[a](e)},n.mediaHandlers.openModal=function(){var e=n.file_frames[n.formfield].state().get("selection");if(!n.attach_id)return e.reset();var t=wp.media.attachment(n.attach_id);t.fetch(),e.set(t?[t]:[])},n.file_frames[n.formfield].on("select",n.mediaHandlers.selectFile).on("open",n.mediaHandlers.openModal),n.file_frames[n.formfield].open()}},n.handleRemoveMedia=function(e){e.preventDefault();var t=i(this);return t.is(".cmb-attach-list .cmb2-remove-file-button")?(t.parents("li").remove(),!1):(n.formfield=t.attr("rel"),n.metabox().find("input#"+n.formfield).val(""),n.metabox().find("input#"+n.formfield+"_id").val(""),t.parents(".cmb2-media-status").html(""),!1)},n.cleanRow=function(e,t,a){var r=e.find('input:not([type="button"]), select, textarea, label'),o=e.find("[id]").not('input:not([type="button"]), select, textarea, label');return a&&(e.find(".cmb-repeat-table .cmb-repeat-row:not(:first-child)").remove(),o.length&&o.each(function(){var a=i(this),r=a.attr("id"),o=r.replace("_"+t,"_"+n.idNumber),l=e.find('[data-selector="'+r+'"]');a.attr("id",o),l.length&&l.attr("data-selector",o).data("selector",o)})),n.neweditor_id=[],r.filter(":checked").prop("checked",!1),r.filter(":selected").prop("selected",!1),e.find("h3.cmb-group-title").length&&e.find("h3.cmb-group-title").text(e.data("title").replace("{#}",n.idNumber+1)),r.each(function(){var e,a,r=i(this),o=r.hasClass("wp-editor-area"),l=r.attr("for"),s={};if(l)s={"for":l.replace("_"+t,"_"+n.idNumber)};else{var d=r.attr("name"),c=d?d.replace("["+t+"]","["+n.idNumber+"]"):"";a=r.attr("id"),e=a?a.replace("_"+t,"_"+n.idNumber):"",s={id:e,name:c,"data-iterator":n.idNumber}}if(r.removeClass("hasDatepicker").attr(s).val(""),o){e=e?a.replace("zx"+t,"zx"+n.idNumber):"",r.html("");var m=r.parents(".cmb-type-wysiwyg");m.find(".mce-tinymce:not(:first-child)").remove();var p=m.html().replace(new RegExp(a,"g"),e);m.html(p),n.neweditor_id.push({id:e,old:a})}}),n},n.newRowHousekeeping=function(e){var t=e.find(".wp-picker-container"),a=e.find(".cmb2-media-status");return t.length&&t.each(function(){var e=i(this).parent();e.html(e.find('input[type="text"].cmb2-colorpicker').attr("style",""))}),a.length&&a.empty(),n},n.afterRowInsert=function(e){var t;if(n.neweditor_id.length){var i;for(i=n.neweditor_id.length-1;i>=0;i--){var a=n.neweditor_id[i].id,r=n.neweditor_id[i].old;if("undefined"==typeof tinyMCEPreInit.mceInit[a]){var o=jQuery.extend({},tinyMCEPreInit.mceInit[r]);for(t in o)"string"==typeof o[t]&&(o[t]=o[t].replace(new RegExp(r,"g"),a));tinyMCEPreInit.mceInit[a]=o}if("undefined"==typeof tinyMCEPreInit.qtInit[a]){var l=jQuery.extend({},tinyMCEPreInit.qtInit[r]);for(t in l)"string"==typeof l[t]&&(l[t]=l[t].replace(new RegExp(r,"g"),a));tinyMCEPreInit.qtInit[a]=l}tinyMCE.init({id:tinyMCEPreInit.mceInit[a]})}}n.initPickers(e.find('input[type="text"].cmb2-timepicker'),e.find('input[type="text"].cmb2-datepicker'),e.find('input[type="text"].cmb2-colorpicker'))},n.updateNameAttr=function(){var e=i(this),t=e.attr("name");if("undefined"==typeof t)return!1;var a=parseInt(e.parents(".cmb-repeatable-grouping").data("iterator")),r=a-1,n=t.replace("["+a+"]","["+r+"]");e.attr("name",n)},n.emptyValue=function(e,t){i('input:not([type="button"]), textarea',t).val("")},n.addGroupRow=function(e){e.preventDefault();var t=i(this);t.trigger("cmb2_add_group_row_start",t);var a=o(t.data("selector")),r=a.find(".cmb-repeatable-grouping").last(),l=parseInt(r.data("iterator"));n.idNumber=l+1;var s=r.clone();n.newRowHousekeeping(s.data("title",t.data("grouptitle"))).cleanRow(s,l,!0),s.find(".cmb-add-row-button").prop("disabled",!1);var d=i('
    '+s.html()+"
    ");r.after(d),n.afterRowInsert(d),a.find(".cmb-repeatable-grouping").length<=1?a.find(".cmb-remove-group-row").prop("disabled",!0):a.find(".cmb-remove-group-row").prop("disabled",!1),a.trigger("cmb2_add_row",d)},n.addAjaxRow=function(e){e.preventDefault();var t=i(this),a=o(t.data("selector")),r=a.find(".empty-row"),l=parseInt(r.find("[data-iterator]").data("iterator"));n.idNumber=l+1;var s=r.clone();n.newRowHousekeeping(s).cleanRow(s,l),r.removeClass("empty-row hidden").addClass("cmb-repeat-row"),r.after(s),n.afterRowInsert(s),a.trigger("cmb2_add_row",s),a.find(".cmb-remove-row-button").removeClass("button-disabled")},n.removeGroupRow=function(e){e.preventDefault();var t=i(this),a=o(t.data("selector")),r=t.parents(".cmb-repeatable-grouping"),l=a.find(".cmb-repeatable-grouping").length;l>1&&(a.trigger("cmb2_remove_group_row_start",t),r.nextAll(".cmb-repeatable-grouping").find(n.repeatEls).each(n.updateNameAttr),r.remove(),2>=l?a.find(".cmb-remove-group-row").prop("disabled",!0):a.find(".cmb-remove-group-row").prop("disabled",!1),a.trigger("cmb2_remove_row"))},n.removeAjaxRow=function(e){e.preventDefault();var t=i(this);if(!t.hasClass("button-disabled")){var a=t.parents(".cmb-row"),r=t.parents(".cmb-repeat-table"),n=r.find(".cmb-row").length;n>2?(a.hasClass("empty-row")&&a.prev().addClass("empty-row").removeClass("cmb-repeat-row"),t.parents(".cmb-repeat-table .cmb-row").remove(),3===n&&r.find(".cmb-remove-row-button").addClass("button-disabled"),r.trigger("cmb2_remove_row")):t.addClass("button-disabled")}},n.shiftRows=function(e){e.preventDefault();var t=i(this);t.trigger("cmb2_shift_rows_enter",t);var a=t.parents(".cmb-repeatable-grouping"),r=t.hasClass("move-up")?a.prev(".cmb-repeatable-grouping"):a.next(".cmb-repeatable-grouping");if(r.length){t.trigger("cmb2_shift_rows_start",t);var o=[];a.find(n.repeatEls).each(function(){var e,t=i(this);e=t.hasClass("cmb2-media-status")?t.html():"checkbox"===t.attr("type")||"radio"===t.attr("type")?t.is(":checked"):"select"===t.prop("tagName")?t.is(":selected"):t.val(),o.push({val:e,$:t})}),r.find(n.repeatEls).each(function(e){var t,a=i(this);a.hasClass("cmb2-media-status")?(t=a.html(),a.html(o[e].val),o[e].$.html(t)):"checkbox"===a.attr("type")||"radio"===a.attr("type")?(o[e].$.prop("checked",a.is(":checked")),a.prop("checked",o[e].val)):"select"===a.prop("tagName")?(o[e].$.prop("selected",a.is(":selected")),a.prop("selected",o[e].val)):(o[e].$.val(a.val()),a.val(o[e].val))}),t.trigger("cmb2_shift_rows_complete",t)}},n.initPickers=function(e,t,i){n.initTimePickers(e),n.initDatePickers(t),n.initColorPickers(i)},n.initTimePickers=function(e){e.length&&e.each(function(){var e=n.defaults.time_picker;i(this).timepicker("destroy");var t=i(this).data("timepicker");i.extend(e,t),i(this).timepicker(e)})},n.initDatePickers=function(e){e.length&&e.each(function(){var e=n.defaults.date_picker;i(this).datepicker("destroy");var t=i(this).data("datepicker");i.extend(e,t),i(this).datepicker(e)})},n.initColorPickers=function(e){e.length&&("object"==typeof jQuery.wp&&"function"==typeof jQuery.wp.wpColorPicker?e.wpColorPicker(n.defaults.color_picker):e.each(function(e){i(this).after('
    '),o("picker-"+e).hide().farbtastic(i(this))}).focus(function(){i(this).next().show()}).blur(function(){i(this).next().hide()}))},n.makeListSortable=function(){var e=n.metabox().find(".cmb2-media-status.cmb-attach-list");e.length&&e.sortable({cursor:"move"}).disableSelection()},n.maybeOembed=function(e){var t=i(this),a=e.type,o={focusout:function(){r(function(){n.spinner(".postbox .cmb2-metabox",!0)},2e3)},keyup:function(){var i=function(t,i){return e.which<=i&&e.which>=t};(i(48,90)||i(96,111)||i(8,9)||187===e.which||190===e.which)&&n.doAjax(t,e)},paste:function(){r(function(){n.doAjax(t)},100)}};o[a]()},n.resizeoEmbeds=function(){n.metabox().each(function(){var e=i(this),t=e.parents(".inside"),a=e.parents(".inner-sidebar").length||e.parents("#side-sortables").length,r=a,o=!1;if(!t.length)return!0;var l=t.width();n.styleBreakPoint>l&&(r=!0,o=n.styleBreakPoint-62>l),l=r?l:Math.round(.82*t.width()*.97);var s=l-30;if(!r||a||o||(s-=75),s>639)return!0;var d=e.find(".cmb-type-oembed .embed-status"),c=d.children().not(".cmb2-remove-wrapper");return c.length?void c.each(function(){var e=i(this),t=e.width(),a=e.height(),n=s;e.parents(".cmb-repeat-row").length&&!r&&(n=s-91,n=785>l?n-15:n);var o=Math.round(n*a/t);e.width(n).height(o)}):!0})},n.log=function(){a.script_debug&&console&&"function"==typeof console.log&&console.log.apply(console,arguments)},n.spinner=function(e,t){t?i(".cmb-spinner",e).hide():i(".cmb-spinner",e).show()},n.doAjax=function(e){var t=e.val();if(!(t.length<6)){var o=e.attr("id"),l=e.closest(".cmb-td"),s=l.find(".embed-status"),d=l.find(".embed_wrap"),c=s.find(":first-child"),m=s.length&&c.length?c.width():e.width();n.log("oembed_url",t,o),n.spinner(l),d.html(""),r(function(){i(".cmb2-oembed:focus").val()===t&&i.ajax({type:"post",dataType:"json",url:a.ajaxurl,data:{action:"cmb2_oembed_handler",oembed_url:t,oembed_width:m>300?m:300,field_id:o,object_id:e.data("objectid"),object_type:e.data("objecttype"),cmb2_ajax_nonce:a.ajax_nonce},success:function(e){n.log(e),n.spinner(l,!0),d.html(e.data)}})},500)}},i(t).ready(n.init),n}(window,document,jQuery); \ No newline at end of file From e0331f520eb4b64834959ba91523b14ac6bbceb7 Mon Sep 17 00:00:00 2001 From: yivi Date: Fri, 8 May 2015 18:59:45 +0200 Subject: [PATCH 08/20] @return missing in some phpdoc blocks --- includes/CMB2_Field.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/includes/CMB2_Field.php b/includes/CMB2_Field.php index 914dc7209..2f8ab5e3c 100644 --- a/includes/CMB2_Field.php +++ b/includes/CMB2_Field.php @@ -245,9 +245,13 @@ public function get_data( $field_id = '', $args = array() ) { /** * Updates metadata/option data + * * @since 1.0.1 + * * @param mixed $new_value Value to update data with * @param bool $single Whether data is an array (add_metadata) + * + * @return bool */ public function update_data( $new_value, $single = true ) { $a = $this->data_args( array( 'single' => $single ) ); @@ -319,8 +323,12 @@ public function update_data( $new_value, $single = true ) { /** * Removes/updates metadata/option data + * * @since 1.0.1 + * * @param string $old Old value + * + * @return array */ public function remove_data( $old = '' ) { $a = $this->data_args( array( 'old' => $old ) ); @@ -540,8 +548,8 @@ public function repeatable_exception( $type ) { /** * Escape the value before output. Defaults to 'esc_attr()' * @since 1.0.1 - * @param mixed $meta_value Meta value * @param callable $func Escaping function (if not esc_attr()) + * @param mixed $meta_value Meta value * @return mixed Final value */ public function escaped_value( $func = 'esc_attr', $meta_value = '' ) { @@ -850,8 +858,12 @@ public function options( $key = '' ) { /** * Fills in empty field parameters with defaults + * * @since 1.1.0 + * * @param array $args Metabox field config array + * + * @return array */ public function _set_field_defaults( $args ) { @@ -929,8 +941,12 @@ public function _set_field_defaults( $args ) { /** * Updates attributes array values unless they exist from the field config array + * * @since 1.1.0 + * * @param array $attrs Array of attributes to update + * + * @return array */ public function maybe_set_attributes( $attrs = array() ) { return wp_parse_args( $this->args['attributes'], $attrs ); From 4edf1f15f4aeb029c4b4218450a7a9c765614b76 Mon Sep 17 00:00:00 2001 From: yivi Date: Fri, 8 May 2015 19:31:21 +0200 Subject: [PATCH 09/20] old style array declaration, to make Travis happy. --- includes/CMB2_Utils.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/CMB2_Utils.php b/includes/CMB2_Utils.php index aac66e2a0..cf0e3bedb 100644 --- a/includes/CMB2_Utils.php +++ b/includes/CMB2_Utils.php @@ -205,7 +205,7 @@ public function url( $path = '' ) { public function php_to_js_dateformat( $format ) { // order is relevant here, since the replacement will be done sequentially. - $supported_options = [ + $supported_options = array( 'd' => 'dd', // Day, leading 0 'j' => 'd', // Day, no 0 'z' => 'o', // Day of the year, no leading zeroes, @@ -225,7 +225,7 @@ public function php_to_js_dateformat( $format ) { 's' => 'ss', // Second with leading 0, 'a' => 'tt', // am/pm 'A' => 'TT' // AM/PM - ]; + ); foreach ( $supported_options as $php => $js ) { // replaces every instance of a supported option, but skips escaped characters From b068a3f5d13492ca5d961d1bc95b6b27f1d5a736 Mon Sep 17 00:00:00 2001 From: yivi Date: Fri, 8 May 2015 22:00:16 +0200 Subject: [PATCH 10/20] Removed anoymous function to satisfy Travis (PHP 5.2) --- includes/CMB2_Utils.php | 4 +--- includes/helper-functions.php | 11 +++++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/includes/CMB2_Utils.php b/includes/CMB2_Utils.php index cf0e3bedb..648c6af8d 100644 --- a/includes/CMB2_Utils.php +++ b/includes/CMB2_Utils.php @@ -232,9 +232,7 @@ public function php_to_js_dateformat( $format ) { $format = preg_replace( "~(?php_to_js_dateformat, because php 5.2 was retarded. + * + * @param $wrap + * + * @return string + */ +function wrap_escaped_chars( $wrapped ) { + return "'" . str_replace( '\\', '', $wrapped[0] ) . "'"; +} \ No newline at end of file From 4df29b445a88cd22e967d664eb386ddc7f285f6a Mon Sep 17 00:00:00 2001 From: yivi Date: Fri, 8 May 2015 22:04:28 +0200 Subject: [PATCH 11/20] Another old style array declaration to satisfy Travis --- includes/CMB2_Sanitize.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/CMB2_Sanitize.php b/includes/CMB2_Sanitize.php index 72b0b9522..7d2ebcc36 100644 --- a/includes/CMB2_Sanitize.php +++ b/includes/CMB2_Sanitize.php @@ -156,7 +156,7 @@ public function colorpicker() { // for repeatable if ( is_array( $this->value ) ) { $check = $this->value; - $this->value = [ ]; + $this->value = array(); foreach ( $check as $key => $val ) { if ( $val && '#' != $val ) { $this->value[ $key ] = esc_attr( $val ); From 70e3b500c1a4ea91687bf8267b5f4d1052654f33 Mon Sep 17 00:00:00 2001 From: yivi Date: Fri, 8 May 2015 22:24:45 +0200 Subject: [PATCH 12/20] Updating tests. Crossing fingers. --- tests/test-cmb-types.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/test-cmb-types.php b/tests/test-cmb-types.php index 2db057923..16374bb87 100644 --- a/tests/test-cmb-types.php +++ b/tests/test-cmb-types.php @@ -360,7 +360,7 @@ public function test_text_date_field_after_value_update() { $value = $field->format_timestamp( strtotime( 'today' ) ); $this->assertHTMLstringsAreEqual( - sprintf( 'This is a description', $value ), + sprintf( "This is a description", $value ), $this->capture_render( array( $type, 'render' ) ) ); @@ -369,7 +369,7 @@ public function test_text_date_field_after_value_update() { public function test_text_time_field_after_value_update() { - update_post_meta( $this->post_id, $this->text_type_field['id'], 'today' ); + update_post_meta( $this->post_id, $this->text_type_field['id'], '12:00 AM' ); $field = $this->get_field_object( 'text_time' ); $type = $this->get_field_type_object( $field ); @@ -377,11 +377,10 @@ public function test_text_time_field_after_value_update() { // Check that time format is set to the default (since we didn't set it) $this->assertEquals( 'h:i A', $field->args( 'time_format' ) ); - $value = $field->format_timestamp( strtotime( 'today' ), 'time_format' ); - + $value = '12:00 AM'; $this->assertHTMLstringsAreEqual( - sprintf( 'This is a description', $value ), + sprintf( "This is a description", $value ), $this->capture_render( array( $type, 'render' ) ) ); @@ -490,7 +489,7 @@ public function test_text_date_timestamp_field_after_value_update() { $formatted_val_to_update = $field->format_timestamp( $val_to_update ); $this->assertHTMLstringsAreEqual( - sprintf( 'This is a description', $formatted_val_to_update ), + sprintf( "This is a description", $formatted_val_to_update ), $this->capture_render( array( $this->get_field_type_object( $field ), 'render' ) ) ); From 0e36e095a26dd39c0ea326a3133d94f8c4557db3 Mon Sep 17 00:00:00 2001 From: yivi Date: Sat, 9 May 2015 12:10:11 +0200 Subject: [PATCH 13/20] yet another new style to old style array declaration --- includes/CMB2_Sanitize.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/includes/CMB2_Sanitize.php b/includes/CMB2_Sanitize.php index 7d2ebcc36..ae7b00f3e 100644 --- a/includes/CMB2_Sanitize.php +++ b/includes/CMB2_Sanitize.php @@ -1,8 +1,9 @@ field->type()}", $override_value, $this->value, @@ -200,8 +204,8 @@ public function text_money() { global $wp_locale; - $search = [ $wp_locale->number_format['thousands_sep'], $wp_locale->number_format['decimal_point'] ]; - $replace = [ '', '.' ]; + $search = array( $wp_locale->number_format['thousands_sep'], $wp_locale->number_format['decimal_point'] ); + $replace = array( '', '.' ); // for repeatable if ( is_array( $this->value ) ) { From 7d5421e83c9abf922e274e163943eb6d0e5aa541 Mon Sep 17 00:00:00 2001 From: yivi Date: Sat, 9 May 2015 12:45:43 +0200 Subject: [PATCH 14/20] yet another new style to old style array declaration... --- includes/CMB2_Sanitize.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/CMB2_Sanitize.php b/includes/CMB2_Sanitize.php index ae7b00f3e..bdb0ae0ec 100644 --- a/includes/CMB2_Sanitize.php +++ b/includes/CMB2_Sanitize.php @@ -227,7 +227,7 @@ public function text_money() { */ public function text_date_timestamp() { if ( is_array( $this->value ) ) { - $returnee = [ ]; + $returnee = array(); foreach ( $this->value as $value ) { $date_object = DateTime::createFromFormat( $this->field->args['date_format'], $value ); $returnee[] = $date_object ? $date_object->setTime( 0, 0, 0 )->getTimeStamp() : ''; From 65ca94021aab82eb0bc3026cee17ab36ed3b202f Mon Sep 17 00:00:00 2001 From: yivi Date: Sat, 9 May 2015 13:07:53 +0200 Subject: [PATCH 15/20] a couple more new style array declarations to 5.2 style --- includes/CMB2_Sanitize.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/CMB2_Sanitize.php b/includes/CMB2_Sanitize.php index bdb0ae0ec..922688dfa 100644 --- a/includes/CMB2_Sanitize.php +++ b/includes/CMB2_Sanitize.php @@ -343,12 +343,12 @@ public function _save_file_id() { unset( $args['_id'], $args['_name'] ); // And get new field object - $field = new CMB2_Field( [ + $field = new CMB2_Field( array( 'field_args' => $args, 'group_field' => $group, 'object_id' => $this->field->object_id, 'object_type' => $this->field->object_type, - ] ); + ) ); $id_key = $field->_id(); $id_val_old = $field->escaped_value( 'absint' ); @@ -411,7 +411,7 @@ public function _check_repeat( $method, $repeat ) { if ( $repeat || ! $this->field->args( 'repeatable' ) ) { return; } - $new_value = [ ]; + $new_value = array(); foreach ( $this->value as $iterator => $val ) { $new_value[] = $this->$method( $val, true ); } From ed179428efab41308c46d58d908a450ef77f8a3e Mon Sep 17 00:00:00 2001 From: yivi Date: Sat, 9 May 2015 13:35:11 +0200 Subject: [PATCH 16/20] and an array declaration in a return statement --- includes/CMB2_Sanitize.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/CMB2_Sanitize.php b/includes/CMB2_Sanitize.php index 922688dfa..2714f87ee 100644 --- a/includes/CMB2_Sanitize.php +++ b/includes/CMB2_Sanitize.php @@ -370,10 +370,10 @@ public function _save_file_id() { } if ( $group ) { - return [ + return array( 'attach_id' => $id_val, 'field_id' => $id_key, - ]; + ); } if ( $id_val && $id_val != $id_val_old ) { From 3be00da25791b80e60056b10ade2ee167c22c49d Mon Sep 17 00:00:00 2001 From: yivi Date: Sat, 9 May 2015 15:07:57 +0200 Subject: [PATCH 17/20] hopefully the last > 5.2 array declaration. :( --- includes/CMB2_Sanitize.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/CMB2_Sanitize.php b/includes/CMB2_Sanitize.php index 2714f87ee..cf295eed0 100644 --- a/includes/CMB2_Sanitize.php +++ b/includes/CMB2_Sanitize.php @@ -394,7 +394,7 @@ public function file() { $clean = $this->text_url( $this->value ); // Return an array with url/id if saving a group field - return $this->field->group ? array_merge( [ 'url' => $clean ], $id_value ) : $clean; + return $this->field->group ? array_merge( array( 'url' => $clean ), $id_value ) : $clean; } /** From 3098d591c603dd0913d01696f7e809bdd2b82361 Mon Sep 17 00:00:00 2001 From: yivi Date: Wed, 10 Jun 2015 17:33:00 +0200 Subject: [PATCH 18/20] proper doc-type for phpdoc in text_date_timestamp --- includes/CMB2_Sanitize.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/CMB2_Sanitize.php b/includes/CMB2_Sanitize.php index cf295eed0..b4e602cc9 100644 --- a/includes/CMB2_Sanitize.php +++ b/includes/CMB2_Sanitize.php @@ -223,7 +223,7 @@ public function text_money() { * Converts text date to timestamp * * @since 1.0.2 - * @return array/int Timestring + * @return array|int Timestring */ public function text_date_timestamp() { if ( is_array( $this->value ) ) { From af4f02af793aa53b8560d5743e7a8acef8371ab5 Mon Sep 17 00:00:00 2001 From: yivi Date: Mon, 13 Jul 2015 19:41:12 +0200 Subject: [PATCH 19/20] removed formatting/docblock changes --- includes/CMB2_Field.php | 20 ++---------- includes/CMB2_Sanitize.php | 65 +++++++++----------------------------- 2 files changed, 17 insertions(+), 68 deletions(-) diff --git a/includes/CMB2_Field.php b/includes/CMB2_Field.php index e33f65cce..24db4ac31 100644 --- a/includes/CMB2_Field.php +++ b/includes/CMB2_Field.php @@ -244,13 +244,9 @@ public function get_data( $field_id = '', $args = array() ) { /** * Updates metadata/option data - * * @since 1.0.1 - * * @param mixed $new_value Value to update data with * @param bool $single Whether data is an array (add_metadata) - * - * @return bool */ public function update_data( $new_value, $single = true ) { $a = $this->data_args( array( 'single' => $single ) ); @@ -319,12 +315,8 @@ public function update_data( $new_value, $single = true ) { /** * Removes/updates metadata/option data - * * @since 1.0.1 - * * @param string $old Old value - * - * @return array */ public function remove_data( $old = '' ) { $a = $this->data_args( array( 'old' => $old ) ); @@ -544,8 +536,8 @@ public function repeatable_exception( $type ) { /** * Escape the value before output. Defaults to 'esc_attr()' * @since 1.0.1 - * @param callable $func Escaping function (if not esc_attr()) * @param mixed $meta_value Meta value + * @param callable $func Escaping function (if not esc_attr()) * @return mixed Final value */ public function escaped_value( $func = 'esc_attr', $meta_value = '' ) { @@ -635,7 +627,7 @@ public function field_timezone() { * @return string Formatted date */ public function format_timestamp( $meta_value, $format = 'date_format' ) { - return date( $this->args( $format ) , $meta_value ); + return date( stripslashes( $this->args( $format ) ), $meta_value ); } /** @@ -873,12 +865,8 @@ public function options( $key = '' ) { /** * Fills in empty field parameters with defaults - * * @since 1.1.0 - * * @param array $args Metabox field config array - * - * @return array */ public function _set_field_defaults( $args ) { @@ -956,12 +944,8 @@ public function _set_field_defaults( $args ) { /** * Updates attributes array values unless they exist from the field config array - * * @since 1.1.0 - * * @param array $attrs Array of attributes to update - * - * @return array */ public function maybe_set_attributes( $attrs = array() ) { return wp_parse_args( $this->args['attributes'], $attrs ); diff --git a/includes/CMB2_Sanitize.php b/includes/CMB2_Sanitize.php index b4e602cc9..be1d07b73 100644 --- a/includes/CMB2_Sanitize.php +++ b/includes/CMB2_Sanitize.php @@ -1,9 +1,8 @@ default_sanitization( $this->value ); @@ -58,7 +49,6 @@ public function __call( $name, $arguments ) { /** * Default fallback sanitization method. Applies filters. - * * @since 1.0.2 */ public function default_sanitization() { @@ -73,21 +63,18 @@ public function default_sanitization() { * * @param bool|mixed $override_value Sanitization/Validation override value to return. * Default false to skip it. - * @param mixed $value The value to be saved to this field. - * @param int $object_id The ID of the object where the value will be saved - * @param array $field_args The current field's arguments - * @param object $sanitizer This `CMB2_Sanitize` object + * @param mixed $value The value to be saved to this field. + * @param int $object_id The ID of the object where the value will be saved + * @param array $field_args The current field's arguments + * @param object $sanitizer This `CMB2_Sanitize` object */ - $override_value = apply_filters( "cmb2_sanitize_{$this->field->type()}", null, $this->value, - $this->field->object_id, $this->field->args(), $this ); + $override_value = apply_filters( "cmb2_sanitize_{$this->field->type()}", null, $this->value, $this->field->object_id, $this->field->args(), $this ); /** * This exists for back-compatibility, but validation * is not what happens here. - * * @deprecated See documentation above. */ - $override_value = apply_filters( "cmb2_validate_{$this->field->type()}", $override_value, $this->value, - $this->field->object_id, $this->field->args(), $this ); + $override_value = apply_filters( "cmb2_validate_{$this->field->type()}", $override_value, $this->value, $this->field->object_id, $this->field->args(), $this ); if ( null !== $override_value ) { return $override_value; @@ -118,8 +105,7 @@ public function default_sanitization() { default: // Handle repeatable fields array // We'll fallback to 'sanitize_text_field' - $sanitized_value = is_array( $this->value ) ? array_map( 'sanitize_text_field', $this->value ) - : call_user_func( 'sanitize_text_field', $this->value ); + $sanitized_value = is_array( $this->value ) ? array_map( 'sanitize_text_field', $this->value ) : call_user_func( 'sanitize_text_field', $this->value ); break; } @@ -128,7 +114,6 @@ public function default_sanitization() { /** * Simple checkbox validation - * * @since 1.0.1 * @return string|false 'on' or false */ @@ -138,7 +123,6 @@ public function checkbox() { /** * Validate url in a meta value - * * @since 1.0.1 * @return string Empty string or escaped url */ @@ -159,7 +143,7 @@ public function text_url() { public function colorpicker() { // for repeatable if ( is_array( $this->value ) ) { - $check = $this->value; + $check = $this->value; $this->value = array(); foreach ( $check as $key => $val ) { if ( $val && '#' != $val ) { @@ -169,13 +153,11 @@ public function colorpicker() { } else { $this->value = ! $this->value || '#' == $this->value ? '' : esc_attr( $this->value ); } - return $this->value; } /** * Validate email in a meta value - * * @since 1.0.1 * @return string Empty string or sanitized email */ @@ -183,7 +165,7 @@ public function text_email() { // for repeatable if ( is_array( $this->value ) ) { foreach ( $this->value as $key => $val ) { - $val = trim( $val ); + $val = trim( $val ); $this->value[ $key ] = is_email( $val ) ? $val : ''; } } else { @@ -196,7 +178,6 @@ public function text_email() { /** * Validate money in a meta value - * * @since 1.0.1 * @return string Empty string or sanitized money value */ @@ -204,7 +185,7 @@ public function text_money() { global $wp_locale; - $search = array( $wp_locale->number_format['thousands_sep'], $wp_locale->number_format['decimal_point'] ); + $search = array( $wp_locale->number_format['thousands_sep'], $wp_locale->number_format['decimal_point'] ); $replace = array( '', '.' ); // for repeatable @@ -221,9 +202,8 @@ public function text_money() { /** * Converts text date to timestamp - * * @since 1.0.2 - * @return array|int Timestring + * @return string Timestring */ public function text_date_timestamp() { if ( is_array( $this->value ) ) { @@ -244,7 +224,6 @@ public function text_date_timestamp() { /** * Datetime to timestamp - * * @since 1.0.1 * @return string Timestring */ @@ -269,8 +248,7 @@ public function text_datetime_timestamp( $repeat = false ) { } /** - * Datetime to timestamp with timezone - * + * Datetime to imestamp with timezone * @since 1.0.1 * @return string Timestring */ @@ -309,7 +287,6 @@ public function text_datetime_timestamp_timezone( $repeat = false ) { /** * Sanitize textareas and wysiwyg fields - * * @since 1.0.1 * @return string Sanitized data */ @@ -319,7 +296,6 @@ public function textarea() { /** * Sanitize code textareas - * * @since 1.0.2 * @return string Sanitized data */ @@ -333,7 +309,6 @@ public function textarea_code( $repeat = false ) { /** * Peforms saving of `file` attachement's ID - * * @since 1.1.0 */ public function _save_file_id() { @@ -385,13 +360,12 @@ public function _save_file_id() { /** * Handles saving of attachment post ID and sanitizing file url - * * @since 1.1.0 * @return string Sanitized url */ public function file() { $id_value = $this->_save_file_id( $this->value ); - $clean = $this->text_url( $this->value ); + $clean = $this->text_url( $this->value ); // Return an array with url/id if saving a group field return $this->field->group ? array_merge( array( 'url' => $clean ), $id_value ) : $clean; @@ -399,12 +373,9 @@ public function file() { /** * If repeating, loop through and re-apply sanitization method - * * @since 1.1.0 - * * @param string $method Class method * @param bool $repeat Whether repeating or not - * * @return mixed Sanitized value */ public function _check_repeat( $method, $repeat ) { @@ -415,26 +386,20 @@ public function _check_repeat( $method, $repeat ) { foreach ( $this->value as $iterator => $val ) { $new_value[] = $this->$method( $val, true ); } - return $new_value; } /** * Determine if passed value is an empty array - * * @since 2.0.6 - * - * @param mixed $to_check Value to check - * + * @param mixed $to_check Value to check * @return boolean Whether value is an array that's empty */ public function _is_empty_array( $to_check ) { if ( is_array( $to_check ) ) { $cleaned_up = array_filter( $to_check ); - return empty( $cleaned_up ); } - return false; } From fe729810df16b97373bb2cd61cf5d6dac12e6121 Mon Sep 17 00:00:00 2001 From: yivi Date: Tue, 14 Jul 2015 20:37:26 +0200 Subject: [PATCH 20/20] Workaround for create_date_from_format not existing in PHP < 5.3 --- includes/CMB2_Sanitize.php | 4 ++-- includes/helper-functions.php | 39 ++++++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/includes/CMB2_Sanitize.php b/includes/CMB2_Sanitize.php index be1d07b73..3765d1690 100644 --- a/includes/CMB2_Sanitize.php +++ b/includes/CMB2_Sanitize.php @@ -209,12 +209,12 @@ public function text_date_timestamp() { if ( is_array( $this->value ) ) { $returnee = array(); foreach ( $this->value as $value ) { - $date_object = DateTime::createFromFormat( $this->field->args['date_format'], $value ); + $date_object = date_create_from_format( $this->field->args['date_format'], $value ); $returnee[] = $date_object ? $date_object->setTime( 0, 0, 0 )->getTimeStamp() : ''; } } else { - $date_object = DateTime::createFromFormat( $this->field->args['date_format'], $this->value ); + $date_object = date_create_from_format( $this->field->args['date_format'], $this->value ); $returnee = $date_object ? $date_object->setTime( 0, 0, 0 )->getTimeStamp() : ''; } diff --git a/includes/helper-functions.php b/includes/helper-functions.php index 229a8341d..e21b794a6 100644 --- a/includes/helper-functions.php +++ b/includes/helper-functions.php @@ -315,4 +315,41 @@ function cmb2_metabox_form( $meta_box, $object_id = 0, $args = array() ) { */ function wrap_escaped_chars( $wrapped ) { return "'" . str_replace( '\\', '', $wrapped[0] ) . "'"; -} \ No newline at end of file +} + + +if( !function_exists("date_create_from_format") ) { + + /** + * Reimplementation of DateTime::createFromFormat for PHP < 5.3. :( + * Borrowed from http://stackoverflow.com/questions/5399075/php-datetimecreatefromformat-in-5-2 + * + * @param $date_format + * @param $date_value + * + * @return DateTime + */ + function date_create_from_format( $date_format, $date_value ) + { + + $schedule_format = str_replace( array( 'M', 'Y', 'm', 'd', 'H', 'i', 'a' ), array('%b', '%Y', '%m', '%d', '%H', '%M', '%p'), $date_format); + // %Y, %m and %d correspond to date()'s Y m and d. + // %I corresponds to H, %M to i and %p to a + $ugly = strptime($date_value, $schedule_format); + $ymd = sprintf( + // This is a format string that takes six total decimal + // arguments, then left-pads them with zeros to either + // 4 or 2 characters, as needed + '%04d-%02d-%02d %02d:%02d:%02d', + $ugly['tm_year'] + 1900, // This will be "111", so we need to add 1900. + $ugly['tm_mon'] + 1, // This will be the month minus one, so we add one. + $ugly['tm_mday'], + $ugly['tm_hour'], + $ugly['tm_min'], + $ugly['tm_sec'] + ); + $new_schedule = new DateTime($ymd); + + return $new_schedule; + } +}