| 1 |
<?php |
| 2 |
/** |
| 3 |
* Common functions class for Import Facebook Events. |
| 4 |
* |
| 5 |
* @link http://xylusthemes.com/ |
| 6 |
* @since 1.0.0 |
| 7 |
* |
| 8 |
* @package Import_Facebook_Events |
| 9 |
* @subpackage Import_Facebook_Events/includes |
| 10 |
*/ |
| 11 |
// Exit if accessed directly |
| 12 |
if ( ! defined( 'ABSPATH' ) ) exit; |
| 13 |
|
| 14 |
class Import_Facebook_Events_Common { |
| 15 |
|
| 16 |
/** |
| 17 |
* Initialize the class and set its properties. |
| 18 |
* |
| 19 |
* @since 1.0.0 |
| 20 |
*/ |
| 21 |
public function __construct() { |
| 22 |
add_action( 'wp_ajax_ife_render_terms_by_plugin', array( $this, 'ife_render_terms_by_plugin' ) ); |
| 23 |
add_action( 'ife_render_pro_notice', array( $this, 'render_pro_notice') ); |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* Format events arguments as per TEC |
| 28 |
* |
| 29 |
* @since 1.0.0 |
| 30 |
* @param array $eventbrite_event Eventbrite event. |
| 31 |
* @return array |
| 32 |
*/ |
| 33 |
public function render_import_into_and_taxonomy() { |
| 34 |
|
| 35 |
$active_plugins = $this->get_active_supported_event_plugins(); |
| 36 |
?> |
| 37 |
<tr class="event_plugis_wrapper"> |
| 38 |
<th scope="row"> |
| 39 |
<?php esc_attr_e( 'Import into','import-facebook-events' ); ?> : |
| 40 |
</th> |
| 41 |
<td> |
| 42 |
<select name="event_plugin" class="fb_event_plugin"> |
| 43 |
<?php |
| 44 |
if( !empty( $active_plugins ) ){ |
| 45 |
foreach ($active_plugins as $slug => $name ) { |
| 46 |
?> |
| 47 |
<option value="<?php echo $slug;?>"><?php echo $name; ?></option> |
| 48 |
<?php |
| 49 |
} |
| 50 |
} |
| 51 |
?> |
| 52 |
</select> |
| 53 |
</td> |
| 54 |
</tr> |
| 55 |
|
| 56 |
<tr class="event_cats_wrapper"> |
| 57 |
<th scope="row"> |
| 58 |
<?php esc_attr_e( 'Event Categories for Event Import','import-facebook-events' ); ?> : |
| 59 |
</th> |
| 60 |
<td> |
| 61 |
<div class="event_taxo_terms_wraper"> |
| 62 |
|
| 63 |
</div> |
| 64 |
<span class="ife_small"> |
| 65 |
<?php esc_attr_e( 'These categories are assign to imported event.', 'import-facebook-events' ); ?> |
| 66 |
</span> |
| 67 |
</td> |
| 68 |
</tr> |
| 69 |
<?php |
| 70 |
|
| 71 |
} |
| 72 |
|
| 73 |
/** |
| 74 |
* Render Taxonomy Terms based on event import into Selection. |
| 75 |
* |
| 76 |
* @since 1.0 |
| 77 |
* @return void |
| 78 |
*/ |
| 79 |
function ife_render_terms_by_plugin() { |
| 80 |
global $ife_events; |
| 81 |
$event_plugin = esc_attr( $_REQUEST['event_plugin'] ); |
| 82 |
$event_taxonomy = ''; |
| 83 |
switch ( $event_plugin ) { |
| 84 |
case 'ife': |
| 85 |
$event_taxonomy = $ife_events->ife->get_taxonomy(); |
| 86 |
break; |
| 87 |
|
| 88 |
case 'tec': |
| 89 |
$event_taxonomy = $ife_events->tec->get_taxonomy(); |
| 90 |
break; |
| 91 |
|
| 92 |
case 'em': |
| 93 |
$event_taxonomy = $ife_events->em->get_taxonomy(); |
| 94 |
break; |
| 95 |
|
| 96 |
case 'eventon': |
| 97 |
$event_taxonomy = $ife_events->eventon->get_taxonomy(); |
| 98 |
break; |
| 99 |
|
| 100 |
case 'event_organizer': |
| 101 |
$event_taxonomy = $ife_events->event_organizer->get_taxonomy(); |
| 102 |
break; |
| 103 |
|
| 104 |
case 'aioec': |
| 105 |
$event_taxonomy = $ife_events->aioec->get_taxonomy(); |
| 106 |
break; |
| 107 |
|
| 108 |
case 'my_calendar': |
| 109 |
$event_taxonomy = $ife_events->my_calendar->get_taxonomy(); |
| 110 |
break; |
| 111 |
|
| 112 |
default: |
| 113 |
break; |
| 114 |
} |
| 115 |
|
| 116 |
$terms = array(); |
| 117 |
if ( $event_taxonomy != '' ) { |
| 118 |
if( taxonomy_exists( $event_taxonomy ) ){ |
| 119 |
$terms = get_terms( $event_taxonomy, array( 'hide_empty' => false ) ); |
| 120 |
} |
| 121 |
} |
| 122 |
if( ! empty( $terms ) ){ ?> |
| 123 |
<select name="event_cats[]" multiple="multiple"> |
| 124 |
<?php foreach ($terms as $term ) { ?> |
| 125 |
<option value="<?php echo $term->term_id; ?>"> |
| 126 |
<?php echo $term->name; ?> |
| 127 |
</option> |
| 128 |
<?php } ?> |
| 129 |
</select> |
| 130 |
<?php |
| 131 |
} |
| 132 |
wp_die(); |
| 133 |
} |
| 134 |
|
| 135 |
/** |
| 136 |
* Get Active supported active plugins. |
| 137 |
* |
| 138 |
* @since 1.0.0 |
| 139 |
* @return array |
| 140 |
*/ |
| 141 |
public function get_active_supported_event_plugins() { |
| 142 |
|
| 143 |
$supported_plugins = array(); |
| 144 |
if ( ! function_exists( 'is_plugin_active' ) ) { |
| 145 |
require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
| 146 |
} |
| 147 |
// check The Events Calendar active or not if active add it into array. |
| 148 |
if( class_exists( 'Tribe__Events__Main' ) ){ |
| 149 |
$supported_plugins['tec'] = __( 'The Events Calendar', 'import-facebook-events' ); |
| 150 |
} |
| 151 |
|
| 152 |
// check Events Manager. |
| 153 |
if( defined( 'EM_VERSION' ) ){ |
| 154 |
$supported_plugins['em'] = __( 'Events Manager', 'import-facebook-events' ); |
| 155 |
} |
| 156 |
|
| 157 |
// Check event_organizer. |
| 158 |
if( defined( 'EVENT_ORGANISER_VER' ) && defined( 'EVENT_ORGANISER_DIR' ) ){ |
| 159 |
$supported_plugins['event_organizer'] = __( 'Event Organiser', 'import-facebook-events' ); |
| 160 |
} |
| 161 |
|
| 162 |
// check EventON. |
| 163 |
if( class_exists( 'EventON' ) ){ |
| 164 |
$supported_plugins['eventon'] = __( 'EventON', 'import-facebook-events' ); |
| 165 |
} |
| 166 |
|
| 167 |
// check All in one Event Calendar |
| 168 |
if( class_exists( 'Ai1ec_Event' ) ){ |
| 169 |
$supported_plugins['aioec'] = __( 'All in one Event Calendar', 'import-facebook-events' ); |
| 170 |
} |
| 171 |
|
| 172 |
// check My Calendar |
| 173 |
if ( is_plugin_active( 'my-calendar/my-calendar.php' ) ) { |
| 174 |
$supported_plugins['my_calendar'] = __( 'My Calendar', 'import-facebook-events' ); |
| 175 |
} |
| 176 |
$supported_plugins['ife'] = __( 'Facebook Events', 'import-facebook-events' ); |
| 177 |
return $supported_plugins; |
| 178 |
} |
| 179 |
|
| 180 |
/** |
| 181 |
* Setup Featured image to events |
| 182 |
* |
| 183 |
* @since 1.0.0 |
| 184 |
* @param int $event_id event id. |
| 185 |
* @param int $image_url Image URL |
| 186 |
* @return attachment_id |
| 187 |
*/ |
| 188 |
public function setup_featured_image_to_event( $event_id, $image_url = '' ) { |
| 189 |
|
| 190 |
if ( $image_url == '' ) { |
| 191 |
return; |
| 192 |
} |
| 193 |
$event = get_post( $event_id ); |
| 194 |
if( Empty ( $event ) ){ |
| 195 |
return; |
| 196 |
} |
| 197 |
|
| 198 |
require_once(ABSPATH . 'wp-admin/includes/media.php'); |
| 199 |
require_once(ABSPATH . 'wp-admin/includes/file.php'); |
| 200 |
require_once(ABSPATH . 'wp-admin/includes/image.php'); |
| 201 |
|
| 202 |
$event_title = $event->post_title; |
| 203 |
//$image = media_sideload_image( $image_url, $event_id, $event_title ); |
| 204 |
if ( ! empty( $image_url ) ) { |
| 205 |
|
| 206 |
// Set variables for storage, fix file filename for query strings. |
| 207 |
preg_match( '/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $image_url, $matches ); |
| 208 |
if ( ! $matches ) { |
| 209 |
return new WP_Error( 'image_sideload_failed', __( 'Invalid image URL' ) ); |
| 210 |
} |
| 211 |
|
| 212 |
$file_array = array(); |
| 213 |
$file_array['name'] = $event->ID . '_image_'.basename( $matches[0] ); |
| 214 |
|
| 215 |
if( has_post_thumbnail( $event_id ) ){ |
| 216 |
$attachment_id = get_post_thumbnail_id( $event_id ); |
| 217 |
$attach_filename = basename( get_attached_file( $attachment_id ) ); |
| 218 |
if( $attach_filename == $file_array['name'] ){ |
| 219 |
return false; |
| 220 |
} |
| 221 |
} |
| 222 |
|
| 223 |
// Download file to temp location. |
| 224 |
$file_array['tmp_name'] = download_url( $image_url ); |
| 225 |
|
| 226 |
// If error storing temporarily, return the error. |
| 227 |
if ( is_wp_error( $file_array['tmp_name'] ) ) { |
| 228 |
return $file_array['tmp_name']; |
| 229 |
} |
| 230 |
|
| 231 |
// Do the validation and storage stuff. |
| 232 |
$att_id = media_handle_sideload( $file_array, $event_id, $event_title ); |
| 233 |
|
| 234 |
// If error storing permanently, unlink. |
| 235 |
if ( is_wp_error( $att_id ) ) { |
| 236 |
@unlink( $file_array['tmp_name'] ); |
| 237 |
return $att_id; |
| 238 |
} |
| 239 |
|
| 240 |
if ($att_id) { |
| 241 |
set_post_thumbnail($event_id, $att_id); |
| 242 |
} |
| 243 |
|
| 244 |
return $att_id; |
| 245 |
} |
| 246 |
|
| 247 |
} |
| 248 |
|
| 249 |
/** |
| 250 |
* Format events arguments as per TEC |
| 251 |
* |
| 252 |
* @since 1.0.0 |
| 253 |
* @param array $eventbrite_event Eventbrite event. |
| 254 |
* @return array |
| 255 |
*/ |
| 256 |
public function display_import_success_message( $import_data = array(),$import_args = array(), $schedule_post = '' ) { |
| 257 |
global $ife_success_msg, $ife_errors; |
| 258 |
if( empty( $import_data ) ){ |
| 259 |
return; |
| 260 |
} |
| 261 |
|
| 262 |
$import_status = $import_ids = array(); |
| 263 |
foreach ($import_data as $key => $value) { |
| 264 |
if( $value['status'] == 'created'){ |
| 265 |
$import_status['created'][] = $value; |
| 266 |
}elseif( $value['status'] == 'updated'){ |
| 267 |
$import_status['updated'][] = $value; |
| 268 |
}elseif( $value['status'] == 'skipped'){ |
| 269 |
$import_status['skipped'][] = $value; |
| 270 |
}else{ |
| 271 |
|
| 272 |
} |
| 273 |
if( isset( $value['id'] ) ){ |
| 274 |
$import_ids[] = $value['id']; |
| 275 |
} |
| 276 |
} |
| 277 |
$created = $updated = $skipped = 0; |
| 278 |
$created = isset( $import_status['created'] ) ? count( $import_status['created'] ) : 0; |
| 279 |
$updated = isset( $import_status['updated'] ) ? count( $import_status['updated'] ) : 0; |
| 280 |
$skipped = isset( $import_status['skipped'] ) ? count( $import_status['skipped'] ) : 0; |
| 281 |
|
| 282 |
$success_message = esc_html__( 'Event(s) are imported successfully.', 'import-facebook-events' )."<br>"; |
| 283 |
if( $created > 0 ){ |
| 284 |
$success_message .= "<strong>".sprintf( __( '%d Created', 'import-facebook-events' ), $created )."</strong><br>"; |
| 285 |
} |
| 286 |
if( $updated > 0 ){ |
| 287 |
$success_message .= "<strong>".sprintf( __( '%d Updated', 'import-facebook-events' ), $updated )."</strong><br>"; |
| 288 |
} |
| 289 |
if( $skipped > 0 ){ |
| 290 |
$success_message .= "<strong>".sprintf( __( '%d Skipped (Already exists)', 'import-facebook-events' ), $skipped ) ."</strong><br>"; |
| 291 |
} |
| 292 |
$ife_success_msg[] = $success_message; |
| 293 |
|
| 294 |
if( $schedule_post != '' && $schedule_post > 0 ){ |
| 295 |
$temp_title = get_the_title( $schedule_post ); |
| 296 |
}else{ |
| 297 |
$temp_title = 'Manual Import'; |
| 298 |
} |
| 299 |
|
| 300 |
if( $created > 0 || $updated > 0 || $skipped >0 ){ |
| 301 |
$insert_args = array( |
| 302 |
'post_type' => 'ife_import_history', |
| 303 |
'post_status' => 'publish', |
| 304 |
'post_title' => $temp_title . " - ".ucfirst( $import_args["import_origin"]), |
| 305 |
); |
| 306 |
|
| 307 |
$insert = wp_insert_post( $insert_args, true ); |
| 308 |
if ( !is_wp_error( $insert ) ) { |
| 309 |
update_post_meta( $insert, 'import_origin', $import_args["import_origin"] ); |
| 310 |
update_post_meta( $insert, 'created', $created ); |
| 311 |
update_post_meta( $insert, 'updated', $updated ); |
| 312 |
update_post_meta( $insert, 'skipped', $skipped ); |
| 313 |
update_post_meta( $insert, 'import_data', $import_args ); |
| 314 |
if( $schedule_post != '' && $schedule_post > 0 ){ |
| 315 |
update_post_meta( $insert, 'schedule_import_id', $schedule_post ); |
| 316 |
} |
| 317 |
} |
| 318 |
} |
| 319 |
} |
| 320 |
|
| 321 |
/** |
| 322 |
* Get Import events into selected destination. |
| 323 |
* |
| 324 |
* @since 1.0.0 |
| 325 |
* @return array |
| 326 |
*/ |
| 327 |
public function import_events_into( $centralize_array, $event_args ){ |
| 328 |
global $ife_events; |
| 329 |
$import_result = array(); |
| 330 |
$import_origin = isset( $event_args['import_origin'] ) ? $event_args['import_origin'] : ''; |
| 331 |
$event_import_into = isset( $event_args['import_into'] ) ? $event_args['import_into'] : ''; |
| 332 |
|
| 333 |
if ( $event_import_into == '' ) { |
| 334 |
if ( $import_origin == 'facebook_tec' ) { |
| 335 |
$event_import_into = 'tec'; |
| 336 |
} elseif ( $import_origin == 'facebook_em' ) { |
| 337 |
$event_import_into = 'em'; |
| 338 |
} else { |
| 339 |
$event_import_into = 'tec'; |
| 340 |
} |
| 341 |
} |
| 342 |
|
| 343 |
switch ( $event_import_into ) { |
| 344 |
case 'ife': |
| 345 |
$import_result = $ife_events->ife->import_event( $centralize_array, $event_args ); |
| 346 |
break; |
| 347 |
|
| 348 |
case 'tec': |
| 349 |
$import_result = $ife_events->tec->import_event( $centralize_array, $event_args ); |
| 350 |
break; |
| 351 |
|
| 352 |
case 'em': |
| 353 |
$import_result = $ife_events->em->import_event( $centralize_array, $event_args ); |
| 354 |
break; |
| 355 |
|
| 356 |
case 'eventon': |
| 357 |
$import_result = $ife_events->eventon->import_event( $centralize_array, $event_args ); |
| 358 |
break; |
| 359 |
|
| 360 |
case 'event_organizer': |
| 361 |
$import_result = $ife_events->event_organizer->import_event( $centralize_array, $event_args ); |
| 362 |
break; |
| 363 |
|
| 364 |
case 'aioec': |
| 365 |
$import_result = $ife_events->aioec->import_event( $centralize_array, $event_args ); |
| 366 |
break; |
| 367 |
|
| 368 |
case 'my_calendar': |
| 369 |
$import_result = $ife_events->my_calendar->import_event( $centralize_array, $event_args ); |
| 370 |
break; |
| 371 |
|
| 372 |
default: |
| 373 |
break; |
| 374 |
} |
| 375 |
return $import_result; |
| 376 |
} |
| 377 |
|
| 378 |
/** |
| 379 |
* Render import Frequency |
| 380 |
* |
| 381 |
* @since 1.0.0 |
| 382 |
* @return void |
| 383 |
*/ |
| 384 |
function render_import_frequency(){ |
| 385 |
?> |
| 386 |
<select name="import_frequency" class="import_frequency" disabled="disabled" > |
| 387 |
<option value='hourly'> |
| 388 |
<?php esc_html_e( 'Once Hourly','import-facebook-events' ); ?> |
| 389 |
</option> |
| 390 |
<option value='twicedaily'> |
| 391 |
<?php esc_html_e( 'Twice Daily','import-facebook-events' ); ?> |
| 392 |
</option> |
| 393 |
<option value="daily" selected="selected"> |
| 394 |
<?php esc_html_e( 'Once Daily','import-facebook-events' ); ?> |
| 395 |
</option> |
| 396 |
<option value="weekly" > |
| 397 |
<?php esc_html_e( 'Once Weekly','import-facebook-events' ); ?> |
| 398 |
</option> |
| 399 |
<option value="monthly"> |
| 400 |
<?php esc_html_e( 'Once a Month','import-facebook-events' ); ?> |
| 401 |
</option> |
| 402 |
</select> |
| 403 |
<?php |
| 404 |
} |
| 405 |
|
| 406 |
/** |
| 407 |
* Render import type, one time or scheduled |
| 408 |
* |
| 409 |
* @since 1.0.0 |
| 410 |
* @return void |
| 411 |
*/ |
| 412 |
function render_import_type(){ |
| 413 |
?> |
| 414 |
<select name="import_type" id="import_type" disabled="disabled"> |
| 415 |
<option value="onetime" disabled="disabled" ><?php esc_attr_e( 'One-time Import','import-facebook-events' ); ?></option> |
| 416 |
<option value="scheduled" disabled="disabled" selected="selected" ><?php esc_attr_e( 'Scheduled Import','import-facebook-events' ); ?></option> |
| 417 |
</select> |
| 418 |
<span class="hide_frequency"> |
| 419 |
<?php $this->render_import_frequency(); ?> |
| 420 |
</span> |
| 421 |
<?php |
| 422 |
do_action( 'ife_render_pro_notice' ); |
| 423 |
} |
| 424 |
|
| 425 |
/** |
| 426 |
* Clean URL. |
| 427 |
* |
| 428 |
* @since 1.0.0 |
| 429 |
*/ |
| 430 |
function clean_url( $url ) { |
| 431 |
|
| 432 |
$url = str_replace( '&#038;', '&', $url ); |
| 433 |
$url = str_replace( '&', '&', $url ); |
| 434 |
return $url; |
| 435 |
|
| 436 |
} |
| 437 |
|
| 438 |
/** |
| 439 |
* Get UTC offset |
| 440 |
* |
| 441 |
* @since 1.0.0 |
| 442 |
*/ |
| 443 |
function get_utc_offset( $datetime ) { |
| 444 |
try { |
| 445 |
$datetime = new DateTime( $datetime ); |
| 446 |
} catch ( Exception $e ) { |
| 447 |
return ''; |
| 448 |
} |
| 449 |
|
| 450 |
$timezone = $datetime->getTimezone(); |
| 451 |
$offset = $timezone->getOffset( $datetime ) / 60 / 60; |
| 452 |
|
| 453 |
if ( $offset >= 0 ) { |
| 454 |
$offset = '+' . $offset; |
| 455 |
} |
| 456 |
|
| 457 |
return 'UTC' . $offset; |
| 458 |
} |
| 459 |
|
| 460 |
/** |
| 461 |
* Render dropdown for Imported event status. |
| 462 |
* |
| 463 |
* @since 1.0 |
| 464 |
* @return void |
| 465 |
*/ |
| 466 |
function render_eventstatus_input() { |
| 467 |
?> |
| 468 |
<tr class="event_status_wrapper"> |
| 469 |
<th scope="row"> |
| 470 |
<?php esc_attr_e( 'Status','import-facebook-events' ); ?> : |
| 471 |
</th> |
| 472 |
<td> |
| 473 |
<select name="event_status" > |
| 474 |
<option value="publish"> |
| 475 |
<?php esc_html_e( 'Published','import-facebook-events' ); ?> |
| 476 |
</option> |
| 477 |
<option value="pending"> |
| 478 |
<?php esc_html_e( 'Pending','import-facebook-events' ); ?> |
| 479 |
</option> |
| 480 |
<option value="draft"> |
| 481 |
<?php esc_html_e( 'Draft','import-facebook-events' ); ?> |
| 482 |
</option> |
| 483 |
</select> |
| 484 |
</td> |
| 485 |
</tr> |
| 486 |
<?php |
| 487 |
} |
| 488 |
|
| 489 |
/** |
| 490 |
* remove query string from URL. |
| 491 |
* |
| 492 |
* @since 1.0.0 |
| 493 |
*/ |
| 494 |
function convert_datetime_to_db_datetime( $datetime ) { |
| 495 |
try { |
| 496 |
$datetime = new DateTime( $datetime ); |
| 497 |
return $datetime->format( 'Y-m-d H:i:s' ); |
| 498 |
} |
| 499 |
catch ( Exception $e ) { |
| 500 |
return $datetime; |
| 501 |
} |
| 502 |
} |
| 503 |
|
| 504 |
/** |
| 505 |
* Check for Existing Event |
| 506 |
* |
| 507 |
* @since 1.0.0 |
| 508 |
* @param int $event_id event id. |
| 509 |
* @return /boolean |
| 510 |
*/ |
| 511 |
public function get_event_by_event_id( $post_type, $event_id ) { |
| 512 |
$event_args = array( |
| 513 |
'post_type' => $post_type, |
| 514 |
'post_status' => array( 'pending', 'draft', 'publish' ), |
| 515 |
'posts_per_page' => -1, |
| 516 |
'suppress_filters' => true, |
| 517 |
'meta_key' => 'ife_facebook_event_id', |
| 518 |
'meta_value' => $event_id, |
| 519 |
); |
| 520 |
if( $post_type == 'tribe_events' && class_exists( 'Tribe__Events__Query' ) ){ |
| 521 |
remove_action( 'pre_get_posts', array( 'Tribe__Events__Query', 'pre_get_posts' ), 50 ); |
| 522 |
} |
| 523 |
$events = new WP_Query( $event_args ); |
| 524 |
if( $post_type == 'tribe_events' && class_exists( 'Tribe__Events__Query' ) ){ |
| 525 |
add_action( 'pre_get_posts', array( 'Tribe__Events__Query', 'pre_get_posts' ), 50 ); |
| 526 |
} |
| 527 |
if ( $events->have_posts() ) { |
| 528 |
while ( $events->have_posts() ) { |
| 529 |
$events->the_post(); |
| 530 |
return get_the_ID(); |
| 531 |
} |
| 532 |
} |
| 533 |
wp_reset_postdata(); |
| 534 |
return false; |
| 535 |
} |
| 536 |
|
| 537 |
/** |
| 538 |
* Display upgrade to pro notice in form. |
| 539 |
* |
| 540 |
* @since 1.0.0 |
| 541 |
*/ |
| 542 |
public function render_pro_notice(){ |
| 543 |
?> |
| 544 |
<span class="ife_small"> |
| 545 |
<?php printf( '<span style="color: red">%s</span> <a href="' . IFE_PLUGIN_BUY_NOW_URL. '" target="_blank" >%s</a>', __( 'Available in Pro version.', 'import-facebook-events' ), __( 'Upgrade to PRO', 'import-facebook-events' ) ); ?> |
| 546 |
</span> |
| 547 |
<?php |
| 548 |
} |
| 549 |
|
| 550 |
/** |
| 551 |
* Get Active supported active plugins. |
| 552 |
* |
| 553 |
* @since 1.0.0 |
| 554 |
* @return array |
| 555 |
*/ |
| 556 |
public function ife_get_country_code( $country ) { |
| 557 |
if ( $country == '' ) { |
| 558 |
return ''; |
| 559 |
} |
| 560 |
|
| 561 |
$countries = array( |
| 562 |
'AF' => 'AFGHANISTAN', |
| 563 |
'AL' => 'ALBANIA', |
| 564 |
'DZ' => 'ALGERIA', |
| 565 |
'AS' => 'AMERICAN SAMOA', |
| 566 |
'AD' => 'ANDORRA', |
| 567 |
'AO' => 'ANGOLA', |
| 568 |
'AI' => 'ANGUILLA', |
| 569 |
'AQ' => 'ANTARCTICA', |
| 570 |
'AG' => 'ANTIGUA AND BARBUDA', |
| 571 |
'AR' => 'ARGENTINA', |
| 572 |
'AM' => 'ARMENIA', |
| 573 |
'AW' => 'ARUBA', |
| 574 |
'AU' => 'AUSTRALIA', |
| 575 |
'AT' => 'AUSTRIA', |
| 576 |
'AZ' => 'AZERBAIJAN', |
| 577 |
'BS' => 'BAHAMAS', |
| 578 |
'BH' => 'BAHRAIN', |
| 579 |
'BD' => 'BANGLADESH', |
| 580 |
'BB' => 'BARBADOS', |
| 581 |
'BY' => 'BELARUS', |
| 582 |
'BE' => 'BELGIUM', |
| 583 |
'BZ' => 'BELIZE', |
| 584 |
'BJ' => 'BENIN', |
| 585 |
'BM' => 'BERMUDA', |
| 586 |
'BT' => 'BHUTAN', |
| 587 |
'BO' => 'BOLIVIA', |
| 588 |
'BA' => 'BOSNIA AND HERZEGOVINA', |
| 589 |
'BW' => 'BOTSWANA', |
| 590 |
'BV' => 'BOUVET ISLAND', |
| 591 |
'BR' => 'BRAZIL', |
| 592 |
'IO' => 'BRITISH INDIAN OCEAN TERRITORY', |
| 593 |
'BN' => 'BRUNEI DARUSSALAM', |
| 594 |
'BG' => 'BULGARIA', |
| 595 |
'BF' => 'BURKINA FASO', |
| 596 |
'BI' => 'BURUNDI', |
| 597 |
'KH' => 'CAMBODIA', |
| 598 |
'CM' => 'CAMEROON', |
| 599 |
'CA' => 'CANADA', |
| 600 |
'CV' => 'CAPE VERDE', |
| 601 |
'KY' => 'CAYMAN ISLANDS', |
| 602 |
'CF' => 'CENTRAL AFRICAN REPUBLIC', |
| 603 |
'TD' => 'CHAD', |
| 604 |
'CL' => 'CHILE', |
| 605 |
'CN' => 'CHINA', |
| 606 |
'CX' => 'CHRISTMAS ISLAND', |
| 607 |
'CC' => 'COCOS (KEELING) ISLANDS', |
| 608 |
'CO' => 'COLOMBIA', |
| 609 |
'KM' => 'COMOROS', |
| 610 |
'CG' => 'CONGO', |
| 611 |
'CD' => 'CONGO, THE DEMOCRATIC REPUBLIC OF THE', |
| 612 |
'CK' => 'COOK ISLANDS', |
| 613 |
'CR' => 'COSTA RICA', |
| 614 |
'CI' => 'COTE D IVOIRE', |
| 615 |
'HR' => 'CROATIA', |
| 616 |
'CU' => 'CUBA', |
| 617 |
'CY' => 'CYPRUS', |
| 618 |
'CZ' => 'CZECH REPUBLIC', |
| 619 |
'DK' => 'DENMARK', |
| 620 |
'DJ' => 'DJIBOUTI', |
| 621 |
'DM' => 'DOMINICA', |
| 622 |
'DO' => 'DOMINICAN REPUBLIC', |
| 623 |
'TP' => 'EAST TIMOR', |
| 624 |
'EC' => 'ECUADOR', |
| 625 |
'EG' => 'EGYPT', |
| 626 |
'SV' => 'EL SALVADOR', |
| 627 |
'GQ' => 'EQUATORIAL GUINEA', |
| 628 |
'ER' => 'ERITREA', |
| 629 |
'EE' => 'ESTONIA', |
| 630 |
'ET' => 'ETHIOPIA', |
| 631 |
'FK' => 'FALKLAND ISLANDS (MALVINAS)', |
| 632 |
'FO' => 'FAROE ISLANDS', |
| 633 |
'FJ' => 'FIJI', |
| 634 |
'FI' => 'FINLAND', |
| 635 |
'FR' => 'FRANCE', |
| 636 |
'GF' => 'FRENCH GUIANA', |
| 637 |
'PF' => 'FRENCH POLYNESIA', |
| 638 |
'TF' => 'FRENCH SOUTHERN TERRITORIES', |
| 639 |
'GA' => 'GABON', |
| 640 |
'GM' => 'GAMBIA', |
| 641 |
'GE' => 'GEORGIA', |
| 642 |
'DE' => 'GERMANY', |
| 643 |
'GH' => 'GHANA', |
| 644 |
'GI' => 'GIBRALTAR', |
| 645 |
'GR' => 'GREECE', |
| 646 |
'GL' => 'GREENLAND', |
| 647 |
'GD' => 'GRENADA', |
| 648 |
'GP' => 'GUADELOUPE', |
| 649 |
'GU' => 'GUAM', |
| 650 |
'GT' => 'GUATEMALA', |
| 651 |
'GN' => 'GUINEA', |
| 652 |
'GW' => 'GUINEA-BISSAU', |
| 653 |
'GY' => 'GUYANA', |
| 654 |
'HT' => 'HAITI', |
| 655 |
'HM' => 'HEARD ISLAND AND MCDONALD ISLANDS', |
| 656 |
'VA' => 'HOLY SEE (VATICAN CITY STATE)', |
| 657 |
'HN' => 'HONDURAS', |
| 658 |
'HK' => 'HONG KONG', |
| 659 |
'HU' => 'HUNGARY', |
| 660 |
'IS' => 'ICELAND', |
| 661 |
'IN' => 'INDIA', |
| 662 |
'ID' => 'INDONESIA', |
| 663 |
'IR' => 'IRAN, ISLAMIC REPUBLIC OF', |
| 664 |
'IQ' => 'IRAQ', |
| 665 |
'IE' => 'IRELAND', |
| 666 |
'IL' => 'ISRAEL', |
| 667 |
'IT' => 'ITALY', |
| 668 |
'JM' => 'JAMAICA', |
| 669 |
'JP' => 'JAPAN', |
| 670 |
'JO' => 'JORDAN', |
| 671 |
'KZ' => 'KAZAKSTAN', |
| 672 |
'KE' => 'KENYA', |
| 673 |
'KI' => 'KIRIBATI', |
| 674 |
'KP' => 'KOREA DEMOCRATIC PEOPLES REPUBLIC OF', |
| 675 |
'KR' => 'KOREA REPUBLIC OF', |
| 676 |
'KW' => 'KUWAIT', |
| 677 |
'KG' => 'KYRGYZSTAN', |
| 678 |
'LA' => 'LAO PEOPLES DEMOCRATIC REPUBLIC', |
| 679 |
'LV' => 'LATVIA', |
| 680 |
'LB' => 'LEBANON', |
| 681 |
'LS' => 'LESOTHO', |
| 682 |
'LR' => 'LIBERIA', |
| 683 |
'LY' => 'LIBYAN ARAB JAMAHIRIYA', |
| 684 |
'LI' => 'LIECHTENSTEIN', |
| 685 |
'LT' => 'LITHUANIA', |
| 686 |
'LU' => 'LUXEMBOURG', |
| 687 |
'MO' => 'MACAU', |
| 688 |
'MK' => 'MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF', |
| 689 |
'MG' => 'MADAGASCAR', |
| 690 |
'MW' => 'MALAWI', |
| 691 |
'MY' => 'MALAYSIA', |
| 692 |
'MV' => 'MALDIVES', |
| 693 |
'ML' => 'MALI', |
| 694 |
'MT' => 'MALTA', |
| 695 |
'MH' => 'MARSHALL ISLANDS', |
| 696 |
'MQ' => 'MARTINIQUE', |
| 697 |
'MR' => 'MAURITANIA', |
| 698 |
'MU' => 'MAURITIUS', |
| 699 |
'YT' => 'MAYOTTE', |
| 700 |
'MX' => 'MEXICO', |
| 701 |
'FM' => 'MICRONESIA, FEDERATED STATES OF', |
| 702 |
'MD' => 'MOLDOVA, REPUBLIC OF', |
| 703 |
'MC' => 'MONACO', |
| 704 |
'MN' => 'MONGOLIA', |
| 705 |
'MS' => 'MONTSERRAT', |
| 706 |
'MA' => 'MOROCCO', |
| 707 |
'MZ' => 'MOZAMBIQUE', |
| 708 |
'MM' => 'MYANMAR', |
| 709 |
'NA' => 'NAMIBIA', |
| 710 |
'NR' => 'NAURU', |
| 711 |
'NP' => 'NEPAL', |
| 712 |
'NL' => 'NETHERLANDS', |
| 713 |
'AN' => 'NETHERLANDS ANTILLES', |
| 714 |
'NC' => 'NEW CALEDONIA', |
| 715 |
'NZ' => 'NEW ZEALAND', |
| 716 |
'NI' => 'NICARAGUA', |
| 717 |
'NE' => 'NIGER', |
| 718 |
'NG' => 'NIGERIA', |
| 719 |
'NU' => 'NIUE', |
| 720 |
'NF' => 'NORFOLK ISLAND', |
| 721 |
'MP' => 'NORTHERN MARIANA ISLANDS', |
| 722 |
'NO' => 'NORWAY', |
| 723 |
'OM' => 'OMAN', |
| 724 |
'PK' => 'PAKISTAN', |
| 725 |
'PW' => 'PALAU', |
| 726 |
'PS' => 'PALESTINIAN TERRITORY, OCCUPIED', |
| 727 |
'PA' => 'PANAMA', |
| 728 |
'PG' => 'PAPUA NEW GUINEA', |
| 729 |
'PY' => 'PARAGUAY', |
| 730 |
'PE' => 'PERU', |
| 731 |
'PH' => 'PHILIPPINES', |
| 732 |
'PN' => 'PITCAIRN', |
| 733 |
'PL' => 'POLAND', |
| 734 |
'PT' => 'PORTUGAL', |
| 735 |
'PR' => 'PUERTO RICO', |
| 736 |
'QA' => 'QATAR', |
| 737 |
'RE' => 'REUNION', |
| 738 |
'RO' => 'ROMANIA', |
| 739 |
'RU' => 'RUSSIAN FEDERATION', |
| 740 |
'RW' => 'RWANDA', |
| 741 |
'SH' => 'SAINT HELENA', |
| 742 |
'KN' => 'SAINT KITTS AND NEVIS', |
| 743 |
'LC' => 'SAINT LUCIA', |
| 744 |
'PM' => 'SAINT PIERRE AND MIQUELON', |
| 745 |
'VC' => 'SAINT VINCENT AND THE GRENADINES', |
| 746 |
'WS' => 'SAMOA', |
| 747 |
'SM' => 'SAN MARINO', |
| 748 |
'ST' => 'SAO TOME AND PRINCIPE', |
| 749 |
'SA' => 'SAUDI ARABIA', |
| 750 |
'SN' => 'SENEGAL', |
| 751 |
'SC' => 'SEYCHELLES', |
| 752 |
'SL' => 'SIERRA LEONE', |
| 753 |
'SG' => 'SINGAPORE', |
| 754 |
'SK' => 'SLOVAKIA', |
| 755 |
'SI' => 'SLOVENIA', |
| 756 |
'SB' => 'SOLOMON ISLANDS', |
| 757 |
'SO' => 'SOMALIA', |
| 758 |
'ZA' => 'SOUTH AFRICA', |
| 759 |
'GS' => 'SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS', |
| 760 |
'ES' => 'SPAIN', |
| 761 |
'LK' => 'SRI LANKA', |
| 762 |
'SD' => 'SUDAN', |
| 763 |
'SR' => 'SURINAME', |
| 764 |
'SJ' => 'SVALBARD AND JAN MAYEN', |
| 765 |
'SZ' => 'SWAZILAND', |
| 766 |
'SE' => 'SWEDEN', |
| 767 |
'CH' => 'SWITZERLAND', |
| 768 |
'SY' => 'SYRIAN ARAB REPUBLIC', |
| 769 |
'TW' => 'TAIWAN, PROVINCE OF CHINA', |
| 770 |
'TJ' => 'TAJIKISTAN', |
| 771 |
'TZ' => 'TANZANIA, UNITED REPUBLIC OF', |
| 772 |
'TH' => 'THAILAND', |
| 773 |
'TG' => 'TOGO', |
| 774 |
'TK' => 'TOKELAU', |
| 775 |
'TO' => 'TONGA', |
| 776 |
'TT' => 'TRINIDAD AND TOBAGO', |
| 777 |
'TN' => 'TUNISIA', |
| 778 |
'TR' => 'TURKEY', |
| 779 |
'TM' => 'TURKMENISTAN', |
| 780 |
'TC' => 'TURKS AND CAICOS ISLANDS', |
| 781 |
'TV' => 'TUVALU', |
| 782 |
'UG' => 'UGANDA', |
| 783 |
'UA' => 'UKRAINE', |
| 784 |
'AE' => 'UNITED ARAB EMIRATES', |
| 785 |
'GB' => 'UNITED KINGDOM', |
| 786 |
'US' => 'UNITED STATES', |
| 787 |
'UM' => 'UNITED STATES MINOR OUTLYING ISLANDS', |
| 788 |
'UY' => 'URUGUAY', |
| 789 |
'UZ' => 'UZBEKISTAN', |
| 790 |
'VU' => 'VANUATU', |
| 791 |
'VE' => 'VENEZUELA', |
| 792 |
'VN' => 'VIET NAM', |
| 793 |
'VG' => 'VIRGIN ISLANDS, BRITISH', |
| 794 |
'VI' => 'VIRGIN ISLANDS, U.S.', |
| 795 |
'WF' => 'WALLIS AND FUTUNA', |
| 796 |
'EH' => 'WESTERN SAHARA', |
| 797 |
'YE' => 'YEMEN', |
| 798 |
'YU' => 'YUGOSLAVIA', |
| 799 |
'ZM' => 'ZAMBIA', |
| 800 |
'ZW' => 'ZIMBABWE', |
| 801 |
); |
| 802 |
|
| 803 |
foreach ( $countries as $code => $name ) { |
| 804 |
if ( strtoupper( $country ) == $name ) { |
| 805 |
return $code; |
| 806 |
} |
| 807 |
} |
| 808 |
return $country; |
| 809 |
} |
| 810 |
} |
| 811 |
|