PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.1
Elementor Website Builder – more than just a page builder v4.3.1
4.3.1 4.3.0 4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 All 454 releases
← All changes | modules/atomic-widgets/props-resolver/transformers/svg-src-transformer.php +23 -9 4.2.0-dev2 → 4.3.1 View file →
@@ -48,25 +48,39 @@
48 48 if ( ! $url ) {
49 49 return null;
50 50 }
51 51
52 + $local_content = $this->fetch_local_svg_content( $url );
53 +
54 + return $local_content ? $local_content : $this->fetch_remote_svg_content( $url );
55 + }
56 +
57 + private function fetch_local_svg_content( string $url ): ?string {
52 58 $local_path = $this->resolve_local_path( $url );
53 59
54 - if ( $local_path ) {
55 - $content = Utils::file_get_contents( $local_path );
60 + if ( ! $local_path ) {
61 + return null;
62 + }
56 63
57 - if ( $content ) {
58 - return $content;
59 - }
60 - }
64 + $content = Utils::file_get_contents( $local_path );
61 65
66 + return $content ? $content : null;
67 + }
68 +
69 + private function fetch_remote_svg_content( string $url ): ?string {
62 70 $response = wp_safe_remote_get( $url );
63 71
64 - if ( ! is_wp_error( $response ) ) {
65 - return $response['body'];
72 + if ( is_wp_error( $response ) ) {
73 + return null;
66 74 }
67 75
68 - return null;
76 + if ( \WP_Http::OK !== (int) wp_remote_retrieve_response_code( $response ) ) {
77 + return null;
78 + }
79 +
80 + $body = wp_remote_retrieve_body( $response );
81 +
82 + return $body ? $body : null;
69 83 }
70 84
71 85 private function resolve_local_path( string $url ): ?string {
72 86 $site_url = site_url();