functions.php
432 lines
| 1 | <?php |
| 2 | |
| 3 | function set_popover_url($base) { |
| 4 | |
| 5 | global $popover_url; |
| 6 | |
| 7 | if(defined('WPMU_PLUGIN_URL') && defined('WPMU_PLUGIN_DIR') && file_exists(WPMU_PLUGIN_DIR . '/' . basename($base))) { |
| 8 | $popover_url = trailingslashit(WPMU_PLUGIN_URL); |
| 9 | } elseif(defined('WP_PLUGIN_URL') && defined('WP_PLUGIN_DIR') && file_exists(WP_PLUGIN_DIR . '/wordpress-popup/' . basename($base))) { |
| 10 | $popover_url = trailingslashit(WP_PLUGIN_URL . '/wordpress-popup'); |
| 11 | } else { |
| 12 | $popover_url = trailingslashit(WP_PLUGIN_URL . '/wordpress-popup'); |
| 13 | } |
| 14 | |
| 15 | } |
| 16 | |
| 17 | function set_popover_dir($base) { |
| 18 | |
| 19 | global $popover_dir; |
| 20 | |
| 21 | if(defined('WPMU_PLUGIN_DIR') && file_exists(WPMU_PLUGIN_DIR . '/' . basename($base))) { |
| 22 | $popover_dir = trailingslashit(WPMU_PLUGIN_URL); |
| 23 | } elseif(defined('WP_PLUGIN_DIR') && file_exists(WP_PLUGIN_DIR . '/wordpress-popup/' . basename($base))) { |
| 24 | $popover_dir = trailingslashit(WP_PLUGIN_DIR . '/wordpress-popup'); |
| 25 | } else { |
| 26 | $popover_dir = trailingslashit(WP_PLUGIN_DIR . '/wordpress-popup'); |
| 27 | } |
| 28 | |
| 29 | |
| 30 | } |
| 31 | |
| 32 | function popover_url($extended) { |
| 33 | |
| 34 | global $popover_url; |
| 35 | |
| 36 | return $popover_url . $extended; |
| 37 | |
| 38 | } |
| 39 | |
| 40 | function popover_dir($extended) { |
| 41 | |
| 42 | global $popover_dir; |
| 43 | |
| 44 | return $popover_dir . $extended; |
| 45 | |
| 46 | |
| 47 | } |
| 48 | |
| 49 | function popover_helpimage( $image ) { |
| 50 | echo "<img src='" . popover_url('popoverincludes/help/images/' . $image) . "' />"; |
| 51 | } |
| 52 | |
| 53 | function popover_db_prefix(&$wpdb, $table) { |
| 54 | |
| 55 | if( defined('PO_GLOBAL') && PO_GLOBAL == true ) { |
| 56 | if(!empty($wpdb->base_prefix)) { |
| 57 | return $wpdb->base_prefix . $table; |
| 58 | } else { |
| 59 | return $wpdb->prefix . $table; |
| 60 | } |
| 61 | } else { |
| 62 | return $wpdb->prefix . $table; |
| 63 | } |
| 64 | |
| 65 | } |
| 66 | |
| 67 | function get_popover_addons() { |
| 68 | if ( is_dir( popover_dir('popoverincludes/addons') ) ) { |
| 69 | if ( $dh = opendir( popover_dir('popoverincludes/addons') ) ) { |
| 70 | $pop_addons = array (); |
| 71 | while ( ( $addon = readdir( $dh ) ) !== false ) |
| 72 | if ( substr( $addon, -4 ) == '.php' ) |
| 73 | $pop_addons[] = $addon; |
| 74 | closedir( $dh ); |
| 75 | sort( $pop_addons ); |
| 76 | |
| 77 | return apply_filters('popover_available_addons', $pop_addons); |
| 78 | |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | return false; |
| 83 | } |
| 84 | |
| 85 | function load_popover_addons() { |
| 86 | |
| 87 | $addons = get_option('popover_activated_addons', array()); |
| 88 | |
| 89 | if ( is_dir( popover_dir('popoverincludes/addons') ) ) { |
| 90 | if ( $dh = opendir( popover_dir('popoverincludes/addons') ) ) { |
| 91 | $pop_addons = array (); |
| 92 | while ( ( $addon = readdir( $dh ) ) !== false ) |
| 93 | if ( substr( $addon, -4 ) == '.php' ) |
| 94 | $pop_addons[] = $addon; |
| 95 | closedir( $dh ); |
| 96 | sort( $pop_addons ); |
| 97 | |
| 98 | $pop_addons = apply_filters('popover_available_addons', $pop_addons); |
| 99 | |
| 100 | foreach( $pop_addons as $pop_addon ) { |
| 101 | if(in_array($pop_addon, (array) $addons)) { |
| 102 | include_once( popover_dir('popoverincludes/addons/' . $pop_addon) ); |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | } |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | function load_all_popover_addons() { |
| 111 | if ( is_dir( popover_dir('popoverincludes/addons') ) ) { |
| 112 | if ( $dh = opendir( popover_dir('popoverincludes/addons') ) ) { |
| 113 | $pop_addons = array (); |
| 114 | while ( ( $addon = readdir( $dh ) ) !== false ) |
| 115 | if ( substr( $addon, -4 ) == '.php' ) |
| 116 | $pop_addons[] = $addon; |
| 117 | closedir( $dh ); |
| 118 | sort( $pop_addons ); |
| 119 | foreach( $pop_addons as $pop_addon ) |
| 120 | include_once( popover_dir('popoverincludes/addons/' . $pop_addon) ); |
| 121 | } |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | function P_style_urls( $styles = array() ) { |
| 126 | |
| 127 | $styles['Default'] = popover_url('popoverincludes/css/default'); |
| 128 | $styles['Default Fixed'] = popover_url('popoverincludes/css/fixed'); |
| 129 | $styles['Dark Background Fixed'] = popover_url('popoverincludes/css/fullbackground'); |
| 130 | |
| 131 | return $styles; |
| 132 | } |
| 133 | add_filter( 'popover_available_styles_url', 'P_style_urls'); |
| 134 | |
| 135 | function P_style_dirs() { |
| 136 | $styles['Default'] = popover_dir('popoverincludes/css/default'); |
| 137 | $styles['Default Fixed'] = popover_dir('popoverincludes/css/fixed'); |
| 138 | $styles['Dark Background Fixed'] = popover_dir('popoverincludes/css/fullbackground'); |
| 139 | |
| 140 | return $styles; |
| 141 | } |
| 142 | add_filter( 'popover_available_styles_directory', 'P_style_dirs'); |
| 143 | |
| 144 | /* country list array from http://snipplr.com/view.php?codeview&id=33825 */ |
| 145 | function P_CountryList() { |
| 146 | |
| 147 | $textdomain = 'popover'; |
| 148 | |
| 149 | $countries = array( |
| 150 | "AU" => __("Australia", $textdomain ), |
| 151 | "AF" => __("Afghanistan", $textdomain ), |
| 152 | "AL" => __("Albania", $textdomain ), |
| 153 | "DZ" => __("Algeria", $textdomain ), |
| 154 | "AS" => __("American Samoa", $textdomain ), |
| 155 | "AD" => __("Andorra", $textdomain ), |
| 156 | "AO" => __("Angola", $textdomain ), |
| 157 | "AI" => __("Anguilla", $textdomain ), |
| 158 | "AQ" => __("Antarctica", $textdomain ), |
| 159 | "AG" => __("Antigua & Barbuda", $textdomain ), |
| 160 | "AR" => __("Argentina", $textdomain ), |
| 161 | "AM" => __("Armenia", $textdomain ), |
| 162 | "AW" => __("Aruba", $textdomain ), |
| 163 | "AT" => __("Austria", $textdomain ), |
| 164 | "AZ" => __("Azerbaijan", $textdomain ), |
| 165 | "BS" => __("Bahamas", $textdomain ), |
| 166 | "BH" => __("Bahrain", $textdomain ), |
| 167 | "BD" => __("Bangladesh", $textdomain ), |
| 168 | "BB" => __("Barbados", $textdomain ), |
| 169 | "BY" => __("Belarus", $textdomain ), |
| 170 | "BE" => __("Belgium", $textdomain ), |
| 171 | "BZ" => __("Belize", $textdomain ), |
| 172 | "BJ" => __("Benin", $textdomain ), |
| 173 | "BM" => __("Bermuda", $textdomain ), |
| 174 | "BT" => __("Bhutan", $textdomain ), |
| 175 | "BO" => __("Bolivia", $textdomain ), |
| 176 | "BA" => __("Bosnia/Hercegovina", $textdomain ), |
| 177 | "BW" => __("Botswana", $textdomain ), |
| 178 | "BV" => __("Bouvet Island", $textdomain ), |
| 179 | "BR" => __("Brazil", $textdomain ), |
| 180 | "IO" => __("British Indian Ocean Territory", $textdomain ), |
| 181 | "BN" => __("Brunei Darussalam", $textdomain ), |
| 182 | "BG" => __("Bulgaria", $textdomain ), |
| 183 | "BF" => __("Burkina Faso", $textdomain ), |
| 184 | "BI" => __("Burundi", $textdomain ), |
| 185 | "KH" => __("Cambodia", $textdomain ), |
| 186 | "CM" => __("Cameroon", $textdomain ), |
| 187 | "CA" => __("Canada", $textdomain ), |
| 188 | "CV" => __("Cape Verde", $textdomain ), |
| 189 | "KY" => __("Cayman Is", $textdomain ), |
| 190 | "CF" => __("Central African Republic", $textdomain ), |
| 191 | "TD" => __("Chad", $textdomain ), |
| 192 | "CL" => __("Chile", $textdomain ), |
| 193 | "CN" => __("China, People's Republic of", $textdomain ), |
| 194 | "CX" => __("Christmas Island", $textdomain ), |
| 195 | "CC" => __("Cocos Islands", $textdomain ), |
| 196 | "CO" => __("Colombia", $textdomain ), |
| 197 | "KM" => __("Comoros", $textdomain ), |
| 198 | "CG" => __("Congo", $textdomain ), |
| 199 | "CD" => __("Congo, Democratic Republic", $textdomain ), |
| 200 | "CK" => __("Cook Islands", $textdomain ), |
| 201 | "CR" => __("Costa Rica", $textdomain ), |
| 202 | "CI" => __("Cote d'Ivoire", $textdomain ), |
| 203 | "HR" => __("Croatia", $textdomain ), |
| 204 | "CU" => __("Cuba", $textdomain ), |
| 205 | "CY" => __("Cyprus", $textdomain ), |
| 206 | "CZ" => __("Czech Republic", $textdomain ), |
| 207 | "DK" => __("Denmark", $textdomain ), |
| 208 | "DJ" => __("Djibouti", $textdomain ), |
| 209 | "DM" => __("Dominica", $textdomain ), |
| 210 | "DO" => __("Dominican Republic", $textdomain ), |
| 211 | "TP" => __("East Timor", $textdomain ), |
| 212 | "EC" => __("Ecuador", $textdomain ), |
| 213 | "EG" => __("Egypt", $textdomain ), |
| 214 | "SV" => __("El Salvador", $textdomain ), |
| 215 | "GQ" => __("Equatorial Guinea", $textdomain ), |
| 216 | "ER" => __("Eritrea", $textdomain ), |
| 217 | "EE" => __("Estonia", $textdomain ), |
| 218 | "ET" => __("Ethiopia", $textdomain ), |
| 219 | "FK" => __("Falkland Islands", $textdomain ), |
| 220 | "FO" => __("Faroe Islands", $textdomain ), |
| 221 | "FJ" => __("Fiji", $textdomain ), |
| 222 | "FI" => __("Finland", $textdomain ), |
| 223 | "FR" => __("France", $textdomain ), |
| 224 | "FX" => __("France, Metropolitan", $textdomain ), |
| 225 | "GF" => __("French Guiana", $textdomain ), |
| 226 | "PF" => __("French Polynesia", $textdomain ), |
| 227 | "TF" => __("French South Territories", $textdomain ), |
| 228 | "GA" => __("Gabon", $textdomain ), |
| 229 | "GM" => __("Gambia", $textdomain ), |
| 230 | "GE" => __("Georgia", $textdomain ), |
| 231 | "DE" => __("Germany", $textdomain ), |
| 232 | "GH" => __("Ghana", $textdomain ), |
| 233 | "GI" => __("Gibraltar", $textdomain ), |
| 234 | "GR" => __("Greece", $textdomain ), |
| 235 | "GL" => __("Greenland", $textdomain ), |
| 236 | "GD" => __("Grenada", $textdomain ), |
| 237 | "GP" => __("Guadeloupe", $textdomain ), |
| 238 | "GU" => __("Guam", $textdomain ), |
| 239 | "GT" => __("Guatemala", $textdomain ), |
| 240 | "GN" => __("Guinea", $textdomain ), |
| 241 | "GW" => __("Guinea-Bissau", $textdomain ), |
| 242 | "GY" => __("Guyana", $textdomain ), |
| 243 | "HT" => __("Haiti", $textdomain ), |
| 244 | "HM" => __("Heard Island And Mcdonald Island", $textdomain ), |
| 245 | "HN" => __("Honduras", $textdomain ), |
| 246 | "HK" => __("Hong Kong", $textdomain ), |
| 247 | "HU" => __("Hungary", $textdomain ), |
| 248 | "IS" => __("Iceland", $textdomain ), |
| 249 | "IN" => __("India", $textdomain ), |
| 250 | "ID" => __("Indonesia", $textdomain ), |
| 251 | "IR" => __("Iran", $textdomain ), |
| 252 | "IQ" => __("Iraq", $textdomain ), |
| 253 | "IE" => __("Ireland", $textdomain ), |
| 254 | "IL" => __("Israel", $textdomain ), |
| 255 | "IT" => __("Italy", $textdomain ), |
| 256 | "JM" => __("Jamaica", $textdomain ), |
| 257 | "JP" => __("Japan", $textdomain ), |
| 258 | "JT" => __("Johnston Island", $textdomain ), |
| 259 | "JO" => __("Jordan", $textdomain ), |
| 260 | "KZ" => __("Kazakhstan", $textdomain ), |
| 261 | "KE" => __("Kenya", $textdomain ), |
| 262 | "KI" => __("Kiribati", $textdomain ), |
| 263 | "KP" => __("Korea, Democratic Peoples Republic", $textdomain ), |
| 264 | "KR" => __("Korea, Republic of", $textdomain ), |
| 265 | "KW" => __("Kuwait", $textdomain ), |
| 266 | "KG" => __("Kyrgyzstan", $textdomain ), |
| 267 | "LA" => __("Lao People's Democratic Republic", $textdomain ), |
| 268 | "LV" => __("Latvia", $textdomain ), |
| 269 | "LB" => __("Lebanon", $textdomain ), |
| 270 | "LS" => __("Lesotho", $textdomain ), |
| 271 | "LR" => __("Liberia", $textdomain ), |
| 272 | "LY" => __("Libyan Arab Jamahiriya", $textdomain ), |
| 273 | "LI" => __("Liechtenstein", $textdomain ), |
| 274 | "LT" => __("Lithuania", $textdomain ), |
| 275 | "LU" => __("Luxembourg", $textdomain ), |
| 276 | "MO" => __("Macau", $textdomain ), |
| 277 | "MK" => __("Macedonia", $textdomain ), |
| 278 | "MG" => __("Madagascar", $textdomain ), |
| 279 | "MW" => __("Malawi", $textdomain ), |
| 280 | "MY" => __("Malaysia", $textdomain ), |
| 281 | "MV" => __("Maldives", $textdomain ), |
| 282 | "ML" => __("Mali", $textdomain ), |
| 283 | "MT" => __("Malta", $textdomain ), |
| 284 | "MH" => __("Marshall Islands", $textdomain ), |
| 285 | "MQ" => __("Martinique", $textdomain ), |
| 286 | "MR" => __("Mauritania", $textdomain ), |
| 287 | "MU" => __("Mauritius", $textdomain ), |
| 288 | "YT" => __("Mayotte", $textdomain ), |
| 289 | "MX" => __("Mexico", $textdomain ), |
| 290 | "FM" => __("Micronesia", $textdomain ), |
| 291 | "MD" => __("Moldavia", $textdomain ), |
| 292 | "MC" => __("Monaco", $textdomain ), |
| 293 | "MN" => __("Mongolia", $textdomain ), |
| 294 | "MS" => __("Montserrat", $textdomain ), |
| 295 | "MA" => __("Morocco", $textdomain ), |
| 296 | "MZ" => __("Mozambique", $textdomain ), |
| 297 | "MM" => __("Union Of Myanmar", $textdomain ), |
| 298 | "NA" => __("Namibia", $textdomain ), |
| 299 | "NR" => __("Nauru Island", $textdomain ), |
| 300 | "NP" => __("Nepal", $textdomain ), |
| 301 | "NL" => __("Netherlands", $textdomain ), |
| 302 | "AN" => __("Netherlands Antilles", $textdomain ), |
| 303 | "NC" => __("New Caledonia", $textdomain ), |
| 304 | "NZ" => __("New Zealand", $textdomain ), |
| 305 | "NI" => __("Nicaragua", $textdomain ), |
| 306 | "NE" => __("Niger", $textdomain ), |
| 307 | "NG" => __("Nigeria", $textdomain ), |
| 308 | "NU" => __("Niue", $textdomain ), |
| 309 | "NF" => __("Norfolk Island", $textdomain ), |
| 310 | "MP" => __("Mariana Islands, Northern", $textdomain ), |
| 311 | "NO" => __("Norway", $textdomain ), |
| 312 | "OM" => __("Oman", $textdomain ), |
| 313 | "PK" => __("Pakistan", $textdomain ), |
| 314 | "PW" => __("Palau Islands", $textdomain ), |
| 315 | "PS" => __("Palestine", $textdomain ), |
| 316 | "PA" => __("Panama", $textdomain ), |
| 317 | "PG" => __("Papua New Guinea", $textdomain ), |
| 318 | "PY" => __("Paraguay", $textdomain ), |
| 319 | "PE" => __("Peru", $textdomain ), |
| 320 | "PH" => __("Philippines", $textdomain ), |
| 321 | "PN" => __("Pitcairn", $textdomain ), |
| 322 | "PL" => __("Poland", $textdomain ), |
| 323 | "PT" => __("Portugal", $textdomain ), |
| 324 | "PR" => __("Puerto Rico", $textdomain ), |
| 325 | "QA" => __("Qatar", $textdomain ), |
| 326 | "RE" => __("Reunion Island", $textdomain ), |
| 327 | "RO" => __("Romania", $textdomain ), |
| 328 | "RU" => __("Russian Federation", $textdomain ), |
| 329 | "RW" => __("Rwanda", $textdomain ), |
| 330 | "WS" => __("Samoa", $textdomain ), |
| 331 | "SH" => __("St Helena", $textdomain ), |
| 332 | "KN" => __("St Kitts & Nevis", $textdomain ), |
| 333 | "LC" => __("St Lucia", $textdomain ), |
| 334 | "PM" => __("St Pierre & Miquelon", $textdomain ), |
| 335 | "VC" => __("St Vincent", $textdomain ), |
| 336 | "SM" => __("San Marino", $textdomain ), |
| 337 | "ST" => __("Sao Tome & Principe", $textdomain ), |
| 338 | "SA" => __("Saudi Arabia", $textdomain ), |
| 339 | "SN" => __("Senegal", $textdomain ), |
| 340 | "SC" => __("Seychelles", $textdomain ), |
| 341 | "SL" => __("Sierra Leone", $textdomain ), |
| 342 | "SG" => __("Singapore", $textdomain ), |
| 343 | "SK" => __("Slovakia", $textdomain ), |
| 344 | "SI" => __("Slovenia", $textdomain ), |
| 345 | "SB" => __("Solomon Islands", $textdomain ), |
| 346 | "SO" => __("Somalia", $textdomain ), |
| 347 | "ZA" => __("South Africa", $textdomain ), |
| 348 | "GS" => __("South Georgia and South Sandwich", $textdomain ), |
| 349 | "ES" => __("Spain", $textdomain ), |
| 350 | "LK" => __("Sri Lanka", $textdomain ), |
| 351 | "XX" => __("Stateless Persons", $textdomain ), |
| 352 | "SD" => __("Sudan", $textdomain ), |
| 353 | "SR" => __("Suriname", $textdomain ), |
| 354 | "SJ" => __("Svalbard and Jan Mayen", $textdomain ), |
| 355 | "SZ" => __("Swaziland", $textdomain ), |
| 356 | "SE" => __("Sweden", $textdomain ), |
| 357 | "CH" => __("Switzerland", $textdomain ), |
| 358 | "SY" => __("Syrian Arab Republic", $textdomain ), |
| 359 | "TW" => __("Taiwan, Republic of China", $textdomain ), |
| 360 | "TJ" => __("Tajikistan", $textdomain ), |
| 361 | "TZ" => __("Tanzania", $textdomain ), |
| 362 | "TH" => __("Thailand", $textdomain ), |
| 363 | "TL" => __("Timor Leste", $textdomain ), |
| 364 | "TG" => __("Togo", $textdomain ), |
| 365 | "TK" => __("Tokelau", $textdomain ), |
| 366 | "TO" => __("Tonga", $textdomain ), |
| 367 | "TT" => __("Trinidad & Tobago", $textdomain ), |
| 368 | "TN" => __("Tunisia", $textdomain ), |
| 369 | "TR" => __("Turkey", $textdomain ), |
| 370 | "TM" => __("Turkmenistan", $textdomain ), |
| 371 | "TC" => __("Turks And Caicos Islands", $textdomain ), |
| 372 | "TV" => __("Tuvalu", $textdomain ), |
| 373 | "UG" => __("Uganda", $textdomain ), |
| 374 | "UA" => __("Ukraine", $textdomain ), |
| 375 | "AE" => __("United Arab Emirates", $textdomain ), |
| 376 | "GB" => __("United Kingdom", $textdomain ), |
| 377 | "UM" => __("US Minor Outlying Islands", $textdomain ), |
| 378 | "US" => __("USA", $textdomain ), |
| 379 | "HV" => __("Upper Volta", $textdomain ), |
| 380 | "UY" => __("Uruguay", $textdomain ), |
| 381 | "UZ" => __("Uzbekistan", $textdomain ), |
| 382 | "VU" => __("Vanuatu", $textdomain ), |
| 383 | "VA" => __("Vatican City State", $textdomain ), |
| 384 | "VE" => __("Venezuela", $textdomain ), |
| 385 | "VN" => __("Vietnam", $textdomain ), |
| 386 | "VG" => __("Virgin Islands (British)", $textdomain ), |
| 387 | "VI" => __("Virgin Islands (US)", $textdomain ), |
| 388 | "WF" => __("Wallis And Futuna Islands", $textdomain ), |
| 389 | "EH" => __("Western Sahara", $textdomain ), |
| 390 | "YE" => __("Yemen Arab Rep.", $textdomain ), |
| 391 | "YD" => __("Yemen Democratic", $textdomain ), |
| 392 | "YU" => __("Yugoslavia", $textdomain ), |
| 393 | "ZR" => __("Zaire", $textdomain ), |
| 394 | "ZM" => __("Zambia", $textdomain ), |
| 395 | "ZW" => __("Zimbabwe", $textdomain ) |
| 396 | ); |
| 397 | |
| 398 | return apply_filters( 'popover_country_list', $countries ); |
| 399 | |
| 400 | } |
| 401 | |
| 402 | function get_popover_option($key, $default = false) { |
| 403 | |
| 404 | if(is_multisite() && function_exists('is_plugin_active_for_network') && is_plugin_active_for_network('wordpress-popup/popover.php')) { |
| 405 | return get_site_option($key, $default); |
| 406 | } else { |
| 407 | return get_option($key, $default); |
| 408 | } |
| 409 | |
| 410 | } |
| 411 | |
| 412 | function update_popover_option($key, $value) { |
| 413 | |
| 414 | if(is_multisite() && function_exists('is_plugin_active_for_network') && is_plugin_active_for_network('wordpress-popup/popover.php')) { |
| 415 | return update_site_option($key, $value); |
| 416 | } else { |
| 417 | return update_option($key, $value); |
| 418 | } |
| 419 | |
| 420 | } |
| 421 | |
| 422 | function delete_popover_option($key) { |
| 423 | |
| 424 | if(is_multisite() && function_exists('is_plugin_active_for_network') && is_plugin_active_for_network('wordpress-popup/popover.php')) { |
| 425 | return delete_site_option($key); |
| 426 | } else { |
| 427 | return delete_option($key); |
| 428 | } |
| 429 | |
| 430 | } |
| 431 | |
| 432 | ?> |