| @@ -221,11 +221,11 @@ | ||
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | // Bail if the API hasn't been configured. |
| 224 | 224 | $settings = new ConvertKit_Settings(); |
| 225 | - if ( ! $settings->has_api_key_and_secret() ) { | |
| 225 | + if ( ! $settings->has_access_and_refresh_token() ) { | |
| 226 | 226 | if ( $settings->debug_enabled() ) { |
| 227 | - return '<!-- ConvertKit Custom Content: No API Key and Secret -->'; | |
| 227 | + return '<!-- ConvertKit Custom Content: No Access Token -->'; | |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | return ''; |
| 231 | 231 | } |
| @@ -230,9 +230,16 @@ | ||
| 230 | 230 | return ''; |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | // Initialize the API. |
| 234 | - $api = new ConvertKit_API( $settings->get_api_key(), $settings->get_api_secret(), $settings->debug_enabled(), 'output_content' ); | |
| 234 | + $api = new ConvertKit_API_V4( | |
| 235 | + CONVERTKIT_OAUTH_CLIENT_ID, | |
| 236 | + CONVERTKIT_OAUTH_CLIENT_REDIRECT_URI, | |
| 237 | + $settings->get_access_token(), | |
| 238 | + $settings->get_refresh_token(), | |
| 239 | + $settings->debug_enabled(), | |
| 240 | + 'output_content' | |
| 241 | + ); | |
| 235 | 242 | |
| 236 | 243 | // Get the subscriber's tags, to see if they subscribed to this tag. |
| 237 | 244 | $tags = $api->get_subscriber_tags( $subscriber_id ); |
| 238 | 245 | |
| @@ -254,9 +261,9 @@ | ||
| 254 | 261 | return ''; |
| 255 | 262 | } |
| 256 | 263 | |
| 257 | 264 | // Iterate through ConvertKit Tags to find a match. |
| 258 | - foreach ( $tags as $tag ) { | |
| 265 | + foreach ( $tags['tags'] as $tag ) { | |
| 259 | 266 | // Skip if this ConvertKit Tag isn't the Tag specified in the block. |
| 260 | 267 | if ( absint( $tag['id'] ) !== absint( $atts['tag'] ) ) { |
| 261 | 268 | continue; |
| 262 | 269 | } |