Skip to content

Commit 1627574

Browse files
Merge pull request #1190 from Codeinwp/bugfix/1186
Make http_headers_useragent filter compatible with WP
2 parents 2bfcf75 + d153ac7 commit 1627574

File tree

2 files changed

+8
-18
lines changed

2 files changed

+8
-18
lines changed

includes/abstract/feedzy-rss-feeds-admin-abstract.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -822,10 +822,10 @@ function ( $url ) {
822822
* @since 3.1.7
823823
* @access private
824824
*
825-
* @param string $feed_url The feed URL.
826-
* @param string $cache The cache string (eg. 1_hour, 30_min etc.).
827-
* @param array $sc The shortcode attributes.
828-
* @param bool $allow_https Defaults to constant FEEDZY_ALLOW_HTTPS.
825+
* @param string|array<string> $feed_url The feed URL.
826+
* @param string $cache The cache string (eg. 1_hour, 30_min etc.).
827+
* @param array $sc The shortcode attributes.
828+
* @param bool $allow_https Defaults to constant FEEDZY_ALLOW_HTTPS.
829829
*
830830
* @return SimplePie
831831
*/
@@ -860,7 +860,7 @@ private function init_feed( $feed_url, $cache, $sc, $allow_https = FEEDZY_ALLOW_
860860

861861
$feed->get_registry()->register( SimplePie\File::class, 'WP_SimplePie_File', true );
862862
$default_agent = $this->get_default_user_agent( $feed_url );
863-
$feed->set_useragent( apply_filters( 'http_headers_useragent', $default_agent ) );
863+
$feed->set_useragent( apply_filters( 'http_headers_useragent', $default_agent, is_array( $feed_url ) ? reset( $feed_url ) : $feed_url ) );
864864
if ( false === apply_filters( 'feedzy_disable_db_cache', false, $feed_url ) ) {
865865
SimplePie_Cache::register( 'wp_transient', 'WP_Feed_Cache_Transient' );
866866
$feed->set_cache_location( 'wp_transient' );
@@ -917,7 +917,7 @@ function ( $time ) use ( $cache_time ) {
917917
if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
918918
// phpcs:ignore WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__
919919
$set_server_agent = sanitize_text_field( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) . SIMPLEPIE_USERAGENT );
920-
$feed->set_useragent( apply_filters( 'http_headers_useragent', $set_server_agent ) );
920+
$feed->set_useragent( apply_filters( 'http_headers_useragent', $set_server_agent, is_array( $feed_url ) ? reset( $feed_url ) : $feed_url ) );
921921
}
922922

923923
$feed->init();

phpstan-baseline.neon

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -270,11 +270,6 @@ parameters:
270270
count: 1
271271
path: includes/abstract/feedzy-rss-feeds-admin-abstract.php
272272

273-
-
274-
message: "#^Parameter \\#1 \\$feed_url of method Feedzy_Rss_Feeds_Admin_Abstract\\:\\:init_feed\\(\\) expects string, array given\\.$#"
275-
count: 2
276-
path: includes/abstract/feedzy-rss-feeds-admin-abstract.php
277-
278273
-
279274
message: "#^Parameter \\#1 \\$text of function esc_attr expects string, int\\<0, max\\>\\|false given\\.$#"
280275
count: 1
@@ -297,17 +292,12 @@ parameters:
297292

298293
-
299294
message: "#^Result of && is always false\\.$#"
300-
count: 4
295+
count: 2
301296
path: includes/abstract/feedzy-rss-feeds-admin-abstract.php
302297

303298
-
304299
message: "#^Result of \\|\\| is always true\\.$#"
305-
count: 3
306-
path: includes/abstract/feedzy-rss-feeds-admin-abstract.php
307-
308-
-
309-
message: "#^Strict comparison using \\=\\=\\= between 1 and \\*NEVER\\* will always evaluate to false\\.$#"
310-
count: 2
300+
count: 1
311301
path: includes/abstract/feedzy-rss-feeds-admin-abstract.php
312302

313303
-

0 commit comments

Comments
 (0)