Skip to content

Commit

Permalink
Rename wpt_post_to_twitter function
Browse files Browse the repository at this point in the history
Retains old function for back compat; remove in the future.
  • Loading branch information
joedolson committed Dec 30, 2023
1 parent 77d2a88 commit 20b71c0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
25 changes: 21 additions & 4 deletions src/wp-to-twitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,23 @@ function wpt_check_recent_tweet( $id, $auth ) {
return false;
}


/**
* Performs the API post to target services. Alias for wpt_post_to_twitter.
*
* @param string $text Text of post to be sent to service.
* @param int $auth Author ID.
* @param int $id Post ID.
* @param boolean $media Whether to upload media attached to the post specified in $id.
*
* @return boolean Success of query.
*/
function wpt_post_to_service( $text, $auth = false, $id = false, $media = false ) {
$return = wpt_post_to_twitter( $text, $auth, $id, $media );

return $return;
}

/**
* Performs the API post to target services.
*
Expand Down Expand Up @@ -1016,7 +1033,7 @@ function wpt_tweet( $post_ID, $type = 'instant', $post = null, $updated = null,
if ( '0' === (string) $post_info['wpt_delay_tweet'] || '' === $post_info['wpt_delay_tweet'] || 'on' === $post_info['wpt_no_delay'] ) {
foreach ( $wpt_selected_users as $acct ) {
if ( wtt_oauth_test( $acct, 'verify' ) ) {
wpt_post_to_twitter( $sentence2, $acct, $post_ID, $media );
wpt_post_to_service( $sentence2, $acct, $post_ID, $media );
}
}
} else {
Expand Down Expand Up @@ -1149,7 +1166,7 @@ function wpt_tweet( $post_ID, $type = 'instant', $post = null, $updated = null,
}
}
} else {
wpt_post_to_twitter( $sentence, false, $post_ID, $media );
wpt_post_to_service( $sentence, false, $post_ID, $media );
}
// END WPT PRO.
}
Expand Down Expand Up @@ -1195,7 +1212,7 @@ function wpt_twit_link( $link_id ) {
}

if ( '' !== $sentence ) {
wpt_post_to_twitter( $sentence, false, $link_id );
wpt_post_to_service( $sentence, false, $link_id );
}

return $link_id;
Expand Down Expand Up @@ -1721,7 +1738,7 @@ function wpt_ajax_tweet() {

switch ( $action ) {
case 'tweet':
wpt_post_to_twitter( $sentence, $auth, $post_ID, $media );
wpt_post_to_service( $sentence, $auth, $post_ID, $media );
break;
case 'schedule':
wp_schedule_single_event(
Expand Down
2 changes: 1 addition & 1 deletion src/wpt-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function wpt_check_functions() {
// check twitter & mastodon credentials.
if ( wtt_oauth_test() || wpt_mastodon_connection() ) {
$rand = wp_rand( 1000000, 9999999 );
$testpost = wpt_post_to_twitter( "This is a test of XPoster. $shrink ($rand)" );
$testpost = wpt_post_to_service( "This is a test of XPoster. $shrink ($rand)" );
if ( $testpost ) {
$message .= '<li><strong>' . __( 'XPoster successfully submitted a status update to X.com.', 'wp-to-twitter' ) . '</strong></li>';
} else {
Expand Down

0 comments on commit 20b71c0

Please sign in to comment.