From 45dbce834aefed9cde049747a06b3d835fb4e585 Mon Sep 17 00:00:00 2001 From: Erick Hitter Date: Sat, 23 Nov 2019 15:24:28 -0800 Subject: [PATCH] PHPCS --- eth-escape-headspace.php | 110 ++++++++++++++++++++++++--------------- 1 file changed, 69 insertions(+), 41 deletions(-) diff --git a/eth-escape-headspace.php b/eth-escape-headspace.php index 0c236f6..62d3f7c 100644 --- a/eth-escape-headspace.php +++ b/eth-escape-headspace.php @@ -1,30 +1,35 @@ - 'description', '_headspace_metakey' => 'keywords', @@ -80,7 +102,7 @@ class ETH_Escape_HeadSpace2 { * Conditionally register plugin's hooks */ public function maybe_add_hooks() { - // Defer to HeadSpace2 when active + // Defer to HeadSpace2 when active. if ( class_exists( 'HeadSpace_Plugin' ) ) { return; } @@ -93,8 +115,10 @@ class ETH_Escape_HeadSpace2 { } /** - * Filter page titles in WP 4.1+ themes - * add_theme_support( 'title-tag' ) + * Filter page titles in WP 4.1+ themes add_theme_support( 'title-tag' ). + * + * @param string $title Page title. + * @return string */ public function filter_pre_get_document_title( $title ) { $_title = get_post_meta( get_the_ID(), '_headspace_page_title', true ); @@ -109,8 +133,12 @@ class ETH_Escape_HeadSpace2 { } /** - * Filter page titles in themes designed for < WP 4.1 - * wp_title() + * Filter page titles in themes designed for < WP 4.1 wp_title(). + * + * @param string $title Object title. + * @param string $sep Title separator. + * @param string $loc Separator location. + * @return string */ public function filter_wp_title( $title, $sep, $loc ) { $_title = get_post_meta( get_the_ID(), '_headspace_page_title', true ); @@ -118,7 +146,7 @@ class ETH_Escape_HeadSpace2 { if ( ! empty( $_title ) ) { $_title = esc_html( $_title ); - if ( 'right' == $loc ) { + if ( 'right' === $loc ) { $title = $_title . ' ' . $sep . ' '; } else { $title = ' ' . $sep . ' ' . $_title; @@ -134,15 +162,15 @@ class ETH_Escape_HeadSpace2 { * Add meta tags */ public function action_wp_head() { - // Applies only to individual post objects + // Applies only to individual post objects. if ( ! is_singular() ) { return; } - // Check for HS data + // Check for HS data. $hs_data = array(); - // Keys that only exist once per post + // Keys that only exist once per post. foreach ( array_merge( $this->hs_string_keys, $this->hs_robots_keys ) as $hs_key ) { $value = get_post_meta( get_the_ID(), $hs_key, true ); @@ -151,7 +179,7 @@ class ETH_Escape_HeadSpace2 { } } - // Keys that can exist multiple times per post + // Keys that can exist multiple times per post. foreach ( $this->hs_array_keys as $hs_key ) { $values = get_post_meta( get_the_ID(), $hs_key, false ); @@ -160,12 +188,12 @@ class ETH_Escape_HeadSpace2 { } } - // Bail if no HS data exists for this post + // Bail if no HS data exists for this post. if ( empty( $hs_data ) ) { return; } - // Handle basic, string-containing keys + // Handle basic, string-containing keys. $output = array(); foreach ( $hs_data as $hs_key => $hs_value ) { @@ -193,7 +221,7 @@ class ETH_Escape_HeadSpace2 { } } - // Handle robots key, which is build from several meta keys + // Handle robots key, which is build from several meta keys. $robots = array(); foreach ( $this->hs_robots_keys as $hs_robot_key ) { @@ -212,8 +240,8 @@ class ETH_Escape_HeadSpace2 { $output[] = '' . "\n"; } - // Raw output should follow all other output - if ( isset( $hs_data[ '_headspace_raw' ] ) && ! empty( $hs_data[ '_headspace_raw' ] ) ) { + // Raw output should follow all other output. + if ( ! empty( $hs_data[ '_headspace_raw' ] ) ) { $output[] = $hs_data[ '_headspace_raw' ]; } -- GitLab