From db7055374e0f942a0d36a6828d6514db2c4c0c2a Mon Sep 17 00:00:00 2001 From: Erick Hitter <services@ethitter.com> Date: Sat, 30 Jan 2016 13:00:15 -0800 Subject: [PATCH] Reduce repetition by mapping HeadSpace2 postmeta keys to their equivalent meta names --- eth-escape-headspace.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/eth-escape-headspace.php b/eth-escape-headspace.php index b1aaa3b..edb9945 100644 --- a/eth-escape-headspace.php +++ b/eth-escape-headspace.php @@ -55,6 +55,11 @@ class ETH_Escape_HeadSpace2 { '_headspace_noydir', ); + private $hs_keys_to_meta_names = array( + '_headspace_description' => 'description', + '_headspace_metakey' => 'keywords', + ); + /** * Register plugin's hooks * @@ -96,11 +101,8 @@ class ETH_Escape_HeadSpace2 { foreach ( $hs_data as $hs_key => $hs_value ) { switch( $hs_key ) { case '_headspace_description' : - echo '<meta name="description" content="' . esc_attr( $hs_value ) . '" />' . "\n"; - break; - case '_headspace_metakey' : - echo '<meta name="keywords" content="' . esc_attr( $hs_value ) . '" />' . "\n"; + echo '<meta name="' . esc_attr( $this->hs_keys_to_meta_names[ $hs_key ] ) . '" content="' . esc_attr( $hs_value ) . '" />' . "\n"; break; default : -- GitLab