diff --git a/includes/REST/apple-news-get-settings.php b/includes/REST/apple-news-get-settings.php index 691b5677..bd9c2e36 100644 --- a/includes/REST/apple-news-get-settings.php +++ b/includes/REST/apple-news-get-settings.php @@ -15,7 +15,7 @@ * @param array $data data from query args. * @return array updated response. */ -function get_settings_response( $data ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable +function get_settings_response( $data ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found // Ensure Apple News is first initialized. \Apple_News::has_uninitialized_error(); diff --git a/includes/apple-exporter/class-component-factory.php b/includes/apple-exporter/class-component-factory.php index 62ba484d..ec07e2b6 100644 --- a/includes/apple-exporter/class-component-factory.php +++ b/includes/apple-exporter/class-component-factory.php @@ -193,6 +193,7 @@ public static function get_component( $shortname, $html ) { * @return array An array of components contained in the node. */ public static function get_components_from_node( $node ) { + /* phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase */ $result = []; foreach ( self::$components as $shortname => $class ) { @@ -241,5 +242,6 @@ public static function get_components_from_node( $node ) { } return $result; + /* phpcs:enable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase */ } } diff --git a/includes/apple-exporter/class-exporter-content.php b/includes/apple-exporter/class-exporter-content.php index 0ec0d04c..988ce69a 100644 --- a/includes/apple-exporter/class-exporter-content.php +++ b/includes/apple-exporter/class-exporter-content.php @@ -292,6 +292,6 @@ public function nodes() { // Find the first-level nodes of the body tag. $body = $dom->getElementsByTagName( 'body' )->item( 0 ); - return $body ? $body->childNodes : new \DOMNodeList(); + return $body ? $body->childNodes : new \DOMNodeList(); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase } } diff --git a/includes/apple-exporter/class-markdown.php b/includes/apple-exporter/class-markdown.php index 71ed80c8..b91e5417 100644 --- a/includes/apple-exporter/class-markdown.php +++ b/includes/apple-exporter/class-markdown.php @@ -9,6 +9,8 @@ * @since 0.2.0 */ +/* phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase */ + namespace Apple_Exporter; use DOMElement; @@ -306,3 +308,4 @@ private function parse_node_unordered_list( $node ) { return $text . "\n\n"; } } +/* phpcs:enable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase */ diff --git a/includes/apple-exporter/components/class-body.php b/includes/apple-exporter/components/class-body.php index 6d62e93a..5e00b9a0 100644 --- a/includes/apple-exporter/components/class-body.php +++ b/includes/apple-exporter/components/class-body.php @@ -40,6 +40,7 @@ class Body extends Component { * @return array|null The node on success, or null on no match. */ public static function node_matches( $node ) { + /* phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase */ // We are only interested in p, pre, ul and ol. if ( ! in_array( $node->nodeName, [ 'p', 'pre', 'ul', 'ol' ], true ) ) { return null; @@ -88,6 +89,7 @@ public static function node_matches( $node ) { $open, $close ); + /* phpcs:enable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase */ } /** @@ -441,7 +443,7 @@ public function set_default_style() { /** * Determine whether to apply a dropcap style for the component. - * + * * @param \Apple_Exporter\Theme $theme Object that stores theme level dropcap configuration. * @param string $html The HTML to check for dropcap conditions. Should be the first paragraph of the post content. * @@ -471,17 +473,17 @@ private function dropcap_determination( $theme, $html ) { $use_dropcap = false; } - /** + /** * Allows for filtering of the dropcap content before return. - * + * * @since 2.4.0 - * + * * @param bool $use_dropcap Whether to apply a dropcap to this paragraph or not. * @param string $html The post content to filter. * @param \Apple_Exporter\Theme $theme The theme whose dropcap options are used. * @param string $post_id The id of the post whose content we're parsing. */ - return apply_filters( 'apple_news_dropcap', $use_dropcap, $html, $theme, $this->workspace->content_id ); + return apply_filters( 'apple_news_dropcap', $use_dropcap, $html, $theme, $this->workspace->content_id ); } /** diff --git a/includes/apple-exporter/components/class-embed-generic.php b/includes/apple-exporter/components/class-embed-generic.php index 341ac6ec..f27249cd 100644 --- a/includes/apple-exporter/components/class-embed-generic.php +++ b/includes/apple-exporter/components/class-embed-generic.php @@ -27,7 +27,7 @@ class Embed_Generic extends Component { * @return \DOMElement|null The node on success, or null on no match. */ public static function node_matches( $node ) { - + /* phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase */ // If we aren't on an element node, bail out. if ( 1 !== $node->nodeType ) { return null; @@ -51,6 +51,7 @@ public static function node_matches( $node ) { && 'iframe' === $node->childNodes->item( 0 )->nodeName ) { return $node; + /* phpcs:enable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase */ } // Anything else isn't supported out of the box. diff --git a/includes/apple-exporter/components/class-facebook.php b/includes/apple-exporter/components/class-facebook.php index da0809a7..4d1f57c7 100644 --- a/includes/apple-exporter/components/class-facebook.php +++ b/includes/apple-exporter/components/class-facebook.php @@ -62,6 +62,7 @@ public function register_specs() { */ public static function node_matches( $node ) { + /* phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase */ // Handling for a Gutenberg Facebook embed. if ( 'figure' === $node->nodeName @@ -105,6 +106,7 @@ public static function node_matches( $node ) { ) { return $node; } + /* phpcs:enable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase */ } // facebook not found. diff --git a/includes/apple-exporter/components/class-gallery.php b/includes/apple-exporter/components/class-gallery.php index d8c15e29..18e1e906 100644 --- a/includes/apple-exporter/components/class-gallery.php +++ b/includes/apple-exporter/components/class-gallery.php @@ -109,17 +109,17 @@ protected function build( $html ) { } // Determine if we have items. - if ( empty( $container->childNodes ) ) { + if ( empty( $container->childNodes ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase return; } // Loop through items and construct slides. $theme = \Apple_Exporter\Theme::get_used(); $items = []; - foreach ( $container->childNodes as $item ) { + foreach ( $container->childNodes as $item ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase // Convert item into HTML for regex matching. - $item_html = $item->ownerDocument->saveXML( $item ); + $item_html = $item->ownerDocument->saveXML( $item ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase // Try to get URL. if ( ! preg_match( '/src="([^"]+)"/', $item_html, $matches ) ) { diff --git a/includes/apple-exporter/components/class-heading.php b/includes/apple-exporter/components/class-heading.php index 61ec1e3e..5af2476b 100644 --- a/includes/apple-exporter/components/class-heading.php +++ b/includes/apple-exporter/components/class-heading.php @@ -37,11 +37,11 @@ public static function node_matches( $node ) { self::$levels[ count( self::$levels ) - 1 ] ); - if ( ! preg_match( $regex, $node->nodeName ) ) { + if ( ! preg_match( $regex, $node->nodeName ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase return null; } - $html = $node->ownerDocument->saveXML( $node ); + $html = $node->ownerDocument->saveXML( $node ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase if ( preg_match( '##si', $html ) ) { return self::split_image( $html ); } diff --git a/includes/apple-exporter/components/class-image.php b/includes/apple-exporter/components/class-image.php index ff52a5e1..55817305 100644 --- a/includes/apple-exporter/components/class-image.php +++ b/includes/apple-exporter/components/class-image.php @@ -23,6 +23,7 @@ class Image extends Component { * @return \DOMElement|null The node on success, or null on no match. */ public static function node_matches( $node ) { + /* phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase */ $has_image_child = false; // If this is a figure and it has children, see if we can find an image. @@ -48,6 +49,7 @@ public static function node_matches( $node ) { } return null; + /* phpcs:enable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase */ } /** diff --git a/includes/apple-exporter/components/class-instagram.php b/includes/apple-exporter/components/class-instagram.php index 8198c8d0..42056657 100644 --- a/includes/apple-exporter/components/class-instagram.php +++ b/includes/apple-exporter/components/class-instagram.php @@ -29,14 +29,14 @@ public static function node_matches( $node ) { // Handling for a Gutenberg Instagram embed. if ( - 'figure' === $node->nodeName + 'figure' === $node->nodeName // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase && self::node_has_class( $node, 'wp-block-embed-instagram' ) ) { return $node; } // Handle Instagram oEmbed URLs. - if ( false !== self::get_instagram_url( $node->nodeValue ) ) { + if ( false !== self::get_instagram_url( $node->nodeValue ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase return $node; } diff --git a/includes/apple-exporter/components/class-link-button.php b/includes/apple-exporter/components/class-link-button.php index 939f2e45..556600f0 100644 --- a/includes/apple-exporter/components/class-link-button.php +++ b/includes/apple-exporter/components/class-link-button.php @@ -23,10 +23,10 @@ class Link_Button extends Component { * @return \DOMElement|null The node on success, or null on no match. */ public static function node_matches( $node ) { - return 'a' === $node->nodeName + return 'a' === $node->nodeName // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase && self::node_has_class( $node, 'wp-block-button__link' ) && ! empty( $node->getAttribute( 'href' ) ) - && ! empty( $node->nodeValue ) + && ! empty( $node->nodeValue ) // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase ? $node : null; } diff --git a/includes/apple-exporter/components/class-podcast.php b/includes/apple-exporter/components/class-podcast.php index 4acdd57b..8d2673a5 100644 --- a/includes/apple-exporter/components/class-podcast.php +++ b/includes/apple-exporter/components/class-podcast.php @@ -23,7 +23,7 @@ class Podcast extends Component { * Look for node matches for this component. * * @param \DOMElement $node The node to examine for matches. - * + * * @return \DOMElement|null The node on success, or null on no match. */ public static function node_matches( $node ) { @@ -100,9 +100,9 @@ private static function get_podcast_url( $node ) { // Remove iframe specific `embed.` prefix on podcast url. $url = str_replace( 'embed.podcasts.apple.com', 'podcasts.apple.com', $url ); - + // Parse url into component parts. - $url_comps = parse_url( $url ); + $url_comps = wp_parse_url( $url ); // Reassemble url without query params. $url = sprintf( diff --git a/includes/apple-exporter/components/class-quote.php b/includes/apple-exporter/components/class-quote.php index 28c18795..e79e5a90 100644 --- a/includes/apple-exporter/components/class-quote.php +++ b/includes/apple-exporter/components/class-quote.php @@ -26,7 +26,7 @@ class Quote extends Component { * @return \DOMElement|null The node on success, or null on no match. */ public static function node_matches( $node ) { - return ( 'blockquote' === $node->nodeName || ( isset( $node->firstChild->tagName ) && 'blockquote' === $node->firstChild->tagName ) ) ? $node : null; + return ( 'blockquote' === $node->nodeName || ( isset( $node->firstChild->tagName ) && 'blockquote' === $node->firstChild->tagName ) ) ? $node : null; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase } /** diff --git a/includes/apple-exporter/components/class-table.php b/includes/apple-exporter/components/class-table.php index 784485e8..71d5290e 100644 --- a/includes/apple-exporter/components/class-table.php +++ b/includes/apple-exporter/components/class-table.php @@ -42,9 +42,9 @@ public static function node_matches( $node ) { ( self::node_has_class( $node, 'wp-block-table' ) && $node->hasChildNodes() && - 'table' === $node->firstChild->nodeName + 'table' === $node->firstChild->nodeName // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase ) || - 'table' === $node->nodeName ) { + 'table' === $node->nodeName ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase return $node; } diff --git a/includes/apple-exporter/components/class-tiktok.php b/includes/apple-exporter/components/class-tiktok.php index 45b50ba0..d9c4ca44 100644 --- a/includes/apple-exporter/components/class-tiktok.php +++ b/includes/apple-exporter/components/class-tiktok.php @@ -25,6 +25,7 @@ class TikTok extends Component { * @return \DOMElement|null The node on success, or null on no match. */ public static function node_matches( $node ) { + /* phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase */ // Handling for a Gutenberg TikTok embed. if ( @@ -45,6 +46,7 @@ public static function node_matches( $node ) { && self::node_has_class( $node, 'tiktok-embed' ) ) { return $node; + /* phpcs:enable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase */ } return null; diff --git a/includes/apple-push-api/class-mime-builder.php b/includes/apple-push-api/class-mime-builder.php index 505ac9cf..5e93fe44 100644 --- a/includes/apple-push-api/class-mime-builder.php +++ b/includes/apple-push-api/class-mime-builder.php @@ -210,8 +210,8 @@ private function build_attachment( $name, $filename, $content, $mime_type, $size throw new Request_Exception( sprintf( // translators: token is an attachment filename. - __( 'The attachment %s could not be included in the request because it was empty.', 'apple-news' ), - esc_html( $filename ) + esc_html__( 'The attachment %s could not be included in the request because it was empty.', 'apple-news' ), + $filename // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped ) ); } @@ -221,9 +221,9 @@ private function build_attachment( $name, $filename, $content, $mime_type, $size throw new Request_Exception( sprintf( // translators: first token is the filename, second is the file size. - __( 'The attachment %1$s could not be included in the request because its size was %2$s.', 'apple-news' ), - esc_html( $filename ), - esc_html( $size ) + esc_html__( 'The attachment %1$s could not be included in the request because its size was %2$s.', 'apple-news' ), + $filename, // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped + $size // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped ) ); } diff --git a/tests/admin/test-class-admin-apple-themes.php b/tests/admin/test-class-admin-apple-themes.php index 3e580c41..441a9edd 100644 --- a/tests/admin/test-class-admin-apple-themes.php +++ b/tests/admin/test-class-admin-apple-themes.php @@ -13,7 +13,7 @@ use Apple_Exporter\Theme; /** - * + * A class to test the Admin_Apple_Themes class. */ class Admin_Apple_Themes_Test extends Apple_News_Testcase { diff --git a/tests/mocks/class-bc-cms-api.php b/tests/mocks/class-bc-cms-api.php index a8062bf2..e8f4f4d6 100644 --- a/tests/mocks/class-bc-cms-api.php +++ b/tests/mocks/class-bc-cms-api.php @@ -22,7 +22,7 @@ class BC_CMS_API { * * @return array Array of the video's images retrieved. */ - public function video_get_images( $video_id ) { + public function video_get_images( $video_id ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found return [ 'poster' => [ 'src' => 'https://cf-images.us-east-1.prod.boltdns.net/v1/jit/1234567890/abcd1234-ef56-ab78-cd90-efabcd123456/main/1280x720/1s234ms/match/image.jpg',