Skip to content

Commit

Permalink
Only display bearer token notice if user is already authenticated
Browse files Browse the repository at this point in the history
  • Loading branch information
joedolson committed Aug 18, 2023
1 parent 74bb2e0 commit 8d222e0
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/wp-to-twitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<div class='notice error important'><p>" . __( '<strong>XPoster (formerly WP to Twitter)</strong> needs a Bearer Token added to your profile settings to support the X.com API.', 'wp-to-twitter' ) . '</p></div>';
} elseif ( current_user_can( 'manage_options' ) ) {
Expand Down

0 comments on commit 8d222e0

Please sign in to comment.