From a2812dc94fb6115db9ba834c78de099c4c6f3d62 Mon Sep 17 00:00:00 2001
From: Erick Hitter <git-contrib@ethitter.com>
Date: Sat, 25 Jun 2022 15:46:17 -0700
Subject: [PATCH] Fix translation support

---
 Gruntfile.js                        |  2 +-
 README.md                           | 10 ++++-
 eth-escape-headspace.php            | 59 +++++++++++++++++++----------
 languages/eth-escape-headspace2.pot |  2 +-
 phpcs.xml                           |  2 +-
 readme.txt                          | 10 ++++-
 6 files changed, 57 insertions(+), 28 deletions(-)

diff --git a/Gruntfile.js b/Gruntfile.js
index 9ab104c..aa0962a 100755
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -9,7 +9,7 @@ module.exports = function( grunt ) {
 
 		addtextdomain: {
 			options: {
-				textdomain: 'eth_escape_headspace2',
+				textdomain: 'eth-escape-headspace2',
 			},
 			update_all_domains: {
 				options: {
diff --git a/README.md b/README.md
index f8f840f..49f6345 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
 **Tags:** seo, meta tags  
 **Requires at least:** 4.4  
 **Tested up to:** 6.0  
-**Stable tag:** 0.2.1  
+**Stable tag:** 0.2.2  
 **License:** GPLv2 or later  
 **License URI:** http://www.gnu.org/licenses/gpl-2.0.html  
 
@@ -49,6 +49,9 @@ Mostly, I either didn't have time or didn't have a good example of how a particu
 
 ## Changelog ##
 
+### 0.2.2 ###
+* Fix translation support.
+
 ### 0.2.1 ###
 * PHP 7.3 compatibility.
 
@@ -61,5 +64,8 @@ Mostly, I either didn't have time or didn't have a good example of how a particu
 
 ## Upgrade Notice ##
 
+### 0.2.2 ###
+Fixes translation support.
+
 ### 0.2.1 ###
-Resolved warning arising in PHP 7.3.
+Resolves warning arising in PHP 7.3.
diff --git a/eth-escape-headspace.php b/eth-escape-headspace.php
index b79cbde..41b4bb2 100644
--- a/eth-escape-headspace.php
+++ b/eth-escape-headspace.php
@@ -1,25 +1,27 @@
 <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
 /**
-  Plugin Name: ETH Escape HeadSpace2
-  Plugin URI: https://ethitter.com/plugins/
-  Description: Output existing HeadSpace2 data without the original plugin. Allows HeadSpace2 (no longer maintained) to be deactivated without impactacting legacy content.
-  Author: Erick Hitter
-  Version: 0.2.1
-  Author URI: https://ethitter.com/
-
-  This program is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published by
-  the Free Software Foundation; either version 2 of the License, or
-  (at your option) any later version.
-
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License
-  along with this program; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ * Plugin Name: ETH Escape HeadSpace2
+ * Plugin URI: https://ethitter.com/plugins/
+ * Description: Output existing HeadSpace2 data without the original plugin. Allows HeadSpace2 (no longer maintained) to be deactivated without impactacting legacy content.
+ * Author: Erick Hitter
+ * Version: 0.2.1
+ * Author URI: https://ethitter.com/
+ * Text Domain: eth-escape-headspace2
+ * Domain Path: /languages/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
 /**
@@ -101,10 +103,12 @@ class ETH_Escape_HeadSpace2 {
 	 */
 	public function maybe_add_hooks() {
 		// Defer to HeadSpace2 when active.
-		if ( class_exists( 'HeadSpace_Plugin' ) ) {
+		if ( class_exists( 'HeadSpace_Plugin', false ) ) {
 			return;
 		}
 
+		add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
+
 		add_filter( 'pre_get_document_title', array( $this, 'filter_pre_get_document_title' ) );
 		add_filter( 'wp_title', array( $this, 'filter_wp_title' ), 10, 3 );
 
@@ -112,6 +116,19 @@ class ETH_Escape_HeadSpace2 {
 		add_action( 'wp_footer', array( $this, 'action_wp_footer' ) );
 	}
 
+	/**
+	 * Load plugin translations.
+	 *
+	 * @return void
+	 */
+	public function load_textdomain() {
+		load_plugin_textdomain(
+			'eth-escape-headspace2',
+			false,
+			dirname( plugin_basename( __FILE__ ) ) . '/languages/'
+		);
+	}
+
 	/**
 	 * Filter page titles in WP 4.1+ themes add_theme_support( 'title-tag' ).
 	 *
diff --git a/languages/eth-escape-headspace2.pot b/languages/eth-escape-headspace2.pot
index ce3c81e..2789de6 100644
--- a/languages/eth-escape-headspace2.pot
+++ b/languages/eth-escape-headspace2.pot
@@ -5,7 +5,7 @@ msgstr ""
 "Project-Id-Version: ETH Escape HeadSpace2 0.2.1\n"
 "Report-Msgid-Bugs-To: "
 "https://wordpress.org/support/plugin/eth-escape-headspace\n"
-"POT-Creation-Date: 2022-06-11 18:55:07+00:00\n"
+"POT-Creation-Date: 2022-06-25 22:45:25+00:00\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=utf-8\n"
 "Content-Transfer-Encoding: 8bit\n"
diff --git a/phpcs.xml b/phpcs.xml
index 01cc6ee..29ee954 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -39,7 +39,7 @@
 	<rule ref="WordPress.WP.I18n">
 		<properties>
 			<!-- Value: replace the text domain used. -->
-			<property name="text_domain" type="array" value="eth_escape_headspace2"/>
+			<property name="text_domain" type="array" value="eth-escape-headspace2"/>
 		</properties>
 	</rule>
 	<rule ref="WordPress.WhiteSpace.ControlStructureSpacing">
diff --git a/readme.txt b/readme.txt
index bfbf07f..1f5598f 100644
--- a/readme.txt
+++ b/readme.txt
@@ -4,7 +4,7 @@ Donate link: https://ethitter.com/donate/
 Tags: seo, meta tags
 Requires at least: 4.4
 Tested up to: 6.0
-Stable tag: 0.2.1
+Stable tag: 0.2.2
 License: GPLv2 or later
 License URI: http://www.gnu.org/licenses/gpl-2.0.html
 
@@ -49,6 +49,9 @@ Mostly, I either didn't have time or didn't have a good example of how a particu
 
 == Changelog ==
 
+= 0.2.2 =
+* Fix translation support.
+
 = 0.2.1 =
 * PHP 7.3 compatibility.
 
@@ -61,5 +64,8 @@ Mostly, I either didn't have time or didn't have a good example of how a particu
 
 == Upgrade Notice ==
 
+= 0.2.2 =
+Fixes translation support.
+
 = 0.2.1 =
-Resolved warning arising in PHP 7.3.
+Resolves warning arising in PHP 7.3.
-- 
GitLab