Myzwer / foothillschurch

Bootcamp II is a wordpress theme (as well as an inside joke) designed to suit the needs of foothillschurch.com. It makes use of webpack, Babel, Sass, Tailwind, Browsersync, PostCSS, ESLint, Stylelint, Prettier and more. It is meant for that site, but if you can use it by all means go for it.
1 stars 1 forks source link

Instagram block issues and optimization #71

Closed rain2o closed 2 weeks ago

rain2o commented 1 month ago

First, there's an error on your instagram feed.

This error message is only visible to WordPress admins There has been a problem with your Instagram Feed. API error 999: Your access token could not be decrypted on this website. Reconnect this account or go to our website to learn how to prevent this. Directions on how to resolve this issue


Some optimizations

Simplify conditions

I've recommended this in a few places, but same goes here.

$account = get_sub_field( 'instagram_account' );
// Set proper feeds
$feed1 = $feed2 = null;
if ( $account === 'foothills' ) {
    $feed1 = '1';
    $feed2 = '2';
} else if ( $account === 'students' ) {
    $feed1 = '3';
    $feed2 = '4';
}

You could also use a switch here instead. For 2 conditions this is fine, but if you get any more accounts I'd make this a switch for sure.

You could also move the URL up into that same condition

$feed1 = $feed2 = $link = null;
if ($account === 'foothills') {
    $feed1 = '1';
    $feed2 = '2';
    $link = "https://www.instagram.com/foothillschurchtn/?hl=en";
} else if ($account === 'students') {
    $feed1 = '3';
    $feed2 = '4';
    $link = "https://www.instagram.com/fc_students/?hl=en";
}

String interpolation

You can simplify strings which use variables by using double quotes and putting the variable directly in it.

echo do_shortcode("[instagram-feed feed=$feed1]");