} return $errors; }); birch_defn($ns, 'urlencode', function ($arg) use($ns) { if (is_array($arg)) { $new_array = array(); foreach ($arg as $field_name => $field_value) { $new_array[$field_name] = $ns->urlencode($field_value); } return $new_array; } if (is_string($arg)) { return urlencode($arg); } else { return $arg; } }); birch_defn($ns, 'get_countries', function () use($ns) { return array("AF" => __("Afghanistan", 'birchschedule'), "AL" => __("Albania", 'birchschedule'), "DZ" => __("Algeria", 'birchschedule'), "AS" => __("American Samoa", 'birchschedule'), "AD" => __("Andorra", 'birchschedule'), "AO" => __("Angola", 'birchschedule'), "AI" => __("Anguilla", 'birchschedule'), "AQ" => __("Antarctica", 'birchschedule'), "AG" => __("Antigua And Barbuda", 'birchschedule'), "AR" => __("Argentina", 'birchschedule'), "AM" => __("Armenia", 'birchschedule'), "AW" => __("Aruba", 'birchschedule'), "AU" => __("Australia", 'birchschedule'), "AT" => __("Austria", 'birchschedule'), "AZ" => __("Azerbaijan", 'birchschedule'), "BS" => __("Bahamas", 'birchschedule'), "BH" => __("Bahrain", 'birchschedule'), "BD" => __("Bangladesh", 'birchschedule'), "BB" => __("Barbados", 'birchschedule'), "BY" => __("Belarus", 'birchschedule'), "BE" => __("Belgium", 'birchschedule'), "BZ" => __("Belize", 'birchschedule'), "BJ" => __("Benin", 'birchschedule'), "BM" => __("Bermuda", 'birchschedule'), "BT" => __("Bhutan", 'birchschedule'), "BO" => __("Bolivia", 'birchschedule'), "BA" => __("Bosnia And Herzegowina", 'birchschedule'), "BW" => __("Botswana", 'birchschedule'), "BV" => __("Bouvet Island", 'birchschedule'), "BR" => __("Brazil", 'birchschedule'), "IO" => __("British Indian Ocean Territory", 'birchschedule'), "BN" => __("Brunei Darussalam", 'birchschedule'), "BG" => __("Bulgaria", 'birchschedule'), "BF" => __("Burkina Faso", 'birchschedule'), "BI" => __("Burundi", 'birchschedule'), "KH" => __("Cambodia", 'birchschedule'), "CM" => __("Cameroon", 'birchschedule'), "CA" => __("Canada", 'birchschedule'), "CV" => __("Cape Verde", 'birchschedule'), "KY" => __("Cayman Islands", 'birchschedule'), "CF" => __("Central African Republic", 'birchschedule'), "TD" => __("Chad", 'birchschedule'), "CL" => __("Chile", 'birchschedule'), "CN" => __("China", 'birchschedule'), "CX" => __("Christmas Island", 'birchschedule'), "CC" => __("Cocos (Keeling) Islands", 'birchschedule'), "CO" => __("Colombia", 'birchschedule'), "KM" => __("Comoros", 'birchschedule'), "CG" => __("Congo", 'birchschedule'), "CD" => __("Congo, The Democratic Republic Of The", 'birchschedule'), "CK" => __("Cook Islands", 'birchschedule'), "CR" => __("Costa Rica", 'birchschedule'), "CI" => __("Cote D'Ivoire", 'birchschedule'), "HR" => __("Croatia (Local Name: Hrvatska)", 'birchschedule'), "CU" => __("Cuba", 'birchschedule'), "CY" => __("Cyprus", 'birchschedule'), "CZ" => __("Czech Republic", 'birchschedule'), "DK" => __("Denmark", 'birchschedule'), "DJ" => __("Djibouti", 'birchschedule'), "DM" => __("Dominica", 'birchschedule'), "DO" => __("Dominican Republic", 'birchschedule'), "TP" => __("East Timor", 'birchschedule'), "EC" => __("Ecuador", 'birchschedule'), "EG" => __("Egypt", 'birchschedule'), "SV" => __("El Salvador", 'birchschedule'), "GQ" => __("Equatorial Guinea", 'birchschedule'), "ER" => __("Eritrea", 'birchschedule'), "EE" => __("Estonia", 'birchschedule'), "ET" => __("Ethiopia", 'birchschedule'), "FK" => __("Falkland Islands (Malvinas)", 'birchschedule'), "FO" => __("Faroe Islands", 'birchschedule'), "FJ" => __("Fiji", 'birchschedule'), "FI" => __("Finland", 'birchschedule'), "FR" => __("France", 'birchschedule'), "FX" => __("France, Metropolitan", 'birchschedule'), "GF" => __("French Guiana", 'birchschedule'), "PF" => __("French Polynesia", 'birchschedule'), "TF" => __("French Southern Territories", 'birchschedule'), "GA" => __("Gabon", 'birchschedule'), "GM" => __("Gambia", 'birchschedule'), "GE" => __("Georgia", 'birchschedule'), "DE" => __("Germany", 'birchschedule'), "GH" => __("Ghana", 'birchschedule'), "GI" => __("Gibraltar", 'birchschedule'), "GR" => __("Greece", 'birchschedule'), "GL" => __("Greenland", 'birchschedule'), "GD" => __("Grenada", 'birchschedule'), "GP" => __("Guadeloupe", 'birchschedule'), "GU" => __("Guam", 'birchschedule'), "GT" => __("Guatemala", 'birchschedule'), "GN" => __("Guinea", 'birchschedule'), "GW" => __("Guinea-Bissau", 'birchschedule'), "GY" => __("Guyana", 'birchschedule'), "HT" => __("Haiti", 'birchschedule'), "HM" => __("Heard And Mc Donald Islands", 'birchschedule'), "VA" => __("Holy See (Vatican City State)", 'birchschedule'), "HN" => __("Honduras", 'birchschedule'), "HK" => __("Hong Kong", 'birchschedule'), "HU" => __("Hungary", 'birchschedule'), "IS" => __("Iceland", 'birchschedule'), "IN" => __("India", 'birchschedule'), "ID" => __("Indonesia", 'birchschedule'), "IR" => __("Iran (Islamic Republic Of)", 'birchschedule'), "IQ" => __("Iraq", 'birchschedule'), "IE" => __("Ireland", 'birchschedule'), "IL" => __("Israel", 'birchschedule'), "IT" => __("Italy", 'birchschedule'), "JM" => __("Jamaica", 'birchschedule'), "JP" => __("Japan", 'birchschedule'), "JO" => __("Jordan", 'birchschedule'), "KZ" => __("Kazakhstan", 'birchschedule'), "KE" => __("Kenya", 'birchschedule'), "KI" => __("Kiribati", 'birchschedule'), "KP" => __("Korea, Democratic People's Republic Of", 'birchschedule'), "KR" => __("Korea, Republic Of", 'birchschedule'), "KW" => __("Kuwait", 'birchschedule'), "KG" => __("Kyrgyzstan", 'birchschedule'), "LA" => __("Lao People's Democratic Republic", 'birchschedule'), "LV" => __("Latvia", 'birchschedule'), "LB" => __("Lebanon", 'birchschedule'), "LS" => __("Lesotho", 'birchschedule'), "LR" => __("Liberia", 'birchschedule'), "LY" => __("Libyan Arab Jamahiriya", 'birchschedule'), "LI" => __("Liechtenstein", 'birchschedule'), "LT" => __("Lithuania", 'birchschedule'), "LU" => __("Luxembourg", 'birchschedule'), "MO" => __("Macau", 'birchschedule'), "MK" => __("Macedonia, Former Yugoslav Republic Of", 'birchschedule'), "MG" => __("Madagascar", 'birchschedule'), "MW" => __("Malawi", 'birchschedule'), "MY" => __("Malaysia", 'birchschedule'), "MV" => __("Maldives", 'birchschedule'), "ML" => __("Mali", 'birchschedule'), "MT" => __("Malta", 'birchschedule'), "MH" => __("Marshall Islands", 'birchschedule'), "MQ" => __("Martinique", 'birchschedule'), "MR" => __("Mauritania", 'birchschedule'), "MU" => __("Mauritius", 'birchschedule'), "YT" => __("Mayotte", 'birchschedule'), "MX" => __("Mexico", 'birchschedule'), "FM" => __("Micronesia, Federated States Of", 'birchschedule'), "MD" => __("Moldova, Republic Of", 'birchschedule'), "MC" => __("Monaco", 'birchschedule'), "MN" => __("Mongolia", 'birchschedule'), "MS" => __("Montserrat", 'birchschedule'), "MA" => __("Morocco", 'birchschedule'), "MZ" => __("Mozambique", 'birchschedule'), "MM" => __("Myanmar", 'birchschedule'), "NA" => __("Namibia", 'birchschedule'), "NR" => __("Nauru", 'birchschedule'), "NP" => __("Nepal", 'birchschedule'), "NL" => __("Netherlands", 'birchschedule'), "AN" => __("Netherlands Antilles", 'birchschedule'), "NC" => __("New Caledonia", 'birchschedule'), "NZ" => __("New Zealand", 'birchschedule'), "NI" => __("Nicaragua", 'birchschedule'), "NE" => __("Niger", 'birchschedule'), "NG" => __("Nigeria", 'birchschedule'), "NU" => __("Niue", 'birchschedule'), "NF" => __("Norfolk Island", 'birchschedule'), "MP" => __("Northern Mariana Islands", 'birchschedule'), "NO" => __("Norway", 'birchschedule'), "OM" => __("Oman", 'birchschedule'), "PK" => __("Pakistan", 'birchschedule'), "PW" => __("Palau", 'birchschedule'), "PA" => __("Panama", 'birchschedule'), "PG" => __("Papua New Guinea", 'birchschedule'), "PY" => __("Paraguay", 'birchschedule'), "PE" => __("Peru", 'birchschedule'), "PH" => __("Philippines", 'birchschedule'), "PN" => __("Pitcairn", 'birchschedule'), "PL" => __("Poland", 'birchschedule'), "PT" => __("Portugal", 'birchschedule'), "PR" => __("Puerto Rico", 'birchschedule'), "QA" => __("Qatar", 'birchschedule'), "RE" => __("Reunion", 'birchschedule'), "RO" => __("Romania", 'birchschedule'), "RU" => __("Russian Federation", 'birchschedule'), "RW" => __("Rwanda", 'birchschedule'), "KN" => __("Saint Kitts And Nevis", 'birchschedule'), "LC" => __("Saint Lucia", 'birchschedule'), "VC" => __("Saint Vincent And The Grenadines", 'birchschedule'), "WS" => __("Samoa", 'birchschedule'), "SM" => __("San Marino", 'birchschedule'), "ST" => __("Sao Tome And Principe", 'birchschedule'), "SA" => __("Saudi Arabia", 'birchschedule'), "SN" => __("Senegal", 'birchschedule'), "SC" => __("Seychelles", 'birchschedule'), "SL" => __("Sierra Leone", 'birchschedule'), "SG" => __("Singapore", 'birchschedule'), "SK" => __("Slovakia (Slovak Republic)", 'birchschedule'), "SI" => __("Slovenia", 'birchschedule'), "SB" => __("Solomon Islands", 'birchschedule'), "SO" => __("Somalia", 'birchschedule'), "ZA" => __("South Africa", 'birchschedule'), "GS" => __("South Georgia, South Sandwich Islands", 'birchschedule'), "ES" => __("Spain", 'birchschedule'), "LK" => __("Sri Lanka", 'birchschedule'), "SH" => __("St. Helena", 'birchschedule'), "PM" => __("St. Pierre And Miquelon", 'birchschedule'), "SD" => __("Sudan", 'birchschedule'), "SR" => __("Suriname", 'birchschedule'), "SJ" => __("Svalbard And Jan Mayen Islands", 'birchschedule'), "SZ" => __("Swaziland", 'birchschedule'), "SE" => __("Sweden", 'birchschedule'), "CH" => __("Switzerland", 'birchschedule'), "SY" => __("Syrian Arab Republic", 'birchschedule'), "TW" => __("Taiwan", 'birchschedule'), "TJ" => __("Tajikistan", 'birchschedule'), "TZ" => __("Tanzania, United Republic Of", 'birchschedule'), "TH" => __("Thailand", 'birchschedule'), "TG" => __("Togo", 'birchschedule'), "TK" => __("Tokelau", 'birchschedule'), "TO" => __("Tonga", 'birchschedule'), "TT" => __("Trinidad And Tobago", 'birchschedule'), "TN" => __("Tunisia", 'birchschedule'), "TR" => __("Turkey", 'birchschedule'), "TM" => __("Turkmenistan", 'birchschedule'), "TC" => __("Turks And Caicos Islands", 'birchschedule'), "TV" => __("Tuvalu", 'birchschedule'), "UG" => __("Uganda", 'birchschedule'), "UA" => __("Ukraine", 'birchschedule'), "AE" => __("United Arab Emirates", 'birchschedule'), "GB" => __("United Kingdom", 'birchschedule'), "US" => __("United States", 'birchschedule'), "UM" => __("United States Minor Outlying Islands", 'birchschedule'), "UY" => __("Uruguay", 'birchschedule'), "UZ" => __("Uzbekistan", 'birchschedule'), "VU" => __("Vanuatu", 'birchschedule'), "VE" => __("Venezuela", 'birchschedule'), "VN" => __("Viet Nam", 'birchschedule'), "VG" => __("Virgin Islands (British)", 'birchschedule'), "VI" => __("Virgin Islands (U.S.)", 'birchschedule'), "WF" => __("Wallis And Futuna Islands", 'birchschedule'), "EH" => __("Western Sahara", 'birchschedule'), "YE" => __("Yemen", 'birchschedule'), "YU" => __("Yugoslavia", 'birchschedule'), "ZM" => __("Zambia", 'birchschedule'), "ZW" => __("Zimbabwe", 'birchschedule')); }); birch_defn($ns, 'get_us_states', function () use($ns) { $states = $ns->get_states(); return $states['US']; }); birch_defn($ns, 'get_states', function () use($ns) { return array('US' => array('AL' => __('Alabama (AL)', 'birchschedule'), 'AK' => __('Alaska (AK)', 'birchschedule'), 'AZ' => __('Arizona (AZ)', 'birchschedule'), 'AR' => __('Arkansas (AR)', 'birchschedule'), 'CA' => __('California (CA)', 'birchschedule'), 'CO' => __('Colorado (CO)', 'birchschedule'), 'CT' => __('Connecticut (CT)', 'birchschedule'), 'DC' => __('District of Columbia (DC)', 'birchschedule'), 'DE' => __('Delaware (DE)', 'birchschedule'), 'FL' => __('Florida (FL)', 'birchschedule'), 'GA' => __('Georgia (GA)', 'birchschedule'), 'HI' => __('Hawaii (HI)', 'birchschedule'), 'ID' => __('Idaho (ID)', 'birchschedule'), 'IL' => __('Illinois (IL)', 'birchschedule'), 'IN' => __('Indiana (IN)', 'birchschedule'), 'IA' => __('Iowa (IA)', 'birchschedule'), 'KS' => __('Kansas (KS)', 'birchschedule'), 'KY' => __('Kentucky (KY)', 'birchschedule'), 'LA' => __('Louisiana (LA)', 'birchschedule'), 'ME' => __('Maine (ME)', 'birchschedule'), 'MD' => __('Maryland (MD)', 'birchschedule'), 'MA' => __('Massachusetts (MA)', 'birchschedule'), 'MI' => __('Michigan (MI)', 'birchschedule'), 'MN' => __('Minnesota (MN)', 'birchschedule'), 'MS' => __('Mississippi (MS)', 'birchschedule'), 'MO' => __('Missouri (MO)', 'birchschedule'), 'MT' => __('Montana (MT)', 'birchschedule'), 'NE' => __('Nebraska (NE)', 'birchschedule'), 'NV' => __('Nevada (NV)', 'birchschedule'), 'NH' => __('New Hampshire (NH)', 'birchschedule'), 'NJ' => __('New Jersey (NJ)', 'birchschedule'), 'NM' => __('New Mexico (NM)', 'birchschedule'), 'NY' => __('New York (NY)', 'birchschedule'), 'NC' => __('North Carolina(NC)', 'birchschedule'), 'ND' => __('North Dakota (ND)', 'birchschedule'), 'OH' => __('Ohio (OH)', 'birchschedule'), 'OK' => __('Oklahoma (OK)', 'birchschedule'), 'OR' => __('Oregon (OR)', 'birchschedule'), 'PA' => __('Pennsylvania (PA)', 'birchschedule'), 'PR' => __('Puerto Rico (PR)', 'birchschedule'), 'RI' => __('Rhode Island (RI)', 'birchschedule'), 'SC' => __('South Carolina (SC)', 'birchschedule'), 'SD' => __('South Dakota', 'birchschedule'), 'TN' => __('Tennessee (TN)', 'birchschedule'), 'TX' => __('Texas (TX)', 'birchschedule'), 'UT' => __('Utah (UT)', 'birchschedule'), 'VA' => __('Virginia (VA)', 'birchschedule'), 'VI' => __('Virgin Islands (VI)', 'birchschedule'), 'VT' => __('Vermont (VT)', 'birchschedule'), 'WA' => __('Washington (WA)', 'birchschedule'), 'WV' => __('West Virginia (WV)', 'birchschedule'), 'WI' => __('Wisconsin (WI)', 'birchschedule'), 'WY' => __('Wyoming (WY)', 'birchschedule')), 'AU' => array('ACT' => __('Australian Capital Territory', 'birchschedule'), 'NSW' => __('New South Wales', 'birchschedule'), 'NT' => __('Northern Territory', 'birchschedule'), 'QLD' => __('Queensland', 'birchschedule'), 'SA' => __('South Australia', 'birchschedule'), 'TAS' => __('Tasmania', 'birchschedule'), 'VIC' => __('Victoria', 'birchschedule'), 'WA' => __('Western Australia', 'birchschedule')), 'BR' => array('AC' => __('Acre', 'birchschedule'), 'AL' => __('Alagoas', 'birchschedule'), 'AP' => __('Amapá', 'birchschedule'), 'AM' => __('Amazonas', 'birchschedule'), 'BA' => __('Bahia', 'birchschedule'), 'CE' => __('Ceará', 'birchschedule'), 'DF' => __('Distrito Federal', 'birchschedule'), 'ES' => __('Espírito Santo', 'birchschedule'), 'GO' => __('Goiás', 'birchschedule'), 'MA' => __('Maranhão', 'birchschedule'), 'MT' => __('Mato Grosso', 'birchschedule'), 'MS' => __('Mato Grosso do Sul', 'birchschedule'), 'MG' => __('Minas Gerais', 'birchschedule'), 'PA' => __('Pará', 'birchschedule'), 'PB' => __('Paraíba', 'birchschedule'), 'PR' => __('Paraná', 'birchschedule'), 'PE' => __('Pernambuco', 'birchschedule'), 'PI' => __('Piauí', 'birchschedule'), 'RJ' => __('Rio de Janeiro', 'birchschedule'), 'RN' => __('Rio Grande do Norte', 'birchschedule'), 'RS' => __('Rio Grande do Sul', 'birchschedule'), 'RO' => __('Rondônia', 'birchschedule'), 'RR' => __('Roraima', 'birchschedule'), 'SC' => __('Santa Catarina', 'birchschedule'), 'SP' => __('São Paulo', 'birchschedule'), 'SE' => __('Sergipe', 'birchschedule'), 'TO' => __('Tocantins', 'birchschedule')), 'CA' => array('AB' => __('Alberta', 'birchschedule'), 'BC' => __('British Columbia', 'birchschedule'), 'MB' => __('Manitoba', 'birchschedule'), 'NB' => __('New Brunswick', 'birchschedule'), 'NF' => __('Newfoundland', 'birchschedule'), 'NT' => __('Northwest Territories', 'birchschedule'), 'NS' => __('Nova Scotia', 'birchschedule'), 'NU' => __('Nunavut', 'birchschedule'), 'ON' => __('Ontario', 'birchschedule'), 'PE' => __('Prince Edward Island', 'birchschedule'), 'QC' => __('Quebec', 'birchschedule'), 'SK' => __('Saskatchewan', 'birchschedule'), 'YT' => __('Yukon Territory', 'birchschedule')), 'CN' => array('CN1' => __('Yunnan / 云南', 'birchschedule'), 'CN2' => __('Beijing / 北京', 'birchschedule'), 'CN3' => __('Tianjin / 天津', 'birchschedule'), 'CN4' => __('Hebei / 河北', 'birchschedule'), 'CN5' => __('Shanxi / 山西', 'birchschedule'), 'CN6' => __('Inner Mongolia / 內蒙古', 'birchschedule'), 'CN7' => __('Liaoning / 辽宁', 'birchschedule'), 'CN8' => __('Jilin / 吉林', 'birchschedule'), 'CN9' => __('Heilongjiang / 黑龙江', 'birchschedule'), 'CN10' => __('Shanghai / 上海', 'birchschedule'), 'CN11' => __('Jiangsu / 江苏', 'birchschedule'), 'CN12' => __('Zhejiang / 浙江', 'birchschedule'), 'CN13' => __('Anhui / 安徽', 'birchschedule'), 'CN14' => __('Fujian / 福建', 'birchschedule'), 'CN15' => __('Jiangxi / 江西', 'birchschedule'), 'CN16' => __('Shandong / 山东', 'birchschedule'), 'CN17' => __('Henan / 河南', 'birchschedule'), 'CN18' => __('Hubei / 湖北', 'birchschedule'), 'CN19' => __('Hunan / 湖南', 'birchschedule'), 'CN20' => __('Guangdong / 广东', 'birchschedule'), 'CN21' => __('Guangxi Zhuang / 广西壮族', 'birchschedule'), 'CN22' => __('Hainan / 海南', 'birchschedule'), 'CN23' => __('Chongqing / 重庆', 'birchschedule'), 'CN24' => __('Sichuan / 四川', 'birchschedule'), 'CN25' => __('Guizhou / 贵州', 'birchschedule'), 'CN26' => __('Shaanxi / 陕西', 'birchschedule'), 'CN27' => __('Gansu / 甘肃', 'birchschedule'), 'CN28' => __('Qinghai / 青海', 'birchschedule'), 'CN29' => __('Ningxia Hui / 宁夏', 'birchschedule'), 'CN30' => __('Macau / 澳门', 'birchschedule'), 'CN31' => __('Tibet / 西藏', 'birchschedule'), 'CN32' => __('Xinjiang / 新疆', 'birchschedule')), "ES" => array('C' => __('A Coruña', 'birchschedule'), 'VI' => __('Álava', 'birchschedule'), 'AB' => __('Albacete', 'birchschedule'), 'A' => __('Alicante', 'birchschedule'), 'AL' => __('Almería', 'birchschedule'), 'O' => __('Asturias', 'birchschedule'), 'AV' => __('Ávila', 'birchschedule'), 'BA' => __('Badajoz', 'birchschedule'), 'PM' => __('Baleares', 'birchschedule'), 'B' => __('Barcelona', 'birchschedule'), 'BU' => __('Burgos', 'birchschedule'), 'CC' => __('Cáceres', 'birchschedule'), 'CA' => __('Cádiz', 'birchschedule'), 'S' => __('Cantabria', 'birchschedule'), 'CS' => __('Castellón', 'birchschedule'), 'CE' => __('Ceuta', 'birchschedule'), 'CR' => __('Ciudad Real', 'birchschedule'), 'CO' => __('Córdoba', 'birchschedule'), 'CU' => __('Cuenca', 'birchschedule'), 'GI' => __('Girona', 'birchschedule'), 'GR' => __('Granada', 'birchschedule'), 'GU' => __('Guadalajara', 'birchschedule'), 'SS' => __('Guipúzcoa', 'birchschedule'), 'H' => __('Huelva', 'birchschedule'), 'HU' => __('Huesca', 'birchschedule'), 'J' => __('Jaén', 'birchschedule'), 'LO' => __('La Rioja', 'birchschedule'), 'GC' => __('Las Palmas', 'birchschedule'), 'LE' => __('León', 'birchschedule'), 'L' => __('Lleida', 'birchschedule'), 'LU' => __('Lugo', 'birchschedule'), 'M' => __('Madrid', 'birchschedule'), 'MA' => __('Málaga', 'birchschedule'), 'ML' => __('Melilla', 'birchschedule'), 'MU' => __('Murcia', 'birchschedule'), 'NA' => __('Navarra', 'birchschedule'), 'OR' => __('Ourense', 'birchschedule'), 'P' => __('Palencia', 'birchschedule'), 'PO' => __('Pontevedra', 'birchschedule'), 'SA' => __('Salamanca', 'birchschedule'), 'TF' => __('Santa Cruz de Tenerife', 'birchschedule'), 'SG' => __('Segovia', 'birchschedule'), 'SE' => __('Sevilla', 'birchschedule'), 'SO' => __('Soria', 'birchschedule'), 'T' => __('Tarragona', 'birchschedule'), 'TE' => __('Teruel', 'birchschedule'), 'TO' => __('Toledo', 'birchschedule'), 'V' => __('Valencia', 'birchschedule'), 'VA' => __('Valladolid', 'birchschedule'), 'BI' => __('Vizcaya', 'birchschedule'), 'ZA' => __('Zamora', 'birchschedule'), 'Z' => __('Zaragoza', 'birchschedule')), 'HK' => array('HONG KONG' => __('Hong Kong Island', 'birchschedule'), 'KOWLOON' => __('Kowloon', 'birchschedule'), 'NEW TERRITORIES' => __('New Territories', 'birchschedule')), 'HU' => array('BK' => __('Bács-Kiskun', 'birchschedule'), 'BE' => __('Békés', 'birchschedule'), 'BA' => __('Baranya', 'birchschedule'), 'BZ' => __('Borsod-Abaúj-Zemplén', 'birchschedule'), 'BU' => __('Budapest', 'birchschedule'), 'CS' => __('Csongrád', 'birchschedule'), 'FE' => __('Fejér', 'birchschedule'), 'GS' => __('Győr-Moson-Sopron', 'birchschedule'), 'HB' => __('Hajdú-Bihar', 'birchschedule'), 'HE' => __('Heves', 'birchschedule'), 'JN' => __('Jász-Nagykun-Szolnok', 'birchschedule'), 'KE' => __('Komárom-Esztergom', 'birchschedule'), 'NO' => __('Nógrád', 'birchschedule'), 'PE' => __('Pest', 'birchschedule'), 'SO' => __('Somogy', 'birchschedule'), 'SZ' => __('Szabolcs-Szatmár-Bereg', 'birchschedule'), 'TO' => __('Tolna', 'birchschedule'), 'VA' => __('Vas', 'birchschedule'), 'VE' => __('Veszprém', 'birchschedule'), 'ZA' => __('Zala', 'birchschedule')), 'HZ' => array('AK' => __('Auckland', 'birchschedule'), 'BP' => __('Bay of Plenty', 'birchschedule'), 'CT' => __('Canterbury', 'birchschedule'), 'HB' => __('Hawke’s Bay', 'birchschedule'), 'MW' => __('Manawatu-Wanganui', 'birchschedule'), 'MB' => __('Marlborough', 'birchschedule'), 'NS' => __('Nelson', 'birchschedule'), 'NL' => __('Northland', 'birchschedule'), 'OT' => __('Otago', 'birchschedule'), 'SL' => __('Southland', 'birchschedule'), 'TK' => __('Taranaki', 'birchschedule'), 'TM' => __('Tasman', 'birchschedule'), 'WA' => __('Waikato', 'birchschedule'), 'WE' => __('Wellington', 'birchschedule'), 'WC' => __('West Coast', 'birchschedule')), 'ID' => array('AC' => __('Daerah Istimewa Aceh', 'birchschedule'), 'SU' => __('Sumatera Utara', 'birchschedule'), 'SB' => __('Sumatera Barat', 'birchschedule'), 'RI' => __('Riau', 'birchschedule'), 'KR' => __('Kepulauan Riau', 'birchschedule'), 'JA' => __('Jambi', 'birchschedule'), 'SS' => __('Sumatera Selatan', 'birchschedule'), 'BB' => __('Bangka Belitung', 'birchschedule'), 'BE' => __('Bengkulu', 'birchschedule'), 'LA' => __('Lampung', 'birchschedule'), 'JK' => __('DKI Jakarta', 'birchschedule'), 'JB' => __('Jawa Barat', 'birchschedule'), 'BT' => __('Banten', 'birchschedule'), 'JT' => __('Jawa Tengah', 'birchschedule'), 'JI' => __('Jawa Timur', 'birchschedule'), 'YO' => __('Daerah Istimewa Yogyakarta', 'birchschedule'), 'BA' => __('Bali', 'birchschedule'), 'NB' => __('Nusa Tenggara Barat', 'birchschedule'), 'NT' => __('Nusa Tenggara Timur', 'birchschedule'), 'KB' => __('Kalimantan Barat', 'birchschedule'), 'KT' => __('Kalimantan Tengah', 'birchschedule'), 'KI' => __('Kalimantan Timur', 'birchschedule'), 'KS' => __('Kalimantan Selatan', 'birchschedule'), 'KU' => __('Kalimantan Utara', 'birchschedule'), 'SA' => __('Sulawesi Utara', 'birchschedule'), 'ST' => __('Sulawesi Tengah', 'birchschedule'), 'SG' => __('Sulawesi Tenggara', 'birchschedule'), 'SR' => __('Sulawesi Barat', 'birchschedule'), 'SN' => __('Sulawesi Selatan', 'birchschedule'), 'GO' => __('Gorontalo', 'birchschedule'), 'MA' => __('Maluku', 'birchschedule'), 'MU' => __('Maluku Utara', 'birchschedule'), 'PA' => __('Papua', 'birchschedule'), 'PB' => __('Papua Barat', 'birchschedule')), 'IN' => array('AP' => __('Andra Pradesh', 'birchschedule'), 'AR' => __('Arunachal Pradesh', 'birchschedule'), 'AS' => __('Assam', 'birchschedule'), 'BR' => __('Bihar', 'birchschedule'), 'CT' => __('Chhattisgarh', 'birchschedule'), 'GA' => __('Goa', 'birchschedule'), 'GJ' => __('Gujarat', 'birchschedule'), 'HR' => __('Haryana', 'birchschedule'), 'HP' => __('Himachal Pradesh', 'birchschedule'), 'JK' => __('Jammu and Kashmir', 'birchschedule'), 'JH' => __('Jharkhand', 'birchschedule'), 'KA' => __('Karnataka', 'birchschedule'), 'KL' => __('Kerala', 'birchschedule'), 'MP' => __('Madhya Pradesh', 'birchschedule'), 'MH' => __('Maharashtra', 'birchschedule'), 'MN' => __('Manipur', 'birchschedule'), 'ML' => __('Meghalaya', 'birchschedule'), 'MZ' => __('Mizoram', 'birchschedule'), 'NL' => __('Nagaland', 'birchschedule'), 'OR' => __('Orissa', 'birchschedule'), 'PB' => __('Punjab', 'birchschedule'), 'RJ' => __('Rajasthan', 'birchschedule'), 'SK' => __('Sikkim', 'birchschedule'), 'TN' => __('Tamil Nadu', 'birchschedule'), 'TR' => __('Tripura', 'birchschedule'), 'UT' => __('Uttaranchal', 'birchschedule'), 'UP' => __('Uttar Pradesh', 'birchschedule'), 'WB' => __('West Bengal', 'birchschedule'), 'AN' => __('Andaman and Nicobar Islands', 'birchschedule'), 'CH' => __('Chandigarh', 'birchschedule'), 'DN' => __('Dadar and Nagar Haveli', 'birchschedule'), 'DD' => __('Daman and Diu', 'birchschedule'), 'DL' => __('Delhi', 'birchschedule'), 'LD' => __('Lakshadeep', 'birchschedule'), 'PY' => __('Pondicherry (Puducherry)', 'birchschedule')), 'MY' => array('JHR' => __('Johor', 'birchschedule'), 'KDH' => __('Kedah', 'birchschedule'), 'KTN' => __('Kelantan', 'birchschedule'), 'MLK' => __('Melaka', 'birchschedule'), 'NSN' => __('Negeri Sembilan', 'birchschedule'), 'PHG' => __('Pahang', 'birchschedule'), 'PRK' => __('Perak', 'birchschedule'), 'PLS' => __('Perlis', 'birchschedule'), 'PNG' => __('Pulau Pinang', 'birchschedule'), 'SBH' => __('Sabah', 'birchschedule'), 'SWK' => __('Sarawak', 'birchschedule'), 'SGR' => __('Selangor', 'birchschedule'), 'TRG' => __('Terengganu', 'birchschedule'), 'KUL' => __('W.P. Kuala Lumpur', 'birchschedule'), 'LBN' => __('W.P. Labuan', 'birchschedule'), 'PJY' => __('W.P. Putrajaya', 'birchschedule')), 'NZ' => array('NL' => __('Northland', 'birchschedule'), 'AK' => __('Auckland', 'birchschedule'), 'WA' => __('Waikato', 'birchschedule'), 'BP' => __('Bay of Plenty', 'birchschedule'), 'TK' => __('Taranaki', 'birchschedule'), 'HB' => __('Hawke’s Bay', 'birchschedule'), 'MW' => __('Manawatu-Wanganui', 'birchschedule'), 'WE' => __('Wellington', 'birchschedule'), 'NS' => __('Nelson', 'birchschedule'), 'MB' => __('Marlborough', 'birchschedule'), 'TM' => __('Tasman', 'birchschedule'), 'WC' => __('West Coast', 'birchschedule'), 'CT' => __('Canterbury', 'birchschedule'), 'OT' => __('Otago', 'birchschedule'), 'SL' => __('Southland', 'birchschedule')), 'TH' => array('TH-37' => __('Amnat Charoen (อำนาจเจริญ)', 'birchschedule'), 'TH-15' => __('Ang Thong (อ่างทอง)', 'birchschedule'), 'TH-14' => __('Ayutthaya (พระนครศรีอยุธยา)', 'birchschedule'), 'TH-10' => __('Bangkok (กรุงเทพมหานคร)', 'birchschedule'), 'TH-38' => __('Bueng Kan (บึงกาฬ)', 'birchschedule'), 'TH-31' => __('Buri Ram (บุรีรัมย์)', 'birchschedule'), 'TH-24' => __('Chachoengsao (ฉะเชิงเทรา)', 'birchschedule'), 'TH-18' => __('Chai Nat (ชัยนาท)', 'birchschedule'), 'TH-36' => __('Chaiyaphum (ชัยภูมิ)', 'birchschedule'), 'TH-22' => __('Chanthaburi (จันทบุรี)', 'birchschedule'), 'TH-50' => __('Chiang Mai (เชียงใหม่)', 'birchschedule'), 'TH-57' => __('Chiang Rai (เชียงราย)', 'birchschedule'), 'TH-20' => __('Chonburi (ชลบุรี)', 'birchschedule'), 'TH-86' => __('Chumphon (ชุมพร)', 'birchschedule'), 'TH-46' => __('Kalasin (กาฬสินธุ์)', 'birchschedule'), 'TH-62' => __('Kamphaeng Phet (กำแพงเพชร)', 'birchschedule'), 'TH-71' => __('Kanchanaburi (กาญจนบุรี)', 'birchschedule'), 'TH-40' => __('Khon Kaen (ขอนแก่น)', 'birchschedule'), 'TH-81' => __('Krabi (กระบี่)', 'birchschedule'), 'TH-52' => __('Lampang (ลำปาง)', 'birchschedule'), 'TH-51' => __('Lamphun (ลำพูน)', 'birchschedule'), 'TH-42' => __('Loei (เลย)', 'birchschedule'), 'TH-16' => __('Lopburi (ลพบุรี)', 'birchschedule'), 'TH-58' => __('Mae Hong Son (แม่ฮ่องสอน)', 'birchschedule'), 'TH-44' => __('Maha Sarakham (มหาสารคาม)', 'birchschedule'), 'TH-49' => __('Mukdahan (มุกดาหาร)', 'birchschedule'), 'TH-26' => __('Nakhon Nayok (นครนายก)', 'birchschedule'), 'TH-73' => __('Nakhon Pathom (นครปฐม)', 'birchschedule'), 'TH-48' => __('Nakhon Phanom (นครพนม)', 'birchschedule'), 'TH-30' => __('Nakhon Ratchasima (นครราชสีมา)', 'birchschedule'), 'TH-60' => __('Nakhon Sawan (นครสวรรค์)', 'birchschedule'), 'TH-80' => __('Nakhon Si Thammarat (นครศรีธรรมราช)', 'birchschedule'), 'TH-55' => __('Nan (น่าน)', 'birchschedule'), 'TH-96' => __('Narathiwat (นราธิวาส)', 'birchschedule'), 'TH-39' => __('Nong Bua Lam Phu (หนองบัวลำภู)', 'birchschedule'), 'TH-43' => __('Nong Khai (หนองคาย)', 'birchschedule'), 'TH-12' => __('Nonthaburi (นนทบุรี)', 'birchschedule'), 'TH-13' => __('Pathum Thani (ปทุมธานี)', 'birchschedule'), 'TH-94' => __('Pattani (ปัตตานี)', 'birchschedule'), 'TH-82' => __('Phang Nga (พังงา)', 'birchschedule'), 'TH-93' => __('Phatthalung (พัทลุง)', 'birchschedule'), 'TH-56' => __('Phayao (พะเยา)', 'birchschedule'), 'TH-67' => __('Phetchabun (เพชรบูรณ์)', 'birchschedule'), 'TH-76' => __('Phetchaburi (เพชรบุรี)', 'birchschedule'), 'TH-66' => __('Phichit (พิจิตร)', 'birchschedule'), 'TH-65' => __('Phitsanulok (พิษณุโลก)', 'birchschedule'), 'TH-54' => __('Phrae (แพร่)', 'birchschedule'), 'TH-83' => __('Phuket (ภูเก็ต)', 'birchschedule'), 'TH-25' => __('Prachin Buri (ปราจีนบุรี)', 'birchschedule'), 'TH-77' => __('Prachuap Khiri Khan (ประจวบคีรีขันธ์)', 'birchschedule'), 'TH-85' => __('Ranong (ระนอง)', 'birchschedule'), 'TH-70' => __('Ratchaburi (ราชบุรี)', 'birchschedule'), 'TH-21' => __('Rayong (ระยอง)', 'birchschedule'), 'TH-45' => __('Roi Et (ร้อยเอ็ด)', 'birchschedule'), 'TH-27' => __('Sa Kaeo (สระแก้ว)', 'birchschedule'), 'TH-47' => __('Sakon Nakhon (สกลนคร)', 'birchschedule'), 'TH-11' => __('Samut Prakan (สมุทรปราการ)', 'birchschedule'), 'TH-74' => __('Samut Sakhon (สมุทรสาคร)', 'birchschedule'), 'TH-75' => __('Samut Songkhram (สมุทรสงคราม)', 'birchschedule'), 'TH-19' => __('Saraburi (สระบุรี)', 'birchschedule'), 'TH-91' => __('Satun (สตูล)', 'birchschedule'), 'TH-17' => __('Sing Buri (สิงห์บุรี)', 'birchschedule'), 'TH-33' => __('Sisaket (ศรีสะเกษ)', 'birchschedule'), 'TH-90' => __('Songkhla (สงขลา)', 'birchschedule'), 'TH-64' => __('Sukhothai (สุโขทัย)', 'birchschedule'), 'TH-72' => __('Suphan Buri (สุพรรณบุรี)', 'birchschedule'), 'TH-84' => __('Surat Thani (สุราษฎร์ธานี)', 'birchschedule'), 'TH-32' => __('Surin (สุรินทร์)', 'birchschedule'), 'TH-63' => __('Tak (ตาก)', 'birchschedule'), 'TH-92' => __('Trang (ตรัง)', 'birchschedule'), 'TH-23' => __('Trat (ตราด)', 'birchschedule'), 'TH-34' => __('Ubon Ratchathani (อุบลราชธานี)', 'birchschedule'), 'TH-41' => __('Udon Thani (อุดรธานี)', 'birchschedule'), 'TH-61' => __('Uthai Thani (อุทัยธานี)', 'birchschedule'), 'TH-53' => __('Uttaradit (อุตรดิตถ์)', 'birchschedule'), 'TH-95' => __('Yala (ยะลา)', 'birchschedule'), 'TH-35' => __('Yasothon (ยโสธร)', 'birchschedule')), 'ZA' => array('EC' => __('Eastern Cape', 'birchschedule'), 'FS' => __('Free State', 'birchschedule'), 'GP' => __('Gauteng', 'birchschedule'), 'KZN' => __('KwaZulu-Natal', 'birchschedule'), 'LP' => __('Limpopo', 'birchschedule'), 'MP' => __('Mpumalanga', 'birchschedule'), 'NC' => __('Northern Cape', 'birchschedule'), 'NW' => __('North West', 'birchschedule'), 'WC' => __('Western Cape', 'birchschedule'))); }); birch_defn($ns, 'get_currencies', function () use($ns) { return array('USD' => array('title' => __('U.S. Dollar', 'birchschedule'), 'code' => 'USD', 'symbol_left' => '$', 'symbol_right' => '', 'decimal_point' => '.', 'thousands_point' => ',', 'decimal_places' => '2'), 'EUR' => array('title' => __('Euro', 'birchschedule'), 'code' => 'EUR', 'symbol_left' => '', 'symbol_right' => '€', 'decimal_point' => '.', 'thousands_point' => ',', 'decimal_places' => '2'), 'GBP' => array('title' => __('Pounds Sterling', 'birchschedule'), 'code' => 'GBP', 'symbol_left' => '£', 'symbol_right' => '', 'decimal_point' => '.', 'thousands_point' => ',', 'decimal_places' => '2'), 'AUD' => array('title' => __('Australian Dollar', 'birchschedule'), 'code' => 'AUD', 'symbol_left' => '$', 'symbol_right' => '', 'decimal_point' => '.', 'thousands_point' => ',', 'decimal_places' => '2'), 'BHD' => array('title' => __('Bahraini dinar', 'birchschedule'), 'code' => 'BHD', 'symbol_left' => '', 'symbol_right' => 'BD', 'decimal_point' => '.', 'thousands_point' => ',', 'decimal_places' => '3'), 'BRL' => array('title' => __('Brazilian Real', 'birchschedule'), 'code' => 'BRL', 'symbol_left' => 'R$', 'symbol_right' => '', 'decimal_point' => ',', 'thousands_point' => '.', 'decimal_places' => '2'), 'CAD' => array('title' => __('Canadian Dollar', 'birchschedule'), 'code' => 'CAD', 'symbol_left' => '$', 'symbol_right' => '', 'decimal_point' => '.', 'thousands_point' => ',', 'decimal_places' => '2'), 'CNY' => array('title' => __('Chinese RMB', 'birchschedule'), 'code' => 'CNY', 'symbol_left' => '¥', 'symbol_right' => '', 'decimal_point' => '.', 'thousands_point' => ',', 'decimal_places' => '2'), 'CZK' => array('title' => __('Czech Koruna', 'birchschedule'), 'code' => 'CZK', 'symbol_left' => '', 'symbol_right' => 'Kč', 'decimal_point' => ',', 'thousands_point' => '.', 'decimal_places' => '2'), 'DKK' => array('title' => __('Danish Krone', 'birchschedule'), 'code' => 'DKK', 'symbol_left' => '', 'symbol_right' => 'kr', 'decimal_point' => ',', 'thousands_point' => '.', 'decimal_places' => '2'), 'HKD' => array('title' => __('Hong Kong Dollar', 'birchschedule'), 'code' => 'HKD', 'symbol_left' => '$', 'symbol_right' => '', 'decimal_point' => '.', 'thousands_point' => ',', 'decimal_places' => '2'), 'HUF' => array('title' => __('Hungarian Forint', 'birchschedule'), 'code' => 'HUF', 'symbol_left' => '', 'symbol_right' => 'Ft', 'decimal_point' => '.', 'thousands_point' => ',', 'decimal_places' => '2'), 'INR' => array('title' => __('Indian Rupee', 'birchschedule'), 'code' => 'INR', 'symbol_left' => 'Rs.', 'symbol_right' => '', 'decimal_point' => '.', 'thousands_point' => ',', 'decimal_places' => '2'), 'ILS' => array('title' => __('Israeli New Shekel', 'birchschedule'), 'code' => 'ILS', 'symbol_left' => '₪', 'symbol_right' => '', 'decimal_point' => '.', 'thousands_point' => ',', 'decimal_places' => '2'), 'JPY' => array('title' => __('Japanese Yen', 'birchschedule'), 'code' => 'JPY', 'symbol_left' => '¥', 'symbol_right' => '', 'decimal_point' => '.', 'thousands_point' => ',', 'decimal_places' => '2'), 'MYR' => array('title' => __('Malaysian Ringgit', 'birchschedule'), 'code' => 'MYR', 'symbol_left' => 'RM', 'symbol_right' => '', 'decimal_point' => '.', 'thousands_point' => ',', 'decimal_places' => '2'), 'MXN' => array('title' => __('Mexican Peso', 'birchschedule'), 'code' => 'MXN', 'symbol_left' => '$', 'symbol_right' => '', 'decimal_point' => '.', 'thousands_point' => ',', 'decimal_places' => '2'), 'NZD' => array('title' => __('New Zealand Dollar', 'birchschedule'), 'code' => 'NZD', 'symbol_left' => '$', 'symbol_right' => '', 'decimal_point' => '.', 'thousands_point' => ',', 'decimal_places' => '2'), 'NOK' => array('title' => __('Norwegian Krone', 'birchschedule'), 'code' => 'NOK', 'symbol_left' => 'kr', 'symbol_right' => '', 'decimal_point' => ',', 'thousands_point' => '.', 'decimal_places' => '2'), 'PHP' => array('title' => __('Philippine Peso', 'birchschedule'), 'code' => 'PHP', 'symbol_left' => 'Php', 'symbol_right' => '', 'decimal_point' => '.', 'thousands_point' => ',', 'decimal_places' => '2'), 'PLN' => array('title' => __('Polish Zloty', 'birchschedule'), 'code' => 'PLN', 'symbol_left' => '', 'symbol_right' => 'zł', 'decimal_point' => ',', 'thousands_point' => '.', 'decimal_places' => '2'), 'RON' => array('title' => __('Romanian leu', 'birchschedule'), 'code' => 'RON', 'symbol_left' => '', 'symbol_right' => 'ron', 'decimal_point' => ',', 'thousands_point' => '.', 'decimal_places' => '2'), 'SGD' => array('title' => __('Singapore Dollar', 'birchschedule'), 'code' => 'SGD', 'symbol_left' => '$', 'symbol_right' => '', 'decimal_point' => '.', 'thousands_point' => ',', 'decimal_places' => '2'), 'ZAR' => array('title' => __('South Africa Rand', 'birchschedule'), 'code' => 'ZAR', 'symbol_left' => 'R', 'symbol_right' => '', 'decimal_point' => '.', 'thousands_point' => ',', 'decimal_places' => '2'), 'SEK' => array('title' => __('Swedish Krona', 'birchschedule'), 'code' => 'SEK', 'symbol_left' => '', 'symbol_right' => 'kr', 'decimal_point' => ',', 'thousands_point' => '.', 'decimal_places' => '2'), 'CHF' => array('title' => __('Swiss Franc', 'birchschedule'), 'code' => 'CHF', 'symbol_left' => '', 'symbol_right' => 'CHF', 'decimal_point' => ',', 'thousands_point' => '.', 'decimal_places' => '2'), 'TWD' => array('title' => __('Taiwan New Dollar', 'birchschedule'), 'code' => 'TWD', 'symbol_left' => 'NT$', 'symbol_right' => '', 'decimal_point' => '.', 'thousands_point' => ',', 'decimal_places' => '2'), 'THB' => array('title' => __('Thai Baht', 'birchschedule'), 'code' => 'THB', 'symbol_left' => '', 'symbol_right' => '฿', 'decimal_point' => '.', 'thousands_point' => ',', 'decimal_places' => '2'), 'TRY' => array('title' => __('Turkish Lira', 'birchschedule'), 'code' => 'TRY', 'symbol_left' => '', 'symbol_right' => 'TL', 'decimal_point' => ',', 'thousands_point' => '.', 'decimal_places' => '2'), 'AED' => array('title' => __('United Arab Emirates Dirham', 'birchschedule'), 'code' => 'AED', 'symbol_left' => '', 'symbol_right' => 'AED', 'decimal_point' => '.', 'thousands_point' => ',', 'decimal_places' => '2')); }); });
<?php birch_ns('birchschedule.model.cpt.payment', function ($ns) { global $birchschedule; birch_defn($ns, 'init', function () use($ns, $birchschedule) { birch_defmethod($birchschedule->model, 'pre_save', 'birs_payment', $ns->pre_save); birch_defmethod($birchschedule->model, 'post_get', 'birs_payment', $ns->post_get); }); birch_defn($ns, 'pre_save', function ($payment, $config) { birch_assert(is_array($payment) && isset($payment['post_type'])); if (isset($payment['_birs_payment_amount'])) { $payment['_birs_payment_amount'] = floatval($payment['_birs_payment_amount']); } return $payment; }); birch_defn($ns, 'post_get', function ($payment) { birch_assert(is_array($payment) && isset($payment['post_type'])); $payment['_birs_payment_amount'] = floatval($payment['_birs_payment_amount']); return $payment; }); });
birch_ns('birchschedule.model.cpt.client', function ($ns) { global $birchschedule; birch_defn($ns, 'init', function () use($ns, $birchschedule) { birch_defmethod($birchschedule->model, 'pre_save', 'birs_client', $ns->pre_save); birch_defmethod($birchschedule->model, 'save', 'birs_client', $ns->save); birch_defmethod($birchschedule->model, 'post_get', 'birs_client', $ns->post_get); }); birch_defn($ns, 'pre_save', function ($client, $config) { birch_assert(is_array($client) && isset($client['post_type'])); $name_first = ''; $name_last = ''; if (isset($client['_birs_client_name_first'])) { $name_first = $client['_birs_client_name_first']; } if (isset($client['_birs_client_name_last'])) { $name_last = $client['_birs_client_name_last']; } $client['post_title'] = $name_first . ' ' . $name_last; return $client; }); birch_defn($ns, 'save', function ($client, $config) use($ns, $birchschedule) { return $birchschedule->model->save->fns['_root']($client, $config); }); birch_defn($ns, 'post_get', function ($client) { birch_assert(is_array($client) && isset($client['post_type'])); if (isset($client['_birs_client_name_first']) && isset($client['_birs_client_name_last'])) { $client['_birs_client_name'] = $client['_birs_client_name_first'] . ' ' . $client['_birs_client_name_last']; } return $client; }); });
birch_defn($ns, 'render_meta_boxes', function ($config) use($ns) { $assert_criteria = is_array($config) && isset($config['screen']); birch_assert($assert_criteria); $default_config = array('cols' => 1, 'callback_arg' => ''); $config = array_merge($default_config, $config); if ($config['cols'] === 2) { ?> <div id="poststuff"> <div id="post-body" class="metabox-holder columns-2"> <div id="postbox-container-1" class="postbox-container"> <?php do_meta_boxes($config['screen'], 'side', $config['callback_arg']); ?> </div> <div id="postbox-container-2" class="postbox-container"> <?php do_meta_boxes($config['screen'], 'normal', $config['callback_arg']); ?> </div> </div> <br class="clear" /> </div> <?php } else { ?> <div id="poststuff"> <div id="post-body" class="metabox-holder columns-1"> <div id="postbox-container-1" class="postbox-container"> <?php do_meta_boxes($config['screen'], 'normal', $config['callback_arg']); ?> </div> </div> <br class="clear" /> </div> <?php } });
birch_defn($ns, 'get_appointment_info_html', function ($appointment_id) use($ns) { global $birchpress, $birchschedule; $appointment = $birchschedule->model->get($appointment_id, array('base_keys' => array(), 'meta_keys' => $birchschedule->model->get_appointment_fields())); $options = $birchpress->util->get_time_options(5); if ($appointment) { $location_id = $appointment['_birs_appointment_location']; $location = $birchschedule->model->get($location_id, array('keys' => array('post_title'))); $location_name = $location ? $location['post_title'] : ''; $service_id = $appointment['_birs_appointment_service']; $service = $birchschedule->model->get($service_id, array('keys' => array('post_title'))); $service_name = $service ? $service['post_title'] : ''; $staff_id = $appointment['_birs_appointment_staff']; $staff = $birchschedule->model->get($staff_id, array('keys' => array('post_title'))); $staff_name = $staff ? $staff['post_title'] : ''; $timestamp = $birchpress->util->get_wp_datetime($appointment['_birs_appointment_timestamp']); $date4picker = $timestamp->format(get_option('date_format')); $date = $timestamp->format('m/d/Y'); $time = $timestamp->format(get_option('time_format')); } ob_start(); ?> <input type="hidden" name="birs_appointment_id" id="birs_appointment_id" value="<?php echo $appointment_id; ?> "> <ul> <li class="birs_form_field"> <label> <?php _e('Location', 'birchschedule'); ?> </label> <div class="birs_field_content"> <label><?php echo $location_name; ?> </label> </div> </li> <li class="birs_form_field"> <label> <?php _e('Service', 'birchschedule'); ?> </label> <div class="birs_field_content"> <label><?php echo $service_name; ?> </label> </div> </li> <li class="birs_form_field"> <label> <?php _e('Provider', 'birchschedule'); ?> </label> <div class="birs_field_content"> <label><?php echo $staff_name; ?> </label> </div> </li> <li class="birs_form_field"> <label> <?php _e('Date', 'birchschedule'); ?> </label> <div class="birs_field_content"> <div id="birs_appointment_view_datepicker" style="pointer-events: none;" data-date-value="<?php echo $date; ?> "></div> </div> </li> <li class="birs_form_field"> <label> <?php _e('Time', 'birchschedule'); ?> </label> <div class="birs_field_content"> <label> <?php echo $time; ?> </label> </div> </li> </ul> <?php return ob_get_clean(); });
" /> </div> </li> </ul> <?php }); birch_defn($ns, 'get_calendar_appointment_title_template', function () { return false; }); birch_defn($ns, 'get_calendar_appointment_title', function ($appointment_title, $appointment) use($ns, $birchschedule) { $template = $ns->get_calendar_appointment_title_template(); if ($template === false) { return $appointment_title; } $seperator = "\n"; $description = ''; $appointment1on1s = $appointment['appointment1on1s']; $index = 0; foreach ($appointment1on1s as $appointment1on1) { $appointment1on1_values = $birchschedule->model->mergefields->get_appointment1on1_merge_values($appointment1on1['ID']); $appointment1on1_description = $birchschedule->model->mergefields->apply_merge_fields($template, $appointment1on1_values); if ($index !== 0) { $description .= $seperator . $appointment1on1_description; } else { $description .= $appointment1on1_description; } $index++; } return $description; }); });
$result = array(); foreach ($fully_booked as $date_text => $value) { $today = $birchpress->util->get_wp_datetime(time()); $today_text = $today->format('Y-m-d'); if (strcmp($date_text, $today_text) >= 0) { $result[$date_text] = $value; } } return $result; }); birch_defn($ns, 'mark_fully_booked_day', function ($staff_id, $location_id, $service_id, $date_text) use($ns) { global $birchschedule; $fully_booked = $birchschedule->model->schedule->get_fully_booked_days(); $fully_booked = $birchschedule->model->schedule->clean_past_fully_booked($fully_booked); if ($staff_id != -1) { $fully_booked[$date_text][$staff_id][$location_id][$service_id] = true; } update_option('birchschedule_schedule_fully_booked', $fully_booked); }); birch_defn($ns, 'unmark_fully_booked_day', function ($staff_id, $location_id, $service_id, $date_text) use($ns) { global $birchschedule; $fully_booked = $birchschedule->model->schedule->get_fully_booked_days(); $fully_booked = $birchschedule->model->schedule->clean_past_fully_booked($fully_booked); if ($staff_id != -1) { if (isset($fully_booked[$date_text]) && isset($fully_booked[$date_text][$staff_id]) && isset($fully_booked[$date_text][$staff_id][$location_id]) && isset($fully_booked[$date_text][$staff_id][$location_id][$service_id])) { unset($fully_booked[$date_text][$staff_id][$location_id][$service_id]); } } update_option('birchschedule_schedule_fully_booked', $fully_booked); }); });
} } }); birch_defn($ns, 'upgrade_core', function () { }); birch_defn($ns, 'get_module_lookup_config', function () { return array('key' => 'module', 'lookup_table' => array()); }); birch_defmulti($ns, 'upgrade_module', $ns->get_module_lookup_config, function ($module_a) { }); birch_defn($ns, 'upgrade', function () use($ns, &$module_names) { $ns->upgrade_core(); foreach ($module_names as $module_name) { $ns->upgrade_module(array('module' => $module_name)); } }); birch_defn($ns, 'init_packages', function () use($ns) { global $birchpress; $birchpress->init_package($ns); }); birch_defn($ns, 'run', function () use($ns) { global $birchpress; $ns->load_core(); $ns->load_modules(); $ns->init_packages(); $ns->upgrade(); }); birch_defn($ns, 'spawn_cron', function () { spawn_cron(); }); });
<?php }); birch_defn($ns, 'get_post_types', function () { return array('birs_appointment', 'birs_client', 'birs_location', 'birs_staff', 'birs_service', 'birs_payment'); }); birch_defn($ns, 'get_core_capabilities', function () use($ns) { $capabilities = array(); $capabilities['birs_core'] = array("manage_birs_settings"); $capability_types = $ns->get_post_types(); foreach ($capability_types as $capability_type) { $capabilities[$capability_type] = array("edit_{$capability_type}", "read_{$capability_type}", "delete_{$capability_type}", "edit_{$capability_type}s", "edit_others_{$capability_type}s", "publish_{$capability_type}s", "read_private_{$capability_type}s", "delete_{$capability_type}s", "delete_private_{$capability_type}s", "delete_published_{$capability_type}s", "delete_others_{$capability_type}s", "edit_private_{$capability_type}s", "edit_published_{$capability_type}s"); } return $capabilities; }); birch_defn($ns, 'init_capabilities', function () use($ns) { global $wp_roles, $birchschedule; if (class_exists('WP_Roles')) { if (!isset($wp_roles)) { $wp_roles = new WP_Roles(); } } if (is_object($wp_roles)) { $capabilities = $ns->get_core_capabilities(); foreach ($capabilities as $cap_group) { foreach ($cap_group as $cap) { $wp_roles->add_cap('administrator', $cap); } } } }); });
}); birch_defn($ns, 'load_package', function ($dir) use($ns) { if (is_dir($dir)) { $package_file = $dir . '/package.php'; if (is_file($package_file)) { include_once $package_file; } $sub_packages = scandir($dir); if ($sub_packages) { foreach ($sub_packages as $sub_package) { if ($sub_package != '.' && $sub_package != '..') { $sub_package_dir = $dir . '/' . $sub_package; if (is_dir($sub_package_dir)) { $ns->load_package($sub_package_dir); } } } } } }); birch_defn($ns, 'init_package', function ($package) use($ns) { if (!empty($package->init) && is_callable($package->init)) { $package->init(); } $sub_ns_keys = $package->get_sub_ns_keys(); foreach ($sub_ns_keys as $key) { $sub_package = $package[$key]; $ns->init_package($sub_package); } }); });
birch_defn($ns, 'prepare_items', function ($wp_list_table) use($ns) { global $birchschedule; $perpage = $ns->get_item_count_per_page(); $columns = $wp_list_table->get_columns(); $hidden = array(); $sortable = $wp_list_table->get_sortable_columns(); $wp_list_table->_column_headers = array($columns, $hidden, $sortable); $screen = get_current_screen(); $appointment1on1s = $birchschedule->model->query(array('post_type' => 'birs_appointment1on1', 'post_status' => array('publish'), 'meta_query' => array(array('key' => '_birs_appointment_id', 'value' => $wp_list_table->appointment_id))), array('base_keys' => array(), 'meta_keys' => array('_birs_client_id'))); $client_ids = array(); if ($appointment1on1s) { $appointment1on1s = array_values($appointment1on1s); foreach ($appointment1on1s as $appointment1on1) { $client_ids[] = $appointment1on1['_birs_client_id']; } } $totalitems = count($client_ids); $order = 'ASC'; if (isset($_GET["order"]) && $_GET['order'] == 'desc') { $order = 'DESC'; } $wp_list_table->order = $order; $orderby = 'client_name_first'; if (isset($_GET["orderby"]) && !empty($_GET['orderby'])) { $orderby = $_GET["orderby"]; } $wp_list_table->orderby = $orderby; $totalpages = ceil($totalitems / $perpage); $wp_list_table->set_pagination_args(array("total_items" => $totalitems, "total_pages" => $totalpages, "per_page" => $perpage)); $paged = $wp_list_table->get_pagenum(); $query = array('post_type' => 'birs_client', 'post__in' => $client_ids + array(0), 'post_status' => 'publish', 'nopaging' => false, 'order' => $order, 'orderby' => 'meta_value', 'meta_key' => '_birs_' . $orderby, 'posts_per_page' => $perpage, 'paged' => $paged); $config = array('base_keys' => array(), 'meta_keys' => array('_birs_client_name_first', '_birs_client_name_last', '_birs_client_email', '_birs_client_phone')); $items = $birchschedule->model->query($query, $config); $items = array_values($items); $wp_list_table->items = $items; });
}); birch_defn($ns, 'upgrade_appointment_from_1_1_to_1_2', function () use($ns) { global $birchpress, $birchschedule; $version = $ns->get_db_version_appointment(); if ($version != '1.1') { return; } $appointments = $birchschedule->model->query(array('post_type' => 'birs_appointment', 'post_status' => array('any')), array('base_keys' => array('post_author'), 'meta_keys' => array('_birs_appointment_staff'))); if ($appointments) { foreach ($appointments as $appointment_id => $appointment) { $staff = $birchschedule->model->get($appointment['_birs_appointment_staff'], array('base_keys' => array(), 'meta_keys' => array('_birs_staff_email'))); if ($staff) { $user = WP_User::get_data_by('email', $staff['_birs_staff_email']); if ($user) { $appointment['post_author'] = $user->ID; $birchschedule->model->save($appointment, array('base_keys' => array('post_author'), 'meta_keys' => array())); } } } } update_option('birs_db_version_appointment', '1.2'); }); birch_defn($ns, 'get_db_version_appointment', function () { return get_option('birs_db_version_appointment', '1.0'); }); birch_defn($ns, 'upgrade_core', function () use($ns) { $ns->upgrade_staff_schedule_from_1_0_to_1_1(); $ns->upgrade_appointment_from_1_0_to_1_1(); $ns->upgrade_appointment_from_1_1_to_1_2(); }); });
birch_defn($ns, 'render_location_info', function ($post) use($ns) { global $birchpress, $birchschedule; $post_id = $post->ID; $addresss1 = get_post_meta($post_id, '_birs_location_address1', true); $addresss2 = get_post_meta($post_id, '_birs_location_address2', true); $phone = get_post_meta($post_id, '_birs_location_phone', true); $city = get_post_meta($post_id, '_birs_location_city', true); $zip = get_post_meta($post_id, '_birs_location_zip', true); $state = get_post_meta($post_id, '_birs_location_state', true); $country = get_post_meta($post_id, '_birs_location_country', true); if (!$country) { $country = $birchschedule->model->get_default_country(); } $countries = $birchpress->util->get_countries(); $all_states = $birchpress->util->get_states(); if (isset($all_states[$country])) { $select_display = ""; $text_display = "display:none;"; $states = $all_states[$country]; } else { $select_display = "display:none;"; $text_display = ""; $states = array(); } ?> <div class="panel-wrap birchschedule"> <table class="form-table"> <tr class="form-field"> <th><label><?php _e('Phone Number', 'birchschedule'); ?> </label> </th> <td><input type="text" name="birs_location_phone" id="birs_location_phone" value="<?php echo esc_attr($phone); ?> "> </td> </tr> <tr class="form-field"> <th><label><?php _e('Address', 'birchschedule'); ?> </label> </th> <td><input type="text" name="birs_location_address1" id="birs_location_address1" value="<?php echo esc_attr($addresss1); ?> "> <br> <input type="text" name="birs_location_address2" id="birs_location_address2" value="<?php echo esc_attr($addresss2); ?> "> </td> </tr> <tr class="form-field"> <th><label><?php _e('City', 'birchschedule'); ?> </label> </th> <td><input type="text" name="birs_location_city" id="birs_location_city" value="<?php echo esc_attr($city); ?> "> </td> </tr> <tr class="form-field"> <th><label><?php _e('State/Province', 'birchschedule'); ?> </label> </th> <td> <select name="birs_location_state_select" id="birs_location_state_select" style="<?php echo $select_display; ?> "> <?php $birchpress->util->render_html_options($states, $state); ?> </select> <input type="text" name="birs_location_state" id="birs_location_state" value="<?php echo esc_attr($state); ?> " style="<?php echo $text_display; ?> "> </td> </tr> <tr class="form-field"> <th><label><?php _e('Country', 'birchschedule'); ?> </label></th> <td> <select name="birs_location_country" id="birs_location_country"> <?php $birchpress->util->render_html_options($countries, $country); ?> </select> </td> </tr> <tr class="form-field"> <th><label><?php _e('Zip Code', 'birchschedule'); ?> </label> </th> <td><input type="text" name="birs_location_zip" id="birs_location_zip" value="<?php echo esc_attr($zip); ?> "> </td> </tr> </table> </div> <?php });
$map = $_ns_data->merge_fields_map; if (isset($appointment['_birs_client_country']) && $appointment['_birs_client_country'] !== 'US') { $map['client_state'] = '_birs_client_province'; } if (!isset($appointment[$name])) { if (isset($map[$name])) { $name = $map[$name]; } else { $name = "_birs_" . $name; } } if (isset($appointment[$name])) { $field_value = $appointment[$name]; $field_value_display = $birchschedule->model->mergefields->get_merge_field_display_value($field_value); return $field_value_display; } else { return ""; } }); birch_defn($ns, 'apply_merge_fields', function ($template, $appointment, $map = false) use($ns, $_ns_data) { global $birchschedule; $_ns_data->appointment_for_merge_field = $appointment; if ($map === false) { $_ns_data->merge_fields_map = $birchschedule->model->mergefields->get_merge_fields_map(); } else { $_ns_data->merge_fields_map = $map; } $template = preg_replace_callback('/\\{([a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*)\\}/', array($ns, 'apply_merge_field'), $template); return $template; }); });
birch_defn($ns, 'get_fields_html', function () { global $birchschedule; $labels = $birchschedule->view->bookingform->get_fields_labels(); ob_start(); ?> <ul> <li class="birs_form_field birs_appointment_section"> <h2 class="birs_section"><?php _e('Appointment Info', 'birchschedule'); ?> </h2> </li> <li class="birs_form_field birs_appointment_location"> <label><?php echo $labels['location']; ?> </label> <div class="birs_field_content"> <select id="birs_appointment_location" name="birs_appointment_location"> </select> </div> </li> <li class="birs_form_field birs_appointment_service"> <label><?php echo $labels['service']; ?> </label> <div class="birs_field_content"> <select id="birs_appointment_service" name="birs_appointment_service"> </select> </div> </li> <li class="birs_form_field birs_appointment_staff"> <label><?php echo $labels['service_provider']; ?> </label> <div class="birs_field_content"> <select id="birs_appointment_staff" name="birs_appointment_staff"> </select> <input type="hidden" id="birs_appointment_avaliable_staff" name="birs_appointment_avaliable_staff" /> </div> <div class="birs_error" id="birs_appointment_service_error"></div> </li> <li class="birs_form_field birs_appointment_date"> <label><?php echo $labels['date']; ?> </label> <input id="birs_appointment_date" name="birs_appointment_date" type="hidden"> <div class="birs_field_content"> <div id="birs_appointment_datepicker"> </div> </div> <div class="birs_error" id="birs_appointment_date_error"></div> </li> <li class="birs_form_field birs_appointment_time"> <label><?php echo $labels['time']; ?> </label> <div class="birs_field_content"> </div> <div class="birs_error" id="birs_appointment_time_error"></div> </li> <li class="birs_form_field birs_appointment_notes"> <label><?php echo $labels['appointment_notes']; ?> </label> <div class="birs_field_content birs_field_paragraph"> <textarea id="birs_appointment_notes" name="birs_appointment_notes"></textarea> <input type="hidden" name="birs_appointment_fields[]" value="_birs_appointment_notes" /> </div> </li> <li class="birs_form_field birs_client_section"> <h2 class="birs_section"><?php _e('Your Info', 'birchschedule'); ?> </h2> </li> <li class="birs_form_field birs_client_name_first"> <label><?php echo $labels['client_name_first']; ?> </label> <div class="birs_field_content"> <input id="birs_client_name_first" name="birs_client_name_first" type="text"> <input type="hidden" name="birs_client_fields[]" value="_birs_client_name_first" /> </div> <div class="birs_error" id="birs_client_name_first_error"></div> </li> <li class="birs_form_field birs_client_name_last"> <label><?php echo $labels['client_name_last']; ?> </label> <div class="birs_field_content"> <input id="birs_client_name_last" name="birs_client_name_last" type="text"> <input type="hidden" name="birs_client_fields[]" value="_birs_client_name_last" /> </div> <div class="birs_error" id="birs_client_name_last_error"></div> </li> <li class="birs_form_field birs_client_email"> <label><?php echo $labels['client_email']; ?> </label> <div class="birs_field_content"> <input id="birs_client_email" name="birs_client_email" type="text"> <input type="hidden" name="birs_client_fields[]" value="_birs_client_email" /> </div> <div class="birs_error" id="birs_client_email_error"></div> </li> <li class="birs_form_field birs_client_phone"> <label><?php echo $labels['client_phone']; ?> </label> <div class="birs_field_content"> <input id="birs_client_phone" name="birs_client_phone" type="text"> <input type="hidden" name="birs_client_fields[]" value="_birs_client_phone" /> </div> <div class="birs_error" id="birs_client_phone_error"></div> </li> <li class="birs_footer"> <div class="birs_error" id="birs_booking_error"></div> <div style="display:none;" id="birs_please_wait"><?php _e('Please wait...', 'birchschedule'); ?> </div> <div class="birs_field_content"> <input type="button" value="<?php _e('Submit', 'birchschedule'); ?> " class="button" id="birs_book_appointment"> </div> </li> </ul> <?php $html = ob_get_clean(); return $html; });
birch_defn($ns, 'render_calendar_scene', function () { ?> <div class="birs_scene" id="birs_calendar_scene"> <h2 style="display:none;"></h2> <nav class="navbar navbar-default" role="navigation"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#birs_calendar_menu"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> </div> <div class="collapse navbar-collapse" id="birs_calendar_menu"> <div class="btn-group navbar-btn"> <button type="button" class="btn btn-default" id="birs_add_appointment"> <?php _e('New Appointment', 'birchschedule'); ?> </button> <button type="button" class="btn btn-default" id="birs_calendar_refresh"> <span class="glyphicon glyphicon-refresh"></span> </button> </div> <div class="btn-group navbar-btn"> <button type="button" class="btn btn-default" id="birs_calendar_today"> <?php _e('Today', 'birchschedule'); ?> </button> </div> <div class="btn-group navbar-btn" data-toggle="buttons"> <label class="btn btn-default"> <input type="radio" name="birs_calendar_view_choice" value="month"> <?php _e('Month', 'birchschedule'); ?> </label> <label class="btn btn-default"> <input type="radio" name="birs_calendar_view_choice" value="agendaWeek"> <?php _e('Week', 'birchschedule'); ?> </label> <label class="btn btn-default"> <input type="radio" name="birs_calendar_view_choice" value="agendaDay"> <?php _e('Day', 'birchschedule'); ?> </label> <input type="hidden" name="birs_calendar_view" /> <input type="hidden" name="birs_calendar_current_date" /> </div> <div class="input-group"> <select id="birs_calendar_location"> </select> <select id="birs_calendar_staff"> </select> </div> </div> </nav> <div id="birs_calendar_header"> <table class="fc-header" style="width:100%"> <tbody> <tr> <td class="fc-header-left"> <button type="button" class="btn btn-default btn-sm"> <span class="glyphicon glyphicon-chevron-left"></span> </button> </td> <td class="fc-header-center"> <span class="fc-header-title"> <h2></h2> </span> </td> <td class="fc-header-right"> <button type="button" class="btn btn-default btn-sm"> <span class="glyphicon glyphicon-chevron-right"></span> </button> </td> </tr> </tbody> </table> </div> <div id="birs_calendar"> </div> </div> <?php });
birch_defn($ns, 'ajax_add_new_payment', function () use($ns) { global $birchpress, $birchschedule; $payment_types = $ns->get_payment_types(); $timestamp = time(); $amount = 0; if (isset($_POST['birs_payment_amount'])) { $amount = floatval($_POST['birs_payment_amount']); } $payment_type = $_POST['birs_payment_type']; if (isset($_POST['birs_payment_notes'])) { $payment_notes = $_POST['birs_payment_notes']; } $payment_trid = uniqid(); ?> <tr data-payment-amount="<?php echo $amount; ?> " data-payment-trid="<?php echo $payment_trid; ?> " > <td> <?php echo $birchpress->util->convert_to_datetime($timestamp); ?> <input type="hidden" name="birs_appointment_payments[<?php echo $payment_trid; ?> ][birs_payment_timestamp]" value="<?php echo $timestamp; ?> " /> <div class="row-actions"> <span class="delete"> <a href="javascript:void(0);" data-payment-trid="<?php echo $payment_trid; ?> "> <?php _e('Delete', 'birchschedule'); ?> </a> </span> </div> </td> <td> <?php $currency_code = $birchschedule->model->get_currency_code(); echo $birchschedule->model->apply_currency_symbol($amount, $currency_code); ?> <input type="hidden" name="birs_appointment_payments[<?php echo $payment_trid; ?> ][birs_payment_amount]" value="<?php echo $amount; ?> " /> </td> <td> <?php echo $payment_types[$payment_type]; ?> <input type="hidden" name="birs_appointment_payments[<?php echo $payment_trid; ?> ][birs_payment_type]" value="<?php echo $payment_type; ?> " /> </td> <td> <?php echo $payment_notes; ?> <input type="hidden" name="birs_appointment_payments[<?php echo $payment_trid; ?> ][birs_payment_notes]" value="<?php echo $payment_notes; ?> " /> </td> </tr> <?php die; });
birch_defn($ns, 'merge_data', function ($model, $config, $data) { if (!is_array($config)) { $config = array(); } if (!isset($config['base_keys'])) { $config['base_keys'] = array(); } if (!isset($config['meta_keys'])) { $config['meta_keys'] = array(); } foreach ($config['base_keys'] as $key) { if (isset($data[$key])) { $model[$key] = $data[$key]; } else { $model[$key] = null; } } foreach ($config['meta_keys'] as $key) { $req_key = substr($key, 1); if (isset($data[$key])) { $model[$key] = $data[$key]; } else { if (isset($data[$req_key])) { $model[$key] = $data[$req_key]; } else { $model[$key] = null; } } } return $model; });
<?php birch_ns('birchschedule.model.cpt.location', function ($ns) { global $birchschedule; birch_defn($ns, 'init', function () use($ns, $birchschedule) { birch_defmethod($birchschedule->model, 'pre_save', 'birs_location', $ns->pre_save); birch_defmethod($birchschedule->model, 'post_get', 'birs_location', $ns->post_get); }); birch_defn($ns, 'pre_save', function ($location, $config) { birch_assert(is_array($location) && isset($location['post_type'])); return $location; }); birch_defn($ns, 'post_get', function ($location) { birch_assert(is_array($location) && isset($location['post_type'])); if (isset($location['post_title'])) { $location['_birs_location_name'] = $location['post_title']; } if (isset($location['post_content'])) { $location['_birs_location_description'] = $location['post_content']; } return $location; }); });
$appointment1on1 = $birchschedule->model->mergefields->get_appointment1on1_merge_values($appointment1on1_id); $staff_id = $appointment1on1['_birs_appointment_staff']; $timestamp = $appointment1on1['_birs_appointment_timestamp']; $date = $birchpress->util->get_wp_datetime($timestamp); $date_text = $date->format('Y-m-d'); $ns->check_if_fully_booked($staff_id, $date_text); }); birch_defn($ns, 'check_if_fully_booked', function ($staff_id, $date_text) use($ns) { global $birchpress, $birchschedule; $services = $birchschedule->model->get_services_by_staff($staff_id); $locations = $birchschedule->model->get_locations_listing_order(); foreach ($services as $service_id => $value) { foreach ($locations as $location_id) { $date = $birchpress->util->get_wp_datetime("{$date_text} 00:00:00"); $time_options = $birchschedule->model->schedule->get_staff_avaliable_time($staff_id, $location_id, $service_id, $date); } } }); birch_defn($ns, 'async_recheck_fully_booked_days', function () use($ns) { wp_remote_post(admin_url('admin-post.php'), array('method' => 'POST', 'timeout' => 0.01, 'blocking' => false, 'sslverify' => apply_filters('https_local_ssl_verify', true), 'body' => array('action' => 'birchschedule_model_booking_recheck_fully_booked_days'))); }); birch_defn($ns, 'admin_post_recheck_fully_booked_days', function () use($ns) { global $birchschedule; $fully_booked = $birchschedule->model->schedule->get_fully_booked_days(); foreach ($fully_booked as $date_text => $staff_arr) { foreach ($staff_arr as $staff_id => $arr) { $ns->check_if_fully_booked($staff_id, $date_text); } } }); });
birch_defn($ns, 'query', function ($criteria, $config = array()) use($ns) { $config = $ns->_preprocess_config($config); $criteria = array_merge(array('nopaging' => true, 'post_status' => 'publish', 'cache_results' => false, 'update_post_term_cache' => false, 'update_post_meta_cache' => false), $criteria); if ($criteria['nopaging']) { $criteria['no_found_rows'] = true; } if (isset($config['fn_get'])) { $fn_get = $config['fn_get']; unset($config['fn_get']); } else { $fn_get = array($ns, 'get'); } $fn_filter_posts_fields = function ($fields, $query) use($ns, &$config) { global $wpdb; $new_fields = "{$wpdb->posts}.ID"; $post_columns = $ns->get_post_columns(); foreach ($config['base_keys'] as $key) { if (in_array($key, $post_columns)) { $new_fields .= ", {$wpdb->posts}.{$key}"; } } return $new_fields; }; $query = new WP_Query(); $models = array(); if ($config['base_keys'] || $config['meta_keys']) { if (isset($criteria['post_type'])) { $post_type = $criteria['post_type']; } else { $post_type = 'any'; } $essential_keys = $ns->get_essential_post_columns($post_type); if ($criteria['cache_results']) { $config['base_keys'] = array_merge($essential_keys, $config['base_keys']); } else { $config['base_keys'] = array_merge(array('post_type'), $config['base_keys']); } $criteria['fields'] = 'custom'; add_filter('posts_fields', $fn_filter_posts_fields, 20, 2); $posts = $query->query($criteria); remove_filter('posts_fields', $fn_filter_posts_fields, 20, 2); foreach ($posts as $post) { $model = call_user_func($fn_get, $post, $config); $models[$post->ID] = $model; } } else { $criteria['fields'] = 'ids'; $post_ids = $query->query($criteria); foreach ($post_ids as $post_id) { $models[$post_id] = array('ID' => $post_id); } } return $models; });
}); birch_defn($ns, 'cache_code', function () use($ns, $birchschedule, $_ns_data) { check_admin_referer($_ns_data->RUN_ACTION_NAME); if (isset($_POST['birchschedule_help_php_code'])) { $php_code = stripslashes_deep($_POST['birchschedule_help_php_code']); set_transient("birchschedule_help_php_code", $php_code, 60); } $orig_url = $_POST['_wp_http_referer']; wp_redirect($orig_url); exit; }); birch_defn($ns, 'render_admin_page', function () use($ns) { global $birchschedule; $screen = $ns->get_screen(); $birchschedule->view->show_notice(); ?> <div id="birchschedule_help" class="wrap"> <div id="poststuff"> <div id="post-body" class="metabox-holder columns-1"> <div id="postbox-container-1" class="postbox-container"> <?php do_meta_boxes($screen, 'main', array()); ?> </div> </div> <br class="clear" /> </div> </div> <?php }); });
$staff['_birs_staff_schedule'] = serialize($staff['_birs_staff_schedule']); } return $staff; }); birch_defn($ns, 'post_get', function ($staff) { birch_assert(is_array($staff) && isset($staff['post_type'])); if (isset($staff['post_title'])) { $staff['_birs_staff_name'] = $staff['post_title']; } if (isset($staff['_birs_assigned_services'])) { $assigned_services = $staff['_birs_assigned_services']; $assigned_services = unserialize($assigned_services); $assigned_services = $assigned_services ? $assigned_services : array(); $staff['_birs_assigned_services'] = $assigned_services; } if (isset($staff['_birs_staff_schedule'])) { $schedule = $staff['_birs_staff_schedule']; if (!isset($schedule)) { $schedule = array(); } else { $schedule = unserialize($schedule); } $schedule = $schedule ? $schedule : array(); $staff['_birs_staff_schedule'] = $schedule; } if (isset($staff['post_content'])) { $staff['_birs_staff_description'] = $staff['post_content']; } return $staff; }); });
birch_defn($ns, 'get_client_info_html', function ($client_id) use($ns) { global $birchpress, $birchschedule; $client_titles = $birchpress->util->get_client_title_options(); $client_title = get_post_meta($client_id, '_birs_client_title', true); $first_name = get_post_meta($client_id, '_birs_client_name_first', true); $last_name = get_post_meta($client_id, '_birs_client_name_last', true); $addresss1 = get_post_meta($client_id, '_birs_client_address1', true); $addresss2 = get_post_meta($client_id, '_birs_client_address2', true); $email = get_post_meta($client_id, '_birs_client_email', true); $phone = get_post_meta($client_id, '_birs_client_phone', true); $city = get_post_meta($client_id, '_birs_client_city', true); $zip = get_post_meta($client_id, '_birs_client_zip', true); $state = get_post_meta($client_id, '_birs_client_state', true); $country = get_post_meta($client_id, '_birs_client_country', true); if (!$country) { $country = $birchschedule->model->get_default_country(); } $states = $birchpress->util->get_states(); $countries = $birchpress->util->get_countries(); if (isset($states[$country])) { $select_display = ""; $text_display = "display:none;"; } else { $select_display = "display:none;"; $text_display = ""; } ob_start(); ?> <ul> <li class="birs_form_field birs_client_title"> <label for="birs_client_title"><?php _e('Title', 'birchschedule'); ?> </label> <div class="birs_field_content"> <select name="birs_client_title" id="birs_client_title"> <?php $birchpress->util->render_html_options($client_titles, $client_title); ?> </select> <input type="hidden" name="birs_client_fields[]" value="_birs_client_title"> </div> <div class="birs_error" id="birs_client_title_error"> </div> </li> <li class="birs_form_field birs_client_name_first"> <label for="birs_client_name_first"><?php _e('First Name', 'birchschedule'); ?> </label> <div class="birs_field_content"> <input type="text" name="birs_client_name_first" id="birs_client_name_first" value="<?php echo esc_attr($first_name); ?> "> <input type="hidden" name="birs_client_fields[]" value="_birs_client_name_first"> </div> <div class="birs_error" id="birs_client_name_first_error"> </div> </li> <li class="birs_form_field birs_client_name_last"> <label for="birs_client_name_last"><?php _e('Last Name', 'birchschedule'); ?> </label> <div class="birs_field_content"> <input type="text" name="birs_client_name_last" id="birs_client_name_last" value="<?php echo esc_attr($last_name); ?> "> <input type="hidden" name="birs_client_fields[]" value="_birs_client_name_last"> </div> <div class="birs_error" id="birs_client_name_last_error"> </div> </li> <li class="birs_form_field birs_client_email"> <label for="birs_client_email"><?php _e('Email', 'birchschedule'); ?> </label> <div class="birs_field_content"> <input type="text" name="birs_client_email" id="birs_client_email" value="<?php echo esc_attr($email); ?> "> <input type="hidden" name="birs_client_fields[]" value="_birs_client_email"> </div> <div class="birs_error" id="birs_client_email_error"> </div> </li> <li class="birs_form_field birs_client_phone"> <label for="birs_client_phone"><?php _e('Phone', 'birchschedule'); ?> </label> <div class="birs_field_content"> <input type="text" name="birs_client_phone" id="birs_client_phone" value="<?php echo esc_attr($phone); ?> "> <input type="hidden" name="birs_client_fields[]" value="_birs_client_phone"> </div> <div class="birs_error" id="birs_client_phone_error"> </div> </li> <li class="birs_form_field birs_client_address"> <label for="birs_client_address1"><?php _e('Address', 'birchschedule'); ?> </label> <div class="birs_field_content"> <input type="text" name="birs_client_address1" id="birs_client_address1" style="display: block;" value="<?php echo esc_attr($addresss1); ?> "> <input type="text" name="birs_client_address2" id="birs_client_address2" value="<?php echo esc_attr($addresss2); ?> "> <input type="hidden" name="birs_client_fields[]" value="_birs_client_address1"> <input type="hidden" name="birs_client_fields[]" value="_birs_client_address2"> </div> <div class="birs_error" id="birs_client_address_error"> </div> </li> <li class="birs_form_field birs_client_city"> <label for="birs_client_city"><?php _e('City', 'birchschedule'); ?> </label> <div class="birs_field_content"> <input type="text" name="birs_client_city" id="birs_client_city" value="<?php echo esc_attr($city); ?> "> <input type="hidden" name="birs_client_fields[]" value="_birs_client_city"> </div> <div class="birs_error" id="birs_client_city_error"> </div> </li> <li class="birs_form_field birs_client_state"> <label for="birs_client_state"><?php _e('State/Province', 'birchschedule'); ?> </label> <div class="birs_field_content"> <select name="birs_client_state_select" id ="birs_client_state_select" style="<?php echo $select_display; ?> "> <?php if (isset($states[$country])) { $birchpress->util->render_html_options($states[$country], $state); } ?> </select> <input type="text" name="birs_client_state" id="birs_client_state" value="<?php echo esc_attr($state); ?> " style="<?php echo $text_display; ?> " /> <input type="hidden" name="birs_client_fields[]" value="_birs_client_state"> </div> <div class="birs_error" id="birs_client_state_error"> </div> </li> <li class="birs_form_field birs_client_country"> <label for="birs_client_country"><?php _e('Country', 'birchschedule'); ?> </label> <div class="birs_field_content"> <select name="birs_client_country" id="birs_client_country"> <?php $birchpress->util->render_html_options($countries, $country); ?> </select> <input type="hidden" name="birs_client_fields[]" value="_birs_client_country"> </div> <div class="birs_error" id="birs_client_country_error"> </div> </li> <li class="birs_form_field birs_client_zip"> <label for="birs_client_zip"><?php _e('Zip Code', 'birchschedule'); ?> </label> <div class="birs_field_content"> <input type="text" name="birs_client_zip" id="birs_client_zip" value="<?php echo esc_attr($zip); ?> "> <input type="hidden" name="birs_client_fields[]" value="_birs_client_zip"> </div> <div class="birs_error" id="birs_client_zip_error"> </div> </li> </ul> <?php return ob_get_clean(); });
birch_defn($ns, 'enqueue_scripts_post_edit', function ($arg) { if ($arg['post_type'] != 'birs_appointment') { return; } global $birchschedule; $birchschedule->view->register_3rd_scripts(); $birchschedule->view->register_3rd_styles(); $birchschedule->view->enqueue_scripts(array('birchschedule_view_appointments_edit_clientlist_cancel')); }); birch_defn($ns, 'ajax_cancel', function () use($ns) { global $birchschedule; $client_id = $_POST['birs_client_id']; $appointment_id = $_POST['birs_appointment_id']; $appointment1on1 = $birchschedule->model->booking->get_appointment1on1($appointment_id, $client_id); $success = array('code' => 'reload', 'message' => ''); if ($appointment1on1) { $birchschedule->model->booking->cancel_appointment1on1($appointment1on1['ID']); $cancelled = $birchschedule->model->booking->if_appointment_cancelled($appointment_id); if ($cancelled) { $cal_url = admin_url('admin.php?page=birchschedule_calendar'); $refer_query = parse_url(wp_get_referer(), PHP_URL_QUERY); $hash_string = $birchschedule->view->get_query_string($refer_query, array('calview', 'locationid', 'staffid', 'currentdate')); if ($hash_string) { $cal_url = $cal_url . '#' . $hash_string; } $success = array('code' => 'redirect_to_calendar', 'message' => json_encode(array('url' => htmlentities($cal_url)))); } } $birchschedule->view->render_ajax_success_message($success); }); });
<?php birch_ns('birchschedule.view.appointments', function ($ns) { birch_defn($ns, 'init', function () use($ns) { add_action('admin_init', array($ns, 'wp_admin_init')); add_action('init', array($ns, 'wp_init')); }); birch_defn($ns, 'wp_init', function () use($ns) { $ns->register_post_type(); }); birch_defn($ns, 'wp_admin_init', function () use($ns) { add_filter('post_updated_messages', array($ns, 'get_updated_messages')); }); birch_defn($ns, 'register_post_type', function () use($ns) { register_post_type('birs_appointment', array('labels' => array('name' => __('Appointments', 'birchschedule'), 'singular_name' => __('Appointment', 'birchschedule'), 'add_new' => __('New Appointment', 'birchschedule'), 'add_new_item' => __('New Appointment', 'birchschedule'), 'edit' => __('Edit', 'birchschedule'), 'edit_item' => __('Edit Appointment', 'birchschedule'), 'new_item' => __('New Appointment', 'birchschedule'), 'view' => __('View Appointment', 'birchschedule'), 'view_item' => __('View Appointment', 'birchschedule'), 'search_items' => __('Search Appointments', 'birchschedule'), 'not_found' => __('No Appointments found', 'birchschedule'), 'not_found_in_trash' => __('No Appointments found in trash', 'birchschedule'), 'parent' => __('Parent Appointment', 'birchschedule')), 'description' => __('This is where appointments are stored.', 'birchschedule'), 'public' => false, 'show_ui' => true, 'menu_icon' => 'dashicons-calendar', 'capability_type' => 'birs_appointment', 'map_meta_cap' => true, 'publicly_queryable' => false, 'exclude_from_search' => true, 'show_in_menu' => true, 'hierarchical' => false, 'show_in_nav_menus' => false, 'rewrite' => false, 'query_var' => true, 'supports' => array(''), 'has_archive' => false)); register_post_type('birs_appointment1on1', array('labels' => array('name' => __('One-on-one appointments', 'birchschedule'), 'singular_name' => __('One-on-one appointment', 'birchschedule'), 'add_new' => __('New One-on-one Appointment', 'birchschedule'), 'add_new_item' => __('New One-on-one Appointment', 'birchschedule'), 'edit' => __('Edit', 'birchschedule'), 'edit_item' => __('Edit One-on-one Appointment', 'birchschedule'), 'new_item' => __('New One-on-one Appointment', 'birchschedule'), 'view' => __('View One-on-one Appointment', 'birchschedule'), 'view_item' => __('View One-on-one Appointment', 'birchschedule'), 'search_items' => __('Search One-on-one Appointments', 'birchschedule'), 'not_found' => __('No One-on-one Appointments found', 'birchschedule'), 'not_found_in_trash' => __('No One-on-one Appointments found in trash', 'birchschedule'), 'parent' => __('Parent One-on-one Appointment', 'birchschedule')), 'description' => __('This is where one-on-one appointments are stored.', 'birchschedule'), 'public' => false, 'show_ui' => false, 'menu_icon' => 'dashicons-calendar', 'capability_type' => 'birs_appointment', 'map_meta_cap' => true, 'publicly_queryable' => false, 'exclude_from_search' => true, 'show_in_menu' => false, 'hierarchical' => false, 'show_in_nav_menus' => false, 'rewrite' => false, 'query_var' => true, 'supports' => array(''), 'has_archive' => false)); }); birch_defn($ns, 'get_updated_messages', function ($messages) { global $post, $post_ID; $messages['birs_appointment'] = array(0 => '', 1 => __('Appointment updated.', 'birchschedule'), 2 => __('Custom field updated.', 'birchschedule'), 3 => __('Custom field deleted.', 'birchschedule'), 4 => __('Appointment updated.', 'birchschedule'), 5 => isset($_GET['revision']) ? sprintf(__('Appointment restored to revision from %s', 'birchschedule'), wp_post_revision_title((int) $_GET['revision'], false)) : false, 6 => __('Appointment updated.', 'birchschedule'), 7 => __('Appointment saved.', 'birchschedule'), 8 => __('Appointment submitted.', 'birchschedule'), 9 => sprintf(__('Appointment scheduled for: <strong>%1$s</strong>.', 'birchschedule'), date_i18n('M j, Y @ G:i', strtotime($post->post_date))), 10 => __('Appointment draft updated.', 'birchschedule')); return $messages; }); });
<?php }); birch_defn($ns, 'sanitize_input', function ($input) { return $input; }); birch_defn($ns, 'get_update_info', function ($checked_data) use(&$update_info) { $plugin_slug = "birchschedule"; $slug_str = $plugin_slug . '/' . $plugin_slug . '.php'; if (isset($checked_data->response[$slug_str])) { $update_info = $checked_data->response[$slug_str]; $update_info = array('version' => $update_info->new_version); } return $checked_data; }); birch_defn($ns, 'show_update_notice', function () use(&$update_info) { global $birchschedule; $product_name = $birchschedule->get_product_name(); $update_url = admin_url('update-core.php'); $update_text = "%s %s is available! <a href='{$update_url}'>Please update now</a>."; if ($update_info) { ?> <div class="updated inline"> <p><?php echo sprintf($update_text, $product_name, $update_info['version']); ?> </p> </div> <?php } }); });
birch_defn($ns, 'ajax_schedule', function () use($ns) { global $birchpress, $birchschedule; $appointment_errors = $ns->validate_appointment_info(); $appointment1on1_errors = $ns->validate_appointment1on1_info(); $client_errors = $ns->validate_client_info(); $errors = array_merge($appointment_errors, $appointment1on1_errors, $client_errors); if ($errors) { $birchschedule->view->render_ajax_error_messages($errors); } $client_config = array('base_keys' => array(), 'meta_keys' => $_POST['birs_client_fields']); $client_info = $birchschedule->view->merge_request(array(), $client_config, $_POST); unset($client_info['ID']); $client_id = $birchschedule->model->booking->save_client($client_info); $appointment1on1_config = array('base_keys' => array(), 'meta_keys' => array_merge($birchschedule->model->get_appointment_fields(), $birchschedule->model->get_appointment1on1_fields(), $birchschedule->model->get_appointment1on1_custom_fields())); $appointment1on1_info = $birchschedule->view->merge_request(array(), $appointment1on1_config, $_POST); $datetime = array('date' => $_POST['birs_appointment_date'], 'time' => $_POST['birs_appointment_time']); $datetime = $birchpress->util->get_wp_datetime($datetime); $timestamp = $datetime->format('U'); $appointment1on1_info['_birs_appointment_timestamp'] = $timestamp; $appointment1on1_info['_birs_client_id'] = $client_id; unset($appointment1on1_info['ID']); unset($appointment1on1_info['_birs_appointment_id']); $appointment1on1_id = $birchschedule->model->booking->make_appointment1on1($appointment1on1_info); $birchschedule->model->booking->change_appointment1on1_status($appointment1on1_id, 'publish'); if ($appointment1on1_id) { $cal_url = admin_url('admin.php?page=birchschedule_calendar'); $refer_query = parse_url(wp_get_referer(), PHP_URL_QUERY); $hash_string = $birchschedule->view->get_query_string($refer_query, array('calview', 'locationid', 'staffid', 'currentdate')); if ($hash_string) { $cal_url = $cal_url . '#' . $hash_string; } $birchschedule->view->render_ajax_success_message(array('code' => 'success', 'message' => json_encode(array('url' => htmlentities($cal_url))))); } });
birch_defn($ns, 'get_appointment_info_html', function ($appointment_id) use($ns, $birchschedule) { global $birchpress, $birchschedule; $appointment = $birchschedule->model->get($appointment_id, array('base_keys' => array(), 'meta_keys' => $birchschedule->model->get_appointment_fields())); $options = $birchpress->util->get_time_options(5); if ($appointment) { $location_id = $appointment['_birs_appointment_location']; $service_id = $appointment['_birs_appointment_service']; $staff_id = $appointment['_birs_appointment_staff']; $timestamp = $birchpress->util->get_wp_datetime($appointment['_birs_appointment_timestamp']); $date4picker = $timestamp->format(get_option('date_format')); $date = $timestamp->format('m/d/Y'); $time = $timestamp->format('H') * 60 + $timestamp->format('i'); } ob_start(); ?> <ul> <li class="birs_form_field birs_appointment_location"> <label> <?php _e('Location', 'birchschedule'); ?> </label> <div class="birs_field_content"> <select id="birs_appointment_location" name="birs_appointment_location" data-value="<?php echo $location_id; ?> "> </select> </div> <div class="birs_error" id="birs_appointment_location_error"></div> </li> <li class="birs_form_field birs_appointment_service"> <label> <?php _e('Service', 'birchschedule'); ?> </label> <div class="birs_field_content"> <select id="birs_appointment_service" name="birs_appointment_service" data-value="<?php echo $service_id; ?> "> </select> </div> <div class="birs_error" id="birs_appointment_service_error"></div> </li> <li class="birs_form_field"> <label> <?php _e('Provider', 'birchschedule'); ?> </label> <div class="birs_field_content"> <select id="birs_appointment_staff" name="birs_appointment_staff" data-value="<?php echo $staff_id; ?> "> </select> </div> <div class="birs_error" id="birs_appointment_staff_error"></div> </li> <li class="birs_form_field"> <label> <?php _e('Date', 'birchschedule'); ?> </label> <div class="birs_field_content"> <div id="birs_appointment_datepicker"></div> <input id="birs_appointment_date" name="birs_appointment_date" type="hidden" value="<?php echo $date; ?> "> </div> <div class="birs_error" id="birs_appointment_date_error"></div> </li> <li class="birs_form_field"> <label> <?php _e('Time', 'birchschedule'); ?> </label> <div class="birs_field_content"> <select id="birs_appointment_time" name="birs_appointment_time" size="1"> <?php $birchpress->util->render_html_options($options, $time); ?> </select> </div> <div class="birs_error" id="birs_appointment_time_error"></div> </li> </ul> <?php return ob_get_clean(); });
$default_options_1_1['version'] = '1.1'; $default_options = $default_options_1_1; birch_defn($ns, 'init', function () use(&$default_options, $ns, $birchschedule) { $options = get_option('birchschedule_options'); if ($options === false) { add_option('birchschedule_options', $default_options); } birch_defmethod($birchschedule, 'upgrade_module', 'gsettings', $ns->upgrade_module); }); birch_defn($ns, 'upgrade_module', function () use($ns) { $ns->init(); $ns->upgrade_1_0_to_1_1(); }); birch_defn($ns, 'get_db_version_options', function () { $options = get_option('birchschedule_options'); if (isset($options['version'])) { return $options['version']; } else { return '1.0'; } }); birch_defn($ns, 'upgrade_1_0_to_1_1', function () use($ns) { $version = $ns->get_db_version_options(); if ($version !== '1.0') { return; } $options = get_option('birchschedule_options'); $options['version'] = '1.1'; update_option('birchschedule_options', $options); }); });