diff --git a/includes/class-import-eventbrite-events-common.php b/includes/class-import-eventbrite-events-common.php
index 9b5239b..1e5429c 100644
--- a/includes/class-import-eventbrite-events-common.php
+++ b/includes/class-import-eventbrite-events-common.php
@@ -446,7 +446,7 @@ public function iee_check_for_minimum_pro_version() {
* @param array $eventbrite_event Eventbrite event.
* @return array
*/
- public function display_import_success_message( $import_data = array(), $import_args = array(), $schedule_post = '' ) {
+ public function display_import_success_message( $import_data = array(), $import_args = array(), $schedule_post = '', $error_reason = '' ) {
global $iee_success_msg, $iee_errors;
if ( ! empty( $iee_errors ) ) {
return;
@@ -491,7 +491,10 @@ public function display_import_success_message( $import_data = array(), $import_
if ( $skip_trash > 0 ) {
$success_message .= "" . sprintf( __( '%d Skipped (Already exists in Trash )', 'import-eventbrite-events' ), $skip_trash ) . "
";
}
- $iee_success_msg[] = $success_message;
+ if ( !empty( $error_reason ) ) {
+ $success_message .= "" . sprintf( __( '%d ', 'import-eventbrite-events' ), $error_reason ) . "
";
+ }
+ $iee_success_msg[] = $success_message;
if ( $schedule_post != '' && $schedule_post > 0 ) {
$temp_title = get_the_title( $schedule_post );
@@ -518,6 +521,7 @@ public function display_import_success_message( $import_data = array(), $import_
update_post_meta( $insert, 'skipped', $skipped );
update_post_meta( $insert, 'skip_trash', $skip_trash );
update_post_meta( $insert, 'nothing_to_import', $nothing_to_import );
+ update_post_meta( $insert, 'error_reason', $error_reason );
update_post_meta( $insert, 'imported_data', $import_data );
update_post_meta( $insert, 'import_data', $import_args );
if ( $schedule_post != '' && $schedule_post > 0 ) {
diff --git a/includes/class-import-eventbrite-events-eventbrite.php b/includes/class-import-eventbrite-events-eventbrite.php
index d978950..388c65f 100644
--- a/includes/class-import-eventbrite-events-eventbrite.php
+++ b/includes/class-import-eventbrite-events-eventbrite.php
@@ -63,6 +63,11 @@ public function import_event_by_event_id( $event_data = array() ) {
return $this->save_eventbrite_event( $eventbrite_event, $event_data );
} else {
+ if( $eventbrite_event['error'] == 'INVALID_AUTH' ){
+ $error_description = str_replace( 'OAuth token', 'Private token', $eventbrite_event['error_description'] );
+ $iee_errors[] = __( $error_description, 'import-eventbrite-events-pro');
+ return;
+ }
$iee_errors[] = __( 'Something went wrong, please try again.', 'import-eventbrite-events' );
return;
}
@@ -191,7 +196,15 @@ public function get_organizer( $eventbrite_event ) {
return null;
}
$event_organizer = $eventbrite_event['organizer_id'];
- $get_oraganizer = wp_remote_get( 'https://www.eventbriteapi.com/v3/organizers/' . $event_organizer . '/?token=' . $this->oauth_token, array( 'headers' => array( 'Content-Type' => 'application/json' ) ) );
+ $get_oraganizer = wp_remote_get(
+ 'https://www.eventbriteapi.com/v3/organizers/' . $event_organizer . '/?token=' . $this->oauth_token,
+ array(
+ 'headers' => array(
+ 'Content-Type' => 'application/json'
+ ),
+ 'timeout' => 20,
+ )
+ );
if ( ! is_wp_error( $get_oraganizer ) ) {
$oraganizer = json_decode( $get_oraganizer['body'], true );
@@ -280,7 +293,15 @@ public function get_organizer_name_by_id( $organizer_id ) {
return;
}
- $get_oraganizer = wp_remote_get( 'https://www.eventbriteapi.com/v3/organizers/' . $organizer_id . '/?token=' . $this->oauth_token, array( 'headers' => array( 'Content-Type' => 'application/json' ) ) );
+ $get_oraganizer = wp_remote_get(
+ 'https://www.eventbriteapi.com/v3/organizers/' . $organizer_id . '/?token=' . $this->oauth_token,
+ array(
+ 'headers' => array(
+ 'Content-Type' => 'application/json'
+ ),
+ 'timeout' => 20,
+ )
+ );
if ( ! is_wp_error( $get_oraganizer ) ) {
$oraganizer = json_decode( $get_oraganizer['body'], true );
diff --git a/includes/class-import-eventbrite-events-list-table.php b/includes/class-import-eventbrite-events-list-table.php
index fc8dd99..cab9ac0 100644
--- a/includes/class-import-eventbrite-events-list-table.php
+++ b/includes/class-import-eventbrite-events-list-table.php
@@ -351,11 +351,16 @@ function get_scheduled_import_data( $origin = '' ) {
if( !empty( $stats ) ){
$stats = esc_html__( 'Last Import Stats: ', 'import-eventbrite-events' ).''.implode(', ', $stats).'';
}else{
+ $error_reason = get_post_meta( $history[0], 'error_reason', true );
$nothing_to_import = get_post_meta( $history[0], 'nothing_to_import', true );
- if( $nothing_to_import ){
- $stats = ''.__( 'No events are imported.', 'import-eventbrite-events' ).'';
+ if( !empty( $error_reason ) ){
+ $stats = __( 'The Private token you provided was invalid.', 'import-eventbrite-events' ) . '
';
}else{
- $stats = '';
+ if( $nothing_to_import ){
+ $stats = ''.__( 'No events are imported.', 'import-eventbrite-events' ).'';
+ }else{
+ $stats = '';
+ }
}
}
}
@@ -462,6 +467,7 @@ function column_stats( $item ) {
$updated = get_post_meta( $item['ID'], 'updated', true );
$skipped = get_post_meta( $item['ID'], 'skipped', true );
$skip_trash = get_post_meta( $item['ID'], 'skip_trash', true );
+ $error_reason = get_post_meta( $item['ID'], 'error_reason', true );
$nothing_to_import = get_post_meta( $item['ID'], 'nothing_to_import', true );
$success_message = '';
@@ -477,8 +483,12 @@ function column_stats( $item ) {
if ( $skip_trash > 0 ) {
$success_message .= sprintf( __( '%d Skipped in Trash', 'import-eventbrite-events' ), $skip_trash ) . '
';
}
- if( $nothing_to_import ){
- $success_message .= __( 'No events are imported.', 'import-eventbrite-events' ) . '
';
+ if( !empty( $error_reason ) ){
+ $success_message .= __( 'The Private token you provided was invalid.', 'import-eventbrite-events' ) . '
';
+ }else{
+ if( $nothing_to_import ){
+ $success_message .= __( 'No events are imported.', 'import-eventbrite-events' ) . '
';
+ }
}
$success_message .= '';
diff --git a/languages/import-eventbrite-events.pot b/languages/import-eventbrite-events.pot
index dfb09f7..6250c01 100644
--- a/languages/import-eventbrite-events.pot
+++ b/languages/import-eventbrite-events.pot
@@ -9,7 +9,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"POT-Creation-Date: 2024-09-05T10:41:51+00:00\n"
+"POT-Creation-Date: 2024-09-05T10:43:24+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.11.0\n"
"X-Domain: import-eventbrite-events\n"
@@ -350,8 +350,8 @@ msgstr ""
#: includes/class-import-eventbrite-events-admin.php:543
#: includes/class-import-eventbrite-events-list-table.php:174
-#: includes/class-import-eventbrite-events-list-table.php:537
-#: includes/class-import-eventbrite-events-list-table.php:712
+#: includes/class-import-eventbrite-events-list-table.php:547
+#: includes/class-import-eventbrite-events-list-table.php:722
msgid "Action"
msgstr ""
@@ -426,14 +426,14 @@ msgstr ""
#: includes/class-import-eventbrite-events-common.php:483
#: includes/class-import-eventbrite-events-list-table.php:124
#: includes/class-import-eventbrite-events-list-table.php:340
-#: includes/class-import-eventbrite-events-list-table.php:469
+#: includes/class-import-eventbrite-events-list-table.php:475
msgid "%d Created"
msgstr ""
#: includes/class-import-eventbrite-events-common.php:486
#: includes/class-import-eventbrite-events-list-table.php:127
#: includes/class-import-eventbrite-events-list-table.php:343
-#: includes/class-import-eventbrite-events-list-table.php:472
+#: includes/class-import-eventbrite-events-list-table.php:478
msgid "%d Updated"
msgstr ""
@@ -445,92 +445,96 @@ msgstr ""
msgid "%d Skipped (Already exists in Trash )"
msgstr ""
-#: includes/class-import-eventbrite-events-common.php:556
+#: includes/class-import-eventbrite-events-common.php:495
+msgid "%d "
+msgstr ""
+
+#: includes/class-import-eventbrite-events-common.php:560
msgid "Once Hourly"
msgstr ""
-#: includes/class-import-eventbrite-events-common.php:559
+#: includes/class-import-eventbrite-events-common.php:563
msgid "Twice Daily"
msgstr ""
-#: includes/class-import-eventbrite-events-common.php:562
+#: includes/class-import-eventbrite-events-common.php:566
msgid "Once Daily"
msgstr ""
-#: includes/class-import-eventbrite-events-common.php:565
+#: includes/class-import-eventbrite-events-common.php:569
msgid "Once Weekly"
msgstr ""
-#: includes/class-import-eventbrite-events-common.php:568
+#: includes/class-import-eventbrite-events-common.php:572
msgid "Once a Month"
msgstr ""
-#: includes/class-import-eventbrite-events-common.php:583
+#: includes/class-import-eventbrite-events-common.php:587
msgid "One-time Import"
msgstr ""
-#: includes/class-import-eventbrite-events-common.php:585
+#: includes/class-import-eventbrite-events-common.php:589
msgid "Scheduled Import"
msgstr ""
-#: includes/class-import-eventbrite-events-common.php:640
+#: includes/class-import-eventbrite-events-common.php:644
msgid "Status"
msgstr ""
-#: includes/class-import-eventbrite-events-common.php:645
+#: includes/class-import-eventbrite-events-common.php:649
msgid "Published"
msgstr ""
-#: includes/class-import-eventbrite-events-common.php:648
+#: includes/class-import-eventbrite-events-common.php:652
msgid "Pending"
msgstr ""
-#: includes/class-import-eventbrite-events-common.php:651
+#: includes/class-import-eventbrite-events-common.php:655
msgid "Draft"
msgstr ""
-#: includes/class-import-eventbrite-events-common.php:720
+#: includes/class-import-eventbrite-events-common.php:724
msgid "Available in Pro version."
msgstr ""
-#: includes/class-import-eventbrite-events-common.php:720
+#: includes/class-import-eventbrite-events-common.php:724
msgid "Upgrade to PRO"
msgstr ""
-#: includes/class-import-eventbrite-events-common.php:997
+#: includes/class-import-eventbrite-events-common.php:1001
msgid "Scheduled import deleted successfully."
msgstr ""
-#: includes/class-import-eventbrite-events-common.php:1001
-#: includes/class-import-eventbrite-events-common.php:1025
+#: includes/class-import-eventbrite-events-common.php:1005
+#: includes/class-import-eventbrite-events-common.php:1029
msgid "Scheduled imports are deleted successfully."
msgstr ""
-#: includes/class-import-eventbrite-events-common.php:1005
+#: includes/class-import-eventbrite-events-common.php:1009
msgid "Scheduled import has been run successfully."
msgstr ""
-#: includes/class-import-eventbrite-events-common.php:1009
+#: includes/class-import-eventbrite-events-common.php:1013
msgid "Import history deleted successfully."
msgstr ""
-#: includes/class-import-eventbrite-events-common.php:1013
+#: includes/class-import-eventbrite-events-common.php:1017
msgid "Import histories are deleted successfully."
msgstr ""
-#: includes/class-import-eventbrite-events-common.php:1017
+#: includes/class-import-eventbrite-events-common.php:1021
msgid "Update has been finish successfully."
msgstr ""
-#: includes/class-import-eventbrite-events-common.php:1021
+#: includes/class-import-eventbrite-events-common.php:1025
msgid "Scheduled import has been updated successfully."
msgstr ""
-#: includes/class-import-eventbrite-events-common.php:1178
+#: includes/class-import-eventbrite-events-common.php:1182
msgid "Import settings has been saved successfully."
msgstr ""
-#: includes/class-import-eventbrite-events-common.php:1335
+#: includes/class-import-eventbrite-events-common.php:1339
msgid "Buy Tickets"
msgstr ""
@@ -832,7 +836,7 @@ msgid "Please insert Eventbrite \"Personal OAuth token\"."
msgstr ""
#: includes/class-import-eventbrite-events-eventbrite.php:53
-#: includes/class-import-eventbrite-events-eventbrite.php:66
+#: includes/class-import-eventbrite-events-eventbrite.php:71
#: includes/class-import-eventbrite-events-tec.php:177
#: includes/class-import-eventbrite-events-tec.php:233
msgid "Something went wrong, please try again."
@@ -840,13 +844,13 @@ msgstr ""
#: includes/class-import-eventbrite-events-list-table.php:80
#: includes/class-import-eventbrite-events-list-table.php:182
-#: includes/class-import-eventbrite-events-list-table.php:440
-#: includes/class-import-eventbrite-events-list-table.php:569
+#: includes/class-import-eventbrite-events-list-table.php:445
+#: includes/class-import-eventbrite-events-list-table.php:579
msgid "Delete"
msgstr ""
#: includes/class-import-eventbrite-events-list-table.php:94
-#: includes/class-import-eventbrite-events-list-table.php:448
+#: includes/class-import-eventbrite-events-list-table.php:453
msgid "Origin"
msgstr ""
@@ -868,13 +872,13 @@ msgstr ""
#: includes/class-import-eventbrite-events-list-table.php:130
#: includes/class-import-eventbrite-events-list-table.php:346
-#: includes/class-import-eventbrite-events-list-table.php:475
+#: includes/class-import-eventbrite-events-list-table.php:481
msgid "%d Skipped"
msgstr ""
#: includes/class-import-eventbrite-events-list-table.php:133
#: includes/class-import-eventbrite-events-list-table.php:349
-#: includes/class-import-eventbrite-events-list-table.php:478
+#: includes/class-import-eventbrite-events-list-table.php:484
msgid "%d Skipped in Trash"
msgstr ""
@@ -895,7 +899,7 @@ msgid "Import Event Status"
msgstr ""
#: includes/class-import-eventbrite-events-list-table.php:172
-#: includes/class-import-eventbrite-events-list-table.php:534
+#: includes/class-import-eventbrite-events-list-table.php:544
msgid "Import Category"
msgstr ""
@@ -904,7 +908,7 @@ msgid "Import Frequency"
msgstr ""
#: includes/class-import-eventbrite-events-list-table.php:301
-#: includes/class-import-eventbrite-events-list-table.php:372
+#: includes/class-import-eventbrite-events-list-table.php:377
msgid "Your Events"
msgstr ""
@@ -916,48 +920,56 @@ msgstr ""
msgid "Last Import Stats: "
msgstr ""
-#: includes/class-import-eventbrite-events-list-table.php:356
-#: includes/class-import-eventbrite-events-list-table.php:481
+#: includes/class-import-eventbrite-events-list-table.php:357
+msgid "The Private token you provided was invalid."
+msgstr ""
+
+#: includes/class-import-eventbrite-events-list-table.php:360
+#: includes/class-import-eventbrite-events-list-table.php:490
msgid "No events are imported."
msgstr ""
-#: includes/class-import-eventbrite-events-list-table.php:372
+#: includes/class-import-eventbrite-events-list-table.php:377
msgid "organizer ID"
msgstr ""
-#: includes/class-import-eventbrite-events-list-table.php:510
+#: includes/class-import-eventbrite-events-list-table.php:487
+msgid "The Private token you provided was invalid."
+msgstr ""
+
+#: includes/class-import-eventbrite-events-list-table.php:520
msgid "View Imported Events"
msgstr ""
-#: includes/class-import-eventbrite-events-list-table.php:533
+#: includes/class-import-eventbrite-events-list-table.php:543
msgid "Import"
msgstr ""
-#: includes/class-import-eventbrite-events-list-table.php:535
+#: includes/class-import-eventbrite-events-list-table.php:545
msgid "Import Date"
msgstr ""
-#: includes/class-import-eventbrite-events-list-table.php:536
+#: includes/class-import-eventbrite-events-list-table.php:546
msgid "Import Stats"
msgstr ""
-#: includes/class-import-eventbrite-events-list-table.php:557
+#: includes/class-import-eventbrite-events-list-table.php:567
msgid "Warning!! Are you sure to delete all these import history? Import history will be permanatly deleted."
msgstr ""
-#: includes/class-import-eventbrite-events-list-table.php:560
+#: includes/class-import-eventbrite-events-list-table.php:570
msgid "Clear Import History"
msgstr ""
-#: includes/class-import-eventbrite-events-list-table.php:709
+#: includes/class-import-eventbrite-events-list-table.php:719
msgid "ID"
msgstr ""
-#: includes/class-import-eventbrite-events-list-table.php:710
+#: includes/class-import-eventbrite-events-list-table.php:720
msgid "Title"
msgstr ""
-#: includes/class-import-eventbrite-events-list-table.php:711
+#: includes/class-import-eventbrite-events-list-table.php:721
msgid "Shortcode"
msgstr ""