Skip to content

Commit

Permalink
Switch rand to wp_rand
Browse files Browse the repository at this point in the history
  • Loading branch information
joedolson committed Nov 9, 2023
1 parent 292ecd6 commit 6b609e8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/wp-to-twitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@ function wpt_tweet( $post_ID, $type = 'instant', $post = null, $updated = null,
} else {
foreach ( $wpt_selected_users as $acct ) {
$acct = ( 'main' === $acct ) ? false : $acct;
$offset = ( $auth !== $acct ) ? apply_filters( 'wpt_random_delay', rand( 60, 480 ) ) : 0;
$offset = ( $auth !== $acct ) ? apply_filters( 'wpt_random_delay', wp_rand( 60, 480 ) ) : 0;
if ( wtt_oauth_test( $acct, 'verify' ) ) {
$time = apply_filters( 'wpt_schedule_delay', ( (int) $post_info['wpt_delay_tweet'] ) * 60, $acct );

Expand Down Expand Up @@ -1089,7 +1089,7 @@ function wpt_tweet( $post_ID, $type = 'instant', $post = null, $updated = null,
// add original delay to schedule.
$delay = ( isset( $post_info['wpt_delay_tweet'] ) ) ? ( (int) $post_info['wpt_delay_tweet'] ) * 60 : 0;
// Don't delay the first Tweet of the group.
$offset = ( true === $first ) ? 0 : rand( 60, 240 ); // delay each co-tweet by 1-4 minutes.
$offset = ( true === $first ) ? 0 : wp_rand( 60, 240 ); // delay each co-tweet by 1-4 minutes.
$time = apply_filters( 'wpt_schedule_retweet', ( $post_info['wpt_retweet_after'] ) * ( 60 * 60 ) * $i, $acct, $i, $post_info );
wp_schedule_single_event(
time() + $time + $offset + $delay,
Expand Down Expand Up @@ -1595,7 +1595,7 @@ function wpt_show_tweets( $post_id ) {
function wpt_admin_scripts() {
global $current_screen, $wpt_version;
if ( SCRIPT_DEBUG ) {
$wpt_version .= '-' . rand( 10000, 99999 );
$wpt_version .= '-' . wp_rand( 10000, 99999 );
}
if ( 'post' === $current_screen->base || 'xposter-pro_page_wp-to-twitter-schedule' === $current_screen->id ) {
wp_enqueue_script( 'wpt.charcount', plugins_url( 'js/jquery.charcount.js', __FILE__ ), array( 'jquery' ), $wpt_version );
Expand Down Expand Up @@ -1694,7 +1694,7 @@ function wpt_ajax_tweet() {
$sentence = stripcslashes( trim( $sentence ) );
$post_info = wpt_post_info( $post_ID );
$sentence = jd_truncate_tweet( $sentence, $post_info, $post_ID, false, $user_ID );
$schedule = ( isset( $_REQUEST['tweet_schedule'] ) ) ? strtotime( $_REQUEST['tweet_schedule'] ) : rand( 60, 240 );
$schedule = ( isset( $_REQUEST['tweet_schedule'] ) ) ? strtotime( $_REQUEST['tweet_schedule'] ) : wp_rand( 60, 240 );
$print_schedule = date_i18n( get_option( 'date_format' ) . ' @ ' . get_option( 'time_format' ), $schedule );
$offset = ( 60 * 60 * get_option( 'gmt_offset' ) );
$schedule = $schedule - $offset;
Expand Down Expand Up @@ -1823,7 +1823,7 @@ function wpt_admin_page() {
function wpt_admin_style() {
global $wpt_version;
if ( SCRIPT_DEBUG ) {
$wpt_version .= '-' . rand( 10000, 99999 );
$wpt_version .= '-' . wp_rand( 10000, 99999 );
}
if ( isset( $_GET['page'] ) && ( 'wp-to-twitter' === $_GET['page'] || 'wp-tweets-pro' === $_GET['page'] || 'wp-to-twitter-schedule' === $_GET['page'] || 'wp-to-twitter-tweets' === $_GET['page'] || 'wp-to-twitter-errors' === $_GET['page'] ) ) {
wp_enqueue_style( 'wpt-styles', plugins_url( 'css/styles.css', __FILE__ ), array(), $wpt_version );
Expand Down
2 changes: 1 addition & 1 deletion src/wpt-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function wpt_check_functions() {
}
// check twitter credentials.
if ( wtt_oauth_test() ) {
$rand = rand( 1000000, 9999999 );
$rand = wp_rand( 1000000, 9999999 );
$testpost = wpt_post_to_twitter( "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>';
Expand Down

0 comments on commit 6b609e8

Please sign in to comment.