1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 456: 457: 458: 459: 460: 461: 462: 463: 464: 465: 466: 467: 468: 469: 470: 471: 472: 473: 474: 475: 476: 477: 478: 479: 480: 481: 482: 483: 484: 485: 486: 487: 488: 489: 490: 491: 492: 493: 494: 495: 496: 497: 498: 499: 500: 501: 502: 503: 504: 505: 506: 507: 508: 509: 510: 511: 512: 513: 514: 515: 516: 517: 518: 519: 520: 521: 522: 523: 524: 525: 526: 527: 528: 529: 530: 531: 532: 533: 534: 535: 536: 537: 538: 539: 540: 541: 542: 543: 544: 545: 546: 547: 548: 549: 550: 551: 552: 553: 554: 555: 556: 557: 558: 559: 560: 561: 562: 563: 564: 565: 566: 567: 568: 569: 570: 571: 572: 573: 574: 575: 576: 577: 578: 579: 580: 581: 582: 583: 584: 585: 586: 587: 588: 589: 590: 591: 592: 593: 594: 595: 596: 597: 598: 599: 600: 601: 602: 603: 604: 605: 606: 607: 608: 609: 610: 611: 612: 613: 614: 615: 616: 617: 618: 619: 620: 621: 622: 623: 624: 625: 626: 627: 628: 629: 630: 631: 632: 633: 634: 635: 636: 637: 638: 639: 640: 641: 642: 643: 644: 645: 646: 647: 648: 649: 650: 651: 652: 653: 654: 655: 656: 657: 658: 659: 660: 661: 662: 663: 664: 665: 666: 667: 668: 669: 670: 671: 672: 673: 674: 675: 676: 677: 678: 679: 680: 681: 682: 683: 684: 685: 686: 687: 688: 689: 690: 691: 692: 693: 694: 695: 696: 697: 698: 699: 700: 701: 702: 703: 704: 705: 706: 707: 708: 709: 710: 711: 712: 713: 714: 715: 716: 717: 718: 719: 720: 721: 722: 723: 724: 725: 726: 727: 728: 729: 730: 731: 732: 733: 734: 735: 736: 737: 738: 739: 740: 741: 742: 743: 744: 745: 746: 747: 748: 749: 750: 751: 752: 753: 754: 755: 756: 757: 758: 759: 760: 761: 762: 763: 764: 765: 766: 767: 768: 769: 770: 771: 772: 773: 774: 775: 776: 777: 778: 779: 780: 781: 782: 783: 784: 785: 786: 787: 788: 789: 790: 791: 792: 793: 794: 795: 796: 797: 798: 799: 800: 801: 802: 803: 804: 805: 806: 807: 808: 809: 810: 811: 812: 813: 814: 815: 816: 817: 818: 819: 820: 821: 822: 823: 824: 825: 826: 827: 828: 829: 830: 831: 832: 833: 834: 835: 836: 837: 838: 839: 840: 841: 842: 843: 844: 845: 846: 847: 848: 849: 850: 851: 852: 853: 854: 855: 856: 857: 858: 859: 860: 861: 862: 863: 864: 865: 866: 867: 868: 869: 870: 871: 872: 873: 874: 875: 876: 877: 878: 879: 880: 881: 882: 883: 884: 885: 886: 887: 888: 889: 890: 891: 892: 893: 894: 895: 896: 897: 898: 899: 900: 901: 902: 903: 904: 905: 906: 907: 908: 909: 910: 911: 912: 913: 914: 915: 916: 917: 918: 919: 920: 921: 922: 923: 924: 925: 926: 927: 928: 929: 930: 931: 932: 933: 934: 935: 936: 937: 938: 939: 940: 941: 942: 943: 944: 945: 946: 947: 948: 949: 950: 951: 952: 953: 954: 955: 956: 957: 958: 959: 960: 961: 962: 963: 964: 965: 966: 967: 968: 969: 970: 971: 972: 973: 974: 975: 976: 977: 978: 979: 980: 981: 982: 983: 984: 985: 986: 987: 988: 989: 990: 991: 992: 993: 994: 995: 996: 997: 998: 999: 1000: 1001: 1002: 1003: 1004: 1005: 1006: 1007: 1008: 1009: 1010: 1011: 1012: 1013: 1014: 1015: 1016: 1017: 1018: 1019: 1020: 1021: 1022: 1023: 1024: 1025: 1026: 1027: 1028: 1029: 1030: 1031: 1032: 1033: 1034: 1035: 1036: 1037: 1038: 1039: 1040: 1041: 1042: 1043: 1044: 1045: 1046: 1047: 1048: 1049: 1050: 1051: 1052: 1053: 1054: 1055: 1056: 1057: 1058: 1059: 1060: 1061: 1062: 1063: 1064: 1065: 1066: 1067: 1068: 1069: 1070: 1071: 1072: 1073: 1074: 1075: 1076: 1077: 1078: 1079: 1080: 1081: 1082: 1083: 1084: 1085: 1086: 1087: 1088: 1089: 1090: 1091: 1092: 1093: 1094: 1095: 1096: 1097: 1098: 1099: 1100: 1101: 1102: 1103: 1104: 1105: 1106: 1107: 1108: 1109: 1110: 1111: 1112: 1113: 1114: 1115: 1116: 1117: 1118: 1119: 1120: 1121: 1122: 1123: 1124: 1125: 1126: 1127: 1128: 1129: 1130: 1131: 1132: 1133: 1134: 1135: 1136: 1137: 1138: 1139: 1140: 1141: 1142: 1143: 1144: 1145: 1146: 1147: 1148: 1149: 1150: 1151: 1152: 1153: 1154: 1155: 1156: 1157: 1158: 1159: 1160: 1161: 1162: 1163: 1164: 1165: 1166: 1167: 1168: 1169: 1170: 1171: 1172: 1173: 1174: 1175: 1176: 1177: 1178: 1179: 1180: 1181: 1182: 1183: 1184: 1185: 1186: 1187: 1188: 1189: 1190: 1191: 1192: 1193: 1194: 1195: 1196: 1197: 1198: 1199: 1200: 1201: 1202: 1203: 1204: 1205: 1206: 1207: 1208: 1209: 1210: 1211: 1212: 1213: 1214: 1215: 1216: 1217: 1218: 1219: 1220: 1221: 1222: 1223: 1224: 1225: 1226: 1227: 1228: 1229: 1230: 1231: 1232: 1233: 1234: 1235: 1236: 1237: 1238: 1239: 1240: 1241: 1242: 1243: 1244: 1245: 1246: 1247: 1248: 1249: 1250: 1251: 1252: 1253: 1254: 1255: 1256: 1257: 1258: 1259: 1260: 1261: 1262: 1263: 1264: 1265: 1266: 1267: 1268: 1269: 1270: 1271: 1272: 1273: 1274: 1275: 1276: 1277: 1278: 1279: 1280: 1281: 1282: 1283: 1284: 1285: 1286: 1287: 1288: 1289: 1290: 1291: 1292: 1293: 1294: 1295: 1296: 1297: 1298: 1299: 1300: 1301: 1302: 1303: 1304: 1305: 1306: 1307: 1308: 1309: 1310: 1311: 1312: 1313: 1314: 1315: 1316: 1317: 1318: 1319: 1320: 1321: 1322: 1323: 1324: 1325: 1326: 1327: 1328: 1329: 1330: 1331: 1332: 1333: 1334: 1335: 1336: 1337: 1338: 1339: 1340: 1341: 1342: 1343: 1344: 1345: 1346: 1347: 1348: 1349: 1350: 1351: 1352: 1353: 1354: 1355: 1356: 1357: 1358: 1359: 1360: 1361: 1362: 1363: 1364: 1365: 1366: 1367: 1368: 1369: 1370: 1371: 1372: 1373: 1374: 1375: 1376: 1377: 1378: 1379: 1380: 1381: 1382: 1383: 1384: 1385: 1386: 1387: 1388: 1389: 1390: 1391: 1392: 1393: 1394: 1395: 1396: 1397: 1398: 1399: 1400: 1401: 1402: 1403: 1404: 1405: 1406: 1407: 1408: 1409: 1410: 1411: 1412: 1413: 1414: 1415: 1416: 1417: 1418: 1419: 1420: 1421: 1422: 1423: 1424: 1425: 1426: 1427: 1428: 1429: 1430: 1431: 1432: 1433: 1434: 1435: 1436: 1437: 1438: 1439: 1440: 1441: 1442: 1443: 1444: 1445: 1446: 1447: 1448: 1449: 1450: 1451: 1452: 1453: 1454: 1455: 1456: 1457: 1458: 1459: 1460: 1461: 1462: 1463: 1464: 1465: 1466: 1467: 1468: 1469: 1470: 1471: 1472: 1473: 1474: 1475: 1476: 1477: 1478: 1479: 1480: 1481: 1482: 1483: 1484: 1485: 1486: 1487: 1488: 1489: 1490: 1491: 1492: 1493: 1494: 1495: 1496: 1497: 1498: 1499: 1500: 1501: 1502: 1503: 1504: 1505: 1506: 1507: 1508: 1509: 1510: 1511: 1512: 1513: 1514: 1515: 1516: 1517: 1518: 1519: 1520: 1521: 1522: 1523: 1524: 1525: 1526: 1527: 1528: 1529: 1530: 1531: 1532: 1533: 1534: 1535: 1536: 1537: 1538: 1539: 1540: 1541: 1542: 1543: 1544: 1545: 1546: 1547: 1548: 1549: 1550: 1551: 1552: 1553: 1554: 1555: 1556: 1557: 1558: 1559: 1560: 1561: 1562: 1563: 1564: 1565: 1566: 1567: 1568: 1569: 1570: 1571: 1572: 1573: 1574: 1575: 1576: 1577: 1578: 1579: 1580: 1581: 1582: 1583: 1584: 1585: 1586: 1587: 1588: 1589: 1590: 1591: 1592: 1593: 1594: 1595: 1596: 1597: 1598: 1599: 1600: 1601: 1602: 1603: 1604: 1605: 1606: 1607: 1608: 1609: 1610: 1611: 1612: 1613: 1614: 1615: 1616: 1617: 1618: 1619: 1620: 1621: 1622: 1623: 1624: 1625: 1626: 1627: 1628: 1629: 1630: 1631: 1632: 1633: 1634: 1635: 1636: 1637: 1638: 1639: 1640: 1641: 1642: 1643: 1644: 1645: 1646: 1647: 1648: 1649: 1650: 1651: 1652: 1653: 1654: 1655: 1656: 1657: 1658: 1659: 1660: 1661: 1662: 1663: 1664: 1665: 1666: 1667: 1668: 1669: 1670: 1671: 1672: 1673: 1674: 1675: 1676: 1677: 1678: 1679: 1680: 1681: 1682: 1683: 1684: 1685: 1686: 1687: 1688: 1689: 1690: 1691: 1692: 1693: 1694: 1695: 1696: 1697: 1698: 1699: 1700: 1701: 1702: 1703: 1704: 1705: 1706: 1707: 1708: 1709: 1710: 1711: 1712: 1713: 1714: 1715: 1716: 1717: 1718: 1719: 1720: 1721: 1722: 1723: 1724: 1725: 1726: 1727: 1728: 1729: 1730: 1731: 1732: 1733: 1734: 1735: 1736: 1737: 1738: 1739: 1740: 1741: 1742: 1743: 1744: 1745: 1746: 1747: 1748: 1749: 1750: 1751: 1752: 1753: 1754: 1755: 1756: 1757: 1758: 1759: 1760: 1761: 1762: 1763: 1764: 1765: 1766: 1767: 1768: 1769: 1770: 1771: 1772: 1773: 1774: 1775: 1776: 1777: 1778: 1779: 1780: 1781: 1782: 1783: 1784: 1785: 1786: 1787: 1788: 1789: 1790: 1791: 1792: 1793: 1794: 1795: 1796: 1797: 1798: 1799: 1800: 1801: 1802: 1803: 1804: 1805: 1806: 1807: 1808: 1809: 1810: 1811: 1812: 1813: 1814: 1815: 1816: 1817: 1818: 1819: 1820: 1821: 1822: 1823: 1824: 1825: 1826: 1827: 1828: 1829: 1830: 1831: 1832: 1833: 1834: 1835: 1836: 1837: 1838: 1839: 1840: 1841: 1842: 1843: 1844: 1845: 1846: 1847: 1848: 1849: 1850: 1851: 1852: 1853: 1854: 1855: 1856: 1857: 1858: 1859: 1860: 1861: 1862: 1863: 1864: 1865: 1866: 1867: 1868: 1869: 1870: 1871: 1872: 1873: 1874: 1875: 1876: 1877: 1878: 1879: 1880: 1881: 1882: 1883: 1884: 1885: 1886: 1887: 1888: 1889: 1890: 1891: 1892: 1893: 1894: 1895: 1896: 1897: 1898: 1899: 1900: 1901: 1902: 1903: 1904: 1905: 1906: 1907: 1908: 1909: 1910: 1911: 1912: 1913: 1914: 1915: 1916: 1917: 1918: 1919: 1920: 1921: 1922: 1923: 1924: 1925: 1926: 1927: 1928: 1929: 1930: 1931: 1932: 1933: 1934: 1935: 1936: 1937: 1938: 1939: 1940: 1941: 1942: 1943: 1944: 1945: 1946: 1947: 1948: 1949: 1950: 1951: 1952: 1953: 1954: 1955: 1956: 1957: 1958: 1959: 1960: 1961: 1962: 1963: 1964: 1965: 1966: 1967: 1968: 1969: 1970: 1971: 1972: 1973: 1974: 1975: 1976: 1977: 1978: 1979: 1980: 1981: 1982: 1983: 1984: 1985: 1986: 1987: 1988: 1989: 1990: 1991: 1992: 1993: 1994: 1995: 1996: 1997: 1998: 1999: 2000: 2001: 2002: 2003: 2004: 2005: 2006: 2007: 2008: 2009: 2010: 2011: 2012: 2013: 2014: 2015: 2016: 2017: 2018: 2019: 2020: 2021: 2022: 2023: 2024: 2025: 2026: 2027: 2028: 2029: 2030: 2031: 2032: 2033: 2034: 2035: 2036: 2037: 2038: 2039: 2040: 2041: 2042: 2043: 2044: 2045: 2046: 2047: 2048: 2049: 2050: 2051: 2052: 2053: 2054: 2055: 2056: 2057: 2058: 2059: 2060: 2061: 2062: 2063: 2064: 2065: 2066: 2067: 2068: 2069: 2070: 2071: 2072: 2073: 2074: 2075: 2076: 2077: 2078: 2079: 2080: 2081: 2082: 2083: 2084: 2085: 2086: 2087: 2088: 2089: 2090: 2091: 2092: 2093: 2094: 2095: 2096: 2097: 2098: 2099: 2100: 2101: 2102: 2103: 2104: 2105: 2106: 2107: 2108: 2109: 2110: 2111: 2112: 2113: 2114: 2115: 2116: 2117: 2118: 2119: 2120: 2121: 2122: 2123: 2124: 2125: 2126: 2127: 2128: 2129: 2130: 2131: 2132: 2133: 2134: 2135: 2136: 2137: 2138: 2139: 2140: 2141: 2142: 2143: 2144: 2145: 2146: 2147: 2148: 2149: 2150: 2151: 2152: 2153: 2154: 2155: 2156: 2157: 2158: 2159: 2160: 2161: 2162: 2163: 2164: 2165: 2166: 2167: 2168: 2169: 2170: 2171: 2172: 2173: 2174: 2175: 2176: 2177: 2178: 2179: 2180: 2181: 2182: 2183: 2184: 2185: 2186: 2187: 2188: 2189: 2190: 2191: 2192: 2193: 2194: 2195: 2196: 2197: 2198: 2199: 2200: 2201: 2202: 2203: 2204: 2205: 2206: 2207: 2208: 2209: 2210: 2211: 2212: 2213: 2214: 2215: 2216: 2217: 2218: 2219: 2220: 2221: 2222: 2223: 2224: 2225: 2226: 2227: 2228: 2229: 2230: 2231: 2232: 2233: 2234: 2235: 2236: 2237: 2238: 2239: 2240: 2241: 2242: 2243: 2244: 2245: 2246: 2247: 2248: 2249: 2250: 2251: 2252: 2253: 2254: 2255: 2256: 2257: 2258: 2259: 2260: 2261: 2262: 2263: 2264: 2265: 2266: 2267: 2268: 2269: 2270: 2271: 2272: 2273: 2274: 2275: 2276: 2277: 2278: 2279: 2280: 2281: 2282: 2283: 2284: 2285: 2286: 2287: 2288: 2289: 2290: 2291: 2292: 2293: 2294: 2295: 2296: 2297: 2298: 2299: 2300: 2301: 2302: 2303: 2304: 2305: 2306: 2307: 2308: 2309: 2310: 2311: 2312: 2313: 2314: 2315: 2316: 2317: 2318: 2319: 2320: 2321: 2322: 2323: 2324: 2325: 2326: 2327: 2328: 2329: 2330: 2331: 2332: 2333: 2334: 2335: 2336: 2337: 2338: 2339: 2340: 2341: 2342: 2343: 2344: 2345: 2346: 2347: 2348: 2349: 2350: 2351: 2352: 2353: 2354: 2355: 2356: 2357: 2358: 2359: 2360: 2361: 2362: 2363: 2364: 2365: 2366: 2367: 2368: 2369: 2370: 2371: 2372: 2373: 2374: 2375: 2376: 2377: 2378: 2379: 2380: 2381: 2382: 2383: 2384: 2385: 2386: 2387: 2388: 2389: 2390: 2391: 2392: 2393: 2394: 2395: 2396: 2397: 2398: 2399: 2400: 2401: 2402: 2403: 2404: 2405: 2406: 2407: 2408: 2409: 2410: 2411: 2412: 2413: 2414: 2415: 2416: 2417: 2418: 2419: 2420: 2421: 2422: 2423: 2424: 2425: 2426: 2427: 2428: 2429: 2430: 2431: 2432: 2433: 2434: 2435: 2436: 2437: 2438: 2439: 2440: 2441: 2442: 2443: 2444: 2445: 2446: 2447: 2448: 2449: 2450: 2451: 2452: 2453: 2454: 2455: 2456: 2457: 2458: 2459: 2460: 2461: 2462: 2463: 2464: 2465: 2466: 2467: 2468: 2469: 2470: 2471: 2472: 2473: 2474: 2475: 2476: 2477: 2478: 2479: 2480: 2481: 2482: 2483: 2484: 2485: 2486: 2487: 2488: 2489: 2490: 2491: 2492: 2493: 2494: 2495: 2496: 2497: 2498: 2499: 2500: 2501: 2502: 2503: 2504: 2505: 2506: 2507: 2508: 2509: 2510: 2511: 2512: 2513: 2514: 2515: 2516: 2517: 2518: 2519: 2520: 2521: 2522: 2523: 2524: 2525: 2526: 2527: 2528: 2529: 2530: 2531: 2532: 2533: 2534: 2535: 2536: 2537: 2538: 2539: 2540: 2541: 2542: 2543: 2544: 2545: 2546: 2547: 2548: 2549: 2550: 2551: 2552: 2553: 2554: 2555: 2556: 2557: 2558: 2559: 2560: 2561: 2562: 2563: 2564: 2565: 2566: 2567: 2568: 2569: 2570: 2571: 2572: 2573: 2574: 2575: 2576: 2577: 2578: 2579: 2580: 2581: 2582: 2583: 2584: 2585: 2586: 2587: 2588: 2589: 2590: 2591: 2592: 2593: 2594: 2595: 2596: 2597: 2598: 2599: 2600: 2601: 2602: 2603: 2604: 2605: 2606: 2607: 2608: 2609: 2610: 2611: 2612: 2613: 2614: 2615: 2616: 2617: 2618: 2619: 2620: 2621: 2622: 2623: 2624: 2625: 2626: 2627: 2628: 2629: 2630: 2631: 2632: 2633: 2634: 2635: 2636: 2637: 2638: 2639: 2640: 2641: 2642: 2643: 2644: 2645: 2646: 2647: 2648: 2649: 2650: 2651: 2652: 2653: 2654: 2655: 2656: 2657: 2658: 2659: 2660: 2661: 2662: 2663: 2664: 2665: 2666: 2667: 2668: 2669: 2670: 2671: 2672: 2673: 2674: 2675: 2676: 2677: 2678: 2679: 2680: 2681: 2682: 2683: 2684: 2685: 2686: 2687: 2688: 2689: 2690: 2691: 2692: 2693: 2694: 2695: 2696: 2697: 2698: 2699: 2700: 2701: 2702: 2703: 2704: 2705: 2706: 2707: 2708: 2709: 2710: 2711: 2712: 2713: 2714: 2715: 2716: 2717: 2718: 2719: 2720: 2721: 2722: 2723: 2724: 2725: 2726: 2727: 2728: 2729: 2730: 2731: 2732: 2733: 2734: 2735: 2736: 2737: 2738: 2739: 2740: 2741: 2742: 2743: 2744: 2745: 2746: 2747: 2748: 2749: 2750: 2751: 2752: 2753: 2754: 2755: 2756: 2757: 2758: 2759: 2760: 2761: 2762: 2763: 2764: 2765: 2766: 2767: 2768: 2769: 2770: 2771: 2772: 2773: 2774: 2775: 2776: 2777: 2778: 2779: 2780: 2781: 2782: 2783: 2784: 2785: 2786: 2787: 2788: 2789: 2790: 2791: 2792: 2793: 2794: 2795: 2796: 2797: 2798: 2799: 2800: 2801: 2802: 2803: 2804: 2805: 2806: 2807: 2808: 2809: 2810: 2811: 2812: 2813: 2814: 2815: 2816: 2817: 2818: 2819: 2820: 2821: 2822: 2823: 2824: 2825: 2826: 2827: 2828: 2829: 2830: 2831: 2832: 2833: 2834: 2835: 2836: 2837: 2838: 2839: 2840: 2841: 2842: 2843: 2844: 2845: 2846: 2847: 2848: 2849: 2850: 2851: 2852: 2853: 2854: 2855: 2856: 2857: 2858: 2859: 2860: 2861: 2862: 2863: 2864: 2865: 2866: 2867: 2868: 2869: 2870: 2871: 2872: 2873: 2874: 2875: 2876: 2877: 2878: 2879: 2880: 2881: 2882: 2883: 2884: 2885: 2886: 2887: 2888: 2889: 2890: 2891: 2892: 2893: 2894: 2895: 2896: 2897: 2898: 2899: 2900: 2901: 2902: 2903: 2904: 2905: 2906: 2907: 2908: 2909: 2910: 2911: 2912: 2913: 2914: 2915: 2916: 2917: 2918: 2919: 2920: 2921: 2922: 2923: 2924: 2925: 2926: 2927: 2928: 2929: 2930: 2931: 2932: 2933: 2934: 2935: 2936: 2937: 2938: 2939: 2940: 2941: 2942: 2943: 2944: 2945: 2946: 2947: 2948: 2949: 2950: 2951: 2952: 2953: 2954: 2955: 2956: 2957: 2958: 2959: 2960: 2961: 2962: 2963: 2964: 2965: 2966: 2967: 2968: 2969: 2970: 2971: 2972: 2973: 2974: 2975: 2976: 2977: 2978: 2979: 2980: 2981: 2982: 2983: 2984: 2985: 2986: 2987: 2988: 2989: 2990: 2991: 2992: 2993: 2994: 2995: 2996: 2997: 2998: 2999: 3000: 3001: 3002: 3003: 3004: 3005: 3006: 3007: 3008: 3009: 3010: 3011: 3012: 3013: 3014: 3015: 3016: 3017: 3018: 3019: 3020: 3021: 3022: 3023: 3024: 3025: 3026: 3027: 3028: 3029: 3030: 3031: 3032: 3033: 3034: 3035: 3036: 3037: 3038: 3039: 3040: 3041: 3042: 3043: 3044: 3045: 3046: 3047: 3048: 3049: 3050: 3051: 3052: 3053: 3054: 3055: 3056: 3057: 3058: 3059: 3060: 3061: 3062: 3063: 3064: 3065: 3066: 3067: 3068: 3069: 3070: 3071: 3072: 3073: 3074: 3075: 3076: 3077: 3078: 3079: 3080: 3081: 3082: 3083: 3084: 3085: 3086: 3087: 3088: 3089: 3090: 3091: 3092: 3093: 3094: 3095: 3096: 3097: 3098: 3099: 3100: 3101: 3102: 3103: 3104: 3105: 3106: 3107: 3108: 3109: 3110: 3111: 3112: 3113: 3114: 3115: 3116: 3117: 3118: 3119: 3120: 3121: 3122:
<?php
global $EventPost;
$EventPost = new EventPost();
$EventPost_cache=array();
function EventPost(){
global $EventPost;
return $EventPost;
}
function event_post_format_color($color){
return str_replace('#', '', $color);
}
function event_post_get_all_terms($post_id){
$taxonomies= get_taxonomies('','names');
return wp_get_post_terms($post_id, $taxonomies);
}
class EventPost {
public $version = '5.9.2';
public $META_START = 'event_begin';
public $META_END = 'event_end';
public $META_COLOR = 'event_color';
public $META_ICON = 'event_icon';
public $META_ADD = 'geo_address';
public $META_LAT = 'geo_latitude';
public $META_LONG = 'geo_longitude';
public $META_VIRTUAL_LOCATION = 'event_virtual_location';
public $META_STATUS = 'event_status';
public $META_ATTENDANCE_MODE = 'event_attendance_mode';
public $list_id;
private $is_schema_output=false;
public $NomDuMois;
public $Week;
public $dateformat;
private $pagination;
public $plugin_path;
private $script_sufix;
public $settings;
public $map_interactions;
public $quick_edit_fields;
public $bulk_edit_fields;
public $attendance_modes;
public $statuses;
public $default_list_shema;
public $default_timeline_shema;
public $list_shema;
public $timeline_shema;
public $maps;
public $markpath;
public $markurl;
public $Taxonomies;
public $DashIcons;
public $Settings;
public $Shortcodes;
public $kses_tags;
public function __construct() {
add_action('init', array(&$this,'init'), 1);
add_action('widgets_init', array(&$this,'widgets_init'), 1);
add_action('save_post', array(&$this, 'save_postdata'));
add_filter('dashboard_glance_items', array(&$this, 'dashboard_right_now'));
add_action( 'admin_init', array(&$this, 'editor_styles'));
add_action('admin_enqueue_scripts', array(&$this, 'admin_head'));
add_action('admin_print_scripts', array(&$this, 'admin_scripts'));
add_action('admin_print_scripts', array(&$this, 'load_scripts'), 1);
add_action('wp_enqueue_scripts', array(&$this, 'load_scripts'), 1);
add_action('wp_enqueue_scripts', array(&$this, 'load_styles'));
add_filter('the_content', array(&$this, 'display_single'), 9999);
add_filter('the_title', array(&$this, 'the_title'), 9999, 2);
add_action('the_event', array(&$this, 'print_single'));
add_action('wp_head', array(&$this, 'single_header'));
add_action('wpseo_schema_webpage', array(&$this, 'wpseo_schema_webpage'));
add_action('wp_ajax_EventPostGetLatLong', array(&$this, 'GetLatLong'));
add_action('wp_ajax_EventPostHumanDate', array(&$this, 'HumanDate'));
add_action('wp_ajax_EventPostList', array(&$this, 'ajaxlist'));
add_action('wp_ajax_EventPostTimeline', array(&$this, 'ajaxTimeline'));
add_action('wp_ajax_EventPostNextPage', array(&$this, 'ajaxGetNextPage'));
add_action('wp_ajax_nopriv_EventPostNextPage', array(&$this, 'ajaxGetNextPage'));
add_action('wp_ajax_EventPostMap', array(&$this, 'ajaxmap'));
add_action('wp_ajax_EventPostCalendar', array(&$this, 'ajaxcal'));
add_action('wp_ajax_nopriv_EventPostCalendar', array(&$this, 'ajaxcal'));
add_action('wp_ajax_EventPostCalendarDate', array(&$this, 'ajaxdate'));
add_action('wp_ajax_nopriv_EventPostCalendarDate', array(&$this, 'ajaxdate'));
add_action('parse_request', array(&$this, 'parse_request'), 100);
add_action('wp_ajax_EventPostExport', array(&$this, 'export'));
add_action('wp_ajax_nopriv_EventPostExport', array(&$this, 'export'));
add_action('wp_ajax_EventPostFeed', array(&$this, 'feed'));
add_action('wp_ajax_nopriv_EventPostFeed', array(&$this, 'feed'));
add_filter('eventpost_list_shema',array(&$this, 'custom_shema'),10,1);
add_action('widgets_init', array(&$this, 'register_widgets'),1,1);
add_action( 'bulk_edit_custom_box', array( &$this, 'bulk_edit' ), 10, 2 );
add_action( 'quick_edit_custom_box', array( &$this, 'quick_edit' ), 10, 2 );
add_action( 'admin_print_scripts-edit.php', array(&$this, 'scripts_edit') );
add_action( 'wp_ajax_inline-save', array(&$this, 'inline_save'), 1 );
add_action( 'bulk_edit_posts', array(&$this, 'save_bulkdatas'), 10, 2 );
add_filter( 'eventpost_inline_field', array(&$this, 'inline_field_color'), 10, 3);
add_filter( 'eventpost_inline_field', array(&$this, 'inline_field_icon'), 10, 3);
$inc_path = plugin_dir_path(__FILE__).'inc/';
$this->plugin_path = plugin_dir_path(__FILE__);
include_once ($inc_path . 'class-settings.php');
include_once ($inc_path . 'wrappers.php');
include_once ($inc_path . 'deprecated/widget.php');
include_once ($inc_path . 'deprecated/widget.cal.php');
include_once ($inc_path . 'deprecated/widget.map.php');
include_once ($inc_path . 'class-multisite.php');
include_once ($inc_path . 'class-shortcodes.php');
include_once ($inc_path . 'openweathermap.php');
include_once ($inc_path . 'class-children.php');
include_once ($inc_path . 'class-icons.php');
include_once ($inc_path . 'class-taxonomies.php');
$this->DashIcons = new EventPost\Icons();
$this->Settings = new EventPost\Settings($this->DashIcons);
$this->Taxonomies = new EventPost\Taxonomies($this->DashIcons);
}
public function EventPost(){
$this->__construct();
}
public function init(){
$admin_url = admin_url('admin-ajax.php?action=EventPostFeed');
$admin_url = str_replace(site_url(), '', $admin_url);
$plugins_url = plugins_url('export/ics.php', __FILE__);
$plugins_url = str_replace(site_url(), '', $plugins_url);
add_rewrite_rule('event-feed/?', $admin_url , 'top');
add_rewrite_rule('eventpost/([0-9]*)\.(ics|vcs)?',$plugins_url, 'top');
}
public function widgets_init(){
$this->list_id = 0;
$this->NomDuMois = array('', __('Jan', 'event-post'), __('Feb', 'event-post'), __('Mar', 'event-post'), __('Apr', 'event-post'), __('May', 'event-post'), __('Jun', 'event-post'), __('Jul', 'event-post'), __('Aug', 'event-post'), __('Sept', 'event-post'), __('Oct', 'event-post'), __('Nov', 'event-post'), __('Dec', 'event-post'));
$this->Week = array(__('Sunday', 'event-post'), __('Monday', 'event-post'), __('Tuesday', 'event-post'), __('Wednesday', 'event-post'), __('Thursday', 'event-post'), __('Friday', 'event-post'), __('Saturday', 'event-post'));
$this->attendance_modes = array(
'OfflineEventAttendanceMode' => _x('Physical', 'Attendance Mode', 'event-post'),
'MixedEventAttendanceMode' => _x('Mixed', 'Attendance Mode', 'event-post'),
'OnlineEventAttendanceMode' => _x('Online', 'Attendance Mode', 'event-post'),
);
$this->statuses = array(
'EventScheduled' =>_x('Scheduled', 'Event Status', 'event-post'),
'EventCancelled'=>_x('Cancelled', 'Event Status', 'event-post'),
'EventMovedOnline'=>_x('Moved Online', 'Event Status', 'event-post'),
'EventPostponed'=>_x('Postoned', 'Event Status', 'event-post'),
'EventRescheduled'=>_x('Rescheduled', 'Event Status', 'event-post'),
'EventCompleted'=>_x('Completed', 'Event Status', 'event-post'),
);
$this->maps = $this->get_maps();
$this->settings = $this->get_settings();
do_action('evenpost_init', $this);
$this->Shortcodes = new EventPost\Shortcodes();
if(function_exists('register_block_type')){
$block_path = plugin_dir_path(__FILE__).'inc/blocks/';
include_once ($block_path . 'eventslist.php');
include_once ($block_path . 'eventstimeline.php');
include_once ($block_path . 'eventsmap.php');
include_once ($block_path . 'eventscalendar.php');
include_once ($block_path . 'eventdetails.php');
}
if (class_exists('WooCommerce') && in_array('product', $this->settings['posttypes'])) {
include_once (plugin_dir_path(__FILE__).'inc/woocommerce.php');
}
add_action('add_meta_boxes', array(&$this, 'add_custom_box'));
foreach($this->settings['posttypes'] as $posttype){
add_filter('manage_'.$posttype.'_posts_columns', array(&$this, 'columns_head'), 2);
add_action('manage_'.$posttype.'_posts_custom_column', array(&$this, 'columns_content'), 10, 2);
}
$this->Taxonomies->add_fields_to_taxonomies($this->settings['posttypes']);
$this->markpath = '';
$this->markurl = '';
if (!empty($this->settings['markpath']) && !empty($this->settings['markurl'])) {
$this->markpath = ABSPATH.'/'.$this->settings['markpath'];
$this->markurl = $this->settings['markurl'];
} else {
}
$this->dateformat = str_replace(array('yy', 'mm', 'dd'), array('Y', 'm', 'd'), __('yy-mm-dd', 'event-post'));
$this->default_list_shema = apply_filters('eventpost_default_list_shema', array(
'container' => '<%type% class="event_loop %id% %class%" id="%listid%" style="%style%" %attributes%>'.
'%list%'.
'%pagination%'.
'</%type%><!-- .event_loop -->',
'item' => '<%child% class="event_item %class%" data-color="%color%" style="%style%">'.
'<a href="%event_link%">'.
'%event_thumbnail%'.
'<h5>%event_title% </h5>'.
'</a>'.
'%event_price%'.
'%event_date%'.
'%event_cat%'.
'%event_location%'.
'%event_excerpt%'.
'</%child%><!-- .event_item -->'
));
$this->list_shema = apply_filters('eventpost_list_shema',$this->default_list_shema);
$this->default_timeline_shema = apply_filters('eventpost_default_timeline_shema', array(
'container' => '
<%type% class="event_loop %id% %class%" id="%listid%" style="%style%" %attributes%>
%prev_arrow%
<div class="track">
%list%
</div>
%next_arrow%
</%type%><!-- .event_loop -->',
'item' => '<%child% class="event_item %class%" data-color="%color%" style="%style%">
<div class="anchor" style="background-color:#%color%"></div>
%event_date%
%event_location%
%event_cat%
%event_excerpt%
<a href="%event_link%">
%event_thumbnail%
<h5>%event_title%</h5>
</a>
%event_price%
</%child%><!-- .event_item -->'
));
$this->timeline_shema = apply_filters('eventpost_timeline_shema',$this->default_timeline_shema);
$this->map_interactions=array(
'DragRotate'=>__('Drag Rotate', 'event-post'),
'DoubleClickZoom'=>__('Double Click Zoom', 'event-post'),
'DragPan'=>__('Drag Pan', 'event-post'),
'PinchRotate'=>__('Pinch Rotate', 'event-post'),
'PinchZoom'=>__('Pinch Zoom', 'event-post'),
'KeyboardPan'=>__('Keyboard Pan', 'event-post'),
'KeyboardZoom'=>__('Keyboard Zoom', 'event-post'),
'MouseWheelZoom'=>__('Mouse Wheel Zoom', 'event-post'),
'DragZoom'=>__('Drag Zoom', 'event-post'),
);
$this->quick_edit_fields = apply_filters('eventpost_quick_edit_fields', array(
'event'=>array(
$this->META_START=>__('Begin:', 'event-post'),
$this->META_END=>__('End:', 'event-post'),
$this->META_COLOR=>__('Color:', 'event-post'),
$this->META_ICON=>__('Icon:', 'event-post'),
),
'location'=>array(
$this->META_ADD=>__('Address:', 'event-post'),
$this->META_LAT=>__('Latitude:', 'event-post'),
$this->META_LONG=>__('Longitude:', 'event-post'),
),
)
);
$this->bulk_edit_fields = apply_filters('eventpost_bulk_edit_fields', array(
'event'=>array(
$this->META_COLOR=>__('Color:', 'event-post'),
$this->META_ICON=>__('Icon:', 'event-post'),
),
)
);
$this->kses_tags = apply_filters('eventpost_kses_tags', json_decode(
file_get_contents(plugin_dir_path(__FILE__).'inc/data/kses-tags.json'),
true
));
}
public function register_widgets(){
register_widget('EventPost_List');
register_widget('EventPost_Map');
register_widget('EventPost_Cal');
}
public function hex2dec($color = '000000') {
$tbl_color = array();
if(!is_string($color) || empty($color)){
$color = '000000';
}
if (substr($color, 0, 1)!='#'){
$color = '#' . $color;
}
$tbl_color['R'] = hexdec(substr($color, 1, 2));
$tbl_color['G'] = hexdec(substr($color, 3, 2));
$tbl_color['B'] = hexdec(substr($color, 5, 2));
return $tbl_color;
}
function get_thumbnail_sizes(){
global $_wp_additional_image_sizes;
$sizes = array('thumbnail', 'medium', 'large', 'full');
foreach(array_keys($_wp_additional_image_sizes) as $size){
$sizes[]=$size;
}
return $sizes;
}
public function get_settings() {
$ep_settings = $this->Settings->get_settings();
return apply_filters('eventpost_getsettings', $ep_settings);
}
public function custom_shema($shema){
if(!empty($this->settings['container_shema'])){
$shema['container']=$this->settings['container_shema'];
}
if(!empty($this->settings['item_shema'])){
$shema['item']=$this->settings['item_shema'];
}
return $shema;
}
public function get_maps() {
$maps = array();
$filename = plugin_dir_path(__FILE__) . 'maps.json';
if (is_file($filename) && (false !== $json = json_decode(file_get_contents($filename)))) {
$arrays = array();
foreach($json as $map){
$arrays[$map->id] = (array) $map;
}
$maps = apply_filters('eventpost_maps', $arrays);
}
return $maps;
}
public function get_colors() {
$colors = array();
if (is_dir($this->markpath)) {
$files = scandir($this->markpath);
foreach ($files as $file) {
if (substr($file, -4) == '.png') {
$colors[substr($file, 0, -4)] = $this->markurl . $file;
}
}
}
return $colors;
}
public function get_post_color($post_id, $default = false, $check_taxo = false) {
$color = get_post_meta($post_id, $this->META_COLOR,true);
if($color && !empty($color)){
return event_post_format_color($color);
}else{
if($check_taxo){
foreach(event_post_get_all_terms($post_id) as $term){
$taxo_color = $this->Taxonomies->get_taxonomy_color($term->term_id);
if($taxo_color){
return event_post_format_color($taxo_color);
}
}
}
}
return event_post_format_color($default);
}
public function get_post_icon($post_id, $default = false, $check_taxo = false) {
$icon = get_post_meta($post_id, $this->META_ICON,true);
if($icon && !empty($icon)){
return $icon;
}else{
if($check_taxo){
foreach(event_post_get_all_terms($post_id) as $term){
$taxo_icon = $this->Taxonomies->get_taxonomy_icon($term->term_id);
if($taxo_icon){
return event_post_format_color($taxo_icon);
}
}
}
}
return $default;
}
public function get_marker($color) {
if (is_file($this->markpath . $color . '.png')) {
return $this->markurl . $color . '.png';
}
return "";
}
public function load_styles($deps = null) {
if(!empty($this->settings['customcss'])){
wp_enqueue_style('event-post-custom', $this->settings['customcss']);
}
elseif(is_file(get_stylesheet_directory().'/event-post.css') || is_file(get_template_directory().'/event-post.css')){
wp_enqueue_style('event-post-custom', get_theme_file_uri('event-post.css'));
}
else{
wp_register_style('event-post', plugins_url('/build/front/front.css', __FILE__), $deps, filemtime( "{$this->plugin_path}/build/front/front.css" ));
wp_enqueue_style('event-post');
}
wp_enqueue_style('dashicons', includes_url('/css/dashicons.min.css'));
}
public function editor_styles() {
add_editor_style( plugins_url('/build/front/front.css', __FILE__) );
}
public function load_scripts() {
wp_enqueue_script('event-post', plugins_url('/build/front/front.js', __FILE__), array(), filemtime( "{$this->plugin_path}/build/front/front.js" ), true);
$maps = $this->maps;
foreach($maps as $m=>$map){
if(isset($map['api_param']) && $this->settings['tile_api_key']){
foreach($map['urls'] as $i=>$url){
$maps[$m]['urls'][$i] = add_query_arg($map['api_param'], $this->settings['tile_api_key'], $url);
}
}
}
wp_add_inline_script('event-post', 'var EventPost = EventPost || {}; EventPost.front='.wp_json_encode(array(
'imgpath' => plugins_url('/img/', __FILE__),
'maptiles' => $maps,
'defaulttile' => $this->settings['tile'],
'zoom' => $this->settings['zoom'],
'ajaxurl' => admin_url() . 'admin-ajax.php',
'map_interactions'=>$this->map_interactions,
)), 'before');
}
public function load_map_scripts() {
$this->load_styles(array('event-post-map'));
if(is_admin()){
$this->admin_scripts(array('jquery', 'event-post-map'));
}
}
public function admin_head() {
$page = basename($_SERVER['SCRIPT_NAME']);
if( $page!='post-new.php' && $page!='edit-tags.php' && !($page=='post.php' && filter_input(INPUT_GET, 'action')=='edit') && !($page=='options-general.php' && filter_input(INPUT_GET, 'page')=='event-settings') ){
return;
}
wp_enqueue_style('event-post-admin', plugins_url('/build/admin/admin.css', __FILE__), false, filemtime( "{$this->plugin_path}/build/admin/admin.css" ));
}
public function admin_scripts($deps = array('jquery'), $force=false) {
$page = basename($_SERVER['SCRIPT_NAME']);
if(!$force &&
$page!='post-new.php' &&
$page!='edit-tags.php' &&
$page!='term.php' &&
!($page=='post.php' && filter_input(INPUT_GET, 'action')=='edit') &&
!($page=='options-general.php' && filter_input(INPUT_GET, 'page')=='event-settings')
){
return;
}
wp_enqueue_script('jquery');
wp_enqueue_script('jquery-effects-core');
wp_enqueue_script('jquery-effects-shake');
wp_enqueue_style( 'wp-color-picker');
wp_enqueue_script( 'wp-color-picker');
if(!is_array($deps)){
$deps = array('jquery','wp-color-picker');
}
if($this->settings['datepicker']=='simple' || !is_admin() || (isset($_GET['page']) && $_GET['page']=='event-settings')){
wp_enqueue_script('jquery-ui-datepicker');
$deps[] = 'jquery-ui-datepicker';
}
wp_enqueue_script('event-post-admin', plugins_url('/build/admin/admin.js', __FILE__), $deps, filemtime( "{$this->plugin_path}/build/admin/admin.js" ), true);
$language = get_bloginfo('language');
if (strpos($language, '-') > -1) {
$language = strtolower(substr($language, 0, 2));
}
wp_add_inline_script('event-post-admin', 'var EventPost = EventPost || {}; EventPost.admin='.wp_json_encode(array(
'ajaxurl' => admin_url('admin-ajax.php'),
'imgpath' => plugins_url('/img/', __FILE__),
'date_choose' => __('Choose', 'event-post'),
'date_format' => __('yy-mm-dd', 'event-post'),
'more_icons' => __('More icons', 'event-post'),
'pick_a_date'=>__('Pick a date','event-post'),
'use_current_location'=>__('Use my current location','event-post'),
'start_drag'=>__('Click to<br>drag the map<br>and change location','event-post'),
'empty_address'=>__('Be kind to fill a non empty address:)', 'event-post'),
'search'=>__('Type an address', 'event-post'),
'stop_drag'=>_x('Done','Stop allowing to drag the map', 'event-post'),
'datepickeri18n'=>array(
'order'=>__( '%1$s %2$s, %3$s @ %4$s:%5$s', 'event-post'),
'day'=>__('Day', 'event-post'),
'month'=>__('Month', 'event-post'),
'year'=>__('Day', 'event-post'),
'hour'=>__('Hour', 'event-post'),
'minute'=>__('Minute', 'event-post'),
'ok'=>__('OK', 'event-post'),
'cancel'=>__('Cancel', 'event-post'),
'remove'=>__('Remove', 'event-post'),
'edit'=>__('Edit', 'event-post'),
'months'=>$this->NomDuMois,
),
'META_START' => $this->META_START,
'META_END' => $this->META_END,
'META_ADD' => $this->META_ADD,
'META_LAT' => $this->META_LAT,
'META_LONG' => $this->META_LONG,
'META_STATUS' => $this->META_STATUS,
'META_ATTENDANCE_MODE' => $this->META_ATTENDANCE_MODE,
'lang'=>$language,
'maptiles' => $this->maps,
'defaulttile' => $this->settings['tile'],
'palette' => $this->get_theme_palette("hex"),
'available_images' => $this->get_colors(),
)));
}
function scripts_edit() {
$current_post_type = isset($_GET['post_type']) ? $_GET['post_type'] : 'post';
if ( in_array( $current_post_type, $this->settings['posttypes'] ) ) {
wp_enqueue_script( 'eventpost-inline-edit', plugins_url( 'build/admin/inline-edit.js', __FILE__ ), array( 'jquery', 'inline-edit-post' ), '', true );
wp_add_inline_script('eventpost-inline-edit', 'var EventPost = EventPost || {}; EventPost.inlineEdit='.wp_json_encode(array(
'quick'=>$this->quick_edit_fields,
'bulk'=>$this->bulk_edit_fields,
)));
}
}
function get_rich_result($event){
$location_virtual = array(
'@type'=>'VirtualLocation',
'url'=>$event->virtual_location,
);
$physical_location = array(
'@type'=>'place',
'name'=>$event->address,
'address'=>$event->address,
'geo'=>array(
'@type'=>'GeoCoordinates',
'latitude'=>$event->lat,
'longitude'=>$event->long,
),
);
$min = 60 * get_option('gmt_offset');
$sign = $min < 0 ? "-" : "+";
$absmin = abs($min);
$gmt_offset = sprintf("%s%02d:%02d", $sign, $absmin/60, $absmin%60);
$time_format = (is_numeric($event->time_start) && is_numeric($event->time_end) && date('H:i', $event->time_start) != date('H:i', $event->time_end) && date('H:i', $event->time_start) != '00:00' && date('H:i', $event->time_end) != '00:00') ? 'Y-m-d\Th:i:00'.$gmt_offset : 'Y-m-d';
$rich_data = array(
'@context'=>'https://schema.org',
'@type'=>'event',
'name'=>$event->post_title,
'datePublished'=>str_replace(' ', 'T', $event->post_date_gmt).$gmt_offset,
'dateModified'=>str_replace(' ', 'T', $event->post_modified_gmt).$gmt_offset,
'startDate'=>$event->time_start ? date($time_format, $event->time_start) : null,
'endDate'=>$event->time_end ? date($time_format, $event->time_end) : null,
'eventStatus'=>$event->status,
'eventAttendanceMode'=>$event->attendance_mode,
'location'=> ($event->attendance_mode == 'MixedEventAttendanceMode') ? array($location_virtual,$physical_location) : ($event->attendance_mode == 'OnlineEventAttendanceMode' ? $location_virtual : $physical_location),
'image'=> has_post_thumbnail($event->ID) ? array(
get_the_post_thumbnail_url($event->ID, 'post-thumbnail'),
get_the_post_thumbnail_url($event->ID, 'medium'),
get_the_post_thumbnail_url($event->ID, 'large'),
get_the_post_thumbnail_url($event->ID, 'full'),
) : null,
'description'=>$event->description,
);
return apply_filters('event-post-rich-result', $rich_data, $event);
}
function wpseo_schema_webpage($rich_result){
$event = $this->retreive();
if ($event != false){
if ($event->time_start != '' && $event->time_end != '') {
$rich_result = array_merge($rich_result, $this->get_rich_result($event));
}
$this->is_schema_output = true;
}
return $rich_result;
}
function get_theme_palette($return = "hex"){
$theme_options = wp_get_global_settings();
$colors = [];
if(isset($theme_options['color']['palette']['theme'])){
$colors = $theme_options['color']['palette']['theme'];
}elseif(isset($theme_options['color']['palette']['default'])){
$colors = $theme_options['color']['palette']['default'];
}
if($return == "hex"){
$color_hexs = [];
foreach($colors as $color){
$color_hexs[] = $color["color"];
}
return $color_hexs;
}
return $colors;
}
public function single_header() {
if (is_single()) {
$twitter_label_id=0;
$event = $this->retreive();
$has_location = $has_time = false;
if ($event != false) {
if ($event->address != '' || ($event->lat != '' && $event->long != '')) {
$twitter_label_id++;
$has_location = true;
?>
<meta name="geo.placename" content="<?php echo esc_attr($event->address) ?>" />
<meta name="geo.position" content="<?php echo esc_attr($event->lat) ?>;<?php echo esc_attr($event->long) ?>" />
<meta name="ICBM" content="<?php echo esc_attr($event->lat) ?>;<?php echo esc_attr($event->long) ?>" />
<meta property="place:location:latitude" content="<?php echo esc_attr($event->lat) ?>" />
<meta property="place:location:longitude" content="<?php echo esc_attr($event->long) ?>" />
<meta name="twitter:label<?php echo esc_attr($twitter_label_id); ?>" content="<?php esc_attr_e('Location', 'event-post'); ?>"/>
<meta name="twitter:data<?php echo esc_attr($twitter_label_id); ?>" content="<?php echo esc_attr($event->address) ?>"/>
<?php
}
if ($event->start != '' && $event->end != '') {
$has_time = true;
$twitter_label_id++;
?>
<meta name="datetime-coverage-start" content="<?php echo esc_attr(date('c', $event->time_start)) ?>" />
<meta name="datetime-coverage-end" content="<?php echo esc_attr(date('c', $event->time_end)) ?>" />
<meta name="twitter:label<?php echo esc_attr($twitter_label_id); ?>" content="<?php echo esc_attr('Date', 'event-post'); ?>"/>
<meta name="twitter:data<?php echo esc_attr($twitter_label_id); ?>" content="<?php echo esc_attr($this->human_date($event->time_start)) ?>"/>
<?php
}
if(($has_location || $has_time) && !$this->is_schema_output){
$rich_result = $this->get_rich_result($event);
$this->is_schema_output = true;
?>
<script type="application/ld+json"><?php echo \wp_json_encode($rich_result); ?></script>
<?php
}
}
}
}
public function date_cleanup($str){
return trim(str_replace(array('0', ' ', ':', '-'), '', $str));
}
public function dateisvalid($str) {
return is_string($str) && $this->date_cleanup($str) != '';
}
public function parsedate($date, $sep = '') {
if (!empty($date)) {
return substr($date, 0, 10) . $sep . substr($date, 11, 8);
} else {
return '';
}
}
public function human_date($date, $format = 'l j F Y') {
if($this->settings['dateforhumans']){
if (is_numeric($date) && date('d/m/Y', $date) == date('d/m/Y')) {
return __('today', 'event-post');
} elseif (is_numeric($date) && date('d/m/Y', $date) == date('d/m/Y', strtotime('+1 day'))) {
return __('tomorrow', 'event-post');
} elseif (is_numeric($date) && date('d/m/Y', $date) == date('d/m/Y', strtotime('-1 day'))) {
return __('yesterday', 'event-post');
}
}
return date_i18n($format, $date);
}
public function delta_date($time_start, $time_end){
if(!$time_start || !$time_end){
return;
}
$from_to_days = _x('%1$sfrom%2$s %3$s %4$sto%5$s %6$s', 'Days', 'event-post');
$single_day_at = _x('%1$s%2$s,%3$s %4$s', 'From/To single day at time', 'event-post');
$from_to_hours = _x('%1$sfrom%2$s %3$s %4$sto%5$s %6$s', 'Hours', 'event-post');
$at_time = _x('%1$sat%2$s %3$s', 'Time', 'event-post');
$dates="\t\t\t\t".'<div class="event_date" data-start="' . $this->human_date($time_start) . '" data-end="' . $this->human_date($time_end) . '">';
if (date('Ymd', $time_start) == date('Ymd', $time_end)) {
$dates.= "\n\t\t\t\t\t\t\t".'<time itemprop="dtstart" datetime="' . date_i18n('c', $time_start) . '">'
. '<span class="date date-single">' . $this->human_date($time_end, $this->settings['dateformat']) . "</span>";
if (date('H:i', $time_start) != date('H:i', $time_end) && date('H:i', $time_start) != '00:00' && date('H:i', $time_end) != '00:00') {
$dates.= ' '.sprintf(
$from_to_hours,
'<span class="linking_word linking_word-from">',
'</span>',
'<span class="time time-start">' . date_i18n($this->settings['timeformat'], $time_start) . '</span>',
'<span class="linking_word linking_word-to">',
'</span>',
'<span class="time time-end">' . date_i18n($this->settings['timeformat'], $time_end) . '</span>'
);
}
elseif (date('H:i', $time_start) != '00:00') {
$dates.= ' '.sprintf(
$at_time,
'<span class="linking_word">',
'</span>',
'<span class="time time-single">' . date_i18n($this->settings['timeformat'], $time_start) . '</span>'
);
}
$dates.="\n\t\t\t\t\t\t\t".'</time>';
}
else {
$dates.= ' '.sprintf(
$from_to_days,
'<span class="linking_word linking_word-from">',
'</span>',
'<time class="date date-start" itemprop="dtstart" datetime="' . date('c', $time_start) . '">'
. ((date('H:i:s', $time_start) != '00:00:00' || date('H:i:s', $time_end) != '00:00:00')
? sprintf($single_day_at, '<span class="date">'.$this->human_date($time_start, $this->settings['dateformat']).'</span>', '<span class="linking_word">', '</span>', '<span class="time">'.date_i18n($this->settings['timeformat'], $time_start).'</span>')
: $this->human_date($time_start, $this->settings['dateformat'])
)
. '</time>',
'<span class="linking_word linking_word-to">',
'</span>',
'<time class="date date-to" itemprop="dtend" datetime="' . date('c', $time_end) . '">'
. ((date('H:i:s', $time_start) != '00:00:00' || date('H:i:s', $time_end) != '00:00:00')
? sprintf($single_day_at, '<span class="date">'.$this->human_date($time_end, $this->settings['dateformat']).'</span>', '<span class="linking_word">', '</span>', '<span class="time">'.date_i18n($this->settings['timeformat'], $time_end).'</span>')
: $this->human_date($time_end, $this->settings['dateformat'])
)
. '</time>'
);
}
$dates.="\n\t\t\t\t\t\t".'</div><!-- .event_date -->';
return $dates;
}
public function print_date($post = null, $links = 'deprecated', $context='') {
$dates = '';
$event = $this->retreive($post);
if ($event != false){
if ($event->start != '' && $event->end != '') {
$dates.=$this->delta_date($event->time_start, $event->time_end);
if(
$this->settings['displaystatus'] == 'both' ||
($this->settings['displaystatus'] == 'single' && is_single() ) ||
($this->settings['displaystatus'] == 'list' && !is_single() )
){
$dates.='<span class="eventpost-status">'.$this->statuses[$event->status].'</span>';
}
$timezone_string = get_option('timezone_string');
$gmt_offset = $gmt = $this->get_gmt_offset();
if (
!is_admin()
&& (
$this->settings['export_when'] == 'both' ||
( $this->settings['export_when'] == 'future' && $this->is_future($event) ) ||
( $this->settings['export_when'] == 'past' && $this->is_past($event) )
)
&& (
$this->settings['export'] == 'both' ||
($this->settings['export'] == 'single' && is_single() ) ||
($this->settings['export'] == 'list' && !is_single() )
)
) {
$title = urlencode($post->post_title);
$address = urlencode($post->address);
$desc = urlencode($event->description."\n\n".$post->permalink);
$allday = ($post->time_start && $post->time_end && date('H:i:s', $post->time_start) == '00:00:00' && date('H:i:s', $post->time_end) == '00:00:00');
$d_s = date("Ymd", $event->time_start) . ($allday ? '' : 'T' . date("His", $event->time_start));
$d_e = date("Ymd", $event->time_end) . ($allday ? '' : 'T' . date("His", $event->time_end));
$uid = $post->ID . '-' . $post->blog_id;
$url = $event->permalink;
$permalink_structure = get_option( 'permalink_structure' );
if($permalink_structure != ""){
$ics_url = site_url('eventpost/'.$event->ID.'.ics');
$vcs_url = site_url('eventpost/'.$event->ID.'.vcs');
}
else{
$ics_url = add_query_arg(array('action'=>'EventPostExport', 'event_id'=>$event->ID, 'format'=>'ics'), admin_url('admin-ajax.php'));
$vcs_url = add_query_arg(array('action'=>'EventPostExport', 'event_id'=>$event->ID, 'format'=>'vcs'), admin_url('admin-ajax.php'));
}
$google_url = add_query_arg(array(
'action'=>'TEMPLATE',
'trp'=>'false',
'sprop'=>'name',
'text'=>$title,
'dates'=>$d_s.'/'.$d_e.'',
'location'=>$address,
'details'=>$desc,
'gmt'=> urlencode($gmt_offset)
), 'https://www.google.com/calendar/event');
if(!empty($timezone_string)){
$google_url = add_query_arg(array(
'ctz'=>$timezone_string,
), $google_url);
}
$dates.='
<span class="eventpost-date-export">
<a href="' . $ics_url . '" class="event_link event-export ics" target="_blank" title="' . __('Download ICS file', 'event-post') . '">ical</a>
<a href="' . $google_url . '" class="event_link event-export gcal" target="_blank" title="' . __('Add to Google calendar', 'event-post') . '">Google</a>
<a href="' . $vcs_url . '" class="event_link event-export vcs" target="_blank" title="' . __('Add to Outlook', 'event-post') . '">outlook</a>
<i class="dashicons-before dashicons-calendar"></i>
</span>';
}
}
}
return apply_filters('eventpost_printdate', $dates);
}
public function print_location($post=null, $context='') {
$location = '';
if ($post == null)
$post = get_post();
elseif (is_numeric($post)) {
$post = get_post($post);
}
if (!isset($post->start)) {
$post = $this->retreive($post);
}
if ($post != false){
$address = $post->address;
$lat = $post->lat;
$long = $post->long;
$color = $this->get_post_color($post->ID, $this->settings['default_color'], true);
$icon = $this->DashIcons->icons[$this->get_post_icon($post->ID, $this->settings['default_icon'], true)];
$virtual_location = $post->virtual_location;
$attendance_mode = $post->attendance_mode;
if ($this->is_online($post) && $virtual_location) {
$location.="\t\t\t\t".'<div><a href="'.esc_url($virtual_location).'" class="eventpost-virtual-location-link" target="_blank" rel="noopener">'
.__('Join link', 'event-post')
.'</a></div>'
."\n";
}
if ($this->is_offline($post) && ($address != '' || ($lat != '' && $long != ''))) {
$location.="\t\t\t\t".'<address';
if ($lat != '' && $long != '') {
$location.=' data-id="' . $post->ID . '"
data-latitude="' . $lat . '"
data-longitude="' . $long . '"
data-marker="' . $this->get_marker($color) . '"
data-iconcode="' .$icon. '"
data-icon="' . mb_convert_encoding('&#x'.$icon.';', 'UTF-8', 'HTML-ENTITIES'). '"
data-color="#' . $color. '"';
}
$location.=' itemprop="adr" class="eventpost-address">'
. "\n\t\t\t\t\t\t\t".'<span>'
. "\n".$address
. "\n\t\t\t\t\t\t\t". '</span>';
if ($context=='single' && $lat != '' && $long != '') {
$location.="\n\t\t\t\t\t\t\t".'<a class="event_link gps dashicons-before dashicons-location-alt" href="https://www.openstreetmap.org/?lat=' . $lat .'&lon=' . $long . '&zoom=13" target="_blank" itemprop="geo">' . __('Map', 'event-post') . '</a>';
}
$location.="\n\t\t\t\t\t\t".'</address>';
if (wp_is_mobile() && $lat != '' && $long != '') {
$location.="\n\t\t\t\t\t\t".'<a class="event_link gps-geo-link" href="geo:' . $lat . ',' . $long . '" target="_blank" itemprop="geo"><i class="dashicons-before dashicons-location"></i> ' . __('Open in app', 'event-post') . '</a>';
}
}
}
return apply_filters('eventpost_printlocation', $location);
}
public function color_darkness($color){
$color = str_replace('#', '', $color);
$rgb = array();
for ($x=0;$x<3;$x++) {
$rgb[$x] = hexdec(substr($color,(2*$x),2));
}
return (max($rgb) + min($rgb)) / 510;
}
public function print_categories($post=null, $context='') {
if ($post == null)
$post = get_post();
elseif (is_numeric($post)) {
$post = get_post($post);
}
if (!isset($post->start)) {
$post = $this->retreive($post);
}
$cats = '';
if ($post != false){
$categories = $post->Taxonomies;
if ($categories) {
$cats.="\t\t\t\t".'<span class="event_categories">';
foreach ($categories as $category) {
$cats.="\t\t\t\t\t".'<span ';
$classes = array('event_category');
$darkness = 0;
$color = $this->Taxonomies->get_taxonomy_color($category->term_id);
if ($color != '' && $color) {
$cats.=' style="background-color:#' . $color . '"';
$darkness = $this->color_darkness($color);
if($darkness < 0.5){
array_push($classes, 'event-post-bg-dark');
}
else{
array_push($classes, 'event-post-bg-light');
}
}
$cats.=' class="'.implode(' ', $classes).'">';
$cats .= $category->name . ' ';
$cats.='</span>';
}
$cats.='</span>';
}
}
return $cats;
}
public function get_single($post = null, $class = '', $context='') {
if ($post == null) {
$post = $this->retreive();
}
if ($post != null){
$datas_date = $this->print_date($post, null, $context);
$datas_cat = $this->print_categories($post, $context);
$datas_loc = $this->print_location($post, $context);
$classes = array(
'event_data',
'status-'.$post->status,
'location-type-'.$post->attendance_mode,
$class
);
if ($datas_date != '' || $datas_loc != '') {
$rgb = $this->hex2dec($post->color);
return '<div class="' . implode(' ', $classes) . '" style="border-left-color:#' . $post->color . ';background:rgba(' . $rgb['R'] . ',' . $rgb['G'] . ',' . $rgb['B'] . ',0.1)" itemscope itemtype="http://microformats.org/profile/hcard">'
. apply_filters('eventpost_get_single', $datas_date . $datas_cat . $datas_loc, $post)
. '</div>';
}
}
return '';
}
public function get_singledate($post = null, $class = '', $context='') {
return '<div class="event_data event_date ' . $class . '" itemscope itemtype="http://microformats.org/profile/hcard">' . "\n\t\t".$this->print_date($post, null, $context) . "\n\t\t\t\t\t".'</div><!-- .event_date -->';
}
public function get_singlecat($post = null, $class = '', $context='') {
return '<div class="event_data event_category ' . $class . '" itemscope itemtype="http://microformats.org/profile/hcard">' . "\n\t\t".$this->print_categories($post, $context) . "\n\t\t\t\t\t".'</div><!-- .event_category -->';
}
public function get_singleloc($post = null, $class = '', $context='') {
return '<div class="event_data event_location ' . $class . '" itemscope itemtype="http://microformats.org/profile/hcard">' . "\n\t\t".$this->print_location($post, $context) . "\n\t\t\t\t\t".'</div><!-- .event_location -->';
}
public function display_single($content) {
if (is_page() || !is_single() || is_home() || !in_the_loop() || !is_main_query()){
return $content;
}
$post = $this->retreive();
if($post != false){
if($post->post_type=='product'){
return $content;
}
$eventbar = apply_filters('eventpost_contentbar', $this->get_single($post, 'event_single', 'single'), $post);
if($this->settings['singlepos']=='before'){
$content=$eventbar.$content;
}
elseif($this->settings['singlepos']=='after'){
$content.=$eventbar;
}
$this->load_map_scripts();
}
return $content;
}
public function print_single($post = null) {
echo $this->get_single($post);
}
public function the_title($title, $post_id = null){
if(!$post_id || !in_the_loop() || !$this->settings['loopicons']){
return $title;
}
$icons_ = array(
1=>array('🗓', '🗺'),
2=>array('<span class="dashicons dashicons-calendar"></span>', '<span class="dashicons dashicons-location"></span>'),
);
$event = $this->retreive($post_id);
if ($event !== false){
if(!empty($event->start)){
$title .= ' '.$icons_[$this->settings['loopicons']][0];
}
if(!empty($event->lat) && !empty($event->long)){
$title .= ' '.$icons_[$this->settings['loopicons']][1];
}
}
return $title;
}
function get_price($event,$html=false){
$price = '';
$text_price = $price;
if($event->post_type == 'product'){
$product_id = $event->ID;
$product = wc_get_product($product_id);
$price = $product->get_price();
$currency = get_woocommerce_currency_symbol();
if($product->get_sale_price() != ""){
$old_price = $product->get_regular_price();
$text_price = '<span class="event_price"><del>'.$old_price . $currency . '</del> '.$price. $currency. '</span>';
} else {
$text_price = '<span class="event_price"> '.$price . $currency.'</span>';
}
}
if ($html == true) {
return $text_price;
} else {
return $price;
}
}
public function list_events($atts, $id = 'event_list', $context='') {
$ep_settings = $this->settings;
$defaults = array(
'nb' => 0,
'type' => 'div',
'future' => true,
'past' => false,
'geo' => 0,
'width' => '',
'height' => '',
'list' => 0,
'zoom' => '',
'map_position' => 'false',
'latitude' => '',
'longitude' => '',
'tile' => $ep_settings['tile'],
'pop_element_schema' => 'false',
'htmlPop_element_schema' => '',
'title' => '',
'before_title' => '<h3>',
'after_title' => '</h3>',
'cat' => '',
'tag' => '',
'tax_name' => '',
'tax_term' => '',
'events' => '',
'style' => '',
'thumbnail' => '',
'thumbnail_size' => '',
'excerpt' => '',
'orderby' => 'meta_value',
'order' => 'ASC',
'class' => '',
'className' => '',
'container_schema' => $this->list_shema['container'],
'item_schema' => $this->list_shema['item'],
'pages' => false,
'paged' => '',
);
foreach($this->map_interactions as $int_key=>$int_name){
$defaults[$int_key]=true;
}
$atts_old_nb = $defaults['nb'];
if($id == "event_timeline"){
$atts_old_nb = $atts['nb'];
$atts['nb'] = 0;
}
$atts = shortcode_atts(apply_filters('eventpost_params', $defaults, 'list_events'), $atts);
extract($atts);
if (!is_array($events)) {
$events = $this->get_events($atts);
}
$ret = '';
$this->list_id++;
if (sizeof($events) > 0) {
if (!empty($title)) {
$ret.= html_entity_decode($before_title) . $title . html_entity_decode($after_title);
}
$child = ($type == 'ol' || $type == 'ul') ? 'li' : 'div';
$html = '';
if($id=='event_geolist'){
$this->load_map_scripts();
$html.=sprintf('<%1$s class="event_geolist_icon_loader"><p><span class="dashicons dashicons-location-alt"></span></p><p class="screen-reader-text">'.__('An events map', 'event-post').'</p></%1$s>', $type);
}
$attributes = '';
$prev_arrow = "";
$next_arrow = "";
$item_child_style = "";
if($id == "event_timeline"){
$prev_arrow = '<div class="previous"><span class="screen-reader-text">'.__('« Previous Events', 'event-post')."</span></div>";
$next_arrow = '<div class="next"><span class="screen-reader-text">'.__('Next Events »', 'event-post')."</span></div>";
if($atts_old_nb != 0){
$item_child_style = 'width : '.((100/$atts_old_nb) - 2).'%;';
}
$attributes .= ' data-nb="'.$atts_old_nb.'" data-filter="'.http_build_query($atts).'" ';
}
foreach ($events as $event) {
$text_price = $this->get_price($event,true);
$class_item = array(
$this->is_future($event) ? 'event_future' : 'event_past',
'status-'.$event->status,
'location-type-'.$event->attendance_mode,
);
$taxonomies= get_taxonomies('','names');
$post_terms = [];
$terms = wp_get_post_terms($event->ID, $taxonomies);
foreach($terms as $term){
$class_item[] = $term->taxonomy.'-'.$term->name;
}
if ($ep_settings['emptylink'] == 0 && empty($event->post_content)) {
$event->permalink = '#' . $id . $this->list_id;
}
elseif(empty($event->permalink)){
$event->permalink=$event->guid;
}
$html.=str_replace(
apply_filters('eventpost_item_scheme_entities', array(
'%child%',
'%class%',
'%color%',
'%event_link%',
'%event_thumbnail%',
'%event_title%',
'%event_price%',
'%event_date%',
'%event_cat%',
'%event_location%',
'%event_excerpt%',
'%style%',
)), apply_filters('eventpost_item_scheme_values', array(
$child,
implode(' ', $class_item),
$this->get_post_color($event->ID, $this->settings['default_color'],true),
$event->permalink,
$thumbnail == true ? '<span class="event_thumbnail_wrap">' . get_the_post_thumbnail($event->root_ID, !empty($thumbnail_size) ? $thumbnail_size : 'thumbnail', array('class' => 'attachment-thumbnail wp-post-image event_thumbnail')) . '</span>' : '',
$event->post_title,
$event->post_type == 'product' ? $text_price : '',
$this->get_singledate($event, '', $context),
$this->get_singlecat($event, '', $context),
$this->get_singleloc($event, '', $context),
$excerpt == true && $event->description!='' ? '<span class="event_exerpt">'.$event->description.'</span>' : '',
$item_child_style,
), $event), $item_schema
);
}
if($id == 'event_geolist'){
if($height==''){
$height = '300px';
}
if($width==''){
$width = '100%';
}
$attributes .= ' data-tile="'.esc_attr($tile).'"
data-width="'.esc_attr($width).'"
data-height="'.esc_attr($height).'"
data-zoom="'.esc_attr($zoom).'"
data-map_position="'.esc_attr($map_position).'"
data-latitude="'.esc_attr($latitude).'"
data-longitude="'.esc_attr($longitude).'"
data-pop_element_schema="'.esc_attr($pop_element_schema).'"
data-htmlPop_element_schema="'.esc_attr($htmlPop_element_schema).'"
data-list="'.esc_attr($list).'"
data-disabled-interactions="';
foreach($this->map_interactions as $int_key=>$int_name){
$attributes.=$atts[$int_key]==false ? esc_attr($int_key).', ' : '';
}
$attributes.='" ';
}
$pagination = '';
if($pages && $this->pagination){
global $wp_rewrite;
$paged = ( get_query_var( 'page' ) ) ? absint( get_query_var( 'page' ) ) : 1;
$pagination = paginate_links( array(
'prev_text' => __('« Previous Events', 'event-post'),
'next_text' => __('Next Events »', 'event-post'),
'current' => $paged,
'total' => $this->pagination['max_num_pages'],
)
);
}
if($context == 'events_only'){
$ret = $html;
}else{
$ret.=str_replace(
array(
'%type%',
'%id%',
'%class%',
'%listid%',
'%style%',
'%attributes%',
'%list%',
'%pagination%',
'%prev_arrow%',
'%next_arrow%',
'%number%'
), array(
$type,
$id,
$class.($className ? ' '.esc_attr($className) : '').($id == 'event_geolist' && $list ? ' has-list list-'.esc_attr($list) : ' no-list'),
$id . $this->list_id,
(!empty($width) ? 'width:' . esc_attr($width) . ';' : '') . (!empty($height) ? 'height:' . esc_attr($height) . ';' : '') . esc_attr($style),
$attributes,
$html,
$pagination,
$prev_arrow,
$next_arrow
), $container_schema
);
}
}
elseif(filter_input(INPUT_POST, 'action')=='bulk_do_shortcode'){
return '<div class="event_geolist_icon_loader"><p><span class="dashicons dashicons-calendar"></span></p><p class="screen-reader-text">'.__('An empty list of events', 'event-post').'</p></div>';
}
return apply_filters('eventpost_listevents', $ret, $id.$this->list_id, $atts, $events, $context);
}
public function get_events($atts) {
if(isset($atts['future'])){
$atts['future'] = filter_var( $atts['future'], FILTER_VALIDATE_BOOLEAN);
}
if(isset($atts['past'])){
$atts['past'] = filter_var( $atts['past'], FILTER_VALIDATE_BOOLEAN);
}
if(isset($atts['geo'])){
$atts['geo'] = filter_var( $atts['geo'], FILTER_VALIDATE_BOOLEAN);
}
if(isset($atts['pages'])){
$atts['pages'] = filter_var( $atts['pages'], FILTER_VALIDATE_BOOLEAN);
}
$requete = (shortcode_atts(apply_filters('eventpost_params', array(
'nb' => 5,
'future' => true,
'past' => false,
'geo' => 0,
'cat' => '',
'tag' => '',
'date' => '',
'orderby' => 'meta_value',
'orderbykey' => $this->META_START,
'order' => 'ASC',
'tax_name' => '',
'tax_term' => '',
'paged' => 1,
'post_type'=> $this->settings['posttypes']
), 'get_events'), $atts));
if(!isset($requete['paged']) || $requete['paged'] == ""){
$requete['paged'] = ( get_query_var( 'page' ) ) ? absint( get_query_var( 'page' ) ) : 1;
}
extract($requete);
wp_reset_query();
$arg = array(
'post_status' => 'publish',
'post_type' => $post_type,
'posts_per_page' => $nb,
'paged' => $paged,
'meta_key' => $orderbykey,
'orderby' => $orderby,
'order' => $order
);
if($tax_name=='category'){
$tax_name='';
$cat=$tax_term;
}
elseif($tax_name=='post-tag'){
$tax_name='';
$tag=$tax_term;
}
if ($tax_name != '' && $tax_term != '') {
$arg['tax_query'] = array(
array(
'taxonomy' => $tax_name,
'field' => 'slug',
'terms' => $tax_term,
),
);
}
if ($cat != '') {
if (preg_match('/[a-zA-Z]/i', $cat)) {
$arg['category_name'] = $cat;
} else {
$arg['cat'] = $cat;
}
}
if ($tag != '') {
$arg['tag'] = $tag;
}
$meta_query = array(
array(
'key' => $this->META_END,
'value' => '',
'compare' => '!='
),
array(
'key' => $this->META_END,
'value' => '0:0:00 0:',
'compare' => '!='
),
array(
'key' => $this->META_END,
'value' => ':00',
'compare' => '!='
),
array(
'key' => $this->META_START,
'value' => '',
'compare' => '!='
),
array(
'key' => $this->META_START,
'value' => '0:0:00 0:',
'compare' => '!='
)
);
if ($future == 0 && $past == 0) {
$meta_query = array();
$arg['meta_key'] = null;
$arg['orderby'] = null;
$arg['order'] = null;
}
elseif ($future == 1 && $past == 0) {
$meta_query[] = array(
'key' => $this->META_END,
'value' => current_time('mysql'),
'compare' => '>=',
);
}
elseif ($future == 0 && $past == 1) {
$meta_query[] = array(
'key' => $this->META_END,
'value' => current_time('mysql'),
'compare' => '<=',
);
}
if ($date != '') {
$date = date('Y-m-d', $date);
$meta_query = array(
array(
'key' => $this->META_END,
'value' => $date . ' 00:00:00',
'compare' => '>=',
'type' => 'DATETIME'
),
array(
'key' => $this->META_START,
'value' => $date . ' 23:59:59',
'compare' => '<=',
'type' => 'DATETIME'
)
);
}
if ($geo == 1) {
$meta_query[] = array(
'key' => $this->META_LAT,
'value' => '',
'compare' => '!='
);
$meta_query[] = array(
'key' => $this->META_LONG,
'value' => '',
'compare' => '!='
);
$arg['meta_key'] = $this->META_LAT;
$arg['orderby'] = 'meta_value';
$arg['order'] = 'DESC';
}
$arg['meta_query'] = $meta_query;
$query_md5 = 'eventpost_' . md5(wp_json_encode($requete, true));
if ($this->settings['cache'] == 1 && false !== ( $cached_events = get_transient($query_md5) )) {
return apply_filters('eventpost_get_items', is_array($cached_events) ? $cached_events : array(), $requete, $arg);
}
$events = apply_filters('eventpost_get', '', $requete, $arg);
if ('' === $events) {
global $wpdb;
$query = new WP_Query($arg);
$events = $wpdb->get_col($query->request);
$this->pagination = array(
'found_posts' => $query->found_posts,
'max_num_pages' => $query->max_num_pages,
);
foreach ($events as $k => $post) {
$event = $this->retreive($post);
if ($event != false){
$events[$k] = $event;
}
}
}
if ($this->settings['cache'] == 1){
set_transient($query_md5, $events, 5 * MINUTE_IN_SECONDS);
}
return apply_filters('eventpost_get_items', $events, $requete, $arg);
}
function is_future($event, $exact=false){
$match = current_time('timestamp');
if(!$exact){
$match = mktime(0, 0, 0, date('m', $match), date('d', $match), date('Y', $match));
}
return ($event->time_end >= $match);
}
function is_past($event, $exact=false){
$match = current_time('timestamp');
if(!$exact || ( date('H:i:s', $event->time_start) == '00:00:00' && date('H:i:s', $event->time_end) == '00:00:00' )){
$match = mktime(23, 59, 59, date('m', $match), date('d', $match), date('Y', $match));
}
return ($event->time_end < $match);
}
function is_online($event){
return (in_array($event->attendance_mode, array('MixedEventAttendanceMode', 'OnlineEventAttendanceMode')));
}
function is_offline($event){
return (in_array($event->attendance_mode, array('MixedEventAttendanceMode', 'OfflineEventAttendanceMode')));
}
public function retreive($event = null) {
global $EventPost_cache;
$ob = get_post($event);
if(!$ob){
return false;
}
if(is_object($ob) && $ob->start){
return $ob;
}
if(is_object($ob) && isset($EventPost_cache[$ob->ID])){
return $EventPost_cache[$ob->ID];
}
$ob->start = get_post_meta($ob->ID, $this->META_START, true);
$ob->end = get_post_meta($ob->ID, $this->META_END, true);
if (!$this->dateisvalid($ob->start)){
$ob->start = '';
}
if (!$this->dateisvalid($ob->end)){
$ob->end = '';
}
$ob->root_ID = $ob->ID;
$ob->time_start = !empty($ob->start) ? strtotime($ob->start) : '';
$ob->time_end = !empty($ob->end) ? strtotime($ob->end) : '';
$ob->virtual_location = get_post_meta($ob->ID, $this->META_VIRTUAL_LOCATION, true);
$ob->virtual_location = esc_url($ob->virtual_location);
$ob->address = get_post_meta($ob->ID, $this->META_ADD, true);
$ob->lat = get_post_meta($ob->ID, $this->META_LAT, true);
$ob->long = get_post_meta($ob->ID, $this->META_LONG, true);
$ob->attendance_mode = (null != $att_mod = get_post_meta($ob->ID, $this->META_ATTENDANCE_MODE, true)) ? $att_mod : array_keys($this->attendance_modes)[0];
$ob->status = (null != $status = get_post_meta($ob->ID, $this->META_STATUS, true)) ? $status : array_keys($this->statuses)[0];
$ob->color = $this->get_post_color($ob->ID);
$ob->icon = $this->get_post_icon($ob->ID);
$ob->Taxonomies = get_the_category($ob->ID);
$ob->permalink = get_permalink($ob->ID);
$ob->blog_id = get_current_blog_id();
$ob->description = $ob->post_excerpt ? $ob->post_excerpt : str_replace(' ', ' ', preg_replace("/\n+/", "\n", trim(wp_strip_all_tags(excerpt_remove_blocks($ob->post_content)))));
$EventPost_cache[$ob->ID] = apply_filters('eventpost_retreive', $ob);
return $EventPost_cache[$ob->ID];
}
public function retreive_term($_term=null, $taxonomy='category', $post_type='post') {
$term = get_term($_term, $taxonomy);
if(!$term){
return $term;
}
$term->start = $term->end = $term->time_start = $term->time_end = Null;
$request = array(
'post_type'=>$post_type,
'tax_name'=>$term->taxonomy,
'tax_term'=>$term->slug,
'future'=>true,
'past'=>true,
'nb'=>-1,
'order'=>'ASC'
);
$events = $this->get_events($request);
$term->events_count = count($events);
if($term->events_count){
$term->start = $events[0]->start;
$term->time_start = $events[0]->time_start;
$term->end = $events[$term->events_count-1]->end;
$term->time_end = $events[$term->events_count-1]->time_end;
}
$request['order']='DESC';
$request['nb']=1;
$request['orderbykey']=$this->META_END;
$events = $this->get_events($request);
if(count($events)){
$term->end = $events[0]->end;
$term->time_end = $events[0]->time_end;
}
return $term;
}
public function add_custom_box() {
foreach($this->settings['posttypes'] as $posttype){
add_meta_box(
'event_post_date',
__('Event date', 'event-post'),
array(&$this, 'inner_custom_box_date'),
$posttype,
apply_filters('eventpost_add_custom_box_position', $this->settings['adminpos'], $posttype),
'core',
array(
'__block_editor_compatible_meta_box' => true,
)
);
add_meta_box(
'event_post_loc',
__('Location', 'event-post'),
array(&$this, 'inner_custom_box_loc'),
$posttype,
apply_filters('eventpost_add_custom_box_position', $this->settings['adminpos'], $posttype),
'core',
array(
'__block_editor_compatible_meta_box' => true,
)
);
do_action('eventpost_add_custom_box', $posttype);
}
}
public function inner_custom_box_date() {
wp_nonce_field(plugin_basename(__FILE__), 'eventpost_nonce');
$post_id = get_the_ID();
$event = $this->retreive($post_id);
if ($event != false){
$start_date = $event->start;
$end_date = $event->end;
$eventcolor = $event->color;
$eventicon = $event->icon;
$language = get_bloginfo('language');
if (strpos($language, '-') > -1) {
$language = strtolower(substr($language, 0, 2));
}
$colors = $this->get_colors();
include (plugin_dir_path(__FILE__) . 'views/admin/custombox-date.php');
do_action ('eventpost_custom_box_date', $event);
}
}
public function inner_custom_box_loc($post) {
$event = $this->retreive($post);
if ($event != false){
include (plugin_dir_path(__FILE__) . 'views/admin/custombox-location.php');
do_action ('eventpost_custom_box_loc', $event);
$this->load_map_scripts();
}
}
public function icon_color_fields($item_id, $meta_color,$value_color,$meta_icon,$value_icon ){
?>
<div class="eventpost-misc-pub-section event-color-section">
<span class="screen-reader-text"><?php esc_html_e('Color:', 'event-post'); ?></span>
<input class="color-field-post eventpost-colorpicker"
type="text"
name="<?php echo esc_attr($meta_color); ?>"
value="<?php echo esc_attr($value_color); ?>"
id="color-field<?php echo esc_attr($item_id); ?>"/>
<select style="font-family : dashicons;" class="eventpost-iconpicker" name="<?php echo esc_attr($meta_icon); ?>">
<option value=""><?php esc_attr_e('None','event-post') ?></option>
<?php
foreach($this->DashIcons->icons as $class => $unicode){
?>
<option value="<?php echo esc_attr($class) ?>" <?php selected($value_icon, $class, true); ?>>&; <?php echo esc_html($class) ?></option>
<?php
}
?>
</select>
<div class="custom-marker-container">
<p><?php esc_html_e('An image was found in your custom folder for this color', 'event-post')?> <span class="color-hex"></span> </p>
<img src="" class="image-marker">
</div>
</div>
<?php
}
function quick_edit( $column_name, $post_type, $bulk=false) {
if ($bulk) {
static $eventpostprintNonceBulk = TRUE;
if ($eventpostprintNonceBulk) {
$eventpostprintNonceBulk = FALSE;
}
$fields = $this->bulk_edit_fields;
echo '<input type="hidden" name="eventpost-bulk-editor" id="eventpost-bulk-editor" value="eventpost-bulk-editor">';
}
else {
static $eventpostprintNonce = TRUE;
if ($eventpostprintNonce) {
$eventpostprintNonce = FALSE;
}
$fields = $this->quick_edit_fields;
}
wp_nonce_field(plugin_basename(__FILE__), 'eventpost_nonce');
if(isset($fields[$column_name])): ?>
<fieldset class="inline-edit-col-left inline-edit-<?php echo esc_attr($column_name); ?>">
<div class="inline-edit-group">
<?php foreach ($fields[$column_name] as $fieldname=>$fieldlabel): ?>
<fieldset class="inline-edit-col inline-edit-<?php echo esc_attr($fieldname); ?>">
<div class="inline-edit-col column-<?php echo esc_attr($fieldname); ?>">
<label class="inline-edit-group">
<span class="title"><?php echo esc_html($fieldlabel); ?></span>
<span class="input-text-wrap">
<?php echo $this->inline_field($fieldname, $bulk); ?>
</span>
</label>
</div>
</fieldset>
<?php endforeach; ?>
</div>
</fieldset>
<?php endif;
}
function inline_field($fieldname, $bulk){
return apply_filters('eventpost_inline_field', '<input name="'.esc_attr($fieldname).'" class="eventpost-inline-'.esc_attr($fieldname).'" value="" type="text">', $fieldname, $bulk);
}
function inline_field_color($html, $fieldname, $bulk){
if($fieldname==$this->META_COLOR){
$html='';
if($bulk){
$html.= '<span class="eventpost-bulk-colorpicker-button link">'.esc_html(__('No Change', 'event-post')).'</span>';
}
$html .= '
<input class="eventpost-inline-colorpicker eventpost-inline-'.esc_attr($fieldname).' '.($bulk?'is-bulk':'no-bulk').'" type="color" name="'.esc_attr($fieldname).'" >';
}
return $html;
}
function inline_field_icon($html, $fieldname, $bulk){
if($fieldname==$this->META_ICON){
if($bulk){
$html.= '<span class="eventpost-bulk-icon-button link">'.__('No Change', 'event-post').'</span>';
}
$html = '<select class="eventpost-inline-colorpicker eventpost-inline-'.$fieldname.' '.($bulk?'is-bulk':'no-bulk').'"
type="text"
name="'.$fieldname.'"
style="font-family : dashicons">
<option value="">'.__("None", 'event-post').'</option>';
foreach($this->DashIcons->icons as $class => $unicode){
$html .= '<option value="'.$class.'">&#x'.$unicode.'; '.$class.'</option>';
}
$html .= '</select>';
}
return $html;
}
function bulk_edit($column_name, $post_type){
$this->quick_edit($column_name, $post_type, true);
}
function inline_save(){
$post_id = filter_input(INPUT_POST, 'post_ID', FILTER_SANITIZE_NUMBER_INT);
$this->save_postdata($post_id);
}
public function save_postdata($post_id) {
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){
return;
}
if (!wp_verify_nonce(filter_input(INPUT_POST, 'eventpost_nonce'), plugin_basename(__FILE__))){
return;
}
if (false !== $color = filter_input(INPUT_POST, $this->META_COLOR)) {
update_post_meta($post_id, $this->META_COLOR, sanitize_text_field($color));
}
if (false !== $icon = filter_input(INPUT_POST, $this->META_ICON)) {
update_post_meta($post_id, $this->META_ICON, sanitize_text_field($icon));
}
if (false !== $attendance_mode = filter_input(INPUT_POST, $this->META_ATTENDANCE_MODE)) {
update_post_meta($post_id, $this->META_ATTENDANCE_MODE, sanitize_text_field($attendance_mode));
}
if (false !== $status = filter_input(INPUT_POST, $this->META_STATUS)) {
update_post_meta($post_id, $this->META_STATUS, sanitize_text_field($status));
}
if (false !== $virtual_location = filter_input(INPUT_POST, $this->META_VIRTUAL_LOCATION, FILTER_SANITIZE_URL)) {
update_post_meta($post_id, $this->META_VIRTUAL_LOCATION, sanitize_url($virtual_location));
}
if ((false !== $start = filter_input(INPUT_POST, $this->META_START)) &&
(false !== $end = filter_input(INPUT_POST, $this->META_END)) &&
'' != $start &&
'' != $end) {
update_post_meta($post_id, $this->META_START, sanitize_text_field(substr($start,0,16).':00'));
update_post_meta($post_id, $this->META_END, sanitize_text_field(substr($end,0,16).':00'));
}
else {
delete_post_meta($post_id, $this->META_START);
delete_post_meta($post_id, $this->META_END);
}
if ((false !== $lat = filter_input(INPUT_POST, $this->META_LAT)) &&
(false !== $long = filter_input(INPUT_POST, $this->META_LONG)) &&
'' != $lat &&
'' != $long) {
update_post_meta($post_id, $this->META_ADD, sanitize_text_field(filter_input(INPUT_POST, $this->META_ADD)));
update_post_meta($post_id, $this->META_LAT, sanitize_text_field($lat));
update_post_meta($post_id, $this->META_LONG, sanitize_text_field($long));
}
else {
delete_post_meta($post_id, $this->META_ADD);
delete_post_meta($post_id, $this->META_LAT);
delete_post_meta($post_id, $this->META_LONG);
}
$post_ids = (!empty($_POST['post_ids']) ) ? $_POST['post_ids'] : array();
}
function save_bulkdatas(array $post_ids, array $shared_post_data) {
$current_post_type = isset($shared_post_data['post_type']) ? $shared_post_data['post_type'] : 'post';
if (in_array($current_post_type, $this->settings['posttypes'])) {
if (!empty($post_ids) && is_array($post_ids)) {
foreach ($post_ids as $post_id) {
if(! current_user_can( 'edit_post', $post_id )){
continue;
}
foreach ($this->bulk_edit_fields as $sets) {
foreach ($sets as $fieldname => $fieldlabel) {
if (isset($shared_post_data[$fieldname])) {
update_post_meta($post_id, $fieldname, $shared_post_data[$fieldname]);
}
}
}
}
}
}
}
public function display_caldate($date, $cat = '', $display = false, $colored=true, $thumbnail='', $title='',$tax_name='' ,$tax_term='') {
$events = $this->get_events(array('nb' => -1, 'date' => $date, 'cat' => $cat, 'retreive' => true,'tax_name' => $tax_name ,'tax_term' => $tax_term));
$nb = count($events);
$ret = "";
$price = "";
if(!$display && !$nb){
$ret = date('j', $date);
}
$price = '';
if($nb){
if ($display || $title) {
$ret='<ul>';
foreach ($events as $event) {
$price = $this->get_price($event, true);
if ($this->settings['emptylink'] == 0 && empty($event->post_content)) {
$event->guid = '#';
}
$ret.='<li>'
. '<a href="' . $event->permalink . '" title="'.esc_attr(sprintf(__('View event: %s', 'event-post'), $event->post_title)).'">'
. '<h4>' . $event->post_title . '</h4>'
. '<span class="event_price">' . $price . '</span>'
.$this->get_single($event)
. (!empty($thumbnail) ? '<span class="event_thumbnail_wrap">' . get_the_post_thumbnail($event->ID, $thumbnail) . '</span>' : '')
.'</a>'
. '</li>';
}
$ret.='</ul>';
}
if ($display) {
}
elseif($title) {
$ret = '<span '.($colored?' style="color:#'.$events[0]->color.'"':'').'>'.date('j', $date).'</span>'.$ret;
}
else {
$ret = '<button data-event="'. $tax_term .'" data-date="' . date('Y-m-d', $date).'"'
.' class="'.apply_filters( 'event_post_class_calendar_link', 'eventpost_cal_link' ).'"'.($colored?' style="background-color:#'.$events[0]->color.'"':'')
.' title="'.esc_attr(sprintf(_n('View %1$d event at date %2$s', 'View %1$d events at date %2$s', $nb, 'event-post'), $nb, $this->human_date($date, $this->settings['dateformat']))).'"'
.'>'
. date('j', $date)
. '</button>';
}
}
return apply_filters('eventpost_display_caldate', $ret, $events, $date, $cat ,$price, $display ,$colored ,$thumbnail ,$title ,$tax_name ,$tax_term );
}
public function calendar($atts) {
extract(shortcode_atts(apply_filters('eventpost_params', array(
'date' => date('Y-n'),
'cat' => '',
'mondayfirst' => 0,
'datepicker' => 1,
'colored' => 1,
'display_title'=>0,
'tax_name' => '',
'tax_term' => '',
'thumbnail'=>'',
), 'calendar'), $atts));
if($date && !preg_match('#[0-9][0-9][0-9][0-9]-[0-9][0-9]?#i', $date)){
$date = date('Y-n', strtotime($date));
}
if(!$date){
$date = date('Y-n');
}
$annee = substr($date, 0, 4);
$mois = substr($date, 5);
$time = mktime(0, 0, 0, $mois, 1, $annee);
$prev_year = strtotime('-1 Year', $time);
$next_year = strtotime('+1 Year', $time);
$prev_month = strtotime('-1 Month', $time);
$next_month = strtotime('+1 Month', $time);
$JourMax = date("t", $time);
$NoJour = -date("w", $time);
if ($mondayfirst == 0) {
$NoJour +=1;
} else {
$NoJour +=2;
$this->Week[] = array_shift($this->Week);
}
if ($NoJour > 0 && $mondayfirst == 1) {
$NoJour -=7;
}
$ret = '<table class="event-post-calendar-table">'
. '<caption class="screen-reader-text">'
. __('A calendar of events', 'event-post')
. '</caption>';
$ret.='<thead><tr><th colspan="7">';
if ($datepicker == 1) {
$ret.='<div class="eventpost-calendar-header">';
$ret.='<span class="eventpost-cal-year"><button data-date="' . date('Y-n', $prev_year) . '" tabindex="0" title="'.sprintf(__('Switch to %s', 'event-post'), date('Y', $prev_year)).'" class="eventpost_cal_bt eventpost-cal-bt-prev">«</button><span class="eventpost-cal-header-text">';
$ret.=$annee;
$ret.='</span><button data-date="' . date('Y-n', $next_year) . '" title="'.sprintf(__('Switch to %s', 'event-post'), date('Y', $next_year)).'" class="eventpost_cal_bt eventpost-cal-bt-next">»</button></span>';
$ret.='<span class="eventpost-cal-month"><button data-date="' . date('Y-n', $prev_month) . '" title="'.sprintf(__('Switch to %s', 'event-post'), date_i18n('F Y', $prev_month)).'" class="eventpost_cal_bt eventpost-cal-bt-prev">«</button><span class="eventpost-cal-header-text">';
$ret.=$this->NomDuMois[abs($mois)];
$ret.='</span><button data-date="' . date('Y-n', $next_month) . '" title="'.sprintf(__('Switch to %s', 'event-post'), date_i18n('F Y', $next_month)).'" class="eventpost_cal_bt eventpost-cal-bt-next">»</button> </span>';
$ret.='<span class="eventpost-cal-today"><button data-date="' . date('Y-n') . '" class="eventpost_cal_bt">' . __('Today', 'event-post') . '</button></span>';
$ret.='</div>';
}
$ret.='</th></tr><tr class="event_post_cal_days">';
for ($w = 0; $w < 7; $w++) {
$ret.='<th scope="col">' . strtoupper(substr($this->Week[$w], 0, 1)) . '</th>';
}
$ret.='</tr>';
$ret.='</thead>';
$ret.='<tbody>';
$sqldate = date('Y-m', $time);
$cejour = date('Y-m-d');
for ($semaine = 0; $semaine <= 5; $semaine++) {
$tr_row_content ='';
for ($journee = 0; $journee <= 6; $journee++) {
if ($NoJour > 0 && $NoJour <= $JourMax) {
$td = '<td class="event_post_day">';
if ($sqldate . '-' . ($NoJour<10?'0':'').$NoJour == $cejour) {
$td = '<td class="event_post_day_now">';
}
if ($sqldate . '-' . ($NoJour<10?'0':'').$NoJour < $cejour){
$td = '<td class="event_post_day_over">';
}
$tr_row_content.=$td;
$tr_row_content.= $this->display_caldate(mktime(0, 0, 0, $mois, $NoJour, $annee), $cat, false, $colored, $thumbnail, $display_title ,$tax_name ,$tax_term);
$tr_row_content.='</td>';
} else {
$tr_row_content.='<td></td>';
}
$NoJour ++;
}
if($tr_row_content){
$ret.='<tr>'.$tr_row_content.'</tr>';
}
}
$ret.='</tbody></table>';
return $ret;
}
public function ajaxlist(){
echo wp_kses($this->list_events(array(
'nb' => esc_attr(FILTER_INPUT(INPUT_POST, 'nb')),
'future' => esc_attr(FILTER_INPUT(INPUT_POST, 'future')),
'past' => esc_attr(FILTER_INPUT(INPUT_POST, 'past')),
'geo' => esc_attr(FILTER_INPUT(INPUT_POST, 'geo')),
'width' => esc_attr(FILTER_INPUT(INPUT_POST, 'width')),
'height' => esc_attr(FILTER_INPUT(INPUT_POST, 'height')),
'zoom' => esc_attr(FILTER_INPUT(INPUT_POST, 'zoom')),
'tile' => esc_attr(FILTER_INPUT(INPUT_POST, 'tile')),
'title' => esc_attr(FILTER_INPUT(INPUT_POST, 'title')),
'before_title' => esc_attr(FILTER_INPUT(INPUT_POST, 'before_title')),
'after_title' => esc_attr(FILTER_INPUT(INPUT_POST, 'after_title')),
'cat' => esc_attr(FILTER_INPUT(INPUT_POST, 'cat')),
'tag' => esc_attr(FILTER_INPUT(INPUT_POST, 'tag')),
'events' => esc_attr(FILTER_INPUT(INPUT_POST, 'events')),
'style' => esc_attr(FILTER_INPUT(INPUT_POST, 'style')),
'thumbnail' => esc_attr(FILTER_INPUT(INPUT_POST, 'thumbnail')),
'thumbnail_size' => esc_attr(FILTER_INPUT(INPUT_POST, 'thumbnail_size')),
'excerpt' => esc_attr(FILTER_INPUT(INPUT_POST, 'excerpt')),
'orderby' => esc_attr(FILTER_INPUT(INPUT_POST, 'orderby')),
'order' => esc_attr(FILTER_INPUT(INPUT_POST, 'order')),
'class' => esc_attr(FILTER_INPUT(INPUT_POST, 'class')),
'pages' => esc_attr(FILTER_INPUT(INPUT_POST, 'pages')),
), esc_attr(FILTER_INPUT(INPUT_POST, 'list_type'))), $this->kses_tags);
exit;
}
public function ajaxTimeline(){
echo wp_kses($this->list_events(array(
'nb' => esc_attr(FILTER_INPUT(INPUT_POST, 'nb')),
'future' => esc_attr(FILTER_INPUT(INPUT_POST, 'future')),
'past' => esc_attr(FILTER_INPUT(INPUT_POST, 'past')),
'geo' => esc_attr(FILTER_INPUT(INPUT_POST, 'geo')),
'width' => esc_attr(FILTER_INPUT(INPUT_POST, 'width')),
'height' => esc_attr(FILTER_INPUT(INPUT_POST, 'height')),
'zoom' => esc_attr(FILTER_INPUT(INPUT_POST, 'zoom')),
'tile' => esc_attr(FILTER_INPUT(INPUT_POST, 'tile')),
'title' => esc_attr(FILTER_INPUT(INPUT_POST, 'title')),
'before_title' => esc_attr(FILTER_INPUT(INPUT_POST, 'before_title')),
'after_title' => esc_attr(FILTER_INPUT(INPUT_POST, 'after_title')),
'cat' => esc_attr(FILTER_INPUT(INPUT_POST, 'cat')),
'tag' => esc_attr(FILTER_INPUT(INPUT_POST, 'tag')),
'events' => esc_attr(FILTER_INPUT(INPUT_POST, 'events')),
'style' => esc_attr(FILTER_INPUT(INPUT_POST, 'style')),
'thumbnail' => esc_attr(FILTER_INPUT(INPUT_POST, 'thumbnail')),
'thumbnail_size' => esc_attr(FILTER_INPUT(INPUT_POST, 'thumbnail_size')),
'excerpt' => esc_attr(FILTER_INPUT(INPUT_POST, 'excerpt')),
'orderby' => esc_attr(FILTER_INPUT(INPUT_POST, 'orderby')),
'order' => esc_attr(FILTER_INPUT(INPUT_POST, 'order')),
'class' => esc_attr(FILTER_INPUT(INPUT_POST, 'class')),
'pages' => esc_attr(FILTER_INPUT(INPUT_POST, 'pages')),
), esc_attr(FILTER_INPUT(INPUT_POST, 'list_type'))), $this->kses_tags);
exit;
}
public function ajaxGetNextPage(){
$response = [
"success" => false,
"next_query" => false,
];
if(isset($_POST['query'])){
parse_str($_POST['query'],$query);
foreach($query as $key => $value){
$query[$key] = esc_attr($value);
}
if(isset($_POST['paged'])){
$query["paged"] = esc_attr($_POST['paged']);
}else{
$response['message'] = __('Page number missing', 'event-post');
}
$query['container_schema'] = $this->timeline_shema['container'];
$query['item_schema'] = $this->timeline_shema['item'];
$html = $this->list_events($query,'event_timeline','events_only');
if($html == ""){
$response['message'] = __('No more to load', 'event-post');
}else{
$query["paged"] = $query["paged"] + 1;
$next_html = $this->list_events($query,'event_timeline','events_only');
$response = [
"success" => true,
"html" => $html,
"next_query" => $next_html == "" ? false : true,
];
}
}else{
$response['message'] = __('Query missing', 'event-post');
}
wp_send_json($response);
exit;
}
public function ajaxcal() {
$method = isset($_GET['action']) ? INPUT_GET : INPUT_POST;
echo wp_kses($this->calendar(array(
'date' => esc_attr(FILTER_INPUT($method, 'date')),
'cat' => esc_attr(FILTER_INPUT($method, 'cat')),
'mondayfirst' => esc_attr(FILTER_INPUT($method, 'mf')),
'datepicker' => esc_attr(FILTER_INPUT($method, 'dp')),
'colored' => esc_attr(FILTER_INPUT($method, 'color')),
'display_title' => esc_attr(FILTER_INPUT($method, 'display_title')),
'thumbnail' => esc_attr(FILTER_INPUT($method, 'thumbnail')),
'tax_name' => esc_attr(FILTER_INPUT($method, 'tax_name')),
'tax_term' => esc_attr(FILTER_INPUT($method, 'tax_term')),
)), $this->kses_tags);
exit();
}
public function ajaxdate() {
echo wp_kses($this->display_caldate(
strtotime(esc_attr(FILTER_INPUT(INPUT_GET, 'date'))),
esc_attr(FILTER_INPUT(INPUT_GET, 'cat')),
true,
esc_attr(FILTER_INPUT(INPUT_GET, 'color')),
esc_attr(FILTER_INPUT(INPUT_GET, 'thumbnail')),
esc_attr(FILTER_INPUT(INPUT_GET, 'display_title')),
esc_attr(FILTER_INPUT(INPUT_GET, 'tax_name')),
esc_attr(FILTER_INPUT(INPUT_GET, 'tax_term'))
), $this->kses_tags);
exit();
}
public function HumanDate() {
if (isset($_REQUEST['date']) && !empty($_REQUEST['date'])) {
$date = strtotime($_REQUEST['date']);
echo esc_html($this->human_date($date, $this->settings['dateformat']).(date('H:i', $date)=='00:00' ? '' : ' '. date($this->settings['timeformat'], $date)));
exit();
}
}
public function search($atts) {
$params = shortcode_atts(apply_filters('eventpost_params', array(
'dates' => true,
'q' => true,
'tax' => false,
), 'search'), $atts);
$this->list_id++;
$list_id = $this->list_id;
$q = (false !== $q = filter_input(INPUT_GET, 'q')) ? $q : '';
$from = (false !== $from = filter_input(INPUT_GET, 'from')) ? $from : '';
$to = (false !== $to = filter_input(INPUT_GET, 'to')) ? $to : '';
$tax = (false !== $tax = filter_input(INPUT_GET, 'tax')) ? $tax : '';
$cleaned_from = $this->date_cleanup($from);
$cleaned_to = $this->date_cleanup($to);
if(empty($cleaned_from)){
$from=false;
}
if(empty($cleaned_to)){
$to=false;
}
$this->admin_scripts(null, true);
wp_enqueue_style('jquery-ui', plugins_url('/css/jquery-ui.css', __FILE__), false, filemtime( "/$block_js" ));
include (plugin_dir_path(__FILE__) . 'views/search-form.php');
if ($list_id == filter_input(INPUT_GET, 'evenpost_search')) {
$arg = array(
'post_type' => $this->settings['posttypes'],
'meta_key' => $this->META_START,
'orderby' => 'meta_value',
'order' => 'ASC',
's' => $q
);
if ($tax) {
$arg['cat'] = $tax;
}
if ($from || $to) {
$arg['meta_query'] = array();
if ($from) {
$arg['meta_query'][] = array(
'key' => $this->META_START,
'value' => $from,
'compare' => '>=',
'type' => 'DATETIME'
);
}
if ($to) {
$arg['meta_query'][] = $meta_query = array(
array(
'key' => $this->META_END,
'value' => $to,
'compare' => '<=',
'type' => 'DATETIME'
),
);
}
}
$events = new WP_Query($arg);
include (plugin_dir_path(__FILE__) . 'views/search-results.php');
wp_reset_query();
}
}
public function GetLatLong() {
if (isset($_REQUEST['q']) && !empty($_REQUEST['q'])) {
$q = $_REQUEST['q'];
header('Content-Type: application/json');
$transient_name = 'eventpost_osquery_' . $q;
$val = get_transient($transient_name);
if (false === $val || empty($val) || !is_string($val)) {
$language = get_bloginfo('language');
if (strpos($language, '-') > -1) {
$language = strtolower(substr($language, 0, 2));
}
$remote_val = wp_safe_remote_request('http://nominatim.openstreetmap.org/search?q=' . rawurlencode($q) . '&format=json&accept-language=' . $language);
if(json_decode($remote_val['body'])){
$val = $remote_val['body'];
}
set_transient($transient_name, $val, 30 * DAY_IN_SECONDS);
}
wp_send_json( json_decode($val) );
exit();
}
}
public function columns_head($defaults) {
$defaults['event'] = __('Event', 'event-post');
$defaults['location'] = __('Location', 'event-post');
return apply_filters('eventpost_columns_head', $defaults);
}
public function columns_content($column_name, $post_id) {
if ($column_name == 'location') {
$lat = get_post_meta($post_id, $this->META_LAT, true);
$lon = get_post_meta($post_id, $this->META_LONG, true);
if (!empty($lat) && !empty($lon)) {
add_thickbox();
$color = $this->get_post_color($post_id, $this->settings['default_color'], true);
$icon = $this->get_post_icon($post_id, $this->settings['default_icon'], true);
if ($color == ''){
$color = '777777';
}
if ($icon == ''){
$icon = 'location';
}
echo wp_kses( '<a href="https://www.openstreetmap.org/export/embed.html?bbox='.($lon-0.005).'%2C'.($lat-0.005).'%2C'.($lon+0.005).'%2C'.($lat+0.005).'&TB_iframe=true&width=600&height=550" class="thickbox" target="_blank">'
. '<i class="dashicons dashicons-'.$icon.'" style="color:#'.$color.';"></i>'
. '<span class="screen-reader-text">'.__('View on a map', 'event-post').'</span>'
. get_post_meta($post_id, $this->META_ADD, true)
. '</a> ', $this->kses_tags);
}
$this->column_edit_hidden_fields($post_id, 'location');
}
if ($column_name == 'event') {
echo wp_kses($this->print_date($post_id, false), $this->kses_tags);
$this->column_edit_hidden_fields($post_id, 'event');
}
do_action('eventpost_columns_content', $column_name, $post_id);
}
function column_edit_hidden_fields($post_id, $set){
$event = $this->retreive($post_id);
$html = '<div class="hidden">';
if ($event != false){
foreach($this->quick_edit_fields[$set] as $fieldname=>$fieldlabel){
$html .= '<span class="inline-edit-value '.$fieldname.'">'.esc_attr($event->$fieldname).'</span>';
}
}
$html .= '</div>';
echo wp_kses($html, $this->kses_tags);
}
public function dashboard_right_now($elements){
$nb_date = count($this->get_events(array('future'=>1, 'past'=>1, 'nb'=>-1)));
$nb_geo = count($this->get_events(array('future'=>1, 'past'=>1, 'geo'=>1, 'nb'=>-1)));
if($nb_date){
array_push($elements, '<i class="dashicons dashicons-calendar"></i> <i href="edit.php?post_type=post">'.sprintf(__('%d Events','event-post'), $nb_date)."</i>");
}
if($nb_geo){
array_push($elements, '<i class="dashicons dashicons-location"></i> <i href="edit.php?post_type=post">'.sprintf(__('%d Geolocalized events','event-post'), $nb_geo)."</i>");
}
return $elements;
}
public function ics_date($timestamp){
return date("Ymd",$timestamp).'T'.date("His",$timestamp);
}
public function get_gmt_offset(){
$gmt_offset = get_option('gmt_offset ');
$codegmt = 0;
if ($gmt_offset != 0 && substr($gmt_offset, 0, 1) != '-' && substr($gmt_offset, 0, 1) != '+') {
$codegmt = $gmt_offset * -1;
$gmt_offset = '+' . $gmt_offset;
}
if(abs($gmt_offset < 10)){
$gmt_offset = substr($gmt_offset, 0, 1).'0'.substr($gmt_offset, 1);
}
return $gmt_offset;
}
private function generate_ics($event_id, $format){
$allowed_formats = array('ics', 'vcs');
$event_id = intval($event_id);
$format = sanitize_text_field($format);
if (in_array($format, $allowed_formats)) {
$export_file = plugin_dir_path(__FILE__) . 'inc/export/' . $format . '.php';
if (is_numeric($event_id) && file_exists($export_file)) {
$event = $this->retreive($event_id);
include $export_file;
exit;
}
}
wp_die(__('Invalid request.', 'event-post'));
}
public function parse_request(){
global $wp;
if (preg_match('#^event-feed#i', $wp->request, $match)) {
$this->feed();
exit;
}
if (preg_match('#^eventpost/([0-9]*)\.(ics|vcs)#i', $wp->request, $match)) {
$this->generate_ics($match[1], $match[2]);
}
}
public function export(){
if(false !== $event_id=\filter_input(INPUT_GET, 'event_id',FILTER_SANITIZE_NUMBER_INT)){
$format = \filter_input(INPUT_GET, 'format',FILTER_SANITIZE_STRING);
$this->generate_ics($event_id, $format);
}
}
public function feed(){
if(false !== $cat=\filter_input(INPUT_GET, 'cat',FILTER_SANITIZE_STRING)){
$vtz = get_option('timezone_string');
$gmt = $this->get_gmt_offset();
date_default_timezone_set($vtz);
$separator = "\n";
header("content-type:text/calendar");
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Disposition: attachment; filename=". str_replace('+','-',rawurlencode(get_option('blogname').'-'.$cat)).".ics;" );
$props = array();
$props[] = 'BEGIN:VCALENDAR';
$props[] = 'PRODID://WordPress//Event-Post-V'.$this->version.'//EN';
$props[] = 'VERSION:2.0';
if(!empty($vtz)){
array_push($props,
'BEGIN:VTIMEZONE',
'TZID:'.$vtz,
'BEGIN:DAYLIGHT',
'TZOFFSETFROM:+0100',
'TZOFFSETTO:'.($gmt).'00',
'DTSTART:19700329T020000',
'RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3',
'END:DAYLIGHT',
'BEGIN:STANDARD',
'TZOFFSETFROM:'.($gmt).'00',
'TZOFFSETTO:+0100',
'TZNAME:CET',
'DTSTART:19701025T030000',
'RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10',
'END:STANDARD',
'END:VTIMEZONE'
);
}
$events=$this->get_events(array('cat'=>$cat,'nb'=>-1));
foreach ($events as $event) {
if($event->time_start && $event->time_end){
array_push($props,
'BEGIN:VEVENT',
'CREATED:'.$this->ics_date(strtotime($event->post_date)).'Z',
'LAST-MODIFIED:'.$this->ics_date(strtotime($event->post_modified)).'Z',
'SUMMARY:'.$event->post_title,
'UID:'.md5(site_url()."_eventpost_".$event->ID),
'LOCATION:'.str_replace(',','\,',$event->address),
'DTSTAMP:'.$this->ics_date($event->time_start).(!empty($vtz)?'':'Z'),
'DTSTART'.(!empty($vtz)?';TZID='.$vtz:'').':'.$this->ics_date($event->time_start).(!empty($vtz)?'':'Z'),
'DTEND'.(!empty($vtz)?';TZID='.$vtz:'').':'.$this->ics_date($event->time_end).(!empty($vtz)?'':'Z'),
'DESCRIPTION:'.trim(chunk_split($event->description."\\n\\n".$event->permalink, 60, "\n ")),
'END:VEVENT'
);
}
}
$props[] = 'END:VCALENDAR';
echo esc_html(implode($separator, $props));
exit;
}
}
}