Skip to content

Commit

Permalink
deploy: 8bb2955
Browse files Browse the repository at this point in the history
  • Loading branch information
joedolson committed Jan 21, 2024
1 parent e0c882b commit a2bbf68
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
30 changes: 20 additions & 10 deletions wp-to-twitter.php.html
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@
if ( ! $status || 'publish' !== $status ) {
$error = __( 'This post is no longer published or has been deleted', 'wp-to-twitter' );
wpt_save_error( $id, $auth, $twit, $error, '404', time() );
wpt_set_log( 'wpt_status_message', $id, $error );
wpt_set_log( 'wpt_status_message', $id, $error, '404' );

return false;
}
Expand Down Expand Up @@ -400,7 +400,7 @@
if ( ! $check_twitter && ! $check_mastodon ) {
$error = __( 'This account is not authorized to post to any services.', 'wp-to-twitter' );
wpt_save_error( $id, $auth, $twit, $error, '401', time() );
wpt_set_log( 'wpt_status_message', $id, $error );
wpt_set_log( 'wpt_status_message', $id, $error, '401' );
if ( ! $check_twitter ) {
wpt_mail( 'Account not authorized with X.com API.', 'Post ID: ' . $id );
}
Expand All @@ -417,14 +417,14 @@
wpt_mail( 'Matched: status update identical', "This Update: $twit; Check Update: $check; $auth, $id, $media", $id ); // DEBUG.
$error = __( 'This status update is identical to another update recently sent to this account.', 'wp-to-twitter' ) . ' ' . __( 'All status updates are expected to be unique.', 'wp-to-twitter' );
wpt_save_error( $id, $auth, $twit, $error, '403-1', time() );
wpt_set_log( 'wpt_status_message', $id, $error );
wpt_set_log( 'wpt_status_message', $id, $error, '403' );

return false;
} elseif ( '' === $twit || ! $twit ) {
wpt_mail( 'Status update check: empty sentence', "$twit, $auth, $id, $media", $id ); // DEBUG.
$error = __( 'This status update was blank and could not be sent to the API.', 'wp-to-twitter' );
wpt_save_error( $id, $auth, $twit, $error, '403-2', time() );
wpt_set_log( 'wpt_status_message', $id, $error );
wpt_set_log( 'wpt_status_message', $id, $error, '403' );

return false;
} else {
Expand Down Expand Up @@ -463,7 +463,7 @@

return $return;
} else {
wpt_set_log( 'wpt_status_message', $id, __( 'No API connection found.', 'wp-to-twitter' ) );
wpt_set_log( 'wpt_status_message', $id, __( 'No API connection found.', 'wp-to-twitter' ), '404' );

return false;
}
Expand Down Expand Up @@ -509,7 +509,7 @@
* @param {string} $error Error message returned.
*/
do_action( 'wpt_tweet_failed', $connection, $id, $notice );
wpt_set_log( 'wpt_status_message', $id, $notice );
wpt_set_log( 'wpt_status_message', $id, $notice, $http_code );
} else {
/**
* Executes an action after a status is posted successfully.
Expand Down Expand Up @@ -1428,9 +1428,17 @@
// don't display when draft is updated or if no message.
if ( ! ( ( '1' === $_REQUEST['message'] ) && ( 'publish' === $status && '1' !== $options[ $type ]['post-edited-update'] ) ) && 'no' !== $tweet_this ) {
$log = wpt_get_log( 'wpt_status_message', $post_id );
$class = ( __( 'Status update sent successfully.', 'wp-to-twitter' ) !== $log ) ? 'error' : 'updated';
if ( '' !== trim( $log ) ) {
echo "<div class='$class'><p>$log</p></div>";
if ( is_array( $log ) ) {
$message = $log['message'];
$http = $log['http'];
} else {
$message = $log;
$http = '200';
}
// FIX THIS.
$class = ( '200' !== (string) $http ) ? 'error' : 'success';
if ( '' !== trim( $message ) ) {
echo "<div class='notice notice-$class'><p>$message</p></div>";
}
}
}
Expand Down Expand Up @@ -1802,8 +1810,10 @@
);
break;
}
$log = wpt_get_log( 'wpt_status_message', $post_ID );
$message = is_array( $log ) ? $log['message'] : $log;
// Translators: Full text of Update, time scheduled for.
$return = ( 'tweet' === $action ) ? wpt_get_log( 'wpt_status_message', $post_ID ) : sprintf( __( 'Update scheduled: %1$s for %2$s', 'wp-to-twitter' ), '"' . $sentence . '"', $print_schedule );
$return = ( 'tweet' === $action ) ? $message : sprintf( __( 'Update scheduled: %1$s for %2$s', 'wp-to-twitter' ), '"' . $sentence . '"', $print_schedule );
echo $return;
if ( count( $authors ) > 1 ) {
echo '<br />';
Expand Down
1 change: 1 addition & 0 deletions wpt-post-to-twitter.php.html
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@
);
update_option( 'wpt_app_limit', $rate_limit );
$http_code = $response->getStatusCode();
$notice = __( 'Request Exception occurred when sending to X.com', 'wp-to-twitter' );
wpt_mail( 'X RequestException', print_r( $response, 1 ), $id );
}
} catch ( Exception $e ) {
Expand Down
2 changes: 1 addition & 1 deletion wpt_allowed_post_types.html
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="wp-to-twitter.php.html">wp-to-twitter.php</a>, <a href="wp-to-twitter.php.html#line1977">line 1977</a>
<a href="wp-to-twitter.php.html">wp-to-twitter.php</a>, <a href="wp-to-twitter.php.html#line1987">line 1987</a>
</li></ul></dd>


Expand Down
2 changes: 1 addition & 1 deletion wpt_auto_tweet_allowed.html
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="wp-to-twitter.php.html">wp-to-twitter.php</a>, <a href="wp-to-twitter.php.html#line2015">line 2015</a>
<a href="wp-to-twitter.php.html">wp-to-twitter.php</a>, <a href="wp-to-twitter.php.html#line2025">line 2025</a>
</li></ul></dd>


Expand Down

0 comments on commit a2bbf68

Please sign in to comment.