From 549e13701760221a37f9d4dcf1298b961b72f58a Mon Sep 17 00:00:00 2001
From: Erick Hitter <services@ethitter.com>
Date: Mon, 15 Feb 2016 22:32:09 -0800
Subject: [PATCH] Page titles for older themes

---
 eth-escape-headspace.php | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/eth-escape-headspace.php b/eth-escape-headspace.php
index b33c86a..c003d47 100644
--- a/eth-escape-headspace.php
+++ b/eth-escape-headspace.php
@@ -73,6 +73,8 @@ class ETH_Escape_HeadSpace2 {
 	 */
 	private function __construct() {
 		add_filter( 'pre_get_document_title', array( $this, 'filter_pre_get_document_title' ) );
+		add_filter( 'wp_title', array( $this, 'filter_wp_title' ), 10, 3 );
+
 		add_action( 'wp_head', array( $this, 'action_wp_head' ) );
 		add_action( 'wp_footer', array( $this, 'action_wp_footer' ) );
 	}
@@ -92,6 +94,27 @@ class ETH_Escape_HeadSpace2 {
 		return $title;
 	}
 
+	/**
+	 *
+	 */
+	public function filter_wp_title( $title, $sep, $loc ) {
+		$_title = get_post_meta( get_the_ID(), '_headspace_page_title', true );
+
+		if ( ! empty( $_title ) ) {
+			$_title = esc_html( $_title );
+
+			if ( 'right' == $loc ) {
+				$title = $_title . ' ' . $sep . ' ';
+			} else {
+				$title = ' ' . $sep . ' ' . $_title;
+			}
+		}
+
+		unset( $_title );
+
+		return $title;
+	}
+
 	/**
 	 *
 	 */
-- 
GitLab