From 8d222e05a96621c2ac9391ebf010e7035e8fa1ea Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Thu, 17 Aug 2023 19:15:31 -0500 Subject: [PATCH] Only display bearer token notice if user is already authenticated --- src/wp-to-twitter.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/wp-to-twitter.php b/src/wp-to-twitter.php index 7834de0..546b6ee 100644 --- a/src/wp-to-twitter.php +++ b/src/wp-to-twitter.php @@ -2075,13 +2075,15 @@ function wpt_needs_bearer_token() { if ( current_user_can( 'manage_options' ) || current_user_can( 'wpt_twitter_oauth' ) ) { $screen = get_current_screen(); if ( 'profile' === $screen->id ) { - $auth = wp_get_current_user()->ID; - $bt = get_user_meta( $auth, 'bearer_token', true ); + $auth = wp_get_current_user()->ID; + $authorized = wtt_oauth_test( $auth ); + $bt = get_user_meta( $auth, 'bearer_token', true ); } else { - $auth = false; - $bt = get_option( 'bearer_token', '' ); + $auth = false; + $authorized = wtt_oauth_test(); + $bt = get_option( 'bearer_token', '' ); } - if ( ! $bt ) { + if ( ! $bt && $authorized ) { if ( $auth && get_option( 'jd_individual_twitter_users' ) ) { echo "

" . __( 'XPoster (formerly WP to Twitter) needs a Bearer Token added to your profile settings to support the X.com API.', 'wp-to-twitter' ) . '

'; } elseif ( current_user_can( 'manage_options' ) ) {