-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathreadme.txt
More file actions
148 lines (100 loc) · 4.28 KB
/
readme.txt
File metadata and controls
148 lines (100 loc) · 4.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
=== DCO Insert Analytics Code ===
Contributors: denisco
Tags: analytics, metrika, yandex metrica, google analytics
Requires at least: 4.6
Tested up to: 5.3
Requires PHP: 5.4
Stable tag: 1.1.3
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Allows you to insert analytics code before </head> or after <body> or before </body>
== Description ==
DCO Insert Analytics Code is a WordPress plugin is intended for insert analytics code(or any custom code) before </head> or after <body> or before </body>
= Usage =
After installation and activation, you can insert the necessary code to the respective fields on the plugin settings page.
[GitHub](https://github.com/yadenis/DCO-Insert-Analytics-Code)
= Settings =
* Before </head> code
* After <body> code
* Before </body> code
= Filters list =
**dco_iac_get_options**
Filter for hardcoding override plugin settings. You won't be able to edit them on the settings page anymore when using this filter.
**dco_iac_insert_before_head**
Filter to change the code is inserted before </head>
**dco_iac_insert_before_head_show**
Filter to change show the code is inserted before </head>
**dco_iac_insert_after_body**
Filter to change the code is inserted after <body>
**dco_iac_insert_after_body_show**
Filter to change show the code is inserted after <body>
**dco_iac_insert_before_body**
Filter to change the code is inserted before </body>
**dco_iac_insert_before_body_show**
Filter to change show the code is inserted before </body>
**dco_iac_disable_do_shortcode**
Filter to disable shortcode processing in inserted codes
= Examples of using filters =
**Hardcoding override plugin settings**
/*
* $current - current plugin settings
*
* $options - plugin settings from database
*
* $default - default plugin settings
*/
function custom_get_options($current, $options, $default) {
$array = array(
'before_head' => '<!-- before </head> -->',
'before_head_show' => '0',
'after_body' => '<!-- after <body> -->',
'after_body_show' => '1',
'before_body' => '<!-- before </body> -->',
'before_body_show' => '2'
);
return $array;
}
add_filter('dco_iac_get_options', 'custom_get_options', 10, 3);
**Change before </head> code**
/*
* $code - value from "before </head>" setting
*/
function custom_before_head_code( $code ) {
return $code . '<!-- before <head> -->' . "\n";
}
add_filter( 'dco_iac_insert_before_head', 'custom_before_head_code' );
**Change before </body> code show**
/*
* $value - value from "before </body> show" setting
*/
function custom_before_head_code( $value ) {
return '2';
}
add_filter( 'dco_iac_insert_before_body_show', 'custom_before_body_show' );
**Disable shortcode processing in insert codes**
add_filter('dco_iac_disable_do_shortcode', '__return_true');
== Installation ==
1. Upload `dco-insert-analytics-code` folder to the `/wp-content/plugins/` directory
2. Activate the plugin through the 'Plugins' menu in WordPress
== Frequently Asked Questions ==
= I put the code on the plugin settings page, but it does not appear on the site. What could be the reason? =
* For correct work plugin your theme must support [wp_head action hook](https://developer.wordpress.org/reference/functions/wp_head/) and [wp_footer action hook](https://developer.wordpress.org/reference/functions/wp_footer/).
* If you are using plugins for caching you need to clear the cache to apply the changes.
== Screenshots ==
1. Settings page
2. Example page
== Changelog ==
= 1.1.3 =
* Add settings link to Plugins page
* Correct plugin description
= 1.1.2 =
* Constant `DCO_IAC_DO_SHORTCODE` replaced with `dco_iac_disable_do_shortcode` filter. Use `add_filter('dco_iac_disable_do_shortcode', '__return_true');` to disable shortcodes support.
= 1.1.1 =
* Added feature to hide the code
* Added shortcodes support (add constant `define('DCO_IAC_DO_SHORTCODE', false);` to wp-config.php for disable)
= 1.1.0 =
* Fixed Text Domain
* Added the ability to adjust the show code for logged / not logged users
* Restricted direct access to plugin files
= 1.0.0 =
* Initial Release