@@ -72,13 +72,13 @@ public function feedzy_define_default_image( $default_img ) {
72
72
/**
73
73
* Fetches the SDK logger data.
74
74
*
75
- * @param array $data The default data that needs to be sent.
75
+ * @param array<string, mixed> $data The default data that needs to be sent.
76
+ *
77
+ * @return array<string, mixed> The usage data.
76
78
*
77
79
* @access public
78
80
*/
79
81
public function get_usage_data ( $ data ) {
80
- global $ wpdb ;
81
-
82
82
// how many categories created.
83
83
$ categories = 0 ;
84
84
$ terms = get_terms ( array ( 'taxonomy ' => 'feedzy_categories ' ) );
@@ -110,7 +110,6 @@ public function get_usage_data( $data ) {
110
110
$ imports = apply_filters (
111
111
'feedzy_usage_data ' ,
112
112
array (
113
- // how many active imports are created.
114
113
'publish ' => count (
115
114
get_posts (
116
115
array (
@@ -121,7 +120,6 @@ public function get_usage_data( $data ) {
121
120
)
122
121
)
123
122
),
124
- // how many draft imports are created
125
123
'draft ' => count (
126
124
get_posts (
127
125
array (
@@ -132,7 +130,6 @@ public function get_usage_data( $data ) {
132
130
)
133
131
)
134
132
),
135
- // how many posts were imported by the imports
136
133
'imported ' => count (
137
134
get_posts (
138
135
array (
@@ -145,7 +142,6 @@ public function get_usage_data( $data ) {
145
142
)
146
143
)
147
144
),
148
- // integrations
149
145
'integrations ' => $ integrations ,
150
146
)
151
147
);
@@ -160,7 +156,7 @@ public function get_usage_data( $data ) {
160
156
}
161
157
}
162
158
163
- // how many posts contain the shortcode
159
+ // how many posts contain the shortcode.
164
160
global $ wpdb ;
165
161
$ shortcodes = $ wpdb ->get_var ( "SELECT count(*) FROM {$ wpdb ->prefix }posts WHERE post_status IN ('publish', 'private') AND post_content LIKE '%[feedzy-rss %' " ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching
166
162
$ data = array (
@@ -294,7 +290,13 @@ public function feedzy_classes_item( $item_attr = '', $sizes = '', $item = '', $
294
290
*
295
291
* @return string
296
292
*/
297
- public function feedzy_summary_input_filter ( $ description , $ content , $ feed_url ) {
293
+ public function feedzy_summary_input_filter (
294
+ $ description ,
295
+ // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found
296
+ $ content ,
297
+ // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found
298
+ $ feed_url
299
+ ) {
298
300
$ description = trim ( wp_strip_all_tags ( $ description ) );
299
301
$ description = trim ( str_replace ( array ( '[…] ' , '[…] ' , '[…] ' ), '' , $ description ) );
300
302
@@ -810,7 +812,8 @@ private function init_feed( $feed_url, $cache, $sc, $allow_https = FEEDZY_ALLOW_
810
812
add_filter (
811
813
'wp_feed_cache_transient_lifetime ' ,
812
814
function ( $ time ) use ( $ cache_time ) {
813
- return $ cache_time ;
815
+ $ time = $ cache_time ;
816
+ return $ time ;
814
817
},
815
818
10 ,
816
819
1
@@ -849,6 +852,7 @@ function ( $time ) use ( $cache_time ) {
849
852
}
850
853
851
854
if ( isset ( $ _SERVER ['HTTP_USER_AGENT ' ] ) ) {
855
+ // phpcs:ignore WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__
852
856
$ set_server_agent = sanitize_text_field ( wp_unslash ( $ _SERVER ['HTTP_USER_AGENT ' ] ) . SIMPLEPIE_USERAGENT );
853
857
$ feed ->set_useragent ( apply_filters ( 'http_headers_useragent ' , $ set_server_agent ) );
854
858
}
@@ -868,7 +872,7 @@ function ( $time ) use ( $cache_time ) {
868
872
if ( ! empty ( $ error ) ) {
869
873
do_action ( 'themeisle_log_event ' , FEEDZY_NAME , sprintf ( 'Error while parsing feed: %s ' , $ error ), 'error ' , __FILE__ , __LINE__ );
870
874
871
- // curl: (60) SSL certificate problem: unable to get local issuer certificate
875
+ // curl: (60) SSL certificate problem: unable to get local issuer certificate.
872
876
if ( strpos ( $ error , 'SSL certificate ' ) !== false ) {
873
877
do_action ( 'themeisle_log_event ' , FEEDZY_NAME , sprintf ( 'Got an SSL Error (%s), retrying by ignoring SSL ' , $ error ), 'debug ' , __FILE__ , __LINE__ );
874
878
$ feed = $ this ->init_feed ( $ feed_url , $ cache , $ sc , false );
@@ -920,11 +924,11 @@ private function get_default_user_agent( $urls ) {
920
924
*
921
925
* @param array|string $feed_url The feeds URL/s.
922
926
* @param string $cache The cache string (eg. 1_hour, 30_min etc.).
923
- * @param bool $echo Echo the results.
927
+ * @param bool $echo_result Echo the results.
924
928
*
925
929
* @return array
926
930
*/
927
- protected function get_valid_source_urls ( $ feed_url , $ cache , $ echo = true ) {
931
+ protected function get_valid_source_urls ( $ feed_url , $ cache , $ echo_result = true ) {
928
932
$ valid_feed_url = array ();
929
933
if ( is_array ( $ feed_url ) ) {
930
934
foreach ( $ feed_url as $ url ) {
@@ -937,7 +941,7 @@ protected function get_valid_source_urls( $feed_url, $cache, $echo = true ) {
937
941
}
938
942
if ( $ this ->check_valid_source ( $ url , $ cache , $ source_type ) ) {
939
943
$ valid_feed_url [] = $ url ;
940
- } elseif ( $ echo ) {
944
+ } elseif ( $ echo_result ) {
941
945
echo wp_kses_post (
942
946
sprintf (
943
947
// translators: %s: Feed URL.
@@ -957,7 +961,7 @@ protected function get_valid_source_urls( $feed_url, $cache, $echo = true ) {
957
961
}
958
962
if ( $ this ->check_valid_source ( $ feed_url , $ cache , $ source_type ) ) {
959
963
$ valid_feed_url [] = $ feed_url ;
960
- } elseif ( $ echo ) {
964
+ } elseif ( $ echo_result ) {
961
965
echo wp_kses_post (
962
966
sprintf (
963
967
// translators: %s: Feed URL.
@@ -1090,7 +1094,7 @@ private function render_content( $sc, $feed, $feed_url, $content = '' ) {
1090
1094
$ sizes = apply_filters ( 'feedzy_thumb_sizes ' , $ sizes , $ feed_url );
1091
1095
$ feed_title = $ this ->get_feed_title_filter ( $ feed , $ sc , $ feed_url );
1092
1096
$ feed_title ['use_title ' ] = false ;
1093
- if ( $ sc [ ' feed_title ' ] === ' yes ' ) {
1097
+ if ( ' yes ' === $ sc [ ' feed_title ' ] ) {
1094
1098
$ feed_title ['use_title ' ] = true ;
1095
1099
}
1096
1100
// Display the error message and quit (before showing the template for pro).
@@ -1156,7 +1160,7 @@ private function render_content( $sc, $feed, $feed_url, $content = '' ) {
1156
1160
$ content .= '</ul> </div> ' ;
1157
1161
if ( ! $ is_dry_run ) {
1158
1162
$ content = apply_filters ( 'feedzy_global_output ' , $ content , $ sc , $ feed_title , $ feed_items );
1159
- $ content .= '<style type="text/css" media="all"> ' . esc_attr ( feedzy_default_css ( $ main_class ) ) . '</style> ' ;
1163
+ $ content .= '<style type="text/css" media="all"> ' . feedzy_default_css ( $ main_class ) . '</style> ' ;
1160
1164
}
1161
1165
return $ content ;
1162
1166
}
@@ -1383,13 +1387,13 @@ private function get_feed_item_filter( $sc, $sizes, $item, $feed_url, $index, $i
1383
1387
) {
1384
1388
if ( ! empty ( $ the_thumbnail ) ) {
1385
1389
$ the_thumbnail = $ this ->feedzy_image_encode ( $ the_thumbnail );
1386
- $ content_thumb .= '<span class="fetched" style="background-image: url( \'' . $ the_thumbnail . '\');" title=" ' . esc_html ( $ item ->get_title () ) . '"></span> ' ;
1390
+ $ content_thumb .= '<span class="fetched" style="background-image: url( \'' . $ the_thumbnail . '\');" title=" ' . esc_attr ( $ item ->get_title () ) . '"></span> ' ;
1387
1391
if ( ! isset ( $ sc ['amp ' ] ) || 'no ' !== $ sc ['amp ' ] ) {
1388
1392
$ content_thumb .= '<amp-img width=" ' . $ sizes ['width ' ] . '" height=" ' . $ sizes ['height ' ] . '" src=" ' . $ the_thumbnail . '"> ' ;
1389
1393
}
1390
1394
}
1391
1395
if ( empty ( $ the_thumbnail ) && 'yes ' === $ sc ['thumb ' ] ) {
1392
- $ content_thumb .= '<span class="default" style="background-image:url( ' . $ sc ['default ' ] . ');" title=" ' . esc_html ( $ item ->get_title () ) . '"></span> ' ;
1396
+ $ content_thumb .= '<span class="default" style="background-image:url( ' . $ sc ['default ' ] . ');" title=" ' . esc_attr ( $ item ->get_title () ) . '"></span> ' ;
1393
1397
if ( ! isset ( $ sc ['amp ' ] ) || 'no ' !== $ sc ['amp ' ] ) {
1394
1398
$ content_thumb .= '<amp-img width=" ' . $ sizes ['width ' ] . '" height=" ' . $ sizes ['height ' ] . '" src=" ' . $ sc ['default ' ] . '"> ' ;
1395
1399
}
@@ -1698,12 +1702,12 @@ public function feedzy_retrieve_image( $item, $sc = null ) {
1698
1702
* @since 3.0.0
1699
1703
* @access public
1700
1704
*
1701
- * @param string $string A string with an <img/> tag.
1705
+ * @param string $img_html A string with an <img/> tag.
1702
1706
*
1703
1707
* @return string
1704
1708
*/
1705
- public function feedzy_return_image ( $ string ) {
1706
- $ img = html_entity_decode ( $ string , ENT_QUOTES , 'UTF-8 ' );
1709
+ public function feedzy_return_image ( $ img_html ) {
1710
+ $ img = html_entity_decode ( $ img_html , ENT_QUOTES , 'UTF-8 ' );
1707
1711
$ pattern = '/<img[^>]+\>/i ' ;
1708
1712
preg_match_all ( $ pattern , $ img , $ matches );
1709
1713
@@ -1713,8 +1717,8 @@ public function feedzy_return_image( $string ) {
1713
1717
$ link = $ this ->feedzy_scrape_image ( $ match );
1714
1718
$ blacklist = $ this ->feedzy_blacklist_images ();
1715
1719
$ is_blacklist = false ;
1716
- foreach ( $ blacklist as $ string ) {
1717
- if ( strpos ( (string ) $ link , $ string ) !== false ) {
1720
+ foreach ( $ blacklist as $ img_html ) {
1721
+ if ( strpos ( (string ) $ link , $ img_html ) !== false ) {
1718
1722
$ is_blacklist = true ;
1719
1723
break ;
1720
1724
}
@@ -1735,15 +1739,15 @@ public function feedzy_return_image( $string ) {
1735
1739
* @since 3.0.0
1736
1740
* @access public
1737
1741
*
1738
- * @param string $string A string with an <img/> tag.
1742
+ * @param string $img_html A string with an <img/> tag.
1739
1743
* @param string $link The link to search for.
1740
1744
*
1741
1745
* @return string
1742
1746
*/
1743
- public function feedzy_scrape_image ( $ string , $ link = '' ) {
1747
+ public function feedzy_scrape_image ( $ img_html , $ link = '' ) {
1744
1748
$ pattern = '/< *img[^>]*src *= *[" \']?([^" \']*)/ ' ;
1745
1749
$ match = $ link ;
1746
- preg_match ( $ pattern , $ string , $ link );
1750
+ preg_match ( $ pattern , $ img_html , $ link );
1747
1751
if ( ! empty ( $ link ) && isset ( $ link [1 ] ) ) {
1748
1752
$ match = $ link [1 ];
1749
1753
}
@@ -1799,22 +1803,22 @@ public function feedzy_blacklist_images() {
1799
1803
* @since 3.0.0
1800
1804
* @access public
1801
1805
*
1802
- * @param string $string A string containing the image URL.
1806
+ * @param string $img_url A string containing the image URL.
1803
1807
*
1804
1808
* @return string
1805
1809
*/
1806
- public function feedzy_image_encode ( $ string ) {
1810
+ public function feedzy_image_encode ( $ img_url ) {
1807
1811
// Check if img url is set as an URL parameter.
1808
- $ url_tab = wp_parse_url ( $ string );
1812
+ $ url_tab = wp_parse_url ( $ img_url );
1809
1813
if ( isset ( $ url_tab ['query ' ] ) ) {
1810
1814
preg_match_all ( '/(http|https):\/\/[^ ]+(\.gif|\.GIF|\.jpg|\.JPG|\.jpeg|\.JPEG|\.png|\.PNG)/ ' , $ url_tab ['query ' ], $ img_url );
1811
1815
if ( isset ( $ img_url [0 ][0 ] ) ) {
1812
- $ string = $ img_url [0 ][0 ];
1816
+ $ img_url = $ img_url [0 ][0 ];
1813
1817
}
1814
1818
}
1815
1819
1816
- $ return = apply_filters ( 'feedzy_image_encode ' , esc_url ( $ string ), $ string );
1817
- do_action ( 'themeisle_log_event ' , FEEDZY_NAME , sprintf ( 'Changing image URL from %s to %s ' , $ string , $ return ), 'debug ' , __FILE__ , __LINE__ );
1820
+ $ return = apply_filters ( 'feedzy_image_encode ' , esc_url ( $ img_url ), $ img_url );
1821
+ do_action ( 'themeisle_log_event ' , FEEDZY_NAME , sprintf ( 'Changing image URL from %s to %s ' , $ img_url , $ return ), 'debug ' , __FILE__ , __LINE__ );
1818
1822
return $ return ;
1819
1823
}
1820
1824
@@ -1862,16 +1866,16 @@ public function load_layout( $layout_name ) {
1862
1866
* @access public
1863
1867
*
1864
1868
* @param string $key The key before to insert.
1865
- * @param array $array The array in which to insert the new key.
1869
+ * @param array $from_array The array in which to insert the new key.
1866
1870
* @param string $new_key The new key name.
1867
1871
* @param mixed $new_value The new key value.
1868
1872
*
1869
1873
* @return array|bool
1870
1874
*/
1871
- protected function array_insert_before ( $ key , &$ array , $ new_key , $ new_value ) {
1872
- if ( array_key_exists ( $ key , $ array ) ) {
1875
+ protected function array_insert_before ( $ key , &$ from_array , $ new_key , $ new_value ) {
1876
+ if ( array_key_exists ( $ key , $ from_array ) ) {
1873
1877
$ new = array ();
1874
- foreach ( $ array as $ k => $ value ) {
1878
+ foreach ( $ from_array as $ k => $ value ) {
1875
1879
if ( $ k === $ key ) {
1876
1880
$ new [ $ new_key ] = $ new_value ;
1877
1881
}
0 commit comments