Skip to content

Commit

Permalink
Merge pull request #1 from scottlimmer/scottlimmer-twitter-auth-patch
Browse files Browse the repository at this point in the history
Update functions.php to check if twitter json contains errors
  • Loading branch information
scottlimmer authored May 23, 2023
2 parents 637fb1c + 0819dbb commit 3c93cd0
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,20 +200,24 @@ function build_tweet($tweet, $user_template): string
function display_tweet($template = '')
{
$json = json_decode(file_get_contents(get_template_directory() . '/cron/vwsg_web.json'), JSON_OBJECT_AS_ARRAY);
$tweet = $json[0];
if (!array_key_exists('errors', $json)) {
$tweet = $json[0];

echo build_tweet($tweet, $template);
echo build_tweet($tweet, $template);
}
}

function display_tweets($template = '')
{
$json = json_decode(file_get_contents(get_template_directory() . '/cron/vwsg_web.json'), JSON_OBJECT_AS_ARRAY);

foreach ($json as $i => $tweet) {
if ($i > 2) {
break;
}
echo build_tweet($tweet, $template);
if (!array_key_exists('errors', $json)) {
foreach ($json as $i => $tweet) {
if ($i > 2) {
break;
}
echo build_tweet($tweet, $template);
}
}
}

Expand Down

0 comments on commit 3c93cd0

Please sign in to comment.