Skip to content

Commit

Permalink
display invalid private token notice
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajat1192 committed Aug 5, 2024
1 parent 325efaf commit e36e0c3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
8 changes: 6 additions & 2 deletions includes/class-import-eventbrite-events-common.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -491,7 +491,10 @@ public function display_import_success_message( $import_data = array(), $import_
if ( $skip_trash > 0 ) {
$success_message .= "<strong>" . sprintf( __( '%d Skipped (Already exists in Trash )', 'import-eventbrite-events' ), $skip_trash ) . "</strong><br>";
}
$iee_success_msg[] = $success_message;
if ( !empty( $error_reason ) ) {
$success_message .= "<strong>" . sprintf( __( '%d ', 'import-eventbrite-events' ), $error_reason ) . "</strong><br>";
}
$iee_success_msg[] = $success_message;

if ( $schedule_post != '' && $schedule_post > 0 ) {
$temp_title = get_the_title( $schedule_post );
Expand All @@ -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 ) {
Expand Down
5 changes: 5 additions & 0 deletions includes/class-import-eventbrite-events-eventbrite.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
20 changes: 15 additions & 5 deletions includes/class-import-eventbrite-events-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,16 @@ function get_scheduled_import_data( $origin = '' ) {
if( !empty( $stats ) ){
$stats = esc_html__( 'Last Import Stats: ', 'import-eventbrite-events' ).'<span style="color: silver">'.implode(', ', $stats).'</span>';
}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 = '<span style="color: silver">'.__( 'No events are imported.', 'import-eventbrite-events' ).'</span>';
if( !empty( $error_reason ) ){
$stats = __( '<span style="color: red"><strong>The Private token you provided was invalid.</strong></span>', 'import-eventbrite-events' ) . '<br>';
}else{
$stats = '';
if( $nothing_to_import ){
$stats = '<span style="color: silver">'.__( 'No events are imported.', 'import-eventbrite-events' ).'</span>';
}else{
$stats = '';
}
}
}
}
Expand Down Expand Up @@ -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 = '<span style="color: silver"><strong>';
Expand All @@ -477,8 +483,12 @@ function column_stats( $item ) {
if ( $skip_trash > 0 ) {
$success_message .= sprintf( __( '%d Skipped in Trash', 'import-eventbrite-events' ), $skip_trash ) . '<br>';
}
if( $nothing_to_import ){
$success_message .= __( 'No events are imported.', 'import-eventbrite-events' ) . '<br>';
if( !empty( $error_reason ) ){
$success_message .= __( 'The Private token you provided was invalid.', 'import-eventbrite-events' ) . '<br>';
}else{
if( $nothing_to_import ){
$success_message .= __( 'No events are imported.', 'import-eventbrite-events' ) . '<br>';
}
}
$success_message .= '</strong></span>';

Expand Down

0 comments on commit e36e0c3

Please sign in to comment.