Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
ETH Google Analytics for AMP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
WP Plugins
ETH Google Analytics for AMP
Merge requests
!1
WIP: Initial release
代码
评审变更
检出分支
下载
补丁
文本差异
Closed
WIP: Initial release
develop
into
master
Overview
2
Commits
20
Changes
1
Closed
Erick Hitter
requested to merge
develop
into
master
9 years ago
Overview
2
Commits
20
Changes
1
Expand
0
0
Merge request reports
Viewing commit
4dff290d
Prev
Next
Show latest version
1 file
+
30
−
7
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
4dff290d
Utility method for retrieving options
· 4dff290d
Erick Hitter
authored
9 years ago
eth-amp-analytics-wp.php
+
30
−
7
Options
@@ -89,16 +89,10 @@ class ETH_AMP_Analytics_WP {
* Conditionally load front-end hooks
*/
public
function
action_wp_loaded
()
{
$ga_options
=
get_option
(
$this
->
plugin_option_name
);
if
(
is_array
(
$ga_options
)
)
{
$this
->
options
=
wp_parse_args
(
$ga_options
,
$this
->
plugin_option_defaults
);
if
(
!
empty
(
$this
->
get_option
(
'property_id'
)
)
)
{
add_filter
(
'amp_component_scripts'
,
array
(
$this
,
'filter_amp_component_scripts'
)
);
add_action
(
'amp_post_template_footer'
,
array
(
$this
,
'action_amp_post_template_footer'
)
);
}
unset
(
$ga_options
);
}
/**
@@ -168,6 +162,35 @@ class ETH_AMP_Analytics_WP {
public
function
sanitize_options
(
$options
)
{
return
$options
;
}
/**
* UTILITY FUNCTIONS
*/
/**
*
*/
private
function
get_option
(
$name
)
{
// Prepare options if this is the first request
if
(
is_null
(
$this
->
options
)
)
{
$ga_options
=
get_option
(
$this
->
plugin_option_name
);
if
(
is_array
(
$ga_options
)
)
{
$this
->
options
=
wp_parse_args
(
$ga_options
,
$this
->
plugin_option_defaults
);
}
else
{
return
false
;
}
unset
(
$ga_options
);
}
// Does the key exist?
if
(
isset
(
$this
->
options
[
$name
]
)
)
{
return
$this
->
options
[
$name
];
}
else
{
return
false
;
}
}
}
ETH_AMP_Analytics_WP
::
get_instance
();
\ No newline at end of file
Loading