Skip to content

Commit

Permalink
Fix phan issues
Browse files Browse the repository at this point in the history
  • Loading branch information
justinshreve committed Oct 24, 2024
1 parent b71add9 commit 2b6ca4a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ public function get_feedback( $request ) {
* @param string $endpoint The Tumblr API endpoint.
* @param array $params The parameters for the request.
*
* @return array The response from the Tumblr API.
* @return array|WP_Error The response from the Tumblr API or WP_Error on failure.
*/
protected function proxy_tumblr_request( $endpoint, $params ) {
$params['api_key'] = TUMBLR_API_KEY;
$params['api_key'] = defined( 'TUMBLR_API_KEY' ) ? TUMBLR_API_KEY : '';
$url = add_query_arg( $params, "https://api.tumblr.com/v2/{$endpoint}" );

$response = wp_remote_get( $url );
Expand Down Expand Up @@ -227,8 +227,8 @@ public function proxy_request_to_wpcom( $request, $path = '' ) {
$response_body = json_decode( wp_remote_retrieve_body( $response ), true );

if ( $response_status >= 400 ) {
$code = isset( $response_body['code'] ) ? $response_body['code'] : 'unknown_error';
$message = isset( $response_body['message'] ) ? $response_body['message'] : __( 'An unknown error occurred.', 'jetpack' );
$code = $response_body['code'] ?? 'unknown_error';
$message = $response_body['message'] ?? __( 'An unknown error occurred.', 'jetpack' );
return new WP_Error( $code, $message, array( 'status' => $response_status ) );
}

Expand Down
24 changes: 12 additions & 12 deletions projects/plugins/jetpack/extensions/blocks/gif/gif.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,27 +47,27 @@ function render_block( $attr ) {
}

$classes = Blocks::classes( Blocks::get_block_feature( __DIR__ ), $attr );
$placeholder = sprintf( '<a href="%s">%s</a>', esc_url( $giphy_url ), esc_attr( $search_text ) );
$placeholder = sprintf( '<a href="%s">%s</a>', $giphy_url ? esc_url( $giphy_url ) : '', esc_attr( $search_text ) );

ob_start();
?>
<div class="<?php echo esc_attr( $classes ); ?>">
<figure>
<?php if ( $giphy_url && ! $gif_url ) : ?>
<?php if ( Blocks::is_amp_request() ) : ?>
<amp-iframe src="<?php echo esc_url( $giphy_url ); ?>" width="100" height="<?php echo absint( $padding_top ); ?>" sandbox="allow-scripts allow-same-origin" layout="responsive">
<div placeholder>
<?php echo wp_kses_post( $placeholder ); ?>
<?php if ( Blocks::is_amp_request() ) : ?>
<amp-iframe src="<?php echo esc_url( $giphy_url ); ?>" width="100" height="<?php echo absint( $padding_top ); ?>" sandbox="allow-scripts allow-same-origin" layout="responsive">
<div placeholder>
<?php echo wp_kses_post( $placeholder ); ?>
</div>
</amp-iframe>
<?php else : ?>
<div class="wp-block-jetpack-gif-wrapper" style="<?php echo esc_attr( $style ); ?>">
<iframe src="<?php echo esc_url( $giphy_url ); ?>" title="<?php echo esc_attr( $search_text ); ?>"></iframe>
</div>
</amp-iframe>
<?php else : ?>
<div class="wp-block-jetpack-gif-wrapper" style="<?php echo esc_attr( $style ); ?>">
<iframe src="<?php echo esc_url( $giphy_url ); ?>" title="<?php echo esc_attr( $search_text ); ?>"></iframe>
</div>
<?php endif; ?>
<?php endif; ?>
<?php else : ?>
<div class="wp-block-jetpack-gif-wrapper" style="<?php echo esc_attr( $style ); ?>">
<img src="<?php echo esc_url( $gif_url ); ?>" alt="<?php echo esc_attr( $search_text ); ?>" />
<img src="<?php echo $gif_url ? esc_url( $gif_url ) : ''; ?>" alt="<?php echo esc_attr( $search_text ); ?>" />
</div>
<?php endif; ?>
<?php if ( $caption ) : ?>
Expand Down

0 comments on commit 2b6ca4a

Please sign in to comment.