← All changes
|
json-endpoints/class.wpcom-json-api-render-embed-endpoint.php
+7
-2
12.0.3
→
16.3-a.1
View file →
| @@ -1,6 +1,10 @@ | ||
| 1 | 1 | <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
| 2 | 2 | |
| 3 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 4 | + exit( 0 ); | |
| 5 | +} | |
| 6 | + | |
| 3 | 7 | new WPCOM_JSON_API_Render_Embed_Endpoint( |
| 4 | 8 | array( |
| 5 | 9 | 'description' => 'Get a rendered embed for a site. Note: The current user must have publishing access.', |
| 6 | 10 | 'group' => 'sites', |
| @@ -29,8 +33,10 @@ | ||
| 29 | 33 | /** |
| 30 | 34 | * Render embed endpoint class. |
| 31 | 35 | * |
| 32 | 36 | * /sites/%s/embeds/render -> $blog_id |
| 37 | + * | |
| 38 | + * @phan-constructor-used-for-side-effects | |
| 33 | 39 | */ |
| 34 | 40 | class WPCOM_JSON_API_Render_Embed_Endpoint extends WPCOM_JSON_API_Render_Endpoint { |
| 35 | 41 | /** |
| 36 | 42 | * API Callback. |
| @@ -57,9 +63,9 @@ | ||
| 57 | 63 | if ( ! preg_match_all( '|^\s*(https?://[^\s"]+)\s*$|im', $embed_url, $matches ) ) { |
| 58 | 64 | return new WP_Error( 'invalid_embed_url', __( 'The embed_url parameter must be a valid URL.', 'jetpack' ), 400 ); |
| 59 | 65 | } |
| 60 | 66 | |
| 61 | - if ( count( $matches[1] ) > 1 ) { | |
| 67 | + if ( is_countable( $matches[1] ) && count( $matches[1] ) > 1 ) { | |
| 62 | 68 | return new WP_Error( 'invalid_embed', __( 'Only one embed can be rendered at a time.', 'jetpack' ), 400 ); |
| 63 | 69 | } |
| 64 | 70 | |
| 65 | 71 | $embed_url = array_shift( $matches[1] ); |
| @@ -85,6 +91,5 @@ | ||
| 85 | 91 | $return = $this->add_assets( $return, $render['loaded_scripts'], $render['loaded_styles'] ); |
| 86 | 92 | |
| 87 | 93 | return $return; |
| 88 | 94 | } |
| 89 | - | |
| 90 | 95 | } |