Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
ETH Escape Headspace
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WP Plugins
ETH Escape Headspace
Commits
4d92cdeb
Commit
4d92cdeb
authored
9 years ago
by
Erick Hitter
Browse files
Options
Downloads
Patches
Plain Diff
Support for scripts, stylesheets, and raw header output.
parent
0a6730fb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!2
Support for additional HeadSpace2 features
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
eth-escape-headspace.php
+45
-3
45 additions, 3 deletions
eth-escape-headspace.php
with
45 additions
and
3 deletions
eth-escape-headspace.php
+
45
−
3
View file @
4d92cdeb
...
...
@@ -45,6 +45,14 @@ class ETH_Escape_HeadSpace2 {
private
$hs_string_keys
=
array
(
'_headspace_description'
,
'_headspace_metakey'
,
'_headspace_page_title'
,
'_headspace_raw'
,
'_headspace_raw_footer'
,
);
private
$hs_array_keys
=
array
(
'_headspace_scripts'
,
'_headspace_stylesheets'
,
);
private
$hs_robots_keys
=
array
(
...
...
@@ -81,6 +89,7 @@ class ETH_Escape_HeadSpace2 {
// Check for HS data
$hs_data
=
array
();
// 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
);
...
...
@@ -89,6 +98,15 @@ class ETH_Escape_HeadSpace2 {
}
}
// 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
);
if
(
!
empty
(
$values
)
)
{
$hs_data
[
$hs_key
]
=
$values
;
}
}
// Bail if no HS data exists for this post
if
(
empty
(
$hs_data
)
)
{
return
;
...
...
@@ -98,11 +116,25 @@ class ETH_Escape_HeadSpace2 {
echo
"
\n
<!-- Escape HeadSpace2 by Erick Hitter; ethitter.com -->
\n
"
;
// Handle basic, string-containing keys
$output
=
array
();
foreach
(
$hs_data
as
$hs_key
=>
$hs_value
)
{
switch
(
$hs_key
)
{
case
'_headspace_description'
:
case
'_headspace_metakey'
:
echo
'<meta name="'
.
esc_attr
(
$this
->
hs_keys_to_meta_names
[
$hs_key
]
)
.
'" content="'
.
esc_attr
(
$hs_value
)
.
'" />'
.
"
\n
"
;
$output
[]
=
'<meta name="'
.
esc_attr
(
$this
->
hs_keys_to_meta_names
[
$hs_key
]
)
.
'" content="'
.
esc_attr
(
$hs_value
)
.
'" />'
;
break
;
case
'_headspace_scripts'
:
foreach
(
$hs_value
as
$_source
)
{
$output
[]
=
'<script type="text/javascript" src="'
.
esc_url
(
$_source
)
.
'"></script>'
;
}
break
;
case
'_headspace_stylesheets'
:
foreach
(
$hs_value
as
$_source
)
{
$output
[]
=
'<link rel="stylesheet" href="'
.
esc_url
(
$_source
)
.
'" type="text/css" />'
;
}
break
;
default
:
...
...
@@ -127,11 +159,21 @@ class ETH_Escape_HeadSpace2 {
$robots
=
implode
(
','
,
$robots
);
echo
'<meta name="robots" content="'
.
esc_attr
(
$robots
)
.
'" />'
.
"
\n
"
;
$output
[]
=
'<meta name="robots" content="'
.
esc_attr
(
$robots
)
.
'" />'
.
"
\n
"
;
}
// Raw output should follow all other output
if
(
isset
(
$hs_data
[
'_headspace_raw'
]
)
)
{
$output
[]
=
$hs_data
[
'_headspace_raw'
];
}
// Output whatever we've built
if
(
!
empty
(
$output
)
)
{
echo
implode
(
"
\n
"
,
$output
);
}
// Mark end of output
echo
"<!-- Escape HeadSpace2 -->
\n
"
;
echo
"
\n
<!-- Escape HeadSpace2 -->
\n
"
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment