Contact Form7 Widget For Elementor Page Builder - Version 2.1.1

Version Description

  • Fix: Elementor latest version compatibility
Download this release

Release Info

Developer voidcoders
Plugin Icon 128x128 Contact Form7 Widget For Elementor Page Builder
Version 2.1.1
Comparing to
See all releases

Code changes from version 2.1 to 2.1.1

Files changed (54) hide show
  1. .gitignore +0 -1
  2. analyst/assets/css/customize.css +280 -280
  3. analyst/assets/index.php +2 -2
  4. analyst/assets/js/customize.js +29 -29
  5. analyst/autoload.php +40 -40
  6. analyst/index.php +2 -2
  7. analyst/main.php +36 -36
  8. analyst/sdk_resolver.php +79 -79
  9. analyst/src/Account/Account.php +584 -584
  10. analyst/src/Account/AccountData.php +176 -176
  11. analyst/src/Account/AccountDataFactory.php +125 -125
  12. analyst/src/Analyst.php +167 -167
  13. analyst/src/ApiRequestor.php +257 -257
  14. analyst/src/ApiResponse.php +44 -44
  15. analyst/src/Cache/DatabaseCache.php +127 -127
  16. analyst/src/Collector.php +217 -217
  17. analyst/src/Contracts/AnalystContract.php +12 -12
  18. analyst/src/Contracts/CacheContract.php +47 -47
  19. analyst/src/Contracts/HttpClientContract.php +25 -25
  20. analyst/src/Contracts/RequestContract.php +22 -22
  21. analyst/src/Contracts/RequestorContract.php +44 -44
  22. analyst/src/Contracts/TrackerContract.php +69 -69
  23. analyst/src/Core/AbstractFactory.php +27 -27
  24. analyst/src/Http/CurlHttpClient.php +102 -102
  25. analyst/src/Http/DummyHttpClient.php +33 -33
  26. analyst/src/Http/Requests/AbstractLoggerRequest.php +64 -64
  27. analyst/src/Http/Requests/ActivateRequest.php +42 -42
  28. analyst/src/Http/Requests/DeactivateRequest.php +64 -64
  29. analyst/src/Http/Requests/InstallRequest.php +38 -38
  30. analyst/src/Http/Requests/OptInRequest.php +42 -42
  31. analyst/src/Http/Requests/OptOutRequest.php +40 -40
  32. analyst/src/Http/Requests/UninstallRequest.php +36 -36
  33. analyst/src/Http/WordPressHttpClient.php +61 -61
  34. analyst/src/Mutator.php +103 -103
  35. analyst/src/Notices/Notice.php +121 -121
  36. analyst/src/Notices/NoticeFactory.php +130 -130
  37. analyst/src/helpers.php +84 -84
  38. analyst/templates/forms/deactivate.php +156 -156
  39. analyst/templates/forms/install.php +112 -112
  40. analyst/templates/notice.php +10 -10
  41. analyst/templates/optin.php +60 -60
  42. analyst/templates/optout.php +109 -109
  43. analyst/version.php +15 -15
  44. assets/css/void-cf7-admin.css +124 -124
  45. assets/js/void-cf7-admin.js +82 -82
  46. custom-editor/assets/css/void-cf7-elementor-editor.css +111 -111
  47. custom-editor/assets/js/void-cf7-elementor-editor.js +140 -140
  48. custom-editor/init.php +30 -30
  49. custom-editor/modal-editor.php +99 -99
  50. helper/helper.php +99 -99
  51. plugin.php +93 -93
  52. readme.txt +133 -131
  53. void-cf7-widget-elementor.php +360 -360
  54. widgets/void-section-cf7.php +1686 -1686
.gitignore DELETED
@@ -1 +0,0 @@
1
- .DS_Store
 
analyst/assets/css/customize.css CHANGED
@@ -1,280 +1,280 @@
1
- .analyst-action-opt {
2
- cursor: pointer;
3
- }
4
-
5
- .analyst-modal {
6
- color: #000000;
7
- display: none;
8
- position: fixed;
9
- z-index: 1000;
10
- padding-top: 100px;
11
- left: 0;
12
- top: 0;
13
- width: 100%;
14
- height: 100%;
15
- overflow: auto;
16
- background-color: rgb(0,0,0);
17
- background-color: rgba(0,0,0,0.4);
18
- }
19
-
20
- .analyst-modal-content {
21
- font-family: Helvetica, serif;
22
- position: relative;
23
- background-color: #fefefe;
24
- margin: auto;
25
- padding: 35px 35px 20px;
26
- border: 1px solid #F2F2F2;
27
- width: 40%;
28
- box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19);
29
- -webkit-animation-name: analyst-animatetop;
30
- -webkit-animation-duration: 0.4s;
31
- animation-name: analyst-animatetop;
32
- animation-duration: 0.4s
33
- }
34
-
35
- .analyst-btn-success {
36
- cursor: pointer;
37
- color: #ffffff;
38
- background-color: #00AF5E;
39
- border: none;
40
- width: 100%;
41
- font-size: 18px;
42
- padding: 8px;
43
- font-weight: bold;
44
- }
45
-
46
- .analyst-btn-grey {
47
- cursor: pointer;
48
- color: #2D2D2D;
49
- background-color: #D8D8D8;
50
- border: none;
51
- width: 100%;
52
- font-size: 18px;
53
- padding: 8px;
54
- font-weight: bold;
55
- }
56
-
57
- .analyst-btn-secondary-ghost {
58
- cursor: pointer;
59
- background: transparent;
60
- border: none;
61
- color: #898686;
62
- font-size: 18px;
63
- }
64
-
65
- .analyst-modal-def-top-padding {
66
- padding-top: 20px;
67
- }
68
-
69
- .analyst-modal-header {
70
- font-size: 20px;
71
- font-weight: bold;
72
- }
73
-
74
- /*INSTALL STYLES*/
75
- .analyst-install-footer {
76
- padding-top: 10px;
77
- text-align: center;
78
- }
79
-
80
- .analyst-install-image-block {
81
- width: 140px;
82
- }
83
-
84
- .analyst-install-image-block img {
85
- width: inherit;
86
- }
87
-
88
- .analyst-install-description-block {
89
- padding-left: 40px;
90
- padding-top: 5px
91
- }
92
-
93
- .analyst-install-description-text {
94
- font-size: 16px;
95
- color: #000000;
96
- }
97
-
98
- .analyst-install-permissions-list {
99
- list-style: disc inside;
100
- }
101
-
102
- .analyst-install-permissions-list li {
103
- padding-left: 15px;
104
- margin-bottom: 2px;
105
- }
106
-
107
- .analyst-install-footer span {
108
- color: #8a8787;
109
- padding-right: 10px;
110
- padding-left: 10px;
111
- }
112
-
113
- .analyst-install-footer span:not(:last-child) {
114
- border-right: 1px solid #8a8787;
115
- }
116
-
117
- /*INSTALL STYLES*/
118
-
119
- .reason-answer {
120
- padding: 7px;
121
- margin-left: 23px;
122
- border: 1px solid #F2F2F2;
123
- }
124
-
125
- .analyst-link {
126
- color: #00AF5E;
127
- text-decoration: none;
128
- }
129
-
130
- .analyst-action-text {
131
- cursor: pointer;
132
- }
133
-
134
- .analyst-action-text:hover {
135
- color: #9d9a9a;
136
- }
137
-
138
- .analyst-disable-modal-mask {
139
- width: 100%;
140
- height: 100%;
141
- opacity: 0.5;
142
- position: absolute;
143
- background: white;
144
- top: 0;
145
- left: 0;
146
- }
147
-
148
- .analyst-smile-image {
149
- vertical-align: middle;
150
- padding-bottom: 3px;
151
- width: 24px;
152
- }
153
-
154
- #analyst-deactivation-reasons li {
155
- padding-bottom: 3px;
156
- font-size: 16px;
157
- color: #000000;
158
- }
159
-
160
- @-webkit-keyframes analyst-animatetop {
161
- from {top:-300px; opacity:0}
162
- to {top:0; opacity:1}
163
- }
164
-
165
- @keyframes analyst-animatetop {
166
- from {top:-300px; opacity:0}
167
- to {top:0; opacity:1}
168
- }
169
-
170
- .analyst-modal-close {
171
- color: #48036F;
172
- font-size: 28px;
173
- font-weight: bold;
174
- top: 12px;
175
- position: absolute;
176
- right: 15px;
177
- }
178
-
179
- .analyst-modal-close:hover,
180
- .analyst-modal-close:focus {
181
- color: #000;
182
- text-decoration: none;
183
- cursor: pointer;
184
- }
185
-
186
- .analyst-modal-body {padding: 2px 16px;}
187
-
188
- .analyst-modal-footer {
189
- padding: 6px 16px;
190
- background-color: #FFE773;
191
- color: white;
192
- }
193
-
194
- #analyst-deactivate-modal .question-answer input, textarea {
195
- margin-top: 5px;
196
- width: 100%;
197
- }
198
-
199
- .analyst-btn-primary {
200
- cursor: pointer;
201
- border: none;
202
- display:inline-block;
203
- padding:0.7em 1.4em;
204
- margin:0 0.3em 0.3em 0;
205
- border-radius:0.15em;
206
- box-sizing: border-box;
207
- text-decoration:none;
208
- font-family:'Roboto',sans-serif;
209
- text-transform:uppercase;
210
- font-weight:400;
211
- color:#FFFFFF;
212
- background-color:#9F3ED5;
213
- box-shadow:inset 0 -0.6em 0 -0.35em rgba(0,0,0,0.17);
214
- text-align:center;
215
- position:relative;
216
- }
217
-
218
- .analyst-btn-primary:disabled {
219
- background-color: #AD66D5;
220
- cursor: not-allowed;
221
- }
222
-
223
- .analyst-btn-primary:active{
224
- top:0.1em;
225
- }
226
- @media all and (max-width:30em){
227
- .analyst-btn-primary {
228
- display:block;
229
- margin:0.4em auto;
230
- }
231
- }
232
-
233
- .analyst-btn-secondary {
234
- cursor: pointer;
235
- border: none;
236
- display:inline-block;
237
- padding:0.7em 1.4em;
238
- margin:0 0.3em 0.3em 0;
239
- border-radius:0.15em;
240
- box-sizing: border-box;
241
- text-decoration:none;
242
- font-family:'Roboto',sans-serif;
243
- text-transform:uppercase;
244
- font-weight:400;
245
- color:#FFFFFF;
246
- background-color:#6C8CD5;
247
- box-shadow:inset 0 -0.6em 0 -0.35em rgba(0,0,0,0.17);
248
- text-align:center;
249
- position:relative;
250
- }
251
-
252
- .analyst-btn-secondary:disabled {
253
- background-color: #6C8CD5;
254
- cursor: not-allowed;
255
- }
256
-
257
- .analyst-btn-secondary:active{
258
- top:0.1em;
259
- }
260
- @media all and (max-width:30em){
261
- .analyst-btn-secondary {
262
- display:block;
263
- margin:0.4em auto;
264
- }
265
- }
266
-
267
- .analyst-notice {
268
- padding-right: 38px;
269
- position: relative;
270
- margin-bottom: 30px !important;
271
- }
272
-
273
- .analyst-notice .analyst-plugin-name {
274
- background-color: #00000024;
275
- padding-left: 7px;
276
- padding-right: 7px;
277
- position: absolute;
278
- top: 100%;
279
- border-radius: 0 0 5px 5px;
280
- }
1
+ .analyst-action-opt {
2
+ cursor: pointer;
3
+ }
4
+
5
+ .analyst-modal {
6
+ color: #000000;
7
+ display: none;
8
+ position: fixed;
9
+ z-index: 1000;
10
+ padding-top: 100px;
11
+ left: 0;
12
+ top: 0;
13
+ width: 100%;
14
+ height: 100%;
15
+ overflow: auto;
16
+ background-color: rgb(0,0,0);
17
+ background-color: rgba(0,0,0,0.4);
18
+ }
19
+
20
+ .analyst-modal-content {
21
+ font-family: Helvetica, serif;
22
+ position: relative;
23
+ background-color: #fefefe;
24
+ margin: auto;
25
+ padding: 35px 35px 20px;
26
+ border: 1px solid #F2F2F2;
27
+ width: 40%;
28
+ box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19);
29
+ -webkit-animation-name: analyst-animatetop;
30
+ -webkit-animation-duration: 0.4s;
31
+ animation-name: analyst-animatetop;
32
+ animation-duration: 0.4s
33
+ }
34
+
35
+ .analyst-btn-success {
36
+ cursor: pointer;
37
+ color: #ffffff;
38
+ background-color: #00AF5E;
39
+ border: none;
40
+ width: 100%;
41
+ font-size: 18px;
42
+ padding: 8px;
43
+ font-weight: bold;
44
+ }
45
+
46
+ .analyst-btn-grey {
47
+ cursor: pointer;
48
+ color: #2D2D2D;
49
+ background-color: #D8D8D8;
50
+ border: none;
51
+ width: 100%;
52
+ font-size: 18px;
53
+ padding: 8px;
54
+ font-weight: bold;
55
+ }
56
+
57
+ .analyst-btn-secondary-ghost {
58
+ cursor: pointer;
59
+ background: transparent;
60
+ border: none;
61
+ color: #898686;
62
+ font-size: 18px;
63
+ }
64
+
65
+ .analyst-modal-def-top-padding {
66
+ padding-top: 20px;
67
+ }
68
+
69
+ .analyst-modal-header {
70
+ font-size: 20px;
71
+ font-weight: bold;
72
+ }
73
+
74
+ /*INSTALL STYLES*/
75
+ .analyst-install-footer {
76
+ padding-top: 10px;
77
+ text-align: center;
78
+ }
79
+
80
+ .analyst-install-image-block {
81
+ width: 140px;
82
+ }
83
+
84
+ .analyst-install-image-block img {
85
+ width: inherit;
86
+ }
87
+
88
+ .analyst-install-description-block {
89
+ padding-left: 40px;
90
+ padding-top: 5px
91
+ }
92
+
93
+ .analyst-install-description-text {
94
+ font-size: 16px;
95
+ color: #000000;
96
+ }
97
+
98
+ .analyst-install-permissions-list {
99
+ list-style: disc inside;
100
+ }
101
+
102
+ .analyst-install-permissions-list li {
103
+ padding-left: 15px;
104
+ margin-bottom: 2px;
105
+ }
106
+
107
+ .analyst-install-footer span {
108
+ color: #8a8787;
109
+ padding-right: 10px;
110
+ padding-left: 10px;
111
+ }
112
+
113
+ .analyst-install-footer span:not(:last-child) {
114
+ border-right: 1px solid #8a8787;
115
+ }
116
+
117
+ /*INSTALL STYLES*/
118
+
119
+ .reason-answer {
120
+ padding: 7px;
121
+ margin-left: 23px;
122
+ border: 1px solid #F2F2F2;
123
+ }
124
+
125
+ .analyst-link {
126
+ color: #00AF5E;
127
+ text-decoration: none;
128
+ }
129
+
130
+ .analyst-action-text {
131
+ cursor: pointer;
132
+ }
133
+
134
+ .analyst-action-text:hover {
135
+ color: #9d9a9a;
136
+ }
137
+
138
+ .analyst-disable-modal-mask {
139
+ width: 100%;
140
+ height: 100%;
141
+ opacity: 0.5;
142
+ position: absolute;
143
+ background: white;
144
+ top: 0;
145
+ left: 0;
146
+ }
147
+
148
+ .analyst-smile-image {
149
+ vertical-align: middle;
150
+ padding-bottom: 3px;
151
+ width: 24px;
152
+ }
153
+
154
+ #analyst-deactivation-reasons li {
155
+ padding-bottom: 3px;
156
+ font-size: 16px;
157
+ color: #000000;
158
+ }
159
+
160
+ @-webkit-keyframes analyst-animatetop {
161
+ from {top:-300px; opacity:0}
162
+ to {top:0; opacity:1}
163
+ }
164
+
165
+ @keyframes analyst-animatetop {
166
+ from {top:-300px; opacity:0}
167
+ to {top:0; opacity:1}
168
+ }
169
+
170
+ .analyst-modal-close {
171
+ color: #48036F;
172
+ font-size: 28px;
173
+ font-weight: bold;
174
+ top: 12px;
175
+ position: absolute;
176
+ right: 15px;
177
+ }
178
+
179
+ .analyst-modal-close:hover,
180
+ .analyst-modal-close:focus {
181
+ color: #000;
182
+ text-decoration: none;
183
+ cursor: pointer;
184
+ }
185
+
186
+ .analyst-modal-body {padding: 2px 16px;}
187
+
188
+ .analyst-modal-footer {
189
+ padding: 6px 16px;
190
+ background-color: #FFE773;
191
+ color: white;
192
+ }
193
+
194
+ #analyst-deactivate-modal .question-answer input, textarea {
195
+ margin-top: 5px;
196
+ width: 100%;
197
+ }
198
+
199
+ .analyst-btn-primary {
200
+ cursor: pointer;
201
+ border: none;
202
+ display:inline-block;
203
+ padding:0.7em 1.4em;
204
+ margin:0 0.3em 0.3em 0;
205
+ border-radius:0.15em;
206
+ box-sizing: border-box;
207
+ text-decoration:none;
208
+ font-family:'Roboto',sans-serif;
209
+ text-transform:uppercase;
210
+ font-weight:400;
211
+ color:#FFFFFF;
212
+ background-color:#9F3ED5;
213
+ box-shadow:inset 0 -0.6em 0 -0.35em rgba(0,0,0,0.17);
214
+ text-align:center;
215
+ position:relative;
216
+ }
217
+
218
+ .analyst-btn-primary:disabled {
219
+ background-color: #AD66D5;
220
+ cursor: not-allowed;
221
+ }
222
+
223
+ .analyst-btn-primary:active{
224
+ top:0.1em;
225
+ }
226
+ @media all and (max-width:30em){
227
+ .analyst-btn-primary {
228
+ display:block;
229
+ margin:0.4em auto;
230
+ }
231
+ }
232
+
233
+ .analyst-btn-secondary {
234
+ cursor: pointer;
235
+ border: none;
236
+ display:inline-block;
237
+ padding:0.7em 1.4em;
238
+ margin:0 0.3em 0.3em 0;
239
+ border-radius:0.15em;
240
+ box-sizing: border-box;
241
+ text-decoration:none;
242
+ font-family:'Roboto',sans-serif;
243
+ text-transform:uppercase;
244
+ font-weight:400;
245
+ color:#FFFFFF;
246
+ background-color:#6C8CD5;
247
+ box-shadow:inset 0 -0.6em 0 -0.35em rgba(0,0,0,0.17);
248
+ text-align:center;
249
+ position:relative;
250
+ }
251
+
252
+ .analyst-btn-secondary:disabled {
253
+ background-color: #6C8CD5;
254
+ cursor: not-allowed;
255
+ }
256
+
257
+ .analyst-btn-secondary:active{
258
+ top:0.1em;
259
+ }
260
+ @media all and (max-width:30em){
261
+ .analyst-btn-secondary {
262
+ display:block;
263
+ margin:0.4em auto;
264
+ }
265
+ }
266
+
267
+ .analyst-notice {
268
+ padding-right: 38px;
269
+ position: relative;
270
+ margin-bottom: 30px !important;
271
+ }
272
+
273
+ .analyst-notice .analyst-plugin-name {
274
+ background-color: #00000024;
275
+ padding-left: 7px;
276
+ padding-right: 7px;
277
+ position: absolute;
278
+ top: 100%;
279
+ border-radius: 0 0 5px 5px;
280
+ }
analyst/assets/index.php CHANGED
@@ -1,2 +1,2 @@
1
- <?php
2
- // Silence is golden.
1
+ <?php
2
+ // Silence is golden.
analyst/assets/js/customize.js CHANGED
@@ -1,29 +1,29 @@
1
- (function ($) {
2
- $(document).on('click', '.analyst-notice-dismiss', function () {
3
- var id = $(this).attr('analyst-notice-id');
4
- var self = this;
5
-
6
- $.post(ajaxurl, {action: 'analyst_notification_dismiss', id: id})
7
- .done(function () {
8
- $(self).parent().fadeOut()
9
- })
10
- })
11
-
12
- var url = new URL(window.location.href)
13
-
14
- if (url.searchParams.has('verify')) {
15
- var pluginId = url.searchParams.get('plugin_id')
16
-
17
- $.ajax({
18
- url: ajaxurl,
19
- method: 'POST',
20
- data: {
21
- action: 'analyst_install_verified_' + pluginId,
22
- },
23
- success: function () {
24
- // Refresh page without query params
25
- window.location.href = window.location.origin + window.location.pathname
26
- }
27
- })
28
- }
29
- })(jQuery)
1
+ (function ($) {
2
+ $(document).on('click', '.analyst-notice-dismiss', function () {
3
+ var id = $(this).attr('analyst-notice-id');
4
+ var self = this;
5
+
6
+ $.post(ajaxurl, {action: 'analyst_notification_dismiss', id: id})
7
+ .done(function () {
8
+ $(self).parent().fadeOut()
9
+ })
10
+ })
11
+
12
+ var url = new URL(window.location.href)
13
+
14
+ if (url.searchParams.has('verify')) {
15
+ var pluginId = url.searchParams.get('plugin_id')
16
+
17
+ $.ajax({
18
+ url: ajaxurl,
19
+ method: 'POST',
20
+ data: {
21
+ action: 'analyst_install_verified_' + pluginId,
22
+ },
23
+ success: function () {
24
+ // Refresh page without query params
25
+ window.location.href = window.location.origin + window.location.pathname
26
+ }
27
+ })
28
+ }
29
+ })(jQuery)
analyst/autoload.php CHANGED
@@ -1,40 +1,40 @@
1
- <?php
2
-
3
- require_once __DIR__ . '/src/helpers.php';
4
-
5
- require_once __DIR__ . '/src/Contracts/HttpClientContract.php';
6
- require_once __DIR__ . '/src/Contracts/RequestContract.php';
7
- require_once __DIR__ . '/src/Contracts/RequestorContract.php';
8
- require_once __DIR__ . '/src/Contracts/TrackerContract.php';
9
- require_once __DIR__ . '/src/Contracts/CacheContract.php';
10
-
11
- require_once __DIR__ . '/src/Core/AbstractFactory.php';
12
-
13
- require_once __DIR__ . '/src/Cache/DatabaseCache.php';
14
-
15
- require_once __DIR__ . '/src/Account/Account.php';
16
- require_once __DIR__ . '/src/Account/AccountData.php';
17
- require_once __DIR__ . '/src/Account/AccountDataFactory.php';
18
- require_once __DIR__ . '/src/Contracts/AnalystContract.php';
19
-
20
- require_once __DIR__ . '/src/Http/Requests/AbstractLoggerRequest.php';
21
- require_once __DIR__ . '/src/Http/Requests/ActivateRequest.php';
22
- require_once __DIR__ . '/src/Http/Requests/DeactivateRequest.php';
23
- require_once __DIR__ . '/src/Http/Requests/InstallRequest.php';
24
- require_once __DIR__ . '/src/Http/Requests/OptInRequest.php';
25
- require_once __DIR__ . '/src/Http/Requests/OptOutRequest.php';
26
- require_once __DIR__ . '/src/Http/Requests/UninstallRequest.php';
27
-
28
- require_once __DIR__ . '/src/Http/CurlHttpClient.php';
29
- require_once __DIR__ . '/src/Http/DummyHttpClient.php';
30
- require_once __DIR__ . '/src/Http/WordPressHttpClient.php';
31
-
32
- require_once __DIR__ . '/src/Notices/Notice.php';
33
- require_once __DIR__ . '/src/Notices/NoticeFactory.php';
34
-
35
- require_once __DIR__ . '/src/Analyst.php';
36
- require_once __DIR__ . '/src/ApiRequestor.php';
37
- require_once __DIR__ . '/src/ApiResponse.php';
38
- require_once __DIR__ . '/src/Collector.php';
39
- require_once __DIR__ . '/src/Mutator.php';
40
-
1
+ <?php
2
+
3
+ require_once __DIR__ . '/src/helpers.php';
4
+
5
+ require_once __DIR__ . '/src/Contracts/HttpClientContract.php';
6
+ require_once __DIR__ . '/src/Contracts/RequestContract.php';
7
+ require_once __DIR__ . '/src/Contracts/RequestorContract.php';
8
+ require_once __DIR__ . '/src/Contracts/TrackerContract.php';
9
+ require_once __DIR__ . '/src/Contracts/CacheContract.php';
10
+
11
+ require_once __DIR__ . '/src/Core/AbstractFactory.php';
12
+
13
+ require_once __DIR__ . '/src/Cache/DatabaseCache.php';
14
+
15
+ require_once __DIR__ . '/src/Account/Account.php';
16
+ require_once __DIR__ . '/src/Account/AccountData.php';
17
+ require_once __DIR__ . '/src/Account/AccountDataFactory.php';
18
+ require_once __DIR__ . '/src/Contracts/AnalystContract.php';
19
+
20
+ require_once __DIR__ . '/src/Http/Requests/AbstractLoggerRequest.php';
21
+ require_once __DIR__ . '/src/Http/Requests/ActivateRequest.php';
22
+ require_once __DIR__ . '/src/Http/Requests/DeactivateRequest.php';
23
+ require_once __DIR__ . '/src/Http/Requests/InstallRequest.php';
24
+ require_once __DIR__ . '/src/Http/Requests/OptInRequest.php';
25
+ require_once __DIR__ . '/src/Http/Requests/OptOutRequest.php';
26
+ require_once __DIR__ . '/src/Http/Requests/UninstallRequest.php';
27
+
28
+ require_once __DIR__ . '/src/Http/CurlHttpClient.php';
29
+ require_once __DIR__ . '/src/Http/DummyHttpClient.php';
30
+ require_once __DIR__ . '/src/Http/WordPressHttpClient.php';
31
+
32
+ require_once __DIR__ . '/src/Notices/Notice.php';
33
+ require_once __DIR__ . '/src/Notices/NoticeFactory.php';
34
+
35
+ require_once __DIR__ . '/src/Analyst.php';
36
+ require_once __DIR__ . '/src/ApiRequestor.php';
37
+ require_once __DIR__ . '/src/ApiResponse.php';
38
+ require_once __DIR__ . '/src/Collector.php';
39
+ require_once __DIR__ . '/src/Mutator.php';
40
+
analyst/index.php CHANGED
@@ -1,2 +1,2 @@
1
- <?php
2
- // Silence
1
+ <?php
2
+ // Silence
analyst/main.php CHANGED
@@ -1,36 +1,36 @@
1
- <?php
2
-
3
- require_once 'sdk_resolver.php';
4
-
5
-
6
- if (!function_exists('analyst_init')) {
7
- /**
8
- * Initialize analyst
9
- *
10
- * @param array $options
11
- */
12
- function analyst_init ($options) {
13
- // Try resolve latest supported SDK
14
- // In case resolving is failed exit the execution
15
- try {
16
- analyst_resolve_sdk($options['base-dir']);
17
- } catch (Exception $exception) {
18
- error_log('[ANALYST] Cannot resolve any supported SDK');
19
- return;
20
- }
21
-
22
- try {
23
- global /** @var Analyst\Analyst $analyst */
24
- $analyst;
25
-
26
- // Set global instance of analyst
27
- if (!$analyst) {
28
- $analyst = Analyst\Analyst::getInstance();
29
- }
30
-
31
- $analyst->registerAccount(new Account\Account($options['client-id'], $options['client-secret'], $options['base-dir']));
32
- } catch (Exception $e) {
33
- error_log('Analyst SDK receive an error: [' . $e->getMessage() . '] Please contact our support at support@analyst.com');
34
- }
35
- }
36
- }
1
+ <?php
2
+
3
+ require_once 'sdk_resolver.php';
4
+
5
+
6
+ if (!function_exists('analyst_init')) {
7
+ /**
8
+ * Initialize analyst
9
+ *
10
+ * @param array $options
11
+ */
12
+ function analyst_init ($options) {
13
+ // Try resolve latest supported SDK
14
+ // In case resolving is failed exit the execution
15
+ try {
16
+ analyst_resolve_sdk($options['base-dir']);
17
+ } catch (Exception $exception) {
18
+ error_log('[ANALYST] Cannot resolve any supported SDK');
19
+ return;
20
+ }
21
+
22
+ try {
23
+ global /** @var Analyst\Analyst $analyst */
24
+ $analyst;
25
+
26
+ // Set global instance of analyst
27
+ if (!$analyst) {
28
+ $analyst = Analyst\Analyst::getInstance();
29
+ }
30
+
31
+ $analyst->registerAccount(new Account\Account($options['client-id'], $options['client-secret'], $options['base-dir']));
32
+ } catch (Exception $e) {
33
+ error_log('Analyst SDK receive an error: [' . $e->getMessage() . '] Please contact our support at support@analyst.com');
34
+ }
35
+ }
36
+ }
analyst/sdk_resolver.php CHANGED
@@ -1,79 +1,79 @@
1
- <?php
2
-
3
- if (!function_exists('analyst_resolve_sdk')) {
4
-
5
- /**
6
- * Resolve supported sdk versions and load latest supported one
7
- * also bootstrap sdk with autoloader
8
- *
9
- * @since 1.1.3
10
- *
11
- * @param null $thisPluginPath
12
- * @return void
13
- * @throws Exception
14
- */
15
- function analyst_resolve_sdk($thisPluginPath = null) {
16
- static $loaded = false;
17
-
18
- // Exit if we already resolved SDK
19
- if ($loaded) return;
20
-
21
- $plugins = get_option('active_plugins');
22
-
23
- if ($thisPluginPath) {
24
- array_push($plugins, plugin_basename($thisPluginPath));
25
- }
26
-
27
- $pluginsFolder = WP_PLUGIN_DIR;
28
-
29
- $possibleSDKs = array_map(function ($path) use ($pluginsFolder) {
30
- $sdkFolder = sprintf('%s/%s/analyst/', $pluginsFolder, dirname($path));
31
-
32
- $sdkFolder = str_replace('\\', '/', $sdkFolder);
33
-
34
- $versionPath = $sdkFolder . 'version.php';
35
-
36
- if (file_exists($versionPath)) {
37
- return require $versionPath;
38
- }
39
-
40
- return false;
41
- }, $plugins);
42
-
43
- global $wp_version;
44
-
45
- // Filter out plugins which has no SDK
46
- $SDKs = array_filter($possibleSDKs, function ($s) {return is_array($s);});
47
-
48
- // Filter SDKs which is supported by PHP and WP
49
- $supported = array_values(array_filter($SDKs, function ($sdk) use($wp_version) {
50
- $phpSupported = version_compare(PHP_VERSION, $sdk['php']) >= 0;
51
- $wpSupported = version_compare($wp_version, $sdk['wp']) >= 0;
52
-
53
- return $phpSupported && $wpSupported;
54
- }));
55
-
56
- // Sort SDK by version in descending order
57
- uasort($supported, function ($x, $y) {
58
- return version_compare($y['sdk'], $x['sdk']);
59
- });
60
-
61
- // Reset sorted values keys
62
- $supported = array_values($supported);
63
-
64
- if (!isset($supported[0])) {
65
- throw new Exception('There is no SDK which is support current PHP version and WP version');
66
- }
67
-
68
- // Autoload files for supported SDK
69
- $autoloaderPath = str_replace(
70
- '\\',
71
- '/',
72
- sprintf('%s/autoload.php', $supported[0]['path'])
73
- );
74
-
75
- require_once $autoloaderPath;
76
-
77
- $loaded = true;
78
- }
79
- }
1
+ <?php
2
+
3
+ if (!function_exists('analyst_resolve_sdk')) {
4
+
5
+ /**
6
+ * Resolve supported sdk versions and load latest supported one
7
+ * also bootstrap sdk with autoloader
8
+ *
9
+ * @since 1.1.3
10
+ *
11
+ * @param null $thisPluginPath
12
+ * @return void
13
+ * @throws Exception
14
+ */
15
+ function analyst_resolve_sdk($thisPluginPath = null) {
16
+ static $loaded = false;
17
+
18
+ // Exit if we already resolved SDK
19
+ if ($loaded) return;
20
+
21
+ $plugins = get_option('active_plugins');
22
+
23
+ if ($thisPluginPath) {
24
+ array_push($plugins, plugin_basename($thisPluginPath));
25
+ }
26
+
27
+ $pluginsFolder = WP_PLUGIN_DIR;
28
+
29
+ $possibleSDKs = array_map(function ($path) use ($pluginsFolder) {
30
+ $sdkFolder = sprintf('%s/%s/analyst/', $pluginsFolder, dirname($path));
31
+
32
+ $sdkFolder = str_replace('\\', '/', $sdkFolder);
33
+
34
+ $versionPath = $sdkFolder . 'version.php';
35
+
36
+ if (file_exists($versionPath)) {
37
+ return require $versionPath;
38
+ }
39
+
40
+ return false;
41
+ }, $plugins);
42
+
43
+ global $wp_version;
44
+
45
+ // Filter out plugins which has no SDK
46
+ $SDKs = array_filter($possibleSDKs, function ($s) {return is_array($s);});
47
+
48
+ // Filter SDKs which is supported by PHP and WP
49
+ $supported = array_values(array_filter($SDKs, function ($sdk) use($wp_version) {
50
+ $phpSupported = version_compare(PHP_VERSION, $sdk['php']) >= 0;
51
+ $wpSupported = version_compare($wp_version, $sdk['wp']) >= 0;
52
+
53
+ return $phpSupported && $wpSupported;
54
+ }));
55
+
56
+ // Sort SDK by version in descending order
57
+ uasort($supported, function ($x, $y) {
58
+ return version_compare($y['sdk'], $x['sdk']);
59
+ });
60
+
61
+ // Reset sorted values keys
62
+ $supported = array_values($supported);
63
+
64
+ if (!isset($supported[0])) {
65
+ throw new Exception('There is no SDK which is support current PHP version and WP version');
66
+ }
67
+
68
+ // Autoload files for supported SDK
69
+ $autoloaderPath = str_replace(
70
+ '\\',
71
+ '/',
72
+ sprintf('%s/autoload.php', $supported[0]['path'])
73
+ );
74
+
75
+ require_once $autoloaderPath;
76
+
77
+ $loaded = true;
78
+ }
79
+ }
analyst/src/Account/Account.php CHANGED
@@ -1,584 +1,584 @@
1
- <?php
2
-
3
- namespace Account;
4
-
5
- use Analyst\Analyst;
6
- use Analyst\ApiRequestor;
7
- use Analyst\Cache\DatabaseCache;
8
- use Analyst\Collector;
9
- use Analyst\Http\Requests\ActivateRequest;
10
- use Analyst\Http\Requests\DeactivateRequest;
11
- use Analyst\Http\Requests\InstallRequest;
12
- use Analyst\Http\Requests\OptInRequest;
13
- use Analyst\Http\Requests\OptOutRequest;
14
- use Analyst\Http\Requests\UninstallRequest;
15
- use Analyst\Notices\Notice;
16
- use Analyst\Notices\NoticeFactory;
17
- use Analyst\Contracts\TrackerContract;
18
- use Analyst\Contracts\RequestorContract;
19
-
20
- /**
21
- * Class Account
22
- *
23
- * This is plugin's account object
24
- */
25
- class Account implements TrackerContract
26
- {
27
- /**
28
- * Account id
29
- *
30
- * @var string
31
- */
32
- protected $id;
33
-
34
- /**
35
- * Basename of plugin
36
- *
37
- * @var string
38
- */
39
- protected $path;
40
-
41
- /**
42
- * Whether plugin is active or not
43
- *
44
- * @var bool
45
- */
46
- protected $isInstalled = false;
47
-
48
- /**
49
- * Is user sign in for data tracking
50
- *
51
- * @var bool
52
- */
53
- protected $isOptedIn = false;
54
-
55
- /**
56
- * Is user accepted permissions grant
57
- * for collection site data
58
- *
59
- * @var bool
60
- */
61
- protected $isSigned = false;
62
-
63
- /**
64
- * Is user ever resolved install modal window?
65
- *
66
- * @var bool
67
- */
68
- protected $isInstallResolved = false;
69
-
70
- /**
71
- * Public secret code
72
- *
73
- * @var string
74
- */
75
- protected $clientSecret;
76
-
77
- /**
78
- * @var AccountData
79
- */
80
- protected $data;
81
-
82
- /**
83
- * Base plugin path
84
- *
85
- * @var string
86
- */
87
- protected $basePluginPath;
88
-
89
- /**
90
- * @var RequestorContract
91
- */
92
- protected $requestor;
93
-
94
- /**
95
- * @var Collector
96
- */
97
- protected $collector;
98
-
99
- /**
100
- * Account constructor.
101
- * @param $id
102
- * @param $secret
103
- * @param $baseDir
104
- */
105
- public function __construct($id, $secret, $baseDir)
106
- {
107
- $this->id = $id;
108
- $this->clientSecret = $secret;
109
-
110
- $this->path = $baseDir;
111
-
112
- $this->basePluginPath = plugin_basename($baseDir);
113
- }
114
-
115
- /**
116
- * @return string
117
- */
118
- public function getPath()
119
- {
120
- return $this->path;
121
- }
122
-
123
- /**
124
- * @param string $path
125
- */
126
- public function setPath($path)
127
- {
128
- $this->data->setPath($path);
129
-
130
- $this->path = $path;
131
- }
132
-
133
- /**
134
- * @return bool
135
- */
136
- public function isOptedIn()
137
- {
138
- return $this->isOptedIn;
139
- }
140
-
141
- /**
142
- * @param bool $isOptedIn
143
- */
144
- public function setIsOptedIn($isOptedIn)
145
- {
146
- $this->data->setIsOptedIn($isOptedIn);
147
-
148
- $this->isOptedIn = $isOptedIn;
149
- }
150
-
151
- /**
152
- * Whether plugin is active
153
- *
154
- * @return bool
155
- */
156
- public function isActive()
157
- {
158
- return is_plugin_active($this->path);
159
- }
160
-
161
- /**
162
- * @param string $id
163
- */
164
- public function setId($id)
165
- {
166
- $this->id = $id;
167
- }
168
-
169
- /**
170
- * @return string
171
- */
172
- public function getId()
173
- {
174
- return $this->id;
175
- }
176
-
177
- /**
178
- * @return bool
179
- */
180
- public function isInstalled()
181
- {
182
- return $this->isInstalled;
183
- }
184
-
185
- /**
186
- * @param bool $isInstalled
187
- */
188
- public function setIsInstalled($isInstalled)
189
- {
190
- $this->data->setIsInstalled($isInstalled);
191
-
192
- $this->isInstalled = $isInstalled;
193
- }
194
-
195
- /**
196
- * Should register activation and deactivation
197
- * event hooks
198
- *
199
- * @return void
200
- */
201
- public function registerHooks()
202
- {
203
- register_activation_hook($this->basePluginPath, [&$this, 'onActivePluginListener']);
204
- register_uninstall_hook($this->basePluginPath, ['Account\Account', 'onUninstallPluginListener']);
205
-
206
- $this->addFilter('plugin_action_links', [&$this, 'onRenderActionLinksHook']);
207
-
208
- $this->addAjax('analyst_opt_in', [&$this, 'onOptInListener']);
209
- $this->addAjax('analyst_opt_out', [&$this, 'onOptOutListener']);
210
- $this->addAjax('analyst_plugin_deactivate', [&$this, 'onDeactivatePluginListener']);
211
- $this->addAjax('analyst_install', [&$this, 'onInstallListener']);
212
- $this->addAjax('analyst_skip_install', [&$this, 'onSkipInstallListener']);
213
- $this->addAjax('analyst_install_verified', [&$this, 'onInstallVerifiedListener']);
214
- }
215
-
216
- /**
217
- * Will fire when admin activates plugin
218
- *
219
- * @return void
220
- */
221
- public function onActivePluginListener()
222
- {
223
- if (!$this->isInstallResolved()) {
224
- DatabaseCache::getInstance()->put('plugin_to_install', $this->id);
225
- }
226
-
227
- if (!$this->isAllowingLogging()) return;
228
-
229
- ActivateRequest::make($this->collector, $this->id, $this->path)
230
- ->execute($this->requestor);
231
-
232
- $this->setIsInstalled(true);
233
-
234
- AccountDataFactory::syncData();
235
- }
236
-
237
- /**
238
- * Will fire when admin deactivates plugin
239
- *
240
- * @return void
241
- */
242
- public function onDeactivatePluginListener()
243
- {
244
- if (!$this->isAllowingLogging()) return;
245
-
246
- $question = isset($_POST['question']) ? stripslashes($_POST['question']) : null;
247
- $reason = isset($_POST['reason']) ? stripslashes($_POST['reason']) : null;
248
-
249
- DeactivateRequest::make($this->collector, $this->id, $this->path, $question, $reason)
250
- ->execute($this->requestor);
251
-
252
- $this->setIsInstalled(false);
253
-
254
- AccountDataFactory::syncData();
255
-
256
- wp_send_json_success();
257
- }
258
-
259
- /**
260
- * Will fire when user opted in
261
- *
262
- * @return void
263
- */
264
- public function onOptInListener()
265
- {
266
- OptInRequest::make($this->collector, $this->id, $this->path)->execute($this->requestor);
267
-
268
- $this->setIsOptedIn(true);
269
-
270
- AccountDataFactory::syncData();
271
-
272
- wp_die();
273
- }
274
-
275
- /**
276
- * Will fire when user opted out
277
- *
278
- * @return void
279
- */
280
- public function onOptOutListener()
281
- {
282
- OptOutRequest::make($this->collector, $this->id, $this->path)->execute($this->requestor);
283
-
284
- $this->setIsOptedIn(false);
285
-
286
- AccountDataFactory::syncData();
287
-
288
- wp_send_json_success();
289
- }
290
-
291
- /**
292
- * Will fire when user accept opt-in
293
- * at first time
294
- *
295
- * @return void
296
- */
297
- public function onInstallListener()
298
- {
299
- $cache = DatabaseCache::getInstance();
300
-
301
- // Set flag to true which indicates that install is resolved
302
- // also remove install plugin id from cache
303
- $this->setIsInstallResolved(true);
304
- $cache->delete('plugin_to_install');
305
-
306
- InstallRequest::make($this->collector, $this->id, $this->path)->execute($this->requestor);
307
-
308
- $this->setIsSigned(true);
309
-
310
- $this->setIsOptedIn(true);
311
-
312
- $factory = NoticeFactory::instance();
313
-
314
- $message = sprintf('Please confirm your email by clicking on the link we sent to %s. This makes sure you’re not a bot.', $this->collector->getGeneralEmailAddress());
315
-
316
- $notificationId = uniqid();
317
-
318
- $notice = Notice::make(
319
- $notificationId,
320
- $this->getId(),
321
- $message,
322
- $this->collector->getPluginName($this->path)
323
- );
324
-
325
- $factory->addNotice($notice);
326
-
327
- AccountDataFactory::syncData();
328
-
329
- // Set email confirmation notification id to cache
330
- // se we can extract and remove it when user confirmed email
331
- $cache->put(
332
- sprintf('account_email_confirmation_%s', $this->getId()),
333
- $notificationId
334
- );
335
-
336
- wp_send_json_success();
337
- }
338
-
339
- /**
340
- * Will fire when user skipped installation
341
- *
342
- * @return void
343
- */
344
- public function onSkipInstallListener()
345
- {
346
- // Set flag to true which indicates that install is resolved
347
- // also remove install plugin id from cache
348
- $this->setIsInstallResolved(true);
349
- DatabaseCache::getInstance()->delete('plugin_to_install');
350
- }
351
-
352
- /**
353
- * Will fire when user delete plugin through admin panel.
354
- * This action will happen if admin at least once
355
- * activated the plugin.
356
- *
357
- * @return void
358
- * @throws \Exception
359
- */
360
- public static function onUninstallPluginListener()
361
- {
362
- $factory = AccountDataFactory::instance();
363
-
364
- $pluginFile = substr(current_filter(), strlen( 'uninstall_' ));
365
-
366
- $account = $factory->getAccountDataByBasePath($pluginFile);
367
-
368
- // If account somehow is not found, exit the execution
369
- if (!$account) return;
370
-
371
- $analyst = Analyst::getInstance();
372
-
373
- $collector = new Collector($analyst);
374
-
375
- $requestor = new ApiRequestor($account->getId(), $account->getSecret(), $analyst->getApiBase());
376
-
377
- // Just send request to log uninstall event not caring about response
378
- UninstallRequest::make($collector, $account->getId(), $account->getPath())->execute($requestor);
379
-
380
- $factory->sync();
381
- }
382
-
383
- /**
384
- * Fires when used verified his account
385
- */
386
- public function onInstallVerifiedListener()
387
- {
388
- $factory = NoticeFactory::instance();
389
-
390
- $notice = Notice::make(
391
- uniqid(),
392
- $this->getId(),
393
- 'Thank you for confirming your email.',
394
- $this->collector->getPluginName($this->path)
395
- );
396
-
397
- $factory->addNotice($notice);
398
-
399
- // Remove confirmation notification
400
- $confirmationNotificationId = DatabaseCache::getInstance()->pop(sprintf('account_email_confirmation_%s', $this->getId()));
401
- $factory->remove($confirmationNotificationId);
402
-
403
- AccountDataFactory::syncData();
404
-
405
- wp_send_json_success();
406
- }
407
-
408
- /**
409
- * Will fire when wp renders plugin
410
- * action buttons
411
- *
412
- * @param $defaultLinks
413
- * @return array
414
- */
415
- public function onRenderActionLinksHook($defaultLinks)
416
- {
417
- $customLinks = [];
418
-
419
- $customLinks[] = $this->isOptedIn()
420
- ? '<a class="analyst-action-opt analyst-opt-out" analyst-plugin-id="' . $this->getId() . '" analyst-plugin-signed="' . (int) $this->isSigned() . '">Opt Out</a>'
421
- : '<a class="analyst-action-opt analyst-opt-in" analyst-plugin-id="' . $this->getId() . '" analyst-plugin-signed="' . (int) $this->isSigned() . '">Opt In</a>';
422
-
423
- // Append anchor to find specific deactivation link
424
- if (isset($defaultLinks['deactivate'])) {
425
- $defaultLinks['deactivate'] .= '<span analyst-plugin-id="' . $this->getId() . '" analyst-plugin-opted-in="' . (int) $this->isOptedIn() . '"></span>';
426
- }
427
-
428
- return array_merge($customLinks, $defaultLinks);
429
- }
430
-
431
- /**
432
- * @return AccountData
433
- */
434
- public function getData()
435
- {
436
- return $this->data;
437
- }
438
-
439
- /**
440
- * @param AccountData $data
441
- */
442
- public function setData(AccountData $data)
443
- {
444
- $this->data = $data;
445
-
446
- $this->setIsOptedIn($data->isOptedIn());
447
- $this->setIsInstalled($data->isInstalled());
448
- $this->setIsSigned($data->isSigned());
449
- $this->setIsInstallResolved($data->isInstallResolved());
450
- }
451
-
452
- /**
453
- * Resolves valid action name
454
- * based on client id
455
- *
456
- * @param $action
457
- * @return string
458
- */
459
- private function resolveActionName($action)
460
- {
461
- return sprintf('%s_%s', $action, $this->id);
462
- }
463
-
464
- /**
465
- * Register action for current plugin
466
- *
467
- * @param $action
468
- * @param $callback
469
- */
470
- private function addFilter($action, $callback)
471
- {
472
- $validAction = sprintf('%s_%s', $action, $this->basePluginPath);
473
-
474
- add_filter($validAction, $callback, 10);
475
- }
476
-
477
- /**
478
- * Add ajax action for current plugin
479
- *
480
- * @param $action
481
- * @param $callback
482
- * @param bool $raw Format action ??
483
- */
484
- private function addAjax($action, $callback, $raw = false)
485
- {
486
- $validAction = $raw ? $action : sprintf('%s%s', 'wp_ajax_', $this->resolveActionName($action));
487
-
488
- add_action($validAction, $callback);
489
- }
490
-
491
- /**
492
- * @return bool
493
- */
494
- public function isSigned()
495
- {
496
- return $this->isSigned;
497
- }
498
-
499
- /**
500
- * @param bool $isSigned
501
- */
502
- public function setIsSigned($isSigned)
503
- {
504
- $this->data->setIsSigned($isSigned);
505
-
506
- $this->isSigned = $isSigned;
507
- }
508
-
509
- /**
510
- * @return RequestorContract
511
- */
512
- public function getRequestor()
513
- {
514
- return $this->requestor;
515
- }
516
-
517
- /**
518
- * @param RequestorContract $requestor
519
- */
520
- public function setRequestor(RequestorContract $requestor)
521
- {
522
- $this->requestor = $requestor;
523
- }
524
-
525
- /**
526
- * @return string
527
- */
528
- public function getClientSecret()
529
- {
530
- return $this->clientSecret;
531
- }
532
-
533
- /**
534
- * @return Collector
535
- */
536
- public function getCollector()
537
- {
538
- return $this->collector;
539
- }
540
-
541
- /**
542
- * @param Collector $collector
543
- */
544
- public function setCollector(Collector $collector)
545
- {
546
- $this->collector = $collector;
547
- }
548
-
549
- /**
550
- * Do we allowing logging
551
- *
552
- * @return bool
553
- */
554
- public function isAllowingLogging()
555
- {
556
- return $this->isOptedIn;
557
- }
558
-
559
- /**
560
- * @return string
561
- */
562
- public function getBasePluginPath()
563
- {
564
- return $this->basePluginPath;
565
- }
566
-
567
- /**
568
- * @return bool
569
- */
570
- public function isInstallResolved()
571
- {
572
- return $this->isInstallResolved;
573
- }
574
-
575
- /**
576
- * @param bool $isInstallResolved
577
- */
578
- public function setIsInstallResolved($isInstallResolved)
579
- {
580
- $this->data->setIsInstallResolved($isInstallResolved);
581
-
582
- $this->isInstallResolved = $isInstallResolved;
583
- }
584
- }
1
+ <?php
2
+
3
+ namespace Account;
4
+
5
+ use Analyst\Analyst;
6
+ use Analyst\ApiRequestor;
7
+ use Analyst\Cache\DatabaseCache;
8
+ use Analyst\Collector;
9
+ use Analyst\Http\Requests\ActivateRequest;
10
+ use Analyst\Http\Requests\DeactivateRequest;
11
+ use Analyst\Http\Requests\InstallRequest;
12
+ use Analyst\Http\Requests\OptInRequest;
13
+ use Analyst\Http\Requests\OptOutRequest;
14
+ use Analyst\Http\Requests\UninstallRequest;
15
+ use Analyst\Notices\Notice;
16
+ use Analyst\Notices\NoticeFactory;
17
+ use Analyst\Contracts\TrackerContract;
18
+ use Analyst\Contracts\RequestorContract;
19
+
20
+ /**
21
+ * Class Account
22
+ *
23
+ * This is plugin's account object
24
+ */
25
+ class Account implements TrackerContract
26
+ {
27
+ /**
28
+ * Account id
29
+ *
30
+ * @var string
31
+ */
32
+ protected $id;
33
+
34
+ /**
35
+ * Basename of plugin
36
+ *
37
+ * @var string
38
+ */
39
+ protected $path;
40
+
41
+ /**
42
+ * Whether plugin is active or not
43
+ *
44
+ * @var bool
45
+ */
46
+ protected $isInstalled = false;
47
+
48
+ /**
49
+ * Is user sign in for data tracking
50
+ *
51
+ * @var bool
52
+ */
53
+ protected $isOptedIn = false;
54
+
55
+ /**
56
+ * Is user accepted permissions grant
57
+ * for collection site data
58
+ *
59
+ * @var bool
60
+ */
61
+ protected $isSigned = false;
62
+
63
+ /**
64
+ * Is user ever resolved install modal window?
65
+ *
66
+ * @var bool
67
+ */
68
+ protected $isInstallResolved = false;
69
+
70
+ /**
71
+ * Public secret code
72
+ *
73
+ * @var string
74
+ */
75
+ protected $clientSecret;
76
+
77
+ /**
78
+ * @var AccountData
79
+ */
80
+ protected $data;
81
+
82
+ /**
83
+ * Base plugin path
84
+ *
85
+ * @var string
86
+ */
87
+ protected $basePluginPath;
88
+
89
+ /**
90
+ * @var RequestorContract
91
+ */
92
+ protected $requestor;
93
+
94
+ /**
95
+ * @var Collector
96
+ */
97
+ protected $collector;
98
+
99
+ /**
100
+ * Account constructor.
101
+ * @param $id
102
+ * @param $secret
103
+ * @param $baseDir
104
+ */
105
+ public function __construct($id, $secret, $baseDir)
106
+ {
107
+ $this->id = $id;
108
+ $this->clientSecret = $secret;
109
+
110
+ $this->path = $baseDir;
111
+
112
+ $this->basePluginPath = plugin_basename($baseDir);
113
+ }
114
+
115
+ /**
116
+ * @return string
117
+ */
118
+ public function getPath()
119
+ {
120
+ return $this->path;
121
+ }
122
+
123
+ /**
124
+ * @param string $path
125
+ */
126
+ public function setPath($path)
127
+ {
128
+ $this->data->setPath($path);
129
+
130
+ $this->path = $path;
131
+ }
132
+
133
+ /**
134
+ * @return bool
135
+ */
136
+ public function isOptedIn()
137
+ {
138
+ return $this->isOptedIn;
139
+ }
140
+
141
+ /**
142
+ * @param bool $isOptedIn
143
+ */
144
+ public function setIsOptedIn($isOptedIn)
145
+ {
146
+ $this->data->setIsOptedIn($isOptedIn);
147
+
148
+ $this->isOptedIn = $isOptedIn;
149
+ }
150
+
151
+ /**
152
+ * Whether plugin is active
153
+ *
154
+ * @return bool
155
+ */
156
+ public function isActive()
157
+ {
158
+ return is_plugin_active($this->path);
159
+ }
160
+
161
+ /**
162
+ * @param string $id
163
+ */
164
+ public function setId($id)
165
+ {
166
+ $this->id = $id;
167
+ }
168
+
169
+ /**
170
+ * @return string
171
+ */
172
+ public function getId()
173
+ {
174
+ return $this->id;
175
+ }
176
+
177
+ /**
178
+ * @return bool
179
+ */
180
+ public function isInstalled()
181
+ {
182
+ return $this->isInstalled;
183
+ }
184
+
185
+ /**
186
+ * @param bool $isInstalled
187
+ */
188
+ public function setIsInstalled($isInstalled)
189
+ {
190
+ $this->data->setIsInstalled($isInstalled);
191
+
192
+ $this->isInstalled = $isInstalled;
193
+ }
194
+
195
+ /**
196
+ * Should register activation and deactivation
197
+ * event hooks
198
+ *
199
+ * @return void
200
+ */
201
+ public function registerHooks()
202
+ {
203
+ register_activation_hook($this->basePluginPath, [&$this, 'onActivePluginListener']);
204
+ register_uninstall_hook($this->basePluginPath, ['Account\Account', 'onUninstallPluginListener']);
205
+
206
+ $this->addFilter('plugin_action_links', [&$this, 'onRenderActionLinksHook']);
207
+
208
+ $this->addAjax('analyst_opt_in', [&$this, 'onOptInListener']);
209
+ $this->addAjax('analyst_opt_out', [&$this, 'onOptOutListener']);
210
+ $this->addAjax('analyst_plugin_deactivate', [&$this, 'onDeactivatePluginListener']);
211
+ $this->addAjax('analyst_install', [&$this, 'onInstallListener']);
212
+ $this->addAjax('analyst_skip_install', [&$this, 'onSkipInstallListener']);
213
+ $this->addAjax('analyst_install_verified', [&$this, 'onInstallVerifiedListener']);
214
+ }
215
+
216
+ /**
217
+ * Will fire when admin activates plugin
218
+ *
219
+ * @return void
220
+ */
221
+ public function onActivePluginListener()
222
+ {
223
+ if (!$this->isInstallResolved()) {
224
+ DatabaseCache::getInstance()->put('plugin_to_install', $this->id);
225
+ }
226
+
227
+ if (!$this->isAllowingLogging()) return;
228
+
229
+ ActivateRequest::make($this->collector, $this->id, $this->path)
230
+ ->execute($this->requestor);
231
+
232
+ $this->setIsInstalled(true);
233
+
234
+ AccountDataFactory::syncData();
235
+ }
236
+
237
+ /**
238
+ * Will fire when admin deactivates plugin
239
+ *
240
+ * @return void
241
+ */
242
+ public function onDeactivatePluginListener()
243
+ {
244
+ if (!$this->isAllowingLogging()) return;
245
+
246
+ $question = isset($_POST['question']) ? stripslashes($_POST['question']) : null;
247
+ $reason = isset($_POST['reason']) ? stripslashes($_POST['reason']) : null;
248
+
249
+ DeactivateRequest::make($this->collector, $this->id, $this->path, $question, $reason)
250
+ ->execute($this->requestor);
251
+
252
+ $this->setIsInstalled(false);
253
+
254
+ AccountDataFactory::syncData();
255
+
256
+ wp_send_json_success();
257
+ }
258
+
259
+ /**
260
+ * Will fire when user opted in
261
+ *
262
+ * @return void
263
+ */
264
+ public function onOptInListener()
265
+ {
266
+ OptInRequest::make($this->collector, $this->id, $this->path)->execute($this->requestor);
267
+
268
+ $this->setIsOptedIn(true);
269
+
270
+ AccountDataFactory::syncData();
271
+
272
+ wp_die();
273
+ }
274
+
275
+ /**
276
+ * Will fire when user opted out
277
+ *
278
+ * @return void
279
+ */
280
+ public function onOptOutListener()
281
+ {
282
+ OptOutRequest::make($this->collector, $this->id, $this->path)->execute($this->requestor);
283
+
284
+ $this->setIsOptedIn(false);
285
+
286
+ AccountDataFactory::syncData();
287
+
288
+ wp_send_json_success();
289
+ }
290
+
291
+ /**
292
+ * Will fire when user accept opt-in
293
+ * at first time
294
+ *
295
+ * @return void
296
+ */
297
+ public function onInstallListener()
298
+ {
299
+ $cache = DatabaseCache::getInstance();
300
+
301
+ // Set flag to true which indicates that install is resolved
302
+ // also remove install plugin id from cache
303
+ $this->setIsInstallResolved(true);
304
+ $cache->delete('plugin_to_install');
305
+
306
+ InstallRequest::make($this->collector, $this->id, $this->path)->execute($this->requestor);
307
+
308
+ $this->setIsSigned(true);
309
+
310
+ $this->setIsOptedIn(true);
311
+
312
+ $factory = NoticeFactory::instance();
313
+
314
+ $message = sprintf('Please confirm your email by clicking on the link we sent to %s. This makes sure you’re not a bot.', $this->collector->getGeneralEmailAddress());
315
+
316
+ $notificationId = uniqid();
317
+
318
+ $notice = Notice::make(
319
+ $notificationId,
320
+ $this->getId(),
321
+ $message,
322
+ $this->collector->getPluginName($this->path)
323
+ );
324
+
325
+ $factory->addNotice($notice);
326
+
327
+ AccountDataFactory::syncData();
328
+
329
+ // Set email confirmation notification id to cache
330
+ // se we can extract and remove it when user confirmed email
331
+ $cache->put(
332
+ sprintf('account_email_confirmation_%s', $this->getId()),
333
+ $notificationId
334
+ );
335
+
336
+ wp_send_json_success();
337
+ }
338
+
339
+ /**
340
+ * Will fire when user skipped installation
341
+ *
342
+ * @return void
343
+ */
344
+ public function onSkipInstallListener()
345
+ {
346
+ // Set flag to true which indicates that install is resolved
347
+ // also remove install plugin id from cache
348
+ $this->setIsInstallResolved(true);
349
+ DatabaseCache::getInstance()->delete('plugin_to_install');
350
+ }
351
+
352
+ /**
353
+ * Will fire when user delete plugin through admin panel.
354
+ * This action will happen if admin at least once
355
+ * activated the plugin.
356
+ *
357
+ * @return void
358
+ * @throws \Exception
359
+ */
360
+ public static function onUninstallPluginListener()
361
+ {
362
+ $factory = AccountDataFactory::instance();
363
+
364
+ $pluginFile = substr(current_filter(), strlen( 'uninstall_' ));
365
+
366
+ $account = $factory->getAccountDataByBasePath($pluginFile);
367
+
368
+ // If account somehow is not found, exit the execution
369
+ if (!$account) return;
370
+
371
+ $analyst = Analyst::getInstance();
372
+
373
+ $collector = new Collector($analyst);
374
+
375
+ $requestor = new ApiRequestor($account->getId(), $account->getSecret(), $analyst->getApiBase());
376
+
377
+ // Just send request to log uninstall event not caring about response
378
+ UninstallRequest::make($collector, $account->getId(), $account->getPath())->execute($requestor);
379
+
380
+ $factory->sync();
381
+ }
382
+
383
+ /**
384
+ * Fires when used verified his account
385
+ */
386
+ public function onInstallVerifiedListener()
387
+ {
388
+ $factory = NoticeFactory::instance();
389
+
390
+ $notice = Notice::make(
391
+ uniqid(),
392
+ $this->getId(),
393
+ 'Thank you for confirming your email.',
394
+ $this->collector->getPluginName($this->path)
395
+ );
396
+
397
+ $factory->addNotice($notice);
398
+
399
+ // Remove confirmation notification
400
+ $confirmationNotificationId = DatabaseCache::getInstance()->pop(sprintf('account_email_confirmation_%s', $this->getId()));
401
+ $factory->remove($confirmationNotificationId);
402
+
403
+ AccountDataFactory::syncData();
404
+
405
+ wp_send_json_success();
406
+ }
407
+
408
+ /**
409
+ * Will fire when wp renders plugin
410
+ * action buttons
411
+ *
412
+ * @param $defaultLinks
413
+ * @return array
414
+ */
415
+ public function onRenderActionLinksHook($defaultLinks)
416
+ {
417
+ $customLinks = [];
418
+
419
+ $customLinks[] = $this->isOptedIn()
420
+ ? '<a class="analyst-action-opt analyst-opt-out" analyst-plugin-id="' . $this->getId() . '" analyst-plugin-signed="' . (int) $this->isSigned() . '">Opt Out</a>'
421
+ : '<a class="analyst-action-opt analyst-opt-in" analyst-plugin-id="' . $this->getId() . '" analyst-plugin-signed="' . (int) $this->isSigned() . '">Opt In</a>';
422
+
423
+ // Append anchor to find specific deactivation link
424
+ if (isset($defaultLinks['deactivate'])) {
425
+ $defaultLinks['deactivate'] .= '<span analyst-plugin-id="' . $this->getId() . '" analyst-plugin-opted-in="' . (int) $this->isOptedIn() . '"></span>';
426
+ }
427
+
428
+ return array_merge($customLinks, $defaultLinks);
429
+ }
430
+
431
+ /**
432
+ * @return AccountData
433
+ */
434
+ public function getData()
435
+ {
436
+ return $this->data;
437
+ }
438
+
439
+ /**
440
+ * @param AccountData $data
441
+ */
442
+ public function setData(AccountData $data)
443
+ {
444
+ $this->data = $data;
445
+
446
+ $this->setIsOptedIn($data->isOptedIn());
447
+ $this->setIsInstalled($data->isInstalled());
448
+ $this->setIsSigned($data->isSigned());
449
+ $this->setIsInstallResolved($data->isInstallResolved());
450
+ }
451
+
452
+ /**
453
+ * Resolves valid action name
454
+ * based on client id
455
+ *
456
+ * @param $action
457
+ * @return string
458
+ */
459
+ private function resolveActionName($action)
460
+ {
461
+ return sprintf('%s_%s', $action, $this->id);
462
+ }
463
+
464
+ /**
465
+ * Register action for current plugin
466
+ *
467
+ * @param $action
468
+ * @param $callback
469
+ */
470
+ private function addFilter($action, $callback)
471
+ {
472
+ $validAction = sprintf('%s_%s', $action, $this->basePluginPath);
473
+
474
+ add_filter($validAction, $callback, 10);
475
+ }
476
+
477
+ /**
478
+ * Add ajax action for current plugin
479
+ *
480
+ * @param $action
481
+ * @param $callback
482
+ * @param bool $raw Format action ??
483
+ */
484
+ private function addAjax($action, $callback, $raw = false)
485
+ {
486
+ $validAction = $raw ? $action : sprintf('%s%s', 'wp_ajax_', $this->resolveActionName($action));
487
+
488
+ add_action($validAction, $callback);
489
+ }
490
+
491
+ /**
492
+ * @return bool
493
+ */
494
+ public function isSigned()
495
+ {
496
+ return $this->isSigned;
497
+ }
498
+
499
+ /**
500
+ * @param bool $isSigned
501
+ */
502
+ public function setIsSigned($isSigned)
503
+ {
504
+ $this->data->setIsSigned($isSigned);
505
+
506
+ $this->isSigned = $isSigned;
507
+ }
508
+
509
+ /**
510
+ * @return RequestorContract
511
+ */
512
+ public function getRequestor()
513
+ {
514
+ return $this->requestor;
515
+ }
516
+
517
+ /**
518
+ * @param RequestorContract $requestor
519
+ */
520
+ public function setRequestor(RequestorContract $requestor)
521
+ {
522
+ $this->requestor = $requestor;
523
+ }
524
+
525
+ /**
526
+ * @return string
527
+ */
528
+ public function getClientSecret()
529
+ {
530
+ return $this->clientSecret;
531
+ }
532
+
533
+ /**
534
+ * @return Collector
535
+ */
536
+ public function getCollector()
537
+ {
538
+ return $this->collector;
539
+ }
540
+
541
+ /**
542
+ * @param Collector $collector
543
+ */
544
+ public function setCollector(Collector $collector)
545
+ {
546
+ $this->collector = $collector;
547
+ }
548
+
549
+ /**
550
+ * Do we allowing logging
551
+ *
552
+ * @return bool
553
+ */
554
+ public function isAllowingLogging()
555
+ {
556
+ return $this->isOptedIn;
557
+ }
558
+
559
+ /**
560
+ * @return string
561
+ */
562
+ public function getBasePluginPath()
563
+ {
564
+ return $this->basePluginPath;
565
+ }
566
+
567
+ /**
568
+ * @return bool
569
+ */
570
+ public function isInstallResolved()
571
+ {
572
+ return $this->isInstallResolved;
573
+ }
574
+
575
+ /**
576
+ * @param bool $isInstallResolved
577
+ */
578
+ public function setIsInstallResolved($isInstallResolved)
579
+ {
580
+ $this->data->setIsInstallResolved($isInstallResolved);
581
+
582
+ $this->isInstallResolved = $isInstallResolved;
583
+ }
584
+ }
analyst/src/Account/AccountData.php CHANGED
@@ -1,176 +1,176 @@
1
- <?php
2
-
3
- namespace Account;
4
-
5
- /**
6
- * Class AccountData is the data holder
7
- * for Analyst\Account\Account class
8
- * which is unserialized from database
9
- */
10
- class AccountData
11
- {
12
- /**
13
- * Account id
14
- *
15
- * @var string
16
- */
17
- protected $id;
18
-
19
- /**
20
- * Account secret key
21
- *
22
- * @var string
23
- */
24
- protected $secret;
25
-
26
- /**
27
- * Basename of plugin
28
- *
29
- * @var string
30
- */
31
- protected $path;
32
-
33
- /**
34
- * Whether admin accepted opt in
35
- * terms and permissions
36
- *
37
- * @var bool
38
- */
39
- protected $isInstalled = false;
40
-
41
- /**
42
- * Is user sign in for data tracking
43
- *
44
- * @var bool
45
- */
46
- protected $isOptedIn = false;
47
-
48
- /**
49
- * Is user accepted permissions grant
50
- * for collection site data
51
- *
52
- * @var bool
53
- */
54
- protected $isSigned = false;
55
-
56
- /**
57
- * Is user ever resolved install modal window?
58
- *
59
- * @var bool
60
- */
61
- protected $isInstallResolved;
62
-
63
- /**
64
- * @return string
65
- */
66
- public function getId()
67
- {
68
- return $this->id;
69
- }
70
-
71
- /**
72
- * @param string $id
73
- */
74
- public function setId($id)
75
- {
76
- $this->id = $id;
77
- }
78
-
79
- /**
80
- * @param string $path
81
- * @return AccountData
82
- */
83
- public function setPath($path)
84
- {
85
- $this->path = $path;
86
- return $this;
87
- }
88
-
89
- /**
90
- * @return bool
91
- */
92
- public function isInstalled()
93
- {
94
- return $this->isInstalled;
95
- }
96
-
97
- /**
98
- * @param bool $isInstalled
99
- */
100
- public function setIsInstalled($isInstalled)
101
- {
102
- $this->isInstalled = $isInstalled;
103
- }
104
-
105
- /**
106
- * @return bool
107
- */
108
- public function isOptedIn()
109
- {
110
- return $this->isOptedIn;
111
- }
112
-
113
- /**
114
- * @param bool $isOptedIn
115
- */
116
- public function setIsOptedIn($isOptedIn)
117
- {
118
- $this->isOptedIn = $isOptedIn;
119
- }
120
-
121
- /**
122
- * @return bool
123
- */
124
- public function isSigned()
125
- {
126
- return $this->isSigned;
127
- }
128
-
129
- /**
130
- * @param bool $isSigned
131
- */
132
- public function setIsSigned($isSigned)
133
- {
134
- $this->isSigned = $isSigned;
135
- }
136
-
137
- /**
138
- * @return string
139
- */
140
- public function getPath()
141
- {
142
- return $this->path;
143
- }
144
-
145
- /**
146
- * @return string
147
- */
148
- public function getSecret()
149
- {
150
- return $this->secret;
151
- }
152
-
153
- /**
154
- * @param string $secret
155
- */
156
- public function setSecret($secret)
157
- {
158
- $this->secret = $secret;
159
- }
160
-
161
- /**
162
- * @return bool
163
- */
164
- public function isInstallResolved()
165
- {
166
- return $this->isInstallResolved;
167
- }
168
-
169
- /**
170
- * @param bool $isInstallResolved
171
- */
172
- public function setIsInstallResolved($isInstallResolved)
173
- {
174
- $this->isInstallResolved = $isInstallResolved;
175
- }
176
- }
1
+ <?php
2
+
3
+ namespace Account;
4
+
5
+ /**
6
+ * Class AccountData is the data holder
7
+ * for Analyst\Account\Account class
8
+ * which is unserialized from database
9
+ */
10
+ class AccountData
11
+ {
12
+ /**
13
+ * Account id
14
+ *
15
+ * @var string
16
+ */
17
+ protected $id;
18
+
19
+ /**
20
+ * Account secret key
21
+ *
22
+ * @var string
23
+ */
24
+ protected $secret;
25
+
26
+ /**
27
+ * Basename of plugin
28
+ *
29
+ * @var string
30
+ */
31
+ protected $path;
32
+
33
+ /**
34
+ * Whether admin accepted opt in
35
+ * terms and permissions
36
+ *
37
+ * @var bool
38
+ */
39
+ protected $isInstalled = false;
40
+
41
+ /**
42
+ * Is user sign in for data tracking
43
+ *
44
+ * @var bool
45
+ */
46
+ protected $isOptedIn = false;
47
+
48
+ /**
49
+ * Is user accepted permissions grant
50
+ * for collection site data
51
+ *
52
+ * @var bool
53
+ */
54
+ protected $isSigned = false;
55
+
56
+ /**
57
+ * Is user ever resolved install modal window?
58
+ *
59
+ * @var bool
60
+ */
61
+ protected $isInstallResolved;
62
+
63
+ /**
64
+ * @return string
65
+ */
66
+ public function getId()
67
+ {
68
+ return $this->id;
69
+ }
70
+
71
+ /**
72
+ * @param string $id
73
+ */
74
+ public function setId($id)
75
+ {
76
+ $this->id = $id;
77
+ }
78
+
79
+ /**
80
+ * @param string $path
81
+ * @return AccountData
82
+ */
83
+ public function setPath($path)
84
+ {
85
+ $this->path = $path;
86
+ return $this;
87
+ }
88
+
89
+ /**
90
+ * @return bool
91
+ */
92
+ public function isInstalled()
93
+ {
94
+ return $this->isInstalled;
95
+ }
96
+
97
+ /**
98
+ * @param bool $isInstalled
99
+ */
100
+ public function setIsInstalled($isInstalled)
101
+ {
102
+ $this->isInstalled = $isInstalled;
103
+ }
104
+
105
+ /**
106
+ * @return bool
107
+ */
108
+ public function isOptedIn()
109
+ {
110
+ return $this->isOptedIn;
111
+ }
112
+
113
+ /**
114
+ * @param bool $isOptedIn
115
+ */
116
+ public function setIsOptedIn($isOptedIn)
117
+ {
118
+ $this->isOptedIn = $isOptedIn;
119
+ }
120
+
121
+ /**
122
+ * @return bool
123
+ */
124
+ public function isSigned()
125
+ {
126
+ return $this->isSigned;
127
+ }
128
+
129
+ /**
130
+ * @param bool $isSigned
131
+ */
132
+ public function setIsSigned($isSigned)
133
+ {
134
+ $this->isSigned = $isSigned;
135
+ }
136
+
137
+ /**
138
+ * @return string
139
+ */
140
+ public function getPath()
141
+ {
142
+ return $this->path;
143
+ }
144
+
145
+ /**
146
+ * @return string
147
+ */
148
+ public function getSecret()
149
+ {
150
+ return $this->secret;
151
+ }
152
+
153
+ /**
154
+ * @param string $secret
155
+ */
156
+ public function setSecret($secret)
157
+ {
158
+ $this->secret = $secret;
159
+ }
160
+
161
+ /**
162
+ * @return bool
163
+ */
164
+ public function isInstallResolved()
165
+ {
166
+ return $this->isInstallResolved;
167
+ }
168
+
169
+ /**
170
+ * @param bool $isInstallResolved
171
+ */
172
+ public function setIsInstallResolved($isInstallResolved)
173
+ {
174
+ $this->isInstallResolved = $isInstallResolved;
175
+ }
176
+ }
analyst/src/Account/AccountDataFactory.php CHANGED
@@ -1,125 +1,125 @@
1
- <?php
2
-
3
- namespace Account;
4
-
5
-
6
- use Analyst\Core\AbstractFactory;
7
-
8
- /**
9
- * Class AccountDataFactory
10
- *
11
- * Holds information about this
12
- * wordpress project plugins accounts
13
- *
14
- */
15
- class AccountDataFactory extends AbstractFactory
16
- {
17
- private static $instance;
18
-
19
- CONST OPTIONS_KEY = 'analyst_accounts_data';
20
-
21
- /**
22
- * @var AccountData[]
23
- */
24
- protected $accounts = [];
25
-
26
- /**
27
- * Read factory from options or make fresh instance
28
- *
29
- * @return static
30
- */
31
- public static function instance()
32
- {
33
- if (!static::$instance) {
34
- $raw = get_option(self::OPTIONS_KEY);
35
-
36
- // In case object is already unserialized
37
- // and instance of AccountDataFactory we
38
- // return it, in other case deal with
39
- // serialized string data
40
- if ($raw instanceof self) {
41
- static::$instance = $raw;
42
- } else {
43
- static::$instance = is_string($raw) ? static::unserialize($raw) : new self();
44
- }
45
- }
46
-
47
- return static::$instance;
48
- }
49
-
50
- /**
51
- * Sync this object data with cache
52
- */
53
- public function sync()
54
- {
55
- update_option(self::OPTIONS_KEY, serialize($this));
56
- }
57
-
58
- /**
59
- * Sync this instance data with cache
60
- */
61
- public static function syncData()
62
- {
63
- static::instance()->sync();
64
- }
65
-
66
- /**
67
- * Find plugin account data or create fresh one
68
- *
69
- * @param Account $account
70
- * @return AccountData|null
71
- */
72
- public function resolvePluginAccountData(Account $account)
73
- {
74
- $accountData = $this->findAccountDataById($account->getId());
75
-
76
- if (!$accountData) {
77
- $accountData = new AccountData();
78
-
79
- // Set proper default values
80
- $accountData->setPath($account->getPath());
81
- $accountData->setId($account->getId());
82
- $accountData->setSecret($account->getClientSecret());
83
-
84
- array_push($this->accounts, $accountData);
85
- }
86
-
87
- return $accountData;
88
- }
89
-
90
- /**
91
- * Should return account data by base path
92
- *
93
- * @param $basePath
94
- * @return AccountData
95
- */
96
- public function getAccountDataByBasePath($basePath)
97
- {
98
- foreach ($this->accounts as $iterable) {
99
- $iterableBasePath = plugin_basename($iterable->getPath());
100
-
101
- if ($iterableBasePath === $basePath) {
102
- return $iterable;
103
- }
104
- }
105
-
106
- return null;
107
- }
108
-
109
- /**
110
- * Return account by id
111
- *
112
- * @param $id
113
- * @return AccountData|null
114
- */
115
- private function findAccountDataById($id)
116
- {
117
- foreach ($this->accounts as &$iterable) {
118
- if ($iterable->getId() === $id) {
119
- return $iterable;
120
- }
121
- }
122
-
123
- return null;
124
- }
125
- }
1
+ <?php
2
+
3
+ namespace Account;
4
+
5
+
6
+ use Analyst\Core\AbstractFactory;
7
+
8
+ /**
9
+ * Class AccountDataFactory
10
+ *
11
+ * Holds information about this
12
+ * wordpress project plugins accounts
13
+ *
14
+ */
15
+ class AccountDataFactory extends AbstractFactory
16
+ {
17
+ private static $instance;
18
+
19
+ CONST OPTIONS_KEY = 'analyst_accounts_data';
20
+
21
+ /**
22
+ * @var AccountData[]
23
+ */
24
+ protected $accounts = [];
25
+
26
+ /**
27
+ * Read factory from options or make fresh instance
28
+ *
29
+ * @return static
30
+ */
31
+ public static function instance()
32
+ {
33
+ if (!static::$instance) {
34
+ $raw = get_option(self::OPTIONS_KEY);
35
+
36
+ // In case object is already unserialized
37
+ // and instance of AccountDataFactory we
38
+ // return it, in other case deal with
39
+ // serialized string data
40
+ if ($raw instanceof self) {
41
+ static::$instance = $raw;
42
+ } else {
43
+ static::$instance = is_string($raw) ? static::unserialize($raw) : new self();
44
+ }
45
+ }
46
+
47
+ return static::$instance;
48
+ }
49
+
50
+ /**
51
+ * Sync this object data with cache
52
+ */
53
+ public function sync()
54
+ {
55
+ update_option(self::OPTIONS_KEY, serialize($this));
56
+ }
57
+
58
+ /**
59
+ * Sync this instance data with cache
60
+ */
61
+ public static function syncData()
62
+ {
63
+ static::instance()->sync();
64
+ }
65
+
66
+ /**
67
+ * Find plugin account data or create fresh one
68
+ *
69
+ * @param Account $account
70
+ * @return AccountData|null
71
+ */
72
+ public function resolvePluginAccountData(Account $account)
73
+ {
74
+ $accountData = $this->findAccountDataById($account->getId());
75
+
76
+ if (!$accountData) {
77
+ $accountData = new AccountData();
78
+
79
+ // Set proper default values
80
+ $accountData->setPath($account->getPath());
81
+ $accountData->setId($account->getId());
82
+ $accountData->setSecret($account->getClientSecret());
83
+
84
+ array_push($this->accounts, $accountData);
85
+ }
86
+
87
+ return $accountData;
88
+ }
89
+
90
+ /**
91
+ * Should return account data by base path
92
+ *
93
+ * @param $basePath
94
+ * @return AccountData
95
+ */
96
+ public function getAccountDataByBasePath($basePath)
97
+ {
98
+ foreach ($this->accounts as $iterable) {
99
+ $iterableBasePath = plugin_basename($iterable->getPath());
100
+
101
+ if ($iterableBasePath === $basePath) {
102
+ return $iterable;
103
+ }
104
+ }
105
+
106
+ return null;
107
+ }
108
+
109
+ /**
110
+ * Return account by id
111
+ *
112
+ * @param $id
113
+ * @return AccountData|null
114
+ */
115
+ private function findAccountDataById($id)
116
+ {
117
+ foreach ($this->accounts as &$iterable) {
118
+ if ($iterable->getId() === $id) {
119
+ return $iterable;
120
+ }
121
+ }
122
+
123
+ return null;
124
+ }
125
+ }
analyst/src/Analyst.php CHANGED
@@ -1,167 +1,167 @@
1
- <?php
2
- namespace Analyst;
3
-
4
- use Account\Account;
5
- use Account\AccountDataFactory;
6
- use Analyst\Contracts\AnalystContract;
7
- use Analyst\Contracts\RequestorContract;
8
-
9
- class Analyst implements AnalystContract
10
- {
11
- /**
12
- * All plugin's accounts
13
- *
14
- * @var array
15
- */
16
- protected $accounts = array();
17
-
18
- /**
19
- * @var Mutator
20
- */
21
- protected $mutator;
22
-
23
- /**
24
- * @var AccountDataFactory
25
- */
26
- protected $accountDataFactory;
27
-
28
- /**
29
- * Base url to api
30
- *
31
- * @var string
32
- */
33
- protected $apiBase = 'https://feedback.sellcodes.com/api/v1';
34
-
35
- /**
36
- * @var Collector
37
- */
38
- protected $collector;
39
-
40
- /**
41
- * Singleton instance
42
- *
43
- * @var static
44
- */
45
- protected static $instance;
46
-
47
- /**
48
- * Get instance of analyst
49
- *
50
- * @return Analyst
51
- * @throws \Exception
52
- */
53
- public static function getInstance()
54
- {
55
- if (!static::$instance) {
56
- static::$instance = new Analyst();
57
- }
58
-
59
- return static::$instance;
60
- }
61
-
62
- protected function __construct()
63
- {
64
- $this->mutator = new Mutator();
65
-
66
- $this->accountDataFactory = AccountDataFactory::instance();
67
-
68
- $this->mutator->initialize();
69
-
70
- $this->collector = new Collector($this);
71
-
72
- $this->initialize();
73
- }
74
-
75
- /**
76
- * Initialize rest of application
77
- */
78
- public function initialize()
79
- {
80
- add_action('init', function () {
81
- $this->collector->loadCurrentUser();
82
- });
83
- }
84
-
85
- /**
86
- * Register new account
87
- *
88
- * @param Account $account
89
- * @return Analyst
90
- * @throws \Exception
91
- */
92
- public function registerAccount($account)
93
- {
94
- // Stop propagation when account is already registered
95
- if ($this->isAccountRegistered($account)) {
96
- return $this;
97
- }
98
-
99
- // Resolve account data from factory
100
- $accountData = $this->accountDataFactory->resolvePluginAccountData($account);
101
-
102
- $account->setData($accountData);
103
-
104
- $account->setRequestor(
105
- $this->resolveRequestorForAccount($account)
106
- );
107
-
108
- $account->setCollector($this->collector);
109
-
110
- $account->registerHooks();
111
-
112
- $this->accounts[$account->getId()] = $account;
113
-
114
- return $this;
115
- }
116
-
117
- /**
118
- * Must return version of analyst
119
- *
120
- * @return string
121
- */
122
- public static function version()
123
- {
124
- $version = require __DIR__ . '/../version.php';
125
-
126
- return $version['sdk'];
127
- }
128
-
129
- /**
130
- * Is this account registered
131
- *
132
- * @param Account $account
133
- * @return bool
134
- */
135
- protected function isAccountRegistered($account)
136
- {
137
- return isset($this->accounts[$account->getId()]);
138
- }
139
-
140
- /**
141
- * Resolves requestor for account
142
- *
143
- * @param Account $account
144
- * @return RequestorContract
145
- * @throws \Exception
146
- */
147
- protected function resolveRequestorForAccount(Account $account)
148
- {
149
- $requestor = new ApiRequestor($account->getId(), $account->getClientSecret(), $this->apiBase);
150
-
151
- // Set SDK version
152
- $requestor->setDefaultHeader(
153
- 'x-analyst-client-user-agent',
154
- sprintf('Analyst/%s', $this->version())
155
- );
156
-
157
- return $requestor;
158
- }
159
-
160
- /**
161
- * @return string
162
- */
163
- public function getApiBase()
164
- {
165
- return $this->apiBase;
166
- }
167
- }
1
+ <?php
2
+ namespace Analyst;
3
+
4
+ use Account\Account;
5
+ use Account\AccountDataFactory;
6
+ use Analyst\Contracts\AnalystContract;
7
+ use Analyst\Contracts\RequestorContract;
8
+
9
+ class Analyst implements AnalystContract
10
+ {
11
+ /**
12
+ * All plugin's accounts
13
+ *
14
+ * @var array
15
+ */
16
+ protected $accounts = array();
17
+
18
+ /**
19
+ * @var Mutator
20
+ */
21
+ protected $mutator;
22
+
23
+ /**
24
+ * @var AccountDataFactory
25
+ */
26
+ protected $accountDataFactory;
27
+
28
+ /**
29
+ * Base url to api
30
+ *
31
+ * @var string
32
+ */
33
+ protected $apiBase = 'https://feedback.sellcodes.com/api/v1';
34
+
35
+ /**
36
+ * @var Collector
37
+ */
38
+ protected $collector;
39
+
40
+ /**
41
+ * Singleton instance
42
+ *
43
+ * @var static
44
+ */
45
+ protected static $instance;
46
+
47
+ /**
48
+ * Get instance of analyst
49
+ *
50
+ * @return Analyst
51
+ * @throws \Exception
52
+ */
53
+ public static function getInstance()
54
+ {
55
+ if (!static::$instance) {
56
+ static::$instance = new Analyst();
57
+ }
58
+
59
+ return static::$instance;
60
+ }
61
+
62
+ protected function __construct()
63
+ {
64
+ $this->mutator = new Mutator();
65
+
66
+ $this->accountDataFactory = AccountDataFactory::instance();
67
+
68
+ $this->mutator->initialize();
69
+
70
+ $this->collector = new Collector($this);
71
+
72
+ $this->initialize();
73
+ }
74
+
75
+ /**
76
+ * Initialize rest of application
77
+ */
78
+ public function initialize()
79
+ {
80
+ add_action('init', function () {
81
+ $this->collector->loadCurrentUser();
82
+ });
83
+ }
84
+
85
+ /**
86
+ * Register new account
87
+ *
88
+ * @param Account $account
89
+ * @return Analyst
90
+ * @throws \Exception
91
+ */
92
+ public function registerAccount($account)
93
+ {
94
+ // Stop propagation when account is already registered
95
+ if ($this->isAccountRegistered($account)) {
96
+ return $this;
97
+ }
98
+
99
+ // Resolve account data from factory
100
+ $accountData = $this->accountDataFactory->resolvePluginAccountData($account);
101
+
102
+ $account->setData($accountData);
103
+
104
+ $account->setRequestor(
105
+ $this->resolveRequestorForAccount($account)
106
+ );
107
+
108
+ $account->setCollector($this->collector);
109
+
110
+ $account->registerHooks();
111
+
112
+ $this->accounts[$account->getId()] = $account;
113
+
114
+ return $this;
115
+ }
116
+
117
+ /**
118
+ * Must return version of analyst
119
+ *
120
+ * @return string
121
+ */
122
+ public static function version()
123
+ {
124
+ $version = require __DIR__ . '/../version.php';
125
+
126
+ return $version['sdk'];
127
+ }
128
+
129
+ /**
130
+ * Is this account registered
131
+ *
132
+ * @param Account $account
133
+ * @return bool
134
+ */
135
+ protected function isAccountRegistered($account)
136
+ {
137
+ return isset($this->accounts[$account->getId()]);
138
+ }
139
+
140
+ /**
141
+ * Resolves requestor for account
142
+ *
143
+ * @param Account $account
144
+ * @return RequestorContract
145
+ * @throws \Exception
146
+ */
147
+ protected function resolveRequestorForAccount(Account $account)
148
+ {
149
+ $requestor = new ApiRequestor($account->getId(), $account->getClientSecret(), $this->apiBase);
150
+
151
+ // Set SDK version
152
+ $requestor->setDefaultHeader(
153
+ 'x-analyst-client-user-agent',
154
+ sprintf('Analyst/%s', $this->version())
155
+ );
156
+
157
+ return $requestor;
158
+ }
159
+
160
+ /**
161
+ * @return string
162
+ */
163
+ public function getApiBase()
164
+ {
165
+ return $this->apiBase;
166
+ }
167
+ }
analyst/src/ApiRequestor.php CHANGED
@@ -1,257 +1,257 @@
1
- <?php
2
-
3
- namespace Analyst;
4
-
5
- use Exception;
6
- use Analyst\Contracts\HttpClientContract;
7
- use Analyst\Contracts\RequestorContract;
8
-
9
- class ApiRequestor implements RequestorContract
10
- {
11
- /**
12
- * Supported http client
13
- *
14
- * @var HttpClientContract
15
- */
16
- protected $httpClient;
17
-
18
- /**
19
- * @var string
20
- */
21
- protected $clientId;
22
-
23
- /**
24
- * @var string
25
- */
26
- protected $clientSecret;
27
-
28
- /**
29
- * @var string
30
- */
31
- protected $apiBase;
32
-
33
- /**
34
- * Default headers to be sent
35
- *
36
- * @var array
37
- */
38
- protected $defaultHeaders = [
39
- 'accept' => 'application/json',
40
- 'content-type' => 'application/json'
41
- ];
42
-
43
- /**
44
- * Prioritized http clients
45
- *
46
- * @var array
47
- */
48
- protected $availableClients = [
49
- 'Analyst\Http\WordPressHttpClient',
50
- 'Analyst\Http\CurlHttpClient',
51
- 'Analyst\Http\DummyHttpClient',
52
- ];
53
-
54
- /**
55
- * ApiRequestor constructor.
56
- * @param $id
57
- * @param $secret
58
- * @param $apiBase
59
- * @throws \Exception
60
- */
61
- public function __construct($id, $secret, $apiBase)
62
- {
63
- $this->clientId = $id;
64
- $this->clientSecret = $secret;
65
-
66
- $this->setApiBase($apiBase);
67
-
68
- $this->httpClient = $this->resolveHttpClient();
69
- }
70
-
71
- /**
72
- * Set api base url
73
- *
74
- * @param $url
75
- */
76
- public function setApiBase($url)
77
- {
78
- $this->apiBase = $url;
79
- }
80
-
81
- /**
82
- * Get request
83
- *
84
- * @param $url
85
- * @param array $headers
86
- * @return mixed
87
- */
88
- public function get($url, $headers = [])
89
- {
90
- return $this->request('GET', $url, null, $headers);
91
- }
92
-
93
- /**
94
- * Post request
95
- *
96
- * @param $url
97
- * @param $body
98
- * @param array $headers
99
- * @return mixed
100
- */
101
- public function post($url, $body = [], $headers = [])
102
- {
103
- return $this->request('POST', $url, $body, $headers);
104
- }
105
-
106
- /**
107
- * Put request
108
- *
109
- * @param $url
110
- * @param $body
111
- * @param array $headers
112
- * @return mixed
113
- */
114
- public function put($url, $body = [], $headers = [])
115
- {
116
- return $this->request('PUT', $url, $body, $headers);
117
- }
118
-
119
- /**
120
- * Delete request
121
- *
122
- * @param $url
123
- * @param array $headers
124
- * @return mixed
125
- */
126
- public function delete($url, $headers = [])
127
- {
128
- return $this->request('DELETE', $url, null, $headers);
129
- }
130
-
131
- /**
132
- * Make request to api
133
- *
134
- * @param $method
135
- * @param $url
136
- * @param array $body
137
- * @param array $headers
138
- * @return mixed
139
- */
140
- protected function request($method, $url, $body = [], $headers = [])
141
- {
142
- $fullUrl = $this->resolveFullUrl($url);
143
-
144
- $date = date('r', time());
145
-
146
- $headers['date'] = $date;
147
- $headers['signature'] = $this->resolveSignature($this->clientSecret, $method, $fullUrl, $body, $date);
148
-
149
- // Lowercase header names
150
- $headers = $this->prepareHeaders(
151
- array_merge($headers, $this->defaultHeaders)
152
- );
153
-
154
- $response = $this->httpClient->request($method, $fullUrl, $body, $headers);
155
-
156
- // TODO: Check response code and take actions
157
-
158
- return $response;
159
- }
160
-
161
- /**
162
- * Set one default header
163
- *
164
- * @param $header
165
- * @param $value
166
- */
167
- public function setDefaultHeader($header, $value)
168
- {
169
- $this->defaultHeaders[
170
- $this->resolveValidHeaderName($header)
171
- ] = $value;
172
- }
173
-
174
- /**
175
- * Resolves supported http client
176
- *
177
- * @return HttpClientContract
178
- * @throws Exception
179
- */
180
- protected function resolveHttpClient()
181
- {
182
- $clients = array_filter($this->availableClients, $this->guessClientSupportEnvironment());
183
-
184
- if (!isset($clients[0])) {
185
- throw new Exception('There is no http client which this application can support');
186
- }
187
-
188
- // Instantiate first supported http client
189
- return new $clients[0];
190
- }
191
-
192
- /**
193
- * This will filter out clients which is not supported
194
- * by the current environment
195
- *
196
- * @return \Closure
197
- */
198
- protected function guessClientSupportEnvironment()
199
- {
200
- return function ($client) {
201
- return forward_static_call([$client, 'hasSupport']);
202
- };
203
- }
204
-
205
- /**
206
- * Resolves valid header name
207
- *
208
- * @param $headerName
209
- * @return string
210
- */
211
- private function resolveValidHeaderName($headerName)
212
- {
213
- return strtolower($headerName);
214
- }
215
-
216
- /**
217
- * Lowercase header names
218
- *
219
- * @param $headers
220
- * @return array
221
- */
222
- private function prepareHeaders($headers)
223
- {
224
- return array_change_key_case($headers, CASE_LOWER);
225
- }
226
-
227
- /**
228
- * Sign request
229
- *
230
- * @param $key
231
- * @param $method
232
- * @param $url
233
- * @param $body
234
- * @param $date
235
- *
236
- * @return false|string
237
- */
238
- private function resolveSignature($key, $method, $url, $body, $date)
239
- {
240
- $string = implode('\n', [$method, $url, md5(json_encode($body)), $date]);
241
-
242
- $contentSecret = hash_hmac('sha256', $string, $key);
243
-
244
- return sprintf('%s:%s', $this->clientId, $contentSecret);
245
- }
246
-
247
- /**
248
- * Compose full url
249
- *
250
- * @param $url
251
- * @return string
252
- */
253
- private function resolveFullUrl($url)
254
- {
255
- return sprintf('%s/%s', $this->apiBase, trim($url, '/'));
256
- }
257
- }
1
+ <?php
2
+
3
+ namespace Analyst;
4
+
5
+ use Exception;
6
+ use Analyst\Contracts\HttpClientContract;
7
+ use Analyst\Contracts\RequestorContract;
8
+
9
+ class ApiRequestor implements RequestorContract
10
+ {
11
+ /**
12
+ * Supported http client
13
+ *
14
+ * @var HttpClientContract
15
+ */
16
+ protected $httpClient;
17
+
18
+ /**
19
+ * @var string
20
+ */
21
+ protected $clientId;
22
+
23
+ /**
24
+ * @var string
25
+ */
26
+ protected $clientSecret;
27
+
28
+ /**
29
+ * @var string
30
+ */
31
+ protected $apiBase;
32
+
33
+ /**
34
+ * Default headers to be sent
35
+ *
36
+ * @var array
37
+ */
38
+ protected $defaultHeaders = [
39
+ 'accept' => 'application/json',
40
+ 'content-type' => 'application/json'
41
+ ];
42
+
43
+ /**
44
+ * Prioritized http clients
45
+ *
46
+ * @var array
47
+ */
48
+ protected $availableClients = [
49
+ 'Analyst\Http\WordPressHttpClient',
50
+ 'Analyst\Http\CurlHttpClient',
51
+ 'Analyst\Http\DummyHttpClient',
52
+ ];
53
+
54
+ /**
55
+ * ApiRequestor constructor.
56
+ * @param $id
57
+ * @param $secret
58
+ * @param $apiBase
59
+ * @throws \Exception
60
+ */
61
+ public function __construct($id, $secret, $apiBase)
62
+ {
63
+ $this->clientId = $id;
64
+ $this->clientSecret = $secret;
65
+
66
+ $this->setApiBase($apiBase);
67
+
68
+ $this->httpClient = $this->resolveHttpClient();
69
+ }
70
+
71
+ /**
72
+ * Set api base url
73
+ *
74
+ * @param $url
75
+ */
76
+ public function setApiBase($url)
77
+ {
78
+ $this->apiBase = $url;
79
+ }
80
+
81
+ /**
82
+ * Get request
83
+ *
84
+ * @param $url
85
+ * @param array $headers
86
+ * @return mixed
87
+ */
88
+ public function get($url, $headers = [])
89
+ {
90
+ return $this->request('GET', $url, null, $headers);
91
+ }
92
+
93
+ /**
94
+ * Post request
95
+ *
96
+ * @param $url
97
+ * @param $body
98
+ * @param array $headers
99
+ * @return mixed
100
+ */
101
+ public function post($url, $body = [], $headers = [])
102
+ {
103
+ return $this->request('POST', $url, $body, $headers);
104
+ }
105
+
106
+ /**
107
+ * Put request
108
+ *
109
+ * @param $url
110
+ * @param $body
111
+ * @param array $headers
112
+ * @return mixed
113
+ */
114
+ public function put($url, $body = [], $headers = [])
115
+ {
116
+ return $this->request('PUT', $url, $body, $headers);
117
+ }
118
+
119
+ /**
120
+ * Delete request
121
+ *
122
+ * @param $url
123
+ * @param array $headers
124
+ * @return mixed
125
+ */
126
+ public function delete($url, $headers = [])
127
+ {
128
+ return $this->request('DELETE', $url, null, $headers);
129
+ }
130
+
131
+ /**
132
+ * Make request to api
133
+ *
134
+ * @param $method
135
+ * @param $url
136
+ * @param array $body
137
+ * @param array $headers
138
+ * @return mixed
139
+ */
140
+ protected function request($method, $url, $body = [], $headers = [])
141
+ {
142
+ $fullUrl = $this->resolveFullUrl($url);
143
+
144
+ $date = date('r', time());
145
+
146
+ $headers['date'] = $date;
147
+ $headers['signature'] = $this->resolveSignature($this->clientSecret, $method, $fullUrl, $body, $date);
148
+
149
+ // Lowercase header names
150
+ $headers = $this->prepareHeaders(
151
+ array_merge($headers, $this->defaultHeaders)
152
+ );
153
+
154
+ $response = $this->httpClient->request($method, $fullUrl, $body, $headers);
155
+
156
+ // TODO: Check response code and take actions
157
+
158
+ return $response;
159
+ }
160
+
161
+ /**
162
+ * Set one default header
163
+ *
164
+ * @param $header
165
+ * @param $value
166
+ */
167
+ public function setDefaultHeader($header, $value)
168
+ {
169
+ $this->defaultHeaders[
170
+ $this->resolveValidHeaderName($header)
171
+ ] = $value;
172
+ }
173
+
174
+ /**
175
+ * Resolves supported http client
176
+ *
177
+ * @return HttpClientContract
178
+ * @throws Exception
179
+ */
180
+ protected function resolveHttpClient()
181
+ {
182
+ $clients = array_filter($this->availableClients, $this->guessClientSupportEnvironment());
183
+
184
+ if (!isset($clients[0])) {
185
+ throw new Exception('There is no http client which this application can support');
186
+ }
187
+
188
+ // Instantiate first supported http client
189
+ return new $clients[0];
190
+ }
191
+
192
+ /**
193
+ * This will filter out clients which is not supported
194
+ * by the current environment
195
+ *
196
+ * @return \Closure
197
+ */
198
+ protected function guessClientSupportEnvironment()
199
+ {
200
+ return function ($client) {
201
+ return forward_static_call([$client, 'hasSupport']);
202
+ };
203
+ }
204
+
205
+ /**
206
+ * Resolves valid header name
207
+ *
208
+ * @param $headerName
209
+ * @return string
210
+ */
211
+ private function resolveValidHeaderName($headerName)
212
+ {
213
+ return strtolower($headerName);
214
+ }
215
+
216
+ /**
217
+ * Lowercase header names
218
+ *
219
+ * @param $headers
220
+ * @return array
221
+ */
222
+ private function prepareHeaders($headers)
223
+ {
224
+ return array_change_key_case($headers, CASE_LOWER);
225
+ }
226
+
227
+ /**
228
+ * Sign request
229
+ *
230
+ * @param $key
231
+ * @param $method
232
+ * @param $url
233
+ * @param $body
234
+ * @param $date
235
+ *
236
+ * @return false|string
237
+ */
238
+ private function resolveSignature($key, $method, $url, $body, $date)
239
+ {
240
+ $string = implode('\n', [$method, $url, md5(json_encode($body)), $date]);
241
+
242
+ $contentSecret = hash_hmac('sha256', $string, $key);
243
+
244
+ return sprintf('%s:%s', $this->clientId, $contentSecret);
245
+ }
246
+
247
+ /**
248
+ * Compose full url
249
+ *
250
+ * @param $url
251
+ * @return string
252
+ */
253
+ private function resolveFullUrl($url)
254
+ {
255
+ return sprintf('%s/%s', $this->apiBase, trim($url, '/'));
256
+ }
257
+ }
analyst/src/ApiResponse.php CHANGED
@@ -1,44 +1,44 @@
1
- <?php
2
-
3
- namespace Analyst;
4
-
5
- class ApiResponse
6
- {
7
- /**
8
- * Response headers
9
- *
10
- * @var array
11
- */
12
- public $headers;
13
-
14
- /**
15
- * Response body
16
- *
17
- * @var mixed
18
- */
19
- public $body;
20
-
21
- /**
22
- * Status code
23
- *
24
- * @var string
25
- */
26
- public $code;
27
-
28
- public function __construct($body, $code, $headers)
29
- {
30
- $this->body = $body;
31
- $this->code = $code;
32
- $this->headers = $headers;
33
- }
34
-
35
- /**
36
- * Whether status code is successful
37
- *
38
- * @return bool
39
- */
40
- public function isSuccess()
41
- {
42
- return $this->code >= 200 && $this->code < 300;
43
- }
44
- }
1
+ <?php
2
+
3
+ namespace Analyst;
4
+
5
+ class ApiResponse
6
+ {
7
+ /**
8
+ * Response headers
9
+ *
10
+ * @var array
11
+ */
12
+ public $headers;
13
+
14
+ /**
15
+ * Response body
16
+ *
17
+ * @var mixed
18
+ */
19
+ public $body;
20
+
21
+ /**
22
+ * Status code
23
+ *
24
+ * @var string
25
+ */
26
+ public $code;
27
+
28
+ public function __construct($body, $code, $headers)
29
+ {
30
+ $this->body = $body;
31
+ $this->code = $code;
32
+ $this->headers = $headers;
33
+ }
34
+
35
+ /**
36
+ * Whether status code is successful
37
+ *
38
+ * @return bool
39
+ */
40
+ public function isSuccess()
41
+ {
42
+ return $this->code >= 200 && $this->code < 300;
43
+ }
44
+ }
analyst/src/Cache/DatabaseCache.php CHANGED
@@ -1,127 +1,127 @@
1
- <?php
2
-
3
- namespace Analyst\Cache;
4
-
5
- use Analyst\Contracts\CacheContract;
6
-
7
- /**
8
- * Class DatabaseCache
9
- *
10
- * @since 1.1.5
11
- */
12
- class DatabaseCache implements CacheContract
13
- {
14
- const OPTION_KEY = 'analyst_cache';
15
-
16
- protected static $instance;
17
-
18
- /**
19
- * Get instance of db cache
20
- *
21
- * @return DatabaseCache
22
- */
23
- public static function getInstance()
24
- {
25
- if (!self::$instance) {
26
- self::$instance = new DatabaseCache();
27
- }
28
-
29
- return self::$instance;
30
- }
31
-
32
- /**
33
- * Key value pair
34
- *
35
- * @var array[]
36
- */
37
- protected $values = [];
38
-
39
- /**
40
- * DatabaseCache constructor.
41
- */
42
- public function __construct()
43
- {
44
- $raw = get_option(self::OPTION_KEY, serialize([]));
45
-
46
- // Raw data may be an array already
47
- $this->values = is_array($raw) ? $raw : @unserialize($raw);
48
-
49
- // In case serialization is failed
50
- // make sure values is an array
51
- if (!is_array($this->values)) {
52
- $this->values = [];
53
- }
54
- }
55
-
56
- /**
57
- * Save value with given key
58
- *
59
- * @param string $key
60
- * @param string $value
61
- *
62
- * @return static
63
- */
64
- public function put($key, $value)
65
- {
66
- $this->values[$key] = $value;
67
-
68
- $this->sync();
69
-
70
- return $this;
71
- }
72
-
73
- /**
74
- * Get value by given key
75
- *
76
- * @param $key
77
- *
78
- * @param null $default
79
- * @return string
80
- */
81
- public function get($key, $default = null)
82
- {
83
- $value = isset($this->values[$key]) ? $this->values[$key] : $default;
84
-
85
- return $value;
86
- }
87
-
88
- /**
89
- * @param $key
90
- *
91
- * @return static
92
- */
93
- public function delete($key)
94
- {
95
- if (isset($this->values[$key])) {
96
- unset($this->values[$key]);
97
-
98
- $this->sync();
99
- }
100
-
101
- return $this;
102
- }
103
-
104
- /**
105
- * Update cache in DB
106
- */
107
- protected function sync()
108
- {
109
- update_option(self::OPTION_KEY, serialize($this->values));
110
- }
111
-
112
- /**
113
- * Should get value and remove it from cache
114
- *
115
- * @param $key
116
- * @param null $default
117
- * @return mixed
118
- */
119
- public function pop($key, $default = null)
120
- {
121
- $value = $this->get($key);
122
-
123
- $this->delete($key);
124
-
125
- return $value;
126
- }
127
- }
1
+ <?php
2
+
3
+ namespace Analyst\Cache;
4
+
5
+ use Analyst\Contracts\CacheContract;
6
+
7
+ /**
8
+ * Class DatabaseCache
9
+ *
10
+ * @since 1.1.5
11
+ */
12
+ class DatabaseCache implements CacheContract
13
+ {
14
+ const OPTION_KEY = 'analyst_cache';
15
+
16
+ protected static $instance;
17
+
18
+ /**
19
+ * Get instance of db cache
20
+ *
21
+ * @return DatabaseCache
22
+ */
23
+ public static function getInstance()
24
+ {
25
+ if (!self::$instance) {
26
+ self::$instance = new DatabaseCache();
27
+ }
28
+
29
+ return self::$instance;
30
+ }
31
+
32
+ /**
33
+ * Key value pair
34
+ *
35
+ * @var array[]
36
+ */
37
+ protected $values = [];
38
+
39
+ /**
40
+ * DatabaseCache constructor.
41
+ */
42
+ public function __construct()
43
+ {
44
+ $raw = get_option(self::OPTION_KEY, serialize([]));
45
+
46
+ // Raw data may be an array already
47
+ $this->values = is_array($raw) ? $raw : @unserialize($raw);
48
+
49
+ // In case serialization is failed
50
+ // make sure values is an array
51
+ if (!is_array($this->values)) {
52
+ $this->values = [];
53
+ }
54
+ }
55
+
56
+ /**
57
+ * Save value with given key
58
+ *
59
+ * @param string $key
60
+ * @param string $value
61
+ *
62
+ * @return static
63
+ */
64
+ public function put($key, $value)
65
+ {
66
+ $this->values[$key] = $value;
67
+
68
+ $this->sync();
69
+
70
+ return $this;
71
+ }
72
+
73
+ /**
74
+ * Get value by given key
75
+ *
76
+ * @param $key
77
+ *
78
+ * @param null $default
79
+ * @return string
80
+ */
81
+ public function get($key, $default = null)
82
+ {
83
+ $value = isset($this->values[$key]) ? $this->values[$key] : $default;
84
+
85
+ return $value;
86
+ }
87
+
88
+ /**
89
+ * @param $key
90
+ *
91
+ * @return static
92
+ */
93
+ public function delete($key)
94
+ {
95
+ if (isset($this->values[$key])) {
96
+ unset($this->values[$key]);
97
+
98
+ $this->sync();
99
+ }
100
+
101
+ return $this;
102
+ }
103
+
104
+ /**
105
+ * Update cache in DB
106
+ */
107
+ protected function sync()
108
+ {
109
+ update_option(self::OPTION_KEY, serialize($this->values));
110
+ }
111
+
112
+ /**
113
+ * Should get value and remove it from cache
114
+ *
115
+ * @param $key
116
+ * @param null $default
117
+ * @return mixed
118
+ */
119
+ public function pop($key, $default = null)
120
+ {
121
+ $value = $this->get($key);
122
+
123
+ $this->delete($key);
124
+
125
+ return $value;
126
+ }
127
+ }
analyst/src/Collector.php CHANGED
@@ -1,217 +1,217 @@
1
- <?php
2
-
3
- namespace Analyst;
4
-
5
- use Analyst\Contracts\AnalystContract;
6
-
7
- /**
8
- * Class Collector is a set of getters
9
- * to retrieve some data from wp site
10
- */
11
- class Collector
12
- {
13
- /**
14
- * @var AnalystContract
15
- */
16
- protected $sdk;
17
-
18
- /**
19
- * @var \WP_User
20
- */
21
- protected $user;
22
-
23
- public function __construct(AnalystContract $sdk)
24
- {
25
- $this->sdk = $sdk;
26
- }
27
-
28
- /**
29
- * Load current user into memory
30
- */
31
- public function loadCurrentUser()
32
- {
33
- $this->user = wp_get_current_user();
34
- }
35
-
36
- /**
37
- * Get site url
38
- *
39
- * @return string
40
- */
41
- public function getSiteUrl()
42
- {
43
- return get_option('siteurl');
44
- }
45
-
46
- /**
47
- * Get current user email
48
- *
49
- * @return string
50
- */
51
- public function getCurrentUserEmail()
52
- {
53
- return $this->user->user_email;
54
- }
55
-
56
- /**
57
- * Get's email from general settings
58
- *
59
- * @return string
60
- */
61
- public function getGeneralEmailAddress()
62
- {
63
- return get_option('admin_email');
64
- }
65
-
66
- /**
67
- * Is this user administrator
68
- *
69
- * @return bool
70
- */
71
- public function isUserAdministrator()
72
- {
73
- return in_array('administrator', $this->user->roles);
74
- }
75
-
76
- /**
77
- * User name
78
- *
79
- * @return string
80
- */
81
- public function getCurrentUserName()
82
- {
83
- return $this->user ? $this->user->user_nicename : 'unknown';
84
- }
85
-
86
- /**
87
- * WP version
88
- *
89
- * @return string
90
- */
91
- public function getWordPressVersion()
92
- {
93
- global $wp_version;
94
-
95
- return $wp_version;
96
- }
97
-
98
- /**
99
- * PHP version
100
- *
101
- * @return string
102
- */
103
- public function getPHPVersion()
104
- {
105
- return phpversion();
106
- }
107
-
108
- /**
109
- * Resolves plugin information
110
- *
111
- * @param string $path Absolute path to plugin
112
- * @return array
113
- */
114
- public function resolvePluginData($path)
115
- {
116
- if( !function_exists('get_plugin_data') ){
117
- require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
118
- }
119
-
120
- return get_plugin_data($path);
121
- }
122
-
123
- /**
124
- * Get plugin name by path
125
- *
126
- * @param $path
127
- * @return string
128
- */
129
- public function getPluginName($path)
130
- {
131
- $data = $this->resolvePluginData($path);
132
-
133
- return $data['Name'];
134
- }
135
-
136
- /**
137
- * Get plugin version
138
- *
139
- * @param $path
140
- * @return string
141
- */
142
- public function getPluginVersion($path)
143
- {
144
- $data = $this->resolvePluginData($path);
145
-
146
- return $data['Version'] ? $data['Version'] : null;
147
- }
148
-
149
- /**
150
- * Get server ip
151
- *
152
- * @return string
153
- */
154
- public function getServerIp()
155
- {
156
- return $_SERVER['SERVER_ADDR'];
157
- }
158
-
159
- /**
160
- * @return string
161
- */
162
- public function getSDKVersion()
163
- {
164
- return $this->sdk->version();
165
- }
166
-
167
- /**
168
- * @return string
169
- */
170
- public function getMysqlVersion()
171
- {
172
- $conn = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
173
-
174
- $version = mysqli_get_server_info($conn);
175
-
176
- return $version ? $version : 'unknown';
177
- }
178
-
179
- /**
180
- * @return string
181
- */
182
- public function getSiteLanguage()
183
- {
184
- return get_locale();
185
- }
186
-
187
-
188
- /**
189
- * Current WP theme
190
- *
191
- * @return false|string
192
- */
193
- public function getCurrentThemeName()
194
- {
195
- return wp_get_theme()->get('Name');
196
- }
197
-
198
- /**
199
- * Get active plugins list
200
- *
201
- * @return array
202
- */
203
- public function getActivePluginsList()
204
- {
205
- if (!function_exists('get_plugins')) {
206
- require_once ABSPATH . 'wp-admin/includes/plugin.php';
207
- }
208
-
209
- $allPlugins = get_plugins();
210
-
211
- $activePluginsNames = array_map(function ($path) use ($allPlugins) {
212
- return $allPlugins[$path]['Name'];
213
- }, get_option('active_plugins'));
214
-
215
- return $activePluginsNames;
216
- }
217
- }
1
+ <?php
2
+
3
+ namespace Analyst;
4
+
5
+ use Analyst\Contracts\AnalystContract;
6
+
7
+ /**
8
+ * Class Collector is a set of getters
9
+ * to retrieve some data from wp site
10
+ */
11
+ class Collector
12
+ {
13
+ /**
14
+ * @var AnalystContract
15
+ */
16
+ protected $sdk;
17
+
18
+ /**
19
+ * @var \WP_User
20
+ */
21
+ protected $user;
22
+
23
+ public function __construct(AnalystContract $sdk)
24
+ {
25
+ $this->sdk = $sdk;
26
+ }
27
+
28
+ /**
29
+ * Load current user into memory
30
+ */
31
+ public function loadCurrentUser()
32
+ {
33
+ $this->user = wp_get_current_user();
34
+ }
35
+
36
+ /**
37
+ * Get site url
38
+ *
39
+ * @return string
40
+ */
41
+ public function getSiteUrl()
42
+ {
43
+ return get_option('siteurl');
44
+ }
45
+
46
+ /**
47
+ * Get current user email
48
+ *
49
+ * @return string
50
+ */
51
+ public function getCurrentUserEmail()
52
+ {
53
+ return $this->user->user_email;
54
+ }
55
+
56
+ /**
57
+ * Get's email from general settings
58
+ *
59
+ * @return string
60
+ */
61
+ public function getGeneralEmailAddress()
62
+ {
63
+ return get_option('admin_email');
64
+ }
65
+
66
+ /**
67
+ * Is this user administrator
68
+ *
69
+ * @return bool
70
+ */
71
+ public function isUserAdministrator()
72
+ {
73
+ return in_array('administrator', $this->user->roles);
74
+ }
75
+
76
+ /**
77
+ * User name
78
+ *
79
+ * @return string
80
+ */
81
+ public function getCurrentUserName()
82
+ {
83
+ return $this->user ? $this->user->user_nicename : 'unknown';
84
+ }
85
+
86
+ /**
87
+ * WP version
88
+ *
89
+ * @return string
90
+ */
91
+ public function getWordPressVersion()
92
+ {
93
+ global $wp_version;
94
+
95
+ return $wp_version;
96
+ }
97
+
98
+ /**
99
+ * PHP version
100
+ *
101
+ * @return string
102
+ */
103
+ public function getPHPVersion()
104
+ {
105
+ return phpversion();
106
+ }
107
+
108
+ /**
109
+ * Resolves plugin information
110
+ *
111
+ * @param string $path Absolute path to plugin
112
+ * @return array
113
+ */
114
+ public function resolvePluginData($path)
115
+ {
116
+ if( !function_exists('get_plugin_data') ){
117
+ require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
118
+ }
119
+
120
+ return get_plugin_data($path);
121
+ }
122
+
123
+ /**
124
+ * Get plugin name by path
125
+ *
126
+ * @param $path
127
+ * @return string
128
+ */
129
+ public function getPluginName($path)
130
+ {
131
+ $data = $this->resolvePluginData($path);
132
+
133
+ return $data['Name'];
134
+ }
135
+
136
+ /**
137
+ * Get plugin version
138
+ *
139
+ * @param $path
140
+ * @return string
141
+ */
142
+ public function getPluginVersion($path)
143
+ {
144
+ $data = $this->resolvePluginData($path);
145
+
146
+ return $data['Version'] ? $data['Version'] : null;
147
+ }
148
+
149
+ /**
150
+ * Get server ip
151
+ *
152
+ * @return string
153
+ */
154
+ public function getServerIp()
155
+ {
156
+ return $_SERVER['SERVER_ADDR'];
157
+ }
158
+
159
+ /**
160
+ * @return string
161
+ */
162
+ public function getSDKVersion()
163
+ {
164
+ return $this->sdk->version();
165
+ }
166
+
167
+ /**
168
+ * @return string
169
+ */
170
+ public function getMysqlVersion()
171
+ {
172
+ $conn = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
173
+
174
+ $version = mysqli_get_server_info($conn);
175
+
176
+ return $version ? $version : 'unknown';
177
+ }
178
+
179
+ /**
180
+ * @return string
181
+ */
182
+ public function getSiteLanguage()
183
+ {
184
+ return get_locale();
185
+ }
186
+
187
+
188
+ /**
189
+ * Current WP theme
190
+ *
191
+ * @return false|string
192
+ */
193
+ public function getCurrentThemeName()
194
+ {
195
+ return wp_get_theme()->get('Name');
196
+ }
197
+
198
+ /**
199
+ * Get active plugins list
200
+ *
201
+ * @return array
202
+ */
203
+ public function getActivePluginsList()
204
+ {
205
+ if (!function_exists('get_plugins')) {
206
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
207
+ }
208
+
209
+ $allPlugins = get_plugins();
210
+
211
+ $activePluginsNames = array_map(function ($path) use ($allPlugins) {
212
+ return $allPlugins[$path]['Name'];
213
+ }, get_option('active_plugins'));
214
+
215
+ return $activePluginsNames;
216
+ }
217
+ }
analyst/src/Contracts/AnalystContract.php CHANGED
@@ -1,12 +1,12 @@
1
- <?php
2
- namespace Analyst\Contracts;
3
-
4
- interface AnalystContract
5
- {
6
- /**
7
- * Must return version of analyst
8
- *
9
- * @return string
10
- */
11
- public static function version();
12
- }
1
+ <?php
2
+ namespace Analyst\Contracts;
3
+
4
+ interface AnalystContract
5
+ {
6
+ /**
7
+ * Must return version of analyst
8
+ *
9
+ * @return string
10
+ */
11
+ public static function version();
12
+ }
analyst/src/Contracts/CacheContract.php CHANGED
@@ -1,47 +1,47 @@
1
- <?php
2
-
3
- namespace Analyst\Contracts;
4
-
5
- /**
6
- * Interface CacheContract
7
- *
8
- * @since 1.1.5
9
- */
10
- interface CacheContract
11
- {
12
- /**
13
- * Save value with given key
14
- *
15
- * @param string $key
16
- * @param string $value
17
- *
18
- * @return static
19
- */
20
- public function put($key, $value);
21
-
22
- /**
23
- * Get value by given key
24
- *
25
- * @param $key
26
- *
27
- * @param null $default
28
- * @return string
29
- */
30
- public function get($key, $default = null);
31
-
32
- /**
33
- * @param $key
34
- *
35
- * @return static
36
- */
37
- public function delete($key);
38
-
39
- /**
40
- * Should get value and remove it from cache
41
- *
42
- * @param $key
43
- * @param null $default
44
- * @return mixed
45
- */
46
- public function pop($key, $default = null);
47
- }
1
+ <?php
2
+
3
+ namespace Analyst\Contracts;
4
+
5
+ /**
6
+ * Interface CacheContract
7
+ *
8
+ * @since 1.1.5
9
+ */
10
+ interface CacheContract
11
+ {
12
+ /**
13
+ * Save value with given key
14
+ *
15
+ * @param string $key
16
+ * @param string $value
17
+ *
18
+ * @return static
19
+ */
20
+ public function put($key, $value);
21
+
22
+ /**
23
+ * Get value by given key
24
+ *
25
+ * @param $key
26
+ *
27
+ * @param null $default
28
+ * @return string
29
+ */
30
+ public function get($key, $default = null);
31
+
32
+ /**
33
+ * @param $key
34
+ *
35
+ * @return static
36
+ */
37
+ public function delete($key);
38
+
39
+ /**
40
+ * Should get value and remove it from cache
41
+ *
42
+ * @param $key
43
+ * @param null $default
44
+ * @return mixed
45
+ */
46
+ public function pop($key, $default = null);
47
+ }
analyst/src/Contracts/HttpClientContract.php CHANGED
@@ -1,25 +1,25 @@
1
- <?php
2
- namespace Analyst\Contracts;
3
-
4
- use Analyst\ApiResponse;
5
-
6
- interface HttpClientContract
7
- {
8
- /**
9
- * Make an http request
10
- *
11
- * @param $method
12
- * @param $url
13
- * @param $body
14
- * @param $headers
15
- * @return ApiResponse
16
- */
17
- public function request($method, $url, $body, $headers);
18
-
19
- /**
20
- * Must return `true` if client is supported
21
- *
22
- * @return bool
23
- */
24
- public static function hasSupport();
25
- }
1
+ <?php
2
+ namespace Analyst\Contracts;
3
+
4
+ use Analyst\ApiResponse;
5
+
6
+ interface HttpClientContract
7
+ {
8
+ /**
9
+ * Make an http request
10
+ *
11
+ * @param $method
12
+ * @param $url
13
+ * @param $body
14
+ * @param $headers
15
+ * @return ApiResponse
16
+ */
17
+ public function request($method, $url, $body, $headers);
18
+
19
+ /**
20
+ * Must return `true` if client is supported
21
+ *
22
+ * @return bool
23
+ */
24
+ public static function hasSupport();
25
+ }
analyst/src/Contracts/RequestContract.php CHANGED
@@ -1,22 +1,22 @@
1
- <?php
2
-
3
- namespace Analyst\Contracts;
4
-
5
- use Analyst\ApiResponse;
6
-
7
- interface RequestContract
8
- {
9
- /**
10
- * Cast request data to array
11
- *
12
- * @return array
13
- */
14
- public function toArray();
15
-
16
- /**
17
- * Execute the request
18
- * @param RequestorContract $requestor
19
- * @return ApiResponse
20
- */
21
- public function execute(RequestorContract $requestor);
22
- }
1
+ <?php
2
+
3
+ namespace Analyst\Contracts;
4
+
5
+ use Analyst\ApiResponse;
6
+
7
+ interface RequestContract
8
+ {
9
+ /**
10
+ * Cast request data to array
11
+ *
12
+ * @return array
13
+ */
14
+ public function toArray();
15
+
16
+ /**
17
+ * Execute the request
18
+ * @param RequestorContract $requestor
19
+ * @return ApiResponse
20
+ */
21
+ public function execute(RequestorContract $requestor);
22
+ }
analyst/src/Contracts/RequestorContract.php CHANGED
@@ -1,44 +1,44 @@
1
- <?php
2
-
3
- namespace Analyst\Contracts;
4
-
5
- interface RequestorContract
6
- {
7
- /**
8
- * Get request
9
- *
10
- * @param $url
11
- * @param array $headers
12
- * @return mixed
13
- */
14
- public function get($url, $headers = []);
15
-
16
- /**
17
- * Post request
18
- *
19
- * @param $url
20
- * @param $body
21
- * @param array $headers
22
- * @return mixed
23
- */
24
- public function post($url, $body = [], $headers = []);
25
-
26
- /**
27
- * Put request
28
- *
29
- * @param $url
30
- * @param $body
31
- * @param array $headers
32
- * @return mixed
33
- */
34
- public function put($url, $body = [], $headers = []);
35
-
36
- /**
37
- * Delete request
38
- *
39
- * @param $url
40
- * @param array $headers
41
- * @return mixed
42
- */
43
- public function delete($url, $headers = []);
44
- }
1
+ <?php
2
+
3
+ namespace Analyst\Contracts;
4
+
5
+ interface RequestorContract
6
+ {
7
+ /**
8
+ * Get request
9
+ *
10
+ * @param $url
11
+ * @param array $headers
12
+ * @return mixed
13
+ */
14
+ public function get($url, $headers = []);
15
+
16
+ /**
17
+ * Post request
18
+ *
19
+ * @param $url
20
+ * @param $body
21
+ * @param array $headers
22
+ * @return mixed
23
+ */
24
+ public function post($url, $body = [], $headers = []);
25
+
26
+ /**
27
+ * Put request
28
+ *
29
+ * @param $url
30
+ * @param $body
31
+ * @param array $headers
32
+ * @return mixed
33
+ */
34
+ public function put($url, $body = [], $headers = []);
35
+
36
+ /**
37
+ * Delete request
38
+ *
39
+ * @param $url
40
+ * @param array $headers
41
+ * @return mixed
42
+ */
43
+ public function delete($url, $headers = []);
44
+ }
analyst/src/Contracts/TrackerContract.php CHANGED
@@ -1,69 +1,69 @@
1
- <?php
2
-
3
- namespace Analyst\Contracts;
4
-
5
- interface TrackerContract
6
- {
7
- /**
8
- * Should register activation and deactivation
9
- * event hooks
10
- *
11
- * @return void
12
- */
13
- public function registerHooks();
14
-
15
- /**
16
- * Will fire when admin activates plugin
17
- *
18
- * @return void
19
- */
20
- public function onActivePluginListener();
21
-
22
- /**
23
- * Will fire when admin deactivates plugin
24
- *
25
- * @return void
26
- */
27
- public function onDeactivatePluginListener();
28
-
29
- /**
30
- * Will fire when user opted in
31
- *
32
- * @return void
33
- */
34
- public function onOptInListener();
35
-
36
- /**
37
- * Will fire when user opted out
38
- *
39
- * @return void
40
- */
41
- public function onOptOutListener();
42
-
43
- /**
44
- * Will fire when user accept opt/in at first time
45
- *
46
- * @return void
47
- */
48
- public function onInstallListener();
49
-
50
- /**
51
- * Will fire when user skipped installation
52
- *
53
- * @return void
54
- */
55
- public function onSkipInstallListener();
56
-
57
- /**
58
- * Will fire when user delete plugin through admin panel.
59
- * This action will happen if admin at least once
60
- * activated the plugin.
61
- *
62
- * The register_uninstall_hook function accepts only static
63
- * function or global function to be executed, so this is
64
- * why this method is static
65
- *
66
- * @return void
67
- */
68
- public static function onUninstallPluginListener();
69
- }
1
+ <?php
2
+
3
+ namespace Analyst\Contracts;
4
+
5
+ interface TrackerContract
6
+ {
7
+ /**
8
+ * Should register activation and deactivation
9
+ * event hooks
10
+ *
11
+ * @return void
12
+ */
13
+ public function registerHooks();
14
+
15
+ /**
16
+ * Will fire when admin activates plugin
17
+ *
18
+ * @return void
19
+ */
20
+ public function onActivePluginListener();
21
+
22
+ /**
23
+ * Will fire when admin deactivates plugin
24
+ *
25
+ * @return void
26
+ */
27
+ public function onDeactivatePluginListener();
28
+
29
+ /**
30
+ * Will fire when user opted in
31
+ *
32
+ * @return void
33
+ */
34
+ public function onOptInListener();
35
+
36
+ /**
37
+ * Will fire when user opted out
38
+ *
39
+ * @return void
40
+ */
41
+ public function onOptOutListener();
42
+
43
+ /**
44
+ * Will fire when user accept opt/in at first time
45
+ *
46
+ * @return void
47
+ */
48
+ public function onInstallListener();
49
+
50
+ /**
51
+ * Will fire when user skipped installation
52
+ *
53
+ * @return void
54
+ */
55
+ public function onSkipInstallListener();
56
+
57
+ /**
58
+ * Will fire when user delete plugin through admin panel.
59
+ * This action will happen if admin at least once
60
+ * activated the plugin.
61
+ *
62
+ * The register_uninstall_hook function accepts only static
63
+ * function or global function to be executed, so this is
64
+ * why this method is static
65
+ *
66
+ * @return void
67
+ */
68
+ public static function onUninstallPluginListener();
69
+ }
analyst/src/Core/AbstractFactory.php CHANGED
@@ -1,27 +1,27 @@
1
- <?php
2
-
3
- namespace Analyst\Core;
4
-
5
- abstract class AbstractFactory
6
- {
7
- /**
8
- * Unserialize to static::class instance
9
- *
10
- * @param $raw
11
- * @return static
12
- */
13
- protected static function unserialize($raw)
14
- {
15
- $instance = @unserialize($raw);
16
-
17
- $isProperObject = is_object($instance) && $instance instanceof static;
18
-
19
- // In case for some reason unserialized object is not
20
- // static::class we make sure it is static::class
21
- if (!$isProperObject) {
22
- $instance = new static();
23
- }
24
-
25
- return $instance;
26
- }
27
- }
1
+ <?php
2
+
3
+ namespace Analyst\Core;
4
+
5
+ abstract class AbstractFactory
6
+ {
7
+ /**
8
+ * Unserialize to static::class instance
9
+ *
10
+ * @param $raw
11
+ * @return static
12
+ */
13
+ protected static function unserialize($raw)
14
+ {
15
+ $instance = @unserialize($raw);
16
+
17
+ $isProperObject = is_object($instance) && $instance instanceof static;
18
+
19
+ // In case for some reason unserialized object is not
20
+ // static::class we make sure it is static::class
21
+ if (!$isProperObject) {
22
+ $instance = new static();
23
+ }
24
+
25
+ return $instance;
26
+ }
27
+ }
analyst/src/Http/CurlHttpClient.php CHANGED
@@ -1,102 +1,102 @@
1
- <?php
2
-
3
- namespace Analyst\Http;
4
-
5
- use Analyst\ApiResponse;
6
- use Analyst\Contracts\HttpClientContract;
7
-
8
- class CurlHttpClient implements HttpClientContract
9
- {
10
- /**
11
- * Make an http request
12
- *
13
- * @param $method
14
- * @param $url
15
- * @param array $body
16
- * @param $headers
17
- * @return mixed
18
- */
19
- public function request($method, $url, $body, $headers)
20
- {
21
- $method = strtoupper($method);
22
-
23
- $options = [
24
- CURLOPT_RETURNTRANSFER => true,
25
- CURLOPT_URL => $url,
26
- CURLOPT_HTTPHEADER => $this->prepareRequestHeaders($headers),
27
- CURLOPT_CUSTOMREQUEST => $method,
28
- CURLOPT_FAILONERROR => true,
29
- CURLOPT_HEADER => true,
30
- CURLOPT_TIMEOUT => 30,
31
- ];
32
-
33
- if ($method === 'POST') {
34
- $options[CURLOPT_POST] = 1;
35
- $options[CURLOPT_POSTFIELDS] = json_encode($body);
36
- }
37
-
38
- $curl = curl_init();
39
-
40
- curl_setopt_array($curl, $options);
41
-
42
- $response = curl_exec($curl);
43
-
44
- list($rawHeaders, $rawBody) = explode("\r\n\r\n", $response, 2);
45
-
46
- $info = curl_getinfo($curl);
47
-
48
- curl_close($curl);
49
-
50
- $responseHeaders = $this->resolveResponseHeaders($rawHeaders);
51
- $responseBody = json_decode($rawBody, true);
52
-
53
- return new ApiResponse($responseBody, $info['http_code'], $responseHeaders);
54
- }
55
-
56
- /**
57
- * Must return `true` if client is supported
58
- *
59
- * @return bool
60
- */
61
- public static function hasSupport()
62
- {
63
- return function_exists('curl_version');
64
- }
65
-
66
- /**
67
- * Modify request headers from key value pair
68
- * to vector array
69
- *
70
- * @param array $headers
71
- * @return array
72
- */
73
- protected function prepareRequestHeaders ($headers)
74
- {
75
- return array_map(function ($key, $value) {
76
- return sprintf('%s:%s', $key, $value);
77
- }, array_keys($headers), $headers);
78
- }
79
-
80
- /**
81
- * Resolve raw response headers as
82
- * associative array
83
- *
84
- * @param $rawHeaders
85
- * @return array
86
- */
87
- private function resolveResponseHeaders($rawHeaders)
88
- {
89
- $headers = [];
90
-
91
- foreach (explode("\r\n", $rawHeaders) as $i => $line) {
92
- $parts = explode(': ', $line);
93
-
94
- if (count($parts) === 1) {
95
- continue;
96
- }
97
-
98
- $headers[$parts[0]] = $parts[1];
99
- }
100
- return $headers;
101
- }
102
- }
1
+ <?php
2
+
3
+ namespace Analyst\Http;
4
+
5
+ use Analyst\ApiResponse;
6
+ use Analyst\Contracts\HttpClientContract;
7
+
8
+ class CurlHttpClient implements HttpClientContract
9
+ {
10
+ /**
11
+ * Make an http request
12
+ *
13
+ * @param $method
14
+ * @param $url
15
+ * @param array $body
16
+ * @param $headers
17
+ * @return mixed
18
+ */
19
+ public function request($method, $url, $body, $headers)
20
+ {
21
+ $method = strtoupper($method);
22
+
23
+ $options = [
24
+ CURLOPT_RETURNTRANSFER => true,
25
+ CURLOPT_URL => $url,
26
+ CURLOPT_HTTPHEADER => $this->prepareRequestHeaders($headers),
27
+ CURLOPT_CUSTOMREQUEST => $method,
28
+ CURLOPT_FAILONERROR => true,
29
+ CURLOPT_HEADER => true,
30
+ CURLOPT_TIMEOUT => 30,
31
+ ];
32
+
33
+ if ($method === 'POST') {
34
+ $options[CURLOPT_POST] = 1;
35
+ $options[CURLOPT_POSTFIELDS] = json_encode($body);
36
+ }
37
+
38
+ $curl = curl_init();
39
+
40
+ curl_setopt_array($curl, $options);
41
+
42
+ $response = curl_exec($curl);
43
+
44
+ list($rawHeaders, $rawBody) = explode("\r\n\r\n", $response, 2);
45
+
46
+ $info = curl_getinfo($curl);
47
+
48
+ curl_close($curl);
49
+
50
+ $responseHeaders = $this->resolveResponseHeaders($rawHeaders);
51
+ $responseBody = json_decode($rawBody, true);
52
+
53
+ return new ApiResponse($responseBody, $info['http_code'], $responseHeaders);
54
+ }
55
+
56
+ /**
57
+ * Must return `true` if client is supported
58
+ *
59
+ * @return bool
60
+ */
61
+ public static function hasSupport()
62
+ {
63
+ return function_exists('curl_version');
64
+ }
65
+
66
+ /**
67
+ * Modify request headers from key value pair
68
+ * to vector array
69
+ *
70
+ * @param array $headers
71
+ * @return array
72
+ */
73
+ protected function prepareRequestHeaders ($headers)
74
+ {
75
+ return array_map(function ($key, $value) {
76
+ return sprintf('%s:%s', $key, $value);
77
+ }, array_keys($headers), $headers);
78
+ }
79
+
80
+ /**
81
+ * Resolve raw response headers as
82
+ * associative array
83
+ *
84
+ * @param $rawHeaders
85
+ * @return array
86
+ */
87
+ private function resolveResponseHeaders($rawHeaders)
88
+ {
89
+ $headers = [];
90
+
91
+ foreach (explode("\r\n", $rawHeaders) as $i => $line) {
92
+ $parts = explode(': ', $line);
93
+
94
+ if (count($parts) === 1) {
95
+ continue;
96
+ }
97
+
98
+ $headers[$parts[0]] = $parts[1];
99
+ }
100
+ return $headers;
101
+ }
102
+ }
analyst/src/Http/DummyHttpClient.php CHANGED
@@ -1,33 +1,33 @@
1
- <?php
2
-
3
- namespace Analyst\Http;
4
-
5
- use Analyst\ApiResponse;
6
- use Analyst\Contracts\HttpClientContract;
7
-
8
- class DummyHttpClient implements HttpClientContract
9
- {
10
- /**
11
- * Make an http request
12
- *
13
- * @param $method
14
- * @param $url
15
- * @param $body
16
- * @param $headers
17
- * @return ApiResponse
18
- */
19
- public function request($method, $url, $body, $headers)
20
- {
21
- return new ApiResponse('Dummy response', 200, []);
22
- }
23
-
24
- /**
25
- * Must return `true` if client is supported
26
- *
27
- * @return bool
28
- */
29
- public static function hasSupport()
30
- {
31
- return true;
32
- }
33
- }
1
+ <?php
2
+
3
+ namespace Analyst\Http;
4
+
5
+ use Analyst\ApiResponse;
6
+ use Analyst\Contracts\HttpClientContract;
7
+
8
+ class DummyHttpClient implements HttpClientContract
9
+ {
10
+ /**
11
+ * Make an http request
12
+ *
13
+ * @param $method
14
+ * @param $url
15
+ * @param $body
16
+ * @param $headers
17
+ * @return ApiResponse
18
+ */
19
+ public function request($method, $url, $body, $headers)
20
+ {
21
+ return new ApiResponse('Dummy response', 200, []);
22
+ }
23
+
24
+ /**
25
+ * Must return `true` if client is supported
26
+ *
27
+ * @return bool
28
+ */
29
+ public static function hasSupport()
30
+ {
31
+ return true;
32
+ }
33
+ }
analyst/src/Http/Requests/AbstractLoggerRequest.php CHANGED
@@ -1,64 +1,64 @@
1
- <?php
2
-
3
- namespace Analyst\Http\Requests;
4
-
5
- use Analyst\ApiResponse;
6
- use Analyst\Collector;
7
- use Analyst\Contracts\RequestContract;
8
- use Analyst\Contracts\RequestorContract;
9
-
10
- abstract class AbstractLoggerRequest implements RequestContract
11
- {
12
- /**
13
- * @var Collector
14
- */
15
- protected $collector;
16
-
17
- /**
18
- * @var integer
19
- */
20
- protected $id;
21
-
22
- /**
23
- * @var string
24
- */
25
- protected $path;
26
-
27
- public function __construct(Collector $collector, $pluginId, $path)
28
- {
29
- $this->collector = $collector;
30
- $this->id = $pluginId;
31
- $this->path = $path;
32
- }
33
-
34
- /**
35
- * Cast request data to array
36
- *
37
- * @return array
38
- */
39
- public function toArray()
40
- {
41
- return [
42
- 'plugin_id' => $this->id,
43
- 'php_version' => $this->collector->getPHPVersion(),
44
- 'wp_version' => $this->collector->getWordPressVersion(),
45
- 'plugin_version' => $this->collector->getPluginVersion($this->path),
46
- 'url' => $this->collector->getSiteUrl(),
47
- 'sdk_version' => $this->collector->getSDKVersion(),
48
- 'ip' => $this->collector->getServerIp(),
49
- 'mysql_version' => $this->collector->getMysqlVersion(),
50
- 'locale' => $this->collector->getSiteLanguage(),
51
- 'current_theme' => $this->collector->getCurrentThemeName(),
52
- 'active_plugins_list' => implode(', ', $this->collector->getActivePluginsList()),
53
- 'email' => $this->collector->getGeneralEmailAddress(),
54
- 'name' => $this->collector->getCurrentUserName()
55
- ];
56
- }
57
-
58
- /**
59
- * Execute the request
60
- * @param RequestorContract $requestor
61
- * @return ApiResponse
62
- */
63
- public abstract function execute(RequestorContract $requestor);
64
- }
1
+ <?php
2
+
3
+ namespace Analyst\Http\Requests;
4
+
5
+ use Analyst\ApiResponse;
6
+ use Analyst\Collector;
7
+ use Analyst\Contracts\RequestContract;
8
+ use Analyst\Contracts\RequestorContract;
9
+
10
+ abstract class AbstractLoggerRequest implements RequestContract
11
+ {
12
+ /**
13
+ * @var Collector
14
+ */
15
+ protected $collector;
16
+
17
+ /**
18
+ * @var integer
19
+ */
20
+ protected $id;
21
+
22
+ /**
23
+ * @var string
24
+ */
25
+ protected $path;
26
+
27
+ public function __construct(Collector $collector, $pluginId, $path)
28
+ {
29
+ $this->collector = $collector;
30
+ $this->id = $pluginId;
31
+ $this->path = $path;
32
+ }
33
+
34
+ /**
35
+ * Cast request data to array
36
+ *
37
+ * @return array
38
+ */
39
+ public function toArray()
40
+ {
41
+ return [
42
+ 'plugin_id' => $this->id,
43
+ 'php_version' => $this->collector->getPHPVersion(),
44
+ 'wp_version' => $this->collector->getWordPressVersion(),
45
+ 'plugin_version' => $this->collector->getPluginVersion($this->path),
46
+ 'url' => $this->collector->getSiteUrl(),
47
+ 'sdk_version' => $this->collector->getSDKVersion(),
48
+ 'ip' => $this->collector->getServerIp(),
49
+ 'mysql_version' => $this->collector->getMysqlVersion(),
50
+ 'locale' => $this->collector->getSiteLanguage(),
51
+ 'current_theme' => $this->collector->getCurrentThemeName(),
52
+ 'active_plugins_list' => implode(', ', $this->collector->getActivePluginsList()),
53
+ 'email' => $this->collector->getGeneralEmailAddress(),
54
+ 'name' => $this->collector->getCurrentUserName()
55
+ ];
56
+ }
57
+
58
+ /**
59
+ * Execute the request
60
+ * @param RequestorContract $requestor
61
+ * @return ApiResponse
62
+ */
63
+ public abstract function execute(RequestorContract $requestor);
64
+ }
analyst/src/Http/Requests/ActivateRequest.php CHANGED
@@ -1,42 +1,42 @@
1
- <?php
2
-
3
- namespace Analyst\Http\Requests;
4
-
5
- use Analyst\ApiResponse;
6
- use Analyst\Collector;
7
- use Analyst\Contracts\RequestContract;
8
- use Analyst\Contracts\RequestorContract;
9
-
10
- /**
11
- * Class ActivateRequest
12
- *
13
- * Is is very similar to install request
14
- * but with different path
15
- *
16
- * @since 0.9.12
17
- */
18
- class ActivateRequest extends AbstractLoggerRequest
19
- {
20
- /**
21
- * Execute the request
22
- * @param RequestorContract $requestor
23
- * @return ApiResponse
24
- */
25
- public function execute(RequestorContract $requestor)
26
- {
27
- return $requestor->post('logger/activate', $this->toArray());
28
- }
29
-
30
- /**
31
- * Make request instance
32
- *
33
- * @param Collector $collector
34
- * @param $pluginId
35
- * @param $path
36
- * @return static
37
- */
38
- public static function make(Collector $collector, $pluginId, $path)
39
- {
40
- return new static($collector, $pluginId, $path);
41
- }
42
- }
1
+ <?php
2
+
3
+ namespace Analyst\Http\Requests;
4
+
5
+ use Analyst\ApiResponse;
6
+ use Analyst\Collector;
7
+ use Analyst\Contracts\RequestContract;
8
+ use Analyst\Contracts\RequestorContract;
9
+
10
+ /**
11
+ * Class ActivateRequest
12
+ *
13
+ * Is is very similar to install request
14
+ * but with different path
15
+ *
16
+ * @since 0.9.12
17
+ */
18
+ class ActivateRequest extends AbstractLoggerRequest
19
+ {
20
+ /**
21
+ * Execute the request
22
+ * @param RequestorContract $requestor
23
+ * @return ApiResponse
24
+ */
25
+ public function execute(RequestorContract $requestor)
26
+ {
27
+ return $requestor->post('logger/activate', $this->toArray());
28
+ }
29
+
30
+ /**
31
+ * Make request instance
32
+ *
33
+ * @param Collector $collector
34
+ * @param $pluginId
35
+ * @param $path
36
+ * @return static
37
+ */
38
+ public static function make(Collector $collector, $pluginId, $path)
39
+ {
40
+ return new static($collector, $pluginId, $path);
41
+ }
42
+ }
analyst/src/Http/Requests/DeactivateRequest.php CHANGED
@@ -1,64 +1,64 @@
1
- <?php
2
-
3
- namespace Analyst\Http\Requests;
4
-
5
- use Analyst\ApiResponse;
6
- use Analyst\Collector;
7
- use Analyst\Contracts\RequestorContract;
8
-
9
- /**
10
- * Class DeactivateRequest
11
- *
12
- * @since 0.9.10
13
- */
14
- class DeactivateRequest extends AbstractLoggerRequest
15
- {
16
- /**
17
- * @var string
18
- */
19
- protected $question;
20
-
21
- /**
22
- * @var string
23
- */
24
- protected $answer;
25
-
26
- /**
27
- * @param Collector $collector
28
- * @param $pluginId
29
- * @param $path
30
- * @param $question
31
- * @param $answer
32
- * @return static
33
- */
34
- public static function make(Collector $collector, $pluginId, $path, $question, $answer)
35
- {
36
- return new static($collector, $pluginId, $path, $question, $answer);
37
- }
38
-
39
- public function __construct(Collector $collector, $pluginId, $path, $question, $answer)
40
- {
41
- parent::__construct($collector, $pluginId, $path);
42
-
43
- $this->question = $question;
44
- $this->answer = $answer;
45
- }
46
-
47
- public function toArray()
48
- {
49
- return array_merge(parent::toArray(), [
50
- 'question' => $this->question,
51
- 'answer' => $this->answer,
52
- ]);
53
- }
54
-
55
- /**
56
- * Execute the request
57
- * @param RequestorContract $requestor
58
- * @return ApiResponse
59
- */
60
- public function execute(RequestorContract $requestor)
61
- {
62
- return $requestor->post('logger/deactivate', $this->toArray());
63
- }
64
- }
1
+ <?php
2
+
3
+ namespace Analyst\Http\Requests;
4
+
5
+ use Analyst\ApiResponse;
6
+ use Analyst\Collector;
7
+ use Analyst\Contracts\RequestorContract;
8
+
9
+ /**
10
+ * Class DeactivateRequest
11
+ *
12
+ * @since 0.9.10
13
+ */
14
+ class DeactivateRequest extends AbstractLoggerRequest
15
+ {
16
+ /**
17
+ * @var string
18
+ */
19
+ protected $question;
20
+
21
+ /**
22
+ * @var string
23
+ */
24
+ protected $answer;
25
+
26
+ /**
27
+ * @param Collector $collector
28
+ * @param $pluginId
29
+ * @param $path
30
+ * @param $question
31
+ * @param $answer
32
+ * @return static
33
+ */
34
+ public static function make(Collector $collector, $pluginId, $path, $question, $answer)
35
+ {
36
+ return new static($collector, $pluginId, $path, $question, $answer);
37
+ }
38
+
39
+ public function __construct(Collector $collector, $pluginId, $path, $question, $answer)
40
+ {
41
+ parent::__construct($collector, $pluginId, $path);
42
+
43
+ $this->question = $question;
44
+ $this->answer = $answer;
45
+ }
46
+
47
+ public function toArray()
48
+ {
49
+ return array_merge(parent::toArray(), [
50
+ 'question' => $this->question,
51
+ 'answer' => $this->answer,
52
+ ]);
53
+ }
54
+
55
+ /**
56
+ * Execute the request
57
+ * @param RequestorContract $requestor
58
+ * @return ApiResponse
59
+ */
60
+ public function execute(RequestorContract $requestor)
61
+ {
62
+ return $requestor->post('logger/deactivate', $this->toArray());
63
+ }
64
+ }
analyst/src/Http/Requests/InstallRequest.php CHANGED
@@ -1,38 +1,38 @@
1
- <?php
2
-
3
- namespace Analyst\Http\Requests;
4
-
5
- use Analyst\ApiResponse;
6
- use Analyst\Collector;
7
- use Analyst\Contracts\RequestorContract;
8
-
9
- /**
10
- * Class InstallRequest
11
- *
12
- * @since 0.9.4
13
- */
14
- class InstallRequest extends AbstractLoggerRequest
15
- {
16
- /**
17
- * Execute the request
18
- * @param RequestorContract $requestor
19
- * @return ApiResponse
20
- */
21
- public function execute(RequestorContract $requestor)
22
- {
23
- return $requestor->post('logger/install', $this->toArray());
24
- }
25
-
26
- /**
27
- * Make request instance
28
- *
29
- * @param Collector $collector
30
- * @param $pluginId
31
- * @param $path
32
- * @return static
33
- */
34
- public static function make(Collector $collector, $pluginId, $path)
35
- {
36
- return new static($collector, $pluginId, $path);
37
- }
38
- }
1
+ <?php
2
+
3
+ namespace Analyst\Http\Requests;
4
+
5
+ use Analyst\ApiResponse;
6
+ use Analyst\Collector;
7
+ use Analyst\Contracts\RequestorContract;
8
+
9
+ /**
10
+ * Class InstallRequest
11
+ *
12
+ * @since 0.9.4
13
+ */
14
+ class InstallRequest extends AbstractLoggerRequest
15
+ {
16
+ /**
17
+ * Execute the request
18
+ * @param RequestorContract $requestor
19
+ * @return ApiResponse
20
+ */
21
+ public function execute(RequestorContract $requestor)
22
+ {
23
+ return $requestor->post('logger/install', $this->toArray());
24
+ }
25
+
26
+ /**
27
+ * Make request instance
28
+ *
29
+ * @param Collector $collector
30
+ * @param $pluginId
31
+ * @param $path
32
+ * @return static
33
+ */
34
+ public static function make(Collector $collector, $pluginId, $path)
35
+ {
36
+ return new static($collector, $pluginId, $path);
37
+ }
38
+ }
analyst/src/Http/Requests/OptInRequest.php CHANGED
@@ -1,42 +1,42 @@
1
- <?php
2
-
3
- namespace Analyst\Http\Requests;
4
-
5
- use Analyst\ApiResponse;
6
- use Analyst\Collector;
7
- use Analyst\Contracts\RequestContract;
8
- use Analyst\Contracts\RequestorContract;
9
-
10
- /**
11
- * Class OptInRequest
12
- *
13
- * Is is very similar to install request
14
- * but with different path
15
- *
16
- * @since 0.9.5
17
- */
18
- class OptInRequest extends AbstractLoggerRequest
19
- {
20
- /**
21
- * Execute the request
22
- * @param RequestorContract $requestor
23
- * @return ApiResponse
24
- */
25
- public function execute(RequestorContract $requestor)
26
- {
27
- return $requestor->post('logger/opt-in', $this->toArray());
28
- }
29
-
30
- /**
31
- * Make request instance
32
- *
33
- * @param Collector $collector
34
- * @param $pluginId
35
- * @param $path
36
- * @return static
37
- */
38
- public static function make(Collector $collector, $pluginId, $path)
39
- {
40
- return new static($collector, $pluginId, $path);
41
- }
42
- }
1
+ <?php
2
+
3
+ namespace Analyst\Http\Requests;
4
+
5
+ use Analyst\ApiResponse;
6
+ use Analyst\Collector;
7
+ use Analyst\Contracts\RequestContract;
8
+ use Analyst\Contracts\RequestorContract;
9
+
10
+ /**
11
+ * Class OptInRequest
12
+ *
13
+ * Is is very similar to install request
14
+ * but with different path
15
+ *
16
+ * @since 0.9.5
17
+ */
18
+ class OptInRequest extends AbstractLoggerRequest
19
+ {
20
+ /**
21
+ * Execute the request
22
+ * @param RequestorContract $requestor
23
+ * @return ApiResponse
24
+ */
25
+ public function execute(RequestorContract $requestor)
26
+ {
27
+ return $requestor->post('logger/opt-in', $this->toArray());
28
+ }
29
+
30
+ /**
31
+ * Make request instance
32
+ *
33
+ * @param Collector $collector
34
+ * @param $pluginId
35
+ * @param $path
36
+ * @return static
37
+ */
38
+ public static function make(Collector $collector, $pluginId, $path)
39
+ {
40
+ return new static($collector, $pluginId, $path);
41
+ }
42
+ }
analyst/src/Http/Requests/OptOutRequest.php CHANGED
@@ -1,40 +1,40 @@
1
- <?php
2
-
3
- namespace Analyst\Http\Requests;
4
-
5
- use Analyst\ApiResponse;
6
- use Analyst\Collector;
7
- use Analyst\Contracts\RequestContract;
8
- use Analyst\Contracts\RequestorContract;
9
-
10
- /**
11
- * Class OptOutRequest
12
- *
13
- * Is is very similar to install request
14
- * but with different path
15
- *
16
- * @since 0.9.9
17
- */
18
- class OptOutRequest extends AbstractLoggerRequest
19
- {
20
- /**
21
- * @param Collector $collector
22
- * @param $pluginId
23
- * @param $path
24
- * @return static
25
- */
26
- public static function make(Collector $collector, $pluginId, $path)
27
- {
28
- return new static($collector, $pluginId, $path);
29
- }
30
-
31
- /**
32
- * Execute the request
33
- * @param RequestorContract $requestor
34
- * @return ApiResponse
35
- */
36
- public function execute(RequestorContract $requestor)
37
- {
38
- return $requestor->post('logger/opt-out', $this->toArray());
39
- }
40
- }
1
+ <?php
2
+
3
+ namespace Analyst\Http\Requests;
4
+
5
+ use Analyst\ApiResponse;
6
+ use Analyst\Collector;
7
+ use Analyst\Contracts\RequestContract;
8
+ use Analyst\Contracts\RequestorContract;
9
+
10
+ /**
11
+ * Class OptOutRequest
12
+ *
13
+ * Is is very similar to install request
14
+ * but with different path
15
+ *
16
+ * @since 0.9.9
17
+ */
18
+ class OptOutRequest extends AbstractLoggerRequest
19
+ {
20
+ /**
21
+ * @param Collector $collector
22
+ * @param $pluginId
23
+ * @param $path
24
+ * @return static
25
+ */
26
+ public static function make(Collector $collector, $pluginId, $path)
27
+ {
28
+ return new static($collector, $pluginId, $path);
29
+ }
30
+
31
+ /**
32
+ * Execute the request
33
+ * @param RequestorContract $requestor
34
+ * @return ApiResponse
35
+ */
36
+ public function execute(RequestorContract $requestor)
37
+ {
38
+ return $requestor->post('logger/opt-out', $this->toArray());
39
+ }
40
+ }
analyst/src/Http/Requests/UninstallRequest.php CHANGED
@@ -1,36 +1,36 @@
1
- <?php
2
-
3
- namespace Analyst\Http\Requests;
4
-
5
- use Analyst\ApiResponse;
6
- use Analyst\Collector;
7
- use Analyst\Contracts\RequestorContract;
8
-
9
- /**
10
- * Class DeactivateRequest
11
- *
12
- * @since 0.9.13
13
- */
14
- class UninstallRequest extends AbstractLoggerRequest
15
- {
16
- /**
17
- * @param Collector $collector
18
- * @param $pluginId
19
- * @param $path
20
- * @return static
21
- */
22
- public static function make(Collector $collector, $pluginId, $path)
23
- {
24
- return new static($collector, $pluginId, $path);
25
- }
26
-
27
- /**
28
- * Execute the request
29
- * @param RequestorContract $requestor
30
- * @return ApiResponse
31
- */
32
- public function execute(RequestorContract $requestor)
33
- {
34
- return $requestor->post('logger/uninstall', $this->toArray());
35
- }
36
- }
1
+ <?php
2
+
3
+ namespace Analyst\Http\Requests;
4
+
5
+ use Analyst\ApiResponse;
6
+ use Analyst\Collector;
7
+ use Analyst\Contracts\RequestorContract;
8
+
9
+ /**
10
+ * Class DeactivateRequest
11
+ *
12
+ * @since 0.9.13
13
+ */
14
+ class UninstallRequest extends AbstractLoggerRequest
15
+ {
16
+ /**
17
+ * @param Collector $collector
18
+ * @param $pluginId
19
+ * @param $path
20
+ * @return static
21
+ */
22
+ public static function make(Collector $collector, $pluginId, $path)
23
+ {
24
+ return new static($collector, $pluginId, $path);
25
+ }
26
+
27
+ /**
28
+ * Execute the request
29
+ * @param RequestorContract $requestor
30
+ * @return ApiResponse
31
+ */
32
+ public function execute(RequestorContract $requestor)
33
+ {
34
+ return $requestor->post('logger/uninstall', $this->toArray());
35
+ }
36
+ }
analyst/src/Http/WordPressHttpClient.php CHANGED
@@ -1,61 +1,61 @@
1
- <?php
2
-
3
- namespace Analyst\Http;
4
-
5
- use WP_Error;
6
- use Analyst\ApiResponse;
7
- use Analyst\Contracts\HttpClientContract;
8
- use Requests_Utility_CaseInsensitiveDictionary;
9
-
10
- class WordPressHttpClient implements HttpClientContract
11
- {
12
- /**
13
- * Make an http request
14
- *
15
- * @param $method
16
- * @param $url
17
- * @param $body
18
- * @param $headers
19
- * @return ApiResponse
20
- */
21
- public function request($method, $url, $body, $headers)
22
- {
23
- $options = [
24
- 'body' => json_encode($body),
25
- 'headers' => $headers,
26
- 'method' => $method,
27
- 'timeout' => 30,
28
- ];
29
-
30
- $response = wp_remote_request($url, $options);
31
-
32
- $body = [];
33
- $responseHeaders = [];
34
-
35
- if ($response instanceof WP_Error) {
36
- $code = $response->get_error_code();
37
- } else {
38
- /** @var Requests_Utility_CaseInsensitiveDictionary $headers */
39
- $responseHeaders = $response['headers']->getAll();
40
- $body = json_decode($response['body'], true);
41
- $code = $response['response']['code'];
42
- }
43
-
44
-
45
- return new ApiResponse(
46
- $body,
47
- $code,
48
- $responseHeaders
49
- );
50
- }
51
-
52
- /**
53
- * Must return `true` if client is supported
54
- *
55
- * @return bool
56
- */
57
- public static function hasSupport()
58
- {
59
- return function_exists('wp_remote_request');
60
- }
61
- }
1
+ <?php
2
+
3
+ namespace Analyst\Http;
4
+
5
+ use WP_Error;
6
+ use Analyst\ApiResponse;
7
+ use Analyst\Contracts\HttpClientContract;
8
+ use Requests_Utility_CaseInsensitiveDictionary;
9
+
10
+ class WordPressHttpClient implements HttpClientContract
11
+ {
12
+ /**
13
+ * Make an http request
14
+ *
15
+ * @param $method
16
+ * @param $url
17
+ * @param $body
18
+ * @param $headers
19
+ * @return ApiResponse
20
+ */
21
+ public function request($method, $url, $body, $headers)
22
+ {
23
+ $options = [
24
+ 'body' => json_encode($body),
25
+ 'headers' => $headers,
26
+ 'method' => $method,
27
+ 'timeout' => 30,
28
+ ];
29
+
30
+ $response = wp_remote_request($url, $options);
31
+
32
+ $body = [];
33
+ $responseHeaders = [];
34
+
35
+ if ($response instanceof WP_Error) {
36
+ $code = $response->get_error_code();
37
+ } else {
38
+ /** @var Requests_Utility_CaseInsensitiveDictionary $headers */
39
+ $responseHeaders = $response['headers']->getAll();
40
+ $body = json_decode($response['body'], true);
41
+ $code = $response['response']['code'];
42
+ }
43
+
44
+
45
+ return new ApiResponse(
46
+ $body,
47
+ $code,
48
+ $responseHeaders
49
+ );
50
+ }
51
+
52
+ /**
53
+ * Must return `true` if client is supported
54
+ *
55
+ * @return bool
56
+ */
57
+ public static function hasSupport()
58
+ {
59
+ return function_exists('wp_remote_request');
60
+ }
61
+ }
analyst/src/Mutator.php CHANGED
@@ -1,103 +1,103 @@
1
- <?php
2
-
3
- namespace Analyst;
4
-
5
- use Analyst\Cache\DatabaseCache;
6
- use Analyst\Contracts\CacheContract;
7
- use Analyst\Notices\NoticeFactory;
8
-
9
- /**
10
- * Class Mutator mutates (modifies) UX with additional
11
- * functional
12
- */
13
- class Mutator
14
- {
15
- protected $notices = [];
16
-
17
- /**
18
- * @var NoticeFactory
19
- */
20
- protected $factory;
21
-
22
- /**
23
- * @var CacheContract
24
- */
25
- protected $cache;
26
-
27
- public function __construct()
28
- {
29
- $this->factory = NoticeFactory::instance();
30
-
31
- $this->notices = $this->factory->getNotices();
32
-
33
- $this->cache = DatabaseCache::getInstance();
34
- }
35
-
36
- /**
37
- * Register filters all necessary stuff.
38
- * Can be invoked only once.
39
- *
40
- * @return void
41
- */
42
- public function initialize()
43
- {
44
- $this->registerLinks();
45
- $this->registerAssets();
46
- $this->registerHooks();
47
- }
48
-
49
- /**
50
- * Register all necessary filters and templates
51
- *
52
- * @return void
53
- */
54
- protected function registerLinks()
55
- {
56
- add_action('admin_footer', function () {
57
- analyst_require_template('optout.php', [
58
- 'shieldImage' => analyst_assets_url('img/shield_question.png')
59
- ]);
60
-
61
- analyst_require_template('optin.php');
62
-
63
- analyst_require_template('forms/deactivate.php', [
64
- 'pencilImage' => analyst_assets_url('img/pencil.png'),
65
- 'smileImage' => analyst_assets_url('img/smile.png'),
66
- ]);
67
-
68
- analyst_require_template('forms/install.php', [
69
- 'pluginToInstall' => $this->cache->get('plugin_to_install'),
70
- 'shieldImage' => analyst_assets_url('img/shield_success.png'),
71
- ]);
72
- });
73
-
74
- add_action('admin_notices',function () {
75
- foreach ($this->notices as $notice) {
76
- analyst_require_template('notice.php', ['notice' => $notice]);
77
- }
78
- });
79
- }
80
-
81
- /**
82
- * Register all assets
83
- */
84
- public function registerAssets()
85
- {
86
- add_action('admin_enqueue_scripts', function () {
87
- wp_enqueue_style('analyst_custom', analyst_assets_url('/css/customize.css'));
88
- wp_enqueue_script('analyst_custom', analyst_assets_url('/js/customize.js'));
89
- });
90
- }
91
-
92
- /**
93
- * Register action hooks
94
- */
95
- public function registerHooks()
96
- {
97
- add_action('wp_ajax_analyst_notification_dismiss', function () {
98
- $this->factory->remove($_POST['id']);
99
-
100
- $this->factory->sync();
101
- });
102
- }
103
- }
1
+ <?php
2
+
3
+ namespace Analyst;
4
+
5
+ use Analyst\Cache\DatabaseCache;
6
+ use Analyst\Contracts\CacheContract;
7
+ use Analyst\Notices\NoticeFactory;
8
+
9
+ /**
10
+ * Class Mutator mutates (modifies) UX with additional
11
+ * functional
12
+ */
13
+ class Mutator
14
+ {
15
+ protected $notices = [];
16
+
17
+ /**
18
+ * @var NoticeFactory
19
+ */
20
+ protected $factory;
21
+
22
+ /**
23
+ * @var CacheContract
24
+ */
25
+ protected $cache;
26
+
27
+ public function __construct()
28
+ {
29
+ $this->factory = NoticeFactory::instance();
30
+
31
+ $this->notices = $this->factory->getNotices();
32
+
33
+ $this->cache = DatabaseCache::getInstance();
34
+ }
35
+
36
+ /**
37
+ * Register filters all necessary stuff.
38
+ * Can be invoked only once.
39
+ *
40
+ * @return void
41
+ */
42
+ public function initialize()
43
+ {
44
+ $this->registerLinks();
45
+ $this->registerAssets();
46
+ $this->registerHooks();
47
+ }
48
+
49
+ /**
50
+ * Register all necessary filters and templates
51
+ *
52
+ * @return void
53
+ */
54
+ protected function registerLinks()
55
+ {
56
+ add_action('admin_footer', function () {
57
+ analyst_require_template('optout.php', [
58
+ 'shieldImage' => analyst_assets_url('img/shield_question.png')
59
+ ]);
60
+
61
+ analyst_require_template('optin.php');
62
+
63
+ analyst_require_template('forms/deactivate.php', [
64
+ 'pencilImage' => analyst_assets_url('img/pencil.png'),
65
+ 'smileImage' => analyst_assets_url('img/smile.png'),
66
+ ]);
67
+
68
+ analyst_require_template('forms/install.php', [
69
+ 'pluginToInstall' => $this->cache->get('plugin_to_install'),
70
+ 'shieldImage' => analyst_assets_url('img/shield_success.png'),
71
+ ]);
72
+ });
73
+
74
+ add_action('admin_notices',function () {
75
+ foreach ($this->notices as $notice) {
76
+ analyst_require_template('notice.php', ['notice' => $notice]);
77
+ }
78
+ });
79
+ }
80
+
81
+ /**
82
+ * Register all assets
83
+ */
84
+ public function registerAssets()
85
+ {
86
+ add_action('admin_enqueue_scripts', function () {
87
+ wp_enqueue_style('analyst_custom', analyst_assets_url('/css/customize.css'));
88
+ wp_enqueue_script('analyst_custom', analyst_assets_url('/js/customize.js'));
89
+ });
90
+ }
91
+
92
+ /**
93
+ * Register action hooks
94
+ */
95
+ public function registerHooks()
96
+ {
97
+ add_action('wp_ajax_analyst_notification_dismiss', function () {
98
+ $this->factory->remove($_POST['id']);
99
+
100
+ $this->factory->sync();
101
+ });
102
+ }
103
+ }
analyst/src/Notices/Notice.php CHANGED
@@ -1,121 +1,121 @@
1
- <?php
2
-
3
- namespace Analyst\Notices;
4
-
5
- class Notice
6
- {
7
- /**
8
- * Id of notice
9
- *
10
- * @var string
11
- */
12
- protected $id;
13
-
14
- /**
15
- * Body of notice
16
- *
17
- * @var string
18
- */
19
- protected $body;
20
-
21
- /**
22
- * Account id
23
- *
24
- * @var string
25
- */
26
- protected $accountId;
27
-
28
- /**
29
- * The plugin name
30
- *
31
- * @var string
32
- */
33
- protected $pluginName;
34
-
35
- /**
36
- * New notice
37
- *
38
- * @param $id
39
- * @param $accountId
40
- * @param $body
41
- * @param null $pluginName
42
- *
43
- * @return Notice
44
- */
45
- public static function make($id, $accountId, $body, $pluginName = null)
46
- {
47
- return new Notice($id, $accountId, $body, $pluginName);
48
- }
49
-
50
- public function __construct($id, $accountId, $body, $pluginName)
51
- {
52
- $this->setId($id);
53
- $this->setBody($body);
54
- $this->setAccountId($accountId);
55
- $this->setPluginName($pluginName);
56
- }
57
-
58
- /**
59
- * @return string
60
- */
61
- public function getId()
62
- {
63
- return $this->id;
64
- }
65
-
66
- /**
67
- * @param string $id
68
- */
69
- public function setId($id)
70
- {
71
- $this->id = $id;
72
- }
73
-
74
- /**
75
- * @return string
76
- */
77
- public function getBody()
78
- {
79
- return $this->body;
80
- }
81
-
82
- /**
83
- * @param string $body
84
- */
85
- public function setBody($body)
86
- {
87
- $this->body = $body;
88
- }
89
-
90
- /**
91
- * @return string
92
- */
93
- public function getAccountId()
94
- {
95
- return $this->accountId;
96
- }
97
-
98
- /**
99
- * @param string $accountId
100
- */
101
- public function setAccountId($accountId)
102
- {
103
- $this->accountId = $accountId;
104
- }
105
-
106
- /**
107
- * @return string|null
108
- */
109
- public function getPluginName()
110
- {
111
- return $this->pluginName;
112
- }
113
-
114
- /**
115
- * @param string $pluginName
116
- */
117
- public function setPluginName($pluginName)
118
- {
119
- $this->pluginName = $pluginName;
120
- }
121
- }
1
+ <?php
2
+
3
+ namespace Analyst\Notices;
4
+
5
+ class Notice
6
+ {
7
+ /**
8
+ * Id of notice
9
+ *
10
+ * @var string
11
+ */
12
+ protected $id;
13
+
14
+ /**
15
+ * Body of notice
16
+ *
17
+ * @var string
18
+ */
19
+ protected $body;
20
+
21
+ /**
22
+ * Account id
23
+ *
24
+ * @var string
25
+ */
26
+ protected $accountId;
27
+
28
+ /**
29
+ * The plugin name
30
+ *
31
+ * @var string
32
+ */
33
+ protected $pluginName;
34
+
35
+ /**
36
+ * New notice
37
+ *
38
+ * @param $id
39
+ * @param $accountId
40
+ * @param $body
41
+ * @param null $pluginName
42
+ *
43
+ * @return Notice
44
+ */
45
+ public static function make($id, $accountId, $body, $pluginName = null)
46
+ {
47
+ return new Notice($id, $accountId, $body, $pluginName);
48
+ }
49
+
50
+ public function __construct($id, $accountId, $body, $pluginName)
51
+ {
52
+ $this->setId($id);
53
+ $this->setBody($body);
54
+ $this->setAccountId($accountId);
55
+ $this->setPluginName($pluginName);
56
+ }
57
+
58
+ /**
59
+ * @return string
60
+ */
61
+ public function getId()
62
+ {
63
+ return $this->id;
64
+ }
65
+
66
+ /**
67
+ * @param string $id
68
+ */
69
+ public function setId($id)
70
+ {
71
+ $this->id = $id;
72
+ }
73
+
74
+ /**
75
+ * @return string
76
+ */
77
+ public function getBody()
78
+ {
79
+ return $this->body;
80
+ }
81
+
82
+ /**
83
+ * @param string $body
84
+ */
85
+ public function setBody($body)
86
+ {
87
+ $this->body = $body;
88
+ }
89
+
90
+ /**
91
+ * @return string
92
+ */
93
+ public function getAccountId()
94
+ {
95
+ return $this->accountId;
96
+ }
97
+
98
+ /**
99
+ * @param string $accountId
100
+ */
101
+ public function setAccountId($accountId)
102
+ {
103
+ $this->accountId = $accountId;
104
+ }
105
+
106
+ /**
107
+ * @return string|null
108
+ */
109
+ public function getPluginName()
110
+ {
111
+ return $this->pluginName;
112
+ }
113
+
114
+ /**
115
+ * @param string $pluginName
116
+ */
117
+ public function setPluginName($pluginName)
118
+ {
119
+ $this->pluginName = $pluginName;
120
+ }
121
+ }
analyst/src/Notices/NoticeFactory.php CHANGED
@@ -1,130 +1,130 @@
1
- <?php
2
-
3
- namespace Analyst\Notices;
4
-
5
- use Analyst\Core\AbstractFactory;
6
-
7
- class NoticeFactory extends AbstractFactory
8
- {
9
- private static $instance;
10
-
11
- CONST OPTIONS_KEY = 'analyst_notices';
12
-
13
- /**
14
- * Application notifications
15
- *
16
- * @var array
17
- */
18
- protected $notices = [];
19
-
20
- /**
21
- * Read factory from options or make fresh instance
22
- *
23
- * @return NoticeFactory
24
- */
25
- public static function instance()
26
- {
27
- if (!static::$instance) {
28
- $raw = get_option(self::OPTIONS_KEY);
29
-
30
- // In case object is already unserialized
31
- // and instance of AccountDataFactory we
32
- // return it, in other case deal with
33
- // serialized string data
34
- if ($raw instanceof self) {
35
- static::$instance = $raw;
36
- } else {
37
- static::$instance = is_string($raw) ? static::unserialize($raw) : new self();
38
- }
39
- }
40
-
41
- return static::$instance;
42
- }
43
-
44
- /**
45
- * Sync this object data with cache
46
- */
47
- public function sync()
48
- {
49
- update_option(self::OPTIONS_KEY, serialize($this));
50
- }
51
-
52
- /**
53
- * Sync this instance data with cache
54
- */
55
- public static function syncData()
56
- {
57
- static::instance()->sync();
58
- }
59
-
60
- /**
61
- * @return array
62
- */
63
- public function getNotices()
64
- {
65
- return $this->notices;
66
- }
67
-
68
- /**
69
- * Filter out notices for certain account
70
- *
71
- * @param $accountId
72
- * @return array
73
- */
74
- public function getNoticesForAccount($accountId)
75
- {
76
- return array_filter($this->notices, function (Notice $notice) use ($accountId) {
77
- return $notice->getAccountId() === $accountId;
78
- });
79
- }
80
-
81
- /**
82
- * Add new notice
83
- *
84
- * @param $notice
85
- *
86
- * @return $this
87
- */
88
- public function addNotice($notice)
89
- {
90
- array_push($this->notices, $notice);
91
-
92
- $this->sync();
93
-
94
- return $this;
95
- }
96
-
97
- /**
98
- * Find notice by id
99
- *
100
- * @param $id
101
- * @return Notice|null
102
- */
103
- public function find($id)
104
- {
105
- $notices = array_filter($this->notices, function (Notice $notice) use ($id) {
106
- return $notice->getId() === $id;
107
- });
108
-
109
- return array_pop($notices);
110
- }
111
-
112
- /**
113
- * Remove notice by it's id
114
- *
115
- * @param $id
116
- */
117
- public function remove($id)
118
- {
119
- // Get key of notice to remove
120
- $key = array_search(
121
- $this->find($id),
122
- $this->notices
123
- );
124
-
125
- // Unset notice with key
126
- unset($this->notices[$key]);
127
-
128
- $this->sync();
129
- }
130
- }
1
+ <?php
2
+
3
+ namespace Analyst\Notices;
4
+
5
+ use Analyst\Core\AbstractFactory;
6
+
7
+ class NoticeFactory extends AbstractFactory
8
+ {
9
+ private static $instance;
10
+
11
+ CONST OPTIONS_KEY = 'analyst_notices';
12
+
13
+ /**
14
+ * Application notifications
15
+ *
16
+ * @var array
17
+ */
18
+ protected $notices = [];
19
+
20
+ /**
21
+ * Read factory from options or make fresh instance
22
+ *
23
+ * @return NoticeFactory
24
+ */
25
+ public static function instance()
26
+ {
27
+ if (!static::$instance) {
28
+ $raw = get_option(self::OPTIONS_KEY);
29
+
30
+ // In case object is already unserialized
31
+ // and instance of AccountDataFactory we
32
+ // return it, in other case deal with
33
+ // serialized string data
34
+ if ($raw instanceof self) {
35
+ static::$instance = $raw;
36
+ } else {
37
+ static::$instance = is_string($raw) ? static::unserialize($raw) : new self();
38
+ }
39
+ }
40
+
41
+ return static::$instance;
42
+ }
43
+
44
+ /**
45
+ * Sync this object data with cache
46
+ */
47
+ public function sync()
48
+ {
49
+ update_option(self::OPTIONS_KEY, serialize($this));
50
+ }
51
+
52
+ /**
53
+ * Sync this instance data with cache
54
+ */
55
+ public static function syncData()
56
+ {
57
+ static::instance()->sync();
58
+ }
59
+
60
+ /**
61
+ * @return array
62
+ */
63
+ public function getNotices()
64
+ {
65
+ return $this->notices;
66
+ }
67
+
68
+ /**
69
+ * Filter out notices for certain account
70
+ *
71
+ * @param $accountId
72
+ * @return array
73
+ */
74
+ public function getNoticesForAccount($accountId)
75
+ {
76
+ return array_filter($this->notices, function (Notice $notice) use ($accountId) {
77
+ return $notice->getAccountId() === $accountId;
78
+ });
79
+ }
80
+
81
+ /**
82
+ * Add new notice
83
+ *
84
+ * @param $notice
85
+ *
86
+ * @return $this
87
+ */
88
+ public function addNotice($notice)
89
+ {
90
+ array_push($this->notices, $notice);
91
+
92
+ $this->sync();
93
+
94
+ return $this;
95
+ }
96
+
97
+ /**
98
+ * Find notice by id
99
+ *
100
+ * @param $id
101
+ * @return Notice|null
102
+ */
103
+ public function find($id)
104
+ {
105
+ $notices = array_filter($this->notices, function (Notice $notice) use ($id) {
106
+ return $notice->getId() === $id;
107
+ });
108
+
109
+ return array_pop($notices);
110
+ }
111
+
112
+ /**
113
+ * Remove notice by it's id
114
+ *
115
+ * @param $id
116
+ */
117
+ public function remove($id)
118
+ {
119
+ // Get key of notice to remove
120
+ $key = array_search(
121
+ $this->find($id),
122
+ $this->notices
123
+ );
124
+
125
+ // Unset notice with key
126
+ unset($this->notices[$key]);
127
+
128
+ $this->sync();
129
+ }
130
+ }
analyst/src/helpers.php CHANGED
@@ -1,84 +1,84 @@
1
- <?php
2
-
3
- if (! function_exists('analyst_assets_path')) {
4
- /**
5
- * Generates path to file in assets folder
6
- *
7
- * @param $file
8
- * @return string
9
- */
10
- function analyst_assets_path($file)
11
- {
12
- $path = sprintf('%s/assets/%s', realpath(__DIR__ . '/..'), trim($file, '/'));
13
-
14
- return wp_normalize_path($path);
15
- }
16
- }
17
-
18
-
19
- if (! function_exists('analyst_assets_url')) {
20
- /**
21
- * Generates url to file in assets folder
22
- *
23
- * @param $file
24
- * @return string
25
- */
26
- function analyst_assets_url($file)
27
- {
28
- $absolutePath = analyst_assets_path($file);
29
-
30
- // We can always rely on WP_PLUGIN_DIR, because that's where
31
- // wordpress install it's plugin's. So we remove last segment
32
- // of that path to get the content dir AKA directly where
33
- // plugins are installed and make the magic...
34
- $contentDir = is_link(WP_PLUGIN_DIR) ?
35
- dirname(wp_normalize_path(readlink(WP_PLUGIN_DIR))) :
36
- dirname(wp_normalize_path(WP_PLUGIN_DIR));
37
-
38
- $relativePath = str_replace( $contentDir, '', $absolutePath);
39
-
40
- return content_url(wp_normalize_path($relativePath));
41
- }
42
- }
43
-
44
- if (! function_exists('analyst_templates_path')) {
45
- /**
46
- * Generates path to file in templates folder
47
- *
48
- * @param $file
49
- * @return string
50
- */
51
- function analyst_templates_path($file)
52
- {
53
- $path = sprintf('%s/templates/%s', realpath(__DIR__ . '/..'), trim($file, '/'));
54
-
55
- return wp_normalize_path($path);
56
- }
57
- }
58
-
59
- if (! function_exists('analyst_require_template')) {
60
- /**
61
- * Require certain template with data
62
- *
63
- * @param $file
64
- * @param array $data
65
- */
66
- function analyst_require_template($file, $data = [])
67
- {
68
- // Extract data to current scope table
69
- extract($data);
70
-
71
- require analyst_templates_path($file);
72
- }
73
- }
74
-
75
- if (! function_exists('dd')) {
76
- /**
77
- * Dump some data
78
- */
79
- function dd ()
80
- {
81
- var_dump(func_get_args());
82
- die();
83
- }
84
- }
1
+ <?php
2
+
3
+ if (! function_exists('analyst_assets_path')) {
4
+ /**
5
+ * Generates path to file in assets folder
6
+ *
7
+ * @param $file
8
+ * @return string
9
+ */
10
+ function analyst_assets_path($file)
11
+ {
12
+ $path = sprintf('%s/assets/%s', realpath(__DIR__ . '/..'), trim($file, '/'));
13
+
14
+ return wp_normalize_path($path);
15
+ }
16
+ }
17
+
18
+
19
+ if (! function_exists('analyst_assets_url')) {
20
+ /**
21
+ * Generates url to file in assets folder
22
+ *
23
+ * @param $file
24
+ * @return string
25
+ */
26
+ function analyst_assets_url($file)
27
+ {
28
+ $absolutePath = analyst_assets_path($file);
29
+
30
+ // We can always rely on WP_PLUGIN_DIR, because that's where
31
+ // wordpress install it's plugin's. So we remove last segment
32
+ // of that path to get the content dir AKA directly where
33
+ // plugins are installed and make the magic...
34
+ $contentDir = is_link(WP_PLUGIN_DIR) ?
35
+ dirname(wp_normalize_path(readlink(WP_PLUGIN_DIR))) :
36
+ dirname(wp_normalize_path(WP_PLUGIN_DIR));
37
+
38
+ $relativePath = str_replace( $contentDir, '', $absolutePath);
39
+
40
+ return content_url(wp_normalize_path($relativePath));
41
+ }
42
+ }
43
+
44
+ if (! function_exists('analyst_templates_path')) {
45
+ /**
46
+ * Generates path to file in templates folder
47
+ *
48
+ * @param $file
49
+ * @return string
50
+ */
51
+ function analyst_templates_path($file)
52
+ {
53
+ $path = sprintf('%s/templates/%s', realpath(__DIR__ . '/..'), trim($file, '/'));
54
+
55
+ return wp_normalize_path($path);
56
+ }
57
+ }
58
+
59
+ if (! function_exists('analyst_require_template')) {
60
+ /**
61
+ * Require certain template with data
62
+ *
63
+ * @param $file
64
+ * @param array $data
65
+ */
66
+ function analyst_require_template($file, $data = [])
67
+ {
68
+ // Extract data to current scope table
69
+ extract($data);
70
+
71
+ require analyst_templates_path($file);
72
+ }
73
+ }
74
+
75
+ if (! function_exists('dd')) {
76
+ /**
77
+ * Dump some data
78
+ */
79
+ function dd ()
80
+ {
81
+ var_dump(func_get_args());
82
+ die();
83
+ }
84
+ }
analyst/templates/forms/deactivate.php CHANGED
@@ -1,156 +1,156 @@
1
- <div id="analyst-deactivate-modal" class="analyst-modal" style="display: none">
2
- <div class="analyst-modal-content" style="width: 500px">
3
- <div class="analyst-disable-modal-mask" id="analyst-disable-deactivate-modal-mask" style="display: none"></div>
4
- <div style="display: flex">
5
- <div class="analyst-install-image-block" style="width: 80px">
6
- <img src="<?=$pencilImage?>"/>
7
- </div>
8
- <div class="analyst-install-description-block" style="padding-left: 20px">
9
- <strong class="analyst-modal-header">Why do you deactivate?</strong>
10
- <div class="analyst-install-description-text" style="padding-top: 2px">
11
- Please let us know, so we can improve it! Thank you <img class="analyst-smile-image" src="<?=$smileImage?>" alt="">
12
- </div>
13
- </div>
14
- </div>
15
- <div>
16
- <ul id="analyst-deactivation-reasons">
17
- <li>
18
- <label>
19
- <span>
20
- <input type="radio" name="deactivation-reason">
21
- </span>
22
- <span class="question" data-question="I couldn't understand how to make it work">I couldn't understand how to make it work</span>
23
- </label>
24
- </li>
25
- <li data-input-type="textarea" data-input-placeholder="What should have worked, but didn’t?">
26
- <label>
27
- <span>
28
- <input type="radio" name="deactivation-reason">
29
- </span>
30
- <span class="question" data-question="The plugin didn't work as expected">The plugin didn't work as expected</span>
31
- </label>
32
- <div class="question-answer"></div>
33
- </li>
34
- <li data-input-type="input" data-input-placeholder="What is the plugin name?">
35
- <label>
36
- <span>
37
- <input type="radio" name="deactivation-reason">
38
- </span>
39
- <span class="question" data-question="I found a better plugin">I found a better plugin</span>
40
- </label>
41
- <div class="question-answer"></div>
42
- </li>
43
- <li>
44
- <label>
45
- <span>
46
- <input type="radio" name="deactivation-reason">
47
- </span>
48
- <span class="question" data-question="It's a temporary deactivation">It's a temporary deactivation</span>
49
- </label>
50
- <div class="question-answer"></div>
51
- </li>
52
- <li data-input-type="textarea" data-input-placeholder="Please provide the reason of deactivation">
53
- <label>
54
- <span>
55
- <input type="radio" name="deactivation-reason">
56
- </span>
57
- <span class="question" data-question="Other">Other</span>
58
- </label>
59
- <div class="question-answer"></div>
60
- </li>
61
- </ul>
62
- <p id="analyst-deactivation-error" style="color: #dc3232; font-size: 16px; display: none">Please let us know the reason for de-activation. Thank you!</p>
63
- </div>
64
- <div>
65
- <button class="analyst-btn-grey" id="analyst-disabled-plugin-action">Deactivate</button>
66
- </div>
67
- <div class="" style="text-align: center; font-size: 18px; padding-top: 10px">
68
- <button class="analyst-btn-secondary-ghost analyst-deactivate-modal-close" style="color: #cccccc">Cancel</button>
69
- </div>
70
- </div>
71
- </div>
72
-
73
- <script type="text/javascript">
74
- (function ($) {
75
- $('.deactivate').click(function (e) {
76
- var anchor = $(this).find('[analyst-plugin-id]')
77
- var pluginId = anchor.attr('analyst-plugin-id')
78
- var isOptedIn = anchor.attr('analyst-plugin-opted-in') === '1'
79
-
80
- // Do not ask for reason if not opted in
81
- if (!isOptedIn) {
82
- return
83
- }
84
-
85
- e.preventDefault()
86
-
87
- $('#analyst-deactivate-modal')
88
- .attr({
89
- 'analyst-plugin-id': pluginId,
90
- 'analyst-redirect-url': $(this).find('a').attr('href')
91
- })
92
- .show()
93
- })
94
-
95
- $('.analyst-deactivate-modal-close').click(function () {
96
- $('#analyst-deactivate-modal').hide()
97
- })
98
-
99
- $('#analyst-deactivation-reasons input[name="deactivation-reason"]').change(function () {
100
- $('.question-answer').empty()
101
-
102
- var root = $('#analyst-deactivation-reasons input[name="deactivation-reason"]:checked').parents('li')
103
-
104
- $('#analyst-deactivation-error').hide()
105
-
106
- if (!root.attr('data-input-type')) return
107
-
108
- var reasonInput = $('<' + root.attr('data-input-type') + '/>').attr({placeholder: root.attr('data-input-placeholder'), class: 'reason-answer'})
109
-
110
- root.find('.question-answer').append(reasonInput)
111
- })
112
-
113
- $('#analyst-disabled-plugin-action').click(function () {
114
- var pluginId = $('#analyst-deactivate-modal').attr('analyst-plugin-id')
115
- var pluginDeactivationUrl = $('#analyst-deactivate-modal').attr('analyst-redirect-url')
116
-
117
- var root = $('#analyst-deactivation-reasons input[name="deactivation-reason"]:checked').parents('li');
118
-
119
- var reason = root.find('.question-answer .reason-answer').val();
120
-
121
- var question = root.find('.question').attr('data-question').trim()
122
-
123
- var $errorBlock = $('#analyst-deactivation-error')
124
-
125
- if (!question) {
126
- return $errorBlock.show()
127
- }
128
-
129
- $errorBlock.hide()
130
-
131
- var data = {
132
- action: 'analyst_plugin_deactivate_' + pluginId,
133
- question: question
134
- }
135
-
136
- if (reason) {
137
- data['reason'] = reason.trim();
138
- }
139
-
140
- $(this).attr('disabled', true).text('Deactivating...');
141
-
142
- $('#analyst-disable-deactivate-modal-mask').show();
143
-
144
- $.ajax({
145
- url: ajaxurl,
146
- method: 'POST',
147
- data: data
148
- }).done(function () {
149
- window.location.href = pluginDeactivationUrl
150
-
151
- $('#analyst-disable-deactivate-modal-mask').hide();
152
- })
153
- })
154
-
155
- })(jQuery)
156
- </script>
1
+ <div id="analyst-deactivate-modal" class="analyst-modal" style="display: none">
2
+ <div class="analyst-modal-content" style="width: 500px">
3
+ <div class="analyst-disable-modal-mask" id="analyst-disable-deactivate-modal-mask" style="display: none"></div>
4
+ <div style="display: flex">
5
+ <div class="analyst-install-image-block" style="width: 80px">
6
+ <img src="<?=$pencilImage?>"/>
7
+ </div>
8
+ <div class="analyst-install-description-block" style="padding-left: 20px">
9
+ <strong class="analyst-modal-header">Why do you deactivate?</strong>
10
+ <div class="analyst-install-description-text" style="padding-top: 2px">
11
+ Please let us know, so we can improve it! Thank you <img class="analyst-smile-image" src="<?=$smileImage?>" alt="">
12
+ </div>
13
+ </div>
14
+ </div>
15
+ <div>
16
+ <ul id="analyst-deactivation-reasons">
17
+ <li>
18
+ <label>
19
+ <span>
20
+ <input type="radio" name="deactivation-reason">
21
+ </span>
22
+ <span class="question" data-question="I couldn't understand how to make it work">I couldn't understand how to make it work</span>
23
+ </label>
24
+ </li>
25
+ <li data-input-type="textarea" data-input-placeholder="What should have worked, but didn’t?">
26
+ <label>
27
+ <span>
28
+ <input type="radio" name="deactivation-reason">
29
+ </span>
30
+ <span class="question" data-question="The plugin didn't work as expected">The plugin didn't work as expected</span>
31
+ </label>
32
+ <div class="question-answer"></div>
33
+ </li>
34
+ <li data-input-type="input" data-input-placeholder="What is the plugin name?">
35
+ <label>
36
+ <span>
37
+ <input type="radio" name="deactivation-reason">
38
+ </span>
39
+ <span class="question" data-question="I found a better plugin">I found a better plugin</span>
40
+ </label>
41
+ <div class="question-answer"></div>
42
+ </li>
43
+ <li>
44
+ <label>
45
+ <span>
46
+ <input type="radio" name="deactivation-reason">
47
+ </span>
48
+ <span class="question" data-question="It's a temporary deactivation">It's a temporary deactivation</span>
49
+ </label>
50
+ <div class="question-answer"></div>
51
+ </li>
52
+ <li data-input-type="textarea" data-input-placeholder="Please provide the reason of deactivation">
53
+ <label>
54
+ <span>
55
+ <input type="radio" name="deactivation-reason">
56
+ </span>
57
+ <span class="question" data-question="Other">Other</span>
58
+ </label>
59
+ <div class="question-answer"></div>
60
+ </li>
61
+ </ul>
62
+ <p id="analyst-deactivation-error" style="color: #dc3232; font-size: 16px; display: none">Please let us know the reason for de-activation. Thank you!</p>
63
+ </div>
64
+ <div>
65
+ <button class="analyst-btn-grey" id="analyst-disabled-plugin-action">Deactivate</button>
66
+ </div>
67
+ <div class="" style="text-align: center; font-size: 18px; padding-top: 10px">
68
+ <button class="analyst-btn-secondary-ghost analyst-deactivate-modal-close" style="color: #cccccc">Cancel</button>
69
+ </div>
70
+ </div>
71
+ </div>
72
+
73
+ <script type="text/javascript">
74
+ (function ($) {
75
+ $('.deactivate').click(function (e) {
76
+ var anchor = $(this).find('[analyst-plugin-id]')
77
+ var pluginId = anchor.attr('analyst-plugin-id')
78
+ var isOptedIn = anchor.attr('analyst-plugin-opted-in') === '1'
79
+
80
+ // Do not ask for reason if not opted in
81
+ if (!isOptedIn) {
82
+ return
83
+ }
84
+
85
+ e.preventDefault()
86
+
87
+ $('#analyst-deactivate-modal')
88
+ .attr({
89
+ 'analyst-plugin-id': pluginId,
90
+ 'analyst-redirect-url': $(this).find('a').attr('href')
91
+ })
92
+ .show()
93
+ })
94
+
95
+ $('.analyst-deactivate-modal-close').click(function () {
96
+ $('#analyst-deactivate-modal').hide()
97
+ })
98
+
99
+ $('#analyst-deactivation-reasons input[name="deactivation-reason"]').change(function () {
100
+ $('.question-answer').empty()
101
+
102
+ var root = $('#analyst-deactivation-reasons input[name="deactivation-reason"]:checked').parents('li')
103
+
104
+ $('#analyst-deactivation-error').hide()
105
+
106
+ if (!root.attr('data-input-type')) return
107
+
108
+ var reasonInput = $('<' + root.attr('data-input-type') + '/>').attr({placeholder: root.attr('data-input-placeholder'), class: 'reason-answer'})
109
+
110
+ root.find('.question-answer').append(reasonInput)
111
+ })
112
+
113
+ $('#analyst-disabled-plugin-action').click(function () {
114
+ var pluginId = $('#analyst-deactivate-modal').attr('analyst-plugin-id')
115
+ var pluginDeactivationUrl = $('#analyst-deactivate-modal').attr('analyst-redirect-url')
116
+
117
+ var root = $('#analyst-deactivation-reasons input[name="deactivation-reason"]:checked').parents('li');
118
+
119
+ var reason = root.find('.question-answer .reason-answer').val();
120
+
121
+ var question = root.find('.question').attr('data-question').trim()
122
+
123
+ var $errorBlock = $('#analyst-deactivation-error')
124
+
125
+ if (!question) {
126
+ return $errorBlock.show()
127
+ }
128
+
129
+ $errorBlock.hide()
130
+
131
+ var data = {
132
+ action: 'analyst_plugin_deactivate_' + pluginId,
133
+ question: question
134
+ }
135
+
136
+ if (reason) {
137
+ data['reason'] = reason.trim();
138
+ }
139
+
140
+ $(this).attr('disabled', true).text('Deactivating...');
141
+
142
+ $('#analyst-disable-deactivate-modal-mask').show();
143
+
144
+ $.ajax({
145
+ url: ajaxurl,
146
+ method: 'POST',
147
+ data: data
148
+ }).done(function () {
149
+ window.location.href = pluginDeactivationUrl
150
+
151
+ $('#analyst-disable-deactivate-modal-mask').hide();
152
+ })
153
+ })
154
+
155
+ })(jQuery)
156
+ </script>
analyst/templates/forms/install.php CHANGED
@@ -1,112 +1,112 @@
1
- <div id="analyst-install-modal" class="analyst-modal" style="display: none" analyst-plugin-id="<?=$pluginToInstall?>">
2
- <div class="analyst-modal-content" style="width: 450px">
3
- <div class="analyst-disable-modal-mask" id="analyst-disable-install-modal-mask" style="display: none"></div>
4
- <div style="display: flex">
5
- <div class="analyst-install-image-block">
6
- <img src="<?=$shieldImage?>"/>
7
- </div>
8
- <div class="analyst-install-description-block">
9
- <strong class="analyst-modal-header">Stay on the safe side</strong>
10
- <p class="analyst-install-description-text">Receive our plugin’s alerts in
11
- case of <strong>critical security</strong> & feature
12
- updates and allow non-sensitive
13
- diagnostic tracking.</p>
14
- </div>
15
- </div>
16
- <div class="analyst-modal-def-top-padding">
17
- <button class="analyst-btn-success" id="analyst-install-action">Allow & Continue ></button>
18
- </div>
19
- <div class="analyst-modal-def-top-padding" id="analyst-permissions-block" style="display: none">
20
- <span>You’re granting these permissions:</span>
21
- <ul class="analyst-install-permissions-list">
22
- <li><strong>Your profile information</strong> (name and email) ​</li>
23
- <li><strong>Your site information</strong> (URL, WP version, PHP info, plugins & themes)</li>
24
- <li><strong>Plugin notices</strong> (updates, announcements, marketing, no spam)</li>
25
- <li><strong>Plugin events</strong> (activation, deactivation and uninstall)​</li>
26
- </ul>
27
- </div>
28
- <div class="analyst-install-footer analyst-modal-def-top-padding">
29
- <span class="analyst-action-text" id="analyst-permissions-toggle">Learn more</span>
30
- <span class="analyst-action-text analyst-install-modal-close" id="analyst-install-skip">Skip</span>
31
- </div>
32
- <div id="analyst-install-error" class="analyst-modal-def-top-padding" style="display: none; text-align: center">
33
- <span style="color: #dc3232; font-size: 16px">Service unavailable. Please try again later</span>
34
- </div>
35
- </div>
36
- </div>
37
-
38
- <script type="text/javascript">
39
- (function ($) {
40
-
41
- var installPlugin = function (pluginId) {
42
- var $error = $('#analyst-install-error')
43
-
44
- $error.hide()
45
-
46
- $.ajax({
47
- url: ajaxurl,
48
- method: 'POST',
49
- data: {
50
- action: 'analyst_install_' + pluginId
51
- },
52
- success: function (data) {
53
- if (data && !data.success) {
54
- //error
55
- $('#analyst-install-modal').hide()
56
-
57
- return
58
- }
59
-
60
- window.location.reload()
61
- },
62
- error: function () {
63
- $('#analyst-install-modal').hide()
64
- }
65
- }).done(function () {
66
- $('#analyst-disable-install-modal-mask').hide()
67
-
68
- $('#analyst-install-action')
69
- .attr('disabled', false)
70
- .text('Allow & Continue >')
71
- })
72
- }
73
-
74
- if ($('#analyst-install-modal').attr('analyst-plugin-id')) {
75
- $('#analyst-install-modal').show()
76
- }
77
-
78
-
79
- $('.analyst-install-modal-close').click(function () {
80
- $('#analyst-install-modal').hide()
81
- })
82
-
83
- $('#analyst-install-action').click(function () {
84
- var pluginId = $('#analyst-install-modal').attr('analyst-plugin-id')
85
-
86
- $('#analyst-install-action')
87
- .attr('disabled', true)
88
- .text('Please wait...')
89
-
90
- $('#analyst-disable-install-modal-mask').show()
91
-
92
- installPlugin(pluginId)
93
- })
94
-
95
- $('#analyst-permissions-toggle').click(function () {
96
- var isVisible = $('#analyst-permissions-block').toggle().is(':visible')
97
-
98
- isVisible ? $(this).text('Close section') : $(this).text('Learn more')
99
-
100
- var poweredBy = $('#analyst-powered-by')
101
- isVisible ? poweredBy.show() : poweredBy.hide()
102
- })
103
-
104
- $('#analyst-install-skip').click(function () {
105
- var pluginId = $('#analyst-install-modal').attr('analyst-plugin-id')
106
-
107
- $.post(ajaxurl, {action: 'analyst_skip_install_' + pluginId}).done(function () {
108
- $('#analyst-install-modal').hide()
109
- })
110
- })
111
- })(jQuery)
112
- </script>
1
+ <div id="analyst-install-modal" class="analyst-modal" style="display: none" analyst-plugin-id="<?=$pluginToInstall?>">
2
+ <div class="analyst-modal-content" style="width: 450px">
3
+ <div class="analyst-disable-modal-mask" id="analyst-disable-install-modal-mask" style="display: none"></div>
4
+ <div style="display: flex">
5
+ <div class="analyst-install-image-block">
6
+ <img src="<?=$shieldImage?>"/>
7
+ </div>
8
+ <div class="analyst-install-description-block">
9
+ <strong class="analyst-modal-header">Stay on the safe side</strong>
10
+ <p class="analyst-install-description-text">Receive our plugin’s alerts in
11
+ case of <strong>critical security</strong> & feature
12
+ updates and allow non-sensitive
13
+ diagnostic tracking.</p>
14
+ </div>
15
+ </div>
16
+ <div class="analyst-modal-def-top-padding">
17
+ <button class="analyst-btn-success" id="analyst-install-action">Allow & Continue ></button>
18
+ </div>
19
+ <div class="analyst-modal-def-top-padding" id="analyst-permissions-block" style="display: none">
20
+ <span>You’re granting these permissions:</span>
21
+ <ul class="analyst-install-permissions-list">
22
+ <li><strong>Your profile information</strong> (name and email) ​</li>
23
+ <li><strong>Your site information</strong> (URL, WP version, PHP info, plugins & themes)</li>
24
+ <li><strong>Plugin notices</strong> (updates, announcements, marketing, no spam)</li>
25
+ <li><strong>Plugin events</strong> (activation, deactivation and uninstall)​</li>
26
+ </ul>
27
+ </div>
28
+ <div class="analyst-install-footer analyst-modal-def-top-padding">
29
+ <span class="analyst-action-text" id="analyst-permissions-toggle">Learn more</span>
30
+ <span class="analyst-action-text analyst-install-modal-close" id="analyst-install-skip">Skip</span>
31
+ </div>
32
+ <div id="analyst-install-error" class="analyst-modal-def-top-padding" style="display: none; text-align: center">
33
+ <span style="color: #dc3232; font-size: 16px">Service unavailable. Please try again later</span>
34
+ </div>
35
+ </div>
36
+ </div>
37
+
38
+ <script type="text/javascript">
39
+ (function ($) {
40
+
41
+ var installPlugin = function (pluginId) {
42
+ var $error = $('#analyst-install-error')
43
+
44
+ $error.hide()
45
+
46
+ $.ajax({
47
+ url: ajaxurl,
48
+ method: 'POST',
49
+ data: {
50
+ action: 'analyst_install_' + pluginId
51
+ },
52
+ success: function (data) {
53
+ if (data && !data.success) {
54
+ //error
55
+ $('#analyst-install-modal').hide()
56
+
57
+ return
58
+ }
59
+
60
+ window.location.reload()
61
+ },
62
+ error: function () {
63
+ $('#analyst-install-modal').hide()
64
+ }
65
+ }).done(function () {
66
+ $('#analyst-disable-install-modal-mask').hide()
67
+
68
+ $('#analyst-install-action')
69
+ .attr('disabled', false)
70
+ .text('Allow & Continue >')
71
+ })
72
+ }
73
+
74
+ if ($('#analyst-install-modal').attr('analyst-plugin-id')) {
75
+ $('#analyst-install-modal').show()
76
+ }
77
+
78
+
79
+ $('.analyst-install-modal-close').click(function () {
80
+ $('#analyst-install-modal').hide()
81
+ })
82
+
83
+ $('#analyst-install-action').click(function () {
84
+ var pluginId = $('#analyst-install-modal').attr('analyst-plugin-id')
85
+
86
+ $('#analyst-install-action')
87
+ .attr('disabled', true)
88
+ .text('Please wait...')
89
+
90
+ $('#analyst-disable-install-modal-mask').show()
91
+
92
+ installPlugin(pluginId)
93
+ })
94
+
95
+ $('#analyst-permissions-toggle').click(function () {
96
+ var isVisible = $('#analyst-permissions-block').toggle().is(':visible')
97
+
98
+ isVisible ? $(this).text('Close section') : $(this).text('Learn more')
99
+
100
+ var poweredBy = $('#analyst-powered-by')
101
+ isVisible ? poweredBy.show() : poweredBy.hide()
102
+ })
103
+
104
+ $('#analyst-install-skip').click(function () {
105
+ var pluginId = $('#analyst-install-modal').attr('analyst-plugin-id')
106
+
107
+ $.post(ajaxurl, {action: 'analyst_skip_install_' + pluginId}).done(function () {
108
+ $('#analyst-install-modal').hide()
109
+ })
110
+ })
111
+ })(jQuery)
112
+ </script>
analyst/templates/notice.php CHANGED
@@ -1,10 +1,10 @@
1
- <div class="notice notice-success analyst-notice">
2
- <p>
3
- <strong class="analyst-plugin-name"><?=$notice->getPluginName()?></strong>
4
- <?=$notice->getBody()?>
5
- </p>
6
-
7
- <button type="button" class="analyst-notice-dismiss notice-dismiss" analyst-notice-id="<?=$notice->getId()?>">
8
- <span class="screen-reader-text">Dismiss this notice.</span>
9
- </button>
10
- </div>
1
+ <div class="notice notice-success analyst-notice">
2
+ <p>
3
+ <strong class="analyst-plugin-name"><?=$notice->getPluginName()?></strong>
4
+ <?=$notice->getBody()?>
5
+ </p>
6
+
7
+ <button type="button" class="analyst-notice-dismiss notice-dismiss" analyst-notice-id="<?=$notice->getId()?>">
8
+ <span class="screen-reader-text">Dismiss this notice.</span>
9
+ </button>
10
+ </div>
analyst/templates/optin.php CHANGED
@@ -1,60 +1,60 @@
1
- <script type="text/javascript">
2
-
3
- (function ($) {
4
- var isOptingIn = false
5
-
6
- $('#analyst-opt-in-modal').appendTo($('body'))
7
-
8
- var makeOptIn = function (pluginId) {
9
- if (isOptingIn) return
10
-
11
- isOptingIn = true
12
-
13
- $.ajax({
14
- url: ajaxurl,
15
- method: 'POST',
16
- data: {
17
- action: 'analyst_opt_in_' + pluginId,
18
- },
19
- success: function () {
20
- $('#analyst-opt-in-modal').hide()
21
-
22
- isOptingIn = false
23
-
24
- var optOutAction = $('<a />').attr({
25
- class: 'analyst-action-opt analyst-opt-out',
26
- 'analyst-plugin-id': pluginId,
27
- 'analyst-plugin-signed': '1'
28
- })
29
- .text('Opt Out')
30
- $('.analyst-opt-in[analyst-plugin-id="'+ pluginId +'"').replaceWith(optOutAction)
31
-
32
- $('[analyst-plugin-id="' + pluginId + '"').attr('analyst-plugin-opted-in', 1)
33
- }
34
- })
35
- }
36
-
37
- $(document).on('click', '.analyst-opt-in:not([loading])', function() {
38
- var pluginId = $(this).attr('analyst-plugin-id')
39
- var isSigned = $(this).attr('analyst-plugin-signed') === '1'
40
-
41
- if (!isSigned) {
42
- $('#analyst-install-modal')
43
- .attr('analyst-plugin-id', pluginId)
44
- .show()
45
-
46
- return;
47
- }
48
-
49
- $('#analyst-install-modal').attr({'analyst-plugin-id': pluginId})
50
-
51
- $(this).attr('loading', true).text('Opting In...')
52
-
53
- makeOptIn(pluginId);
54
- })
55
-
56
- $('.opt-in-modal-close').click(function () {
57
- $('#analyst-opt-in-modal').hide()
58
- })
59
- })(jQuery)
60
- </script>
1
+ <script type="text/javascript">
2
+
3
+ (function ($) {
4
+ var isOptingIn = false
5
+
6
+ $('#analyst-opt-in-modal').appendTo($('body'))
7
+
8
+ var makeOptIn = function (pluginId) {
9
+ if (isOptingIn) return
10
+
11
+ isOptingIn = true
12
+
13
+ $.ajax({
14
+ url: ajaxurl,
15
+ method: 'POST',
16
+ data: {
17
+ action: 'analyst_opt_in_' + pluginId,
18
+ },
19
+ success: function () {
20
+ $('#analyst-opt-in-modal').hide()
21
+
22
+ isOptingIn = false
23
+
24
+ var optOutAction = $('<a />').attr({
25
+ class: 'analyst-action-opt analyst-opt-out',
26
+ 'analyst-plugin-id': pluginId,
27
+ 'analyst-plugin-signed': '1'
28
+ })
29
+ .text('Opt Out')
30
+ $('.analyst-opt-in[analyst-plugin-id="'+ pluginId +'"').replaceWith(optOutAction)
31
+
32
+ $('[analyst-plugin-id="' + pluginId + '"').attr('analyst-plugin-opted-in', 1)
33
+ }
34
+ })
35
+ }
36
+
37
+ $(document).on('click', '.analyst-opt-in:not([loading])', function() {
38
+ var pluginId = $(this).attr('analyst-plugin-id')
39
+ var isSigned = $(this).attr('analyst-plugin-signed') === '1'
40
+
41
+ if (!isSigned) {
42
+ $('#analyst-install-modal')
43
+ .attr('analyst-plugin-id', pluginId)
44
+ .show()
45
+
46
+ return;
47
+ }
48
+
49
+ $('#analyst-install-modal').attr({'analyst-plugin-id': pluginId})
50
+
51
+ $(this).attr('loading', true).text('Opting In...')
52
+
53
+ makeOptIn(pluginId);
54
+ })
55
+
56
+ $('.opt-in-modal-close').click(function () {
57
+ $('#analyst-opt-in-modal').hide()
58
+ })
59
+ })(jQuery)
60
+ </script>
analyst/templates/optout.php CHANGED
@@ -1,109 +1,109 @@
1
- <div id="analyst-opt-out-modal" class="analyst-modal" style="display: none">
2
- <div class="analyst-modal-content" style="width: 600px">
3
- <div class="analyst-disable-modal-mask" id="analyst-disable-opt-out-modal-mask" style="display: none"></div>
4
- <div style="display: flex">
5
- <div class="analyst-install-image-block" style="width: 120px">
6
- <img src="<?=$shieldImage?>"/>
7
- </div>
8
- <div class="analyst-install-description-block">
9
- <strong class="analyst-modal-header">By opting out, we cannot alert you anymore in case of important security updates.</strong>
10
- <p class="analyst-install-description-text">
11
- In addition, we won’t get pointers how to further improve the plugin based on your integration with our plugin.
12
- </p>
13
- </div>
14
- </div>
15
- <div class="analyst-modal-def-top-padding">
16
- <button class="analyst-btn-success opt-out-modal-close">Ok, don't opt out</button>
17
- </div>
18
- <div class="analyst-modal-def-top-padding" style="text-align: center;">
19
- <button class="analyst-btn-secondary-ghost" id="opt-out-action">Opt out</button>
20
- </div>
21
- <div id="analyst-opt-out-error" class="analyst-modal-def-top-padding" style="display: none;">
22
- <span style="color: #dc3232; font-size: 16px">Service unavailable. Please try again later</span>
23
- </div>
24
- </div>
25
- </div>
26
- </div>
27
-
28
- <script type="text/javascript">
29
-
30
- (function ($) {
31
- var isOptingOut = false
32
-
33
- $('#analyst-opt-out-modal').appendTo($('body'))
34
-
35
- $(document).on('click', '.analyst-opt-out', function() {
36
- var pluginId = $(this).attr('analyst-plugin-id')
37
-
38
- $('#analyst-opt-out-modal')
39
- .attr({'analyst-plugin-id': pluginId})
40
- .show()
41
- })
42
-
43
- $('.opt-out-modal-close').click(function () {
44
- $('#analyst-opt-out-modal').hide()
45
- })
46
-
47
- $('#opt-out-action').click(function () {
48
- if (isOptingOut) return
49
-
50
- var $mask = $('#analyst-disable-opt-out-modal-mask')
51
- var $error = $('#analyst-opt-out-error')
52
-
53
- var pluginId = $('#analyst-opt-out-modal').attr('analyst-plugin-id')
54
-
55
- $mask.show()
56
- $error.hide()
57
-
58
- var self = this
59
-
60
- isOptingOut = true
61
-
62
- $(self).text('Opting out...')
63
-
64
- $.ajax({
65
- url: ajaxurl,
66
- method: 'POST',
67
- data: {
68
- action: 'analyst_opt_out_' + pluginId,
69
- },
70
- success: function (data) {
71
- $(self).text('Opt out')
72
-
73
- if (data && !data.success) {
74
- $('#analyst-opt-out-modal').hide()
75
-
76
- return
77
- }
78
-
79
- $error.hide()
80
-
81
- $('#analyst-opt-out-modal').hide()
82
-
83
- isOptingOut = false
84
-
85
- var optInAction = $('<a />').attr({
86
- class: 'analyst-action-opt analyst-opt-in',
87
- 'analyst-plugin-id': pluginId,
88
- 'analyst-plugin-signed': '1'
89
- })
90
- .text('Opt In')
91
- $('.analyst-opt-out[analyst-plugin-id="'+ pluginId +'"').replaceWith(optInAction)
92
-
93
- $('[analyst-plugin-id="' + pluginId + '"').attr('analyst-plugin-opted-in', 0)
94
-
95
- $mask.hide()
96
- },
97
- error: function () {
98
- $('#analyst-opt-out-error').show()
99
-
100
- $(self).text('Opt out')
101
- }
102
- }).done(function () {
103
- $mask.hide()
104
-
105
- isOptingOut = false
106
- })
107
- })
108
- })(jQuery)
109
- </script>
1
+ <div id="analyst-opt-out-modal" class="analyst-modal" style="display: none">
2
+ <div class="analyst-modal-content" style="width: 600px">
3
+ <div class="analyst-disable-modal-mask" id="analyst-disable-opt-out-modal-mask" style="display: none"></div>
4
+ <div style="display: flex">
5
+ <div class="analyst-install-image-block" style="width: 120px">
6
+ <img src="<?=$shieldImage?>"/>
7
+ </div>
8
+ <div class="analyst-install-description-block">
9
+ <strong class="analyst-modal-header">By opting out, we cannot alert you anymore in case of important security updates.</strong>
10
+ <p class="analyst-install-description-text">
11
+ In addition, we won’t get pointers how to further improve the plugin based on your integration with our plugin.
12
+ </p>
13
+ </div>
14
+ </div>
15
+ <div class="analyst-modal-def-top-padding">
16
+ <button class="analyst-btn-success opt-out-modal-close">Ok, don't opt out</button>
17
+ </div>
18
+ <div class="analyst-modal-def-top-padding" style="text-align: center;">
19
+ <button class="analyst-btn-secondary-ghost" id="opt-out-action">Opt out</button>
20
+ </div>
21
+ <div id="analyst-opt-out-error" class="analyst-modal-def-top-padding" style="display: none;">
22
+ <span style="color: #dc3232; font-size: 16px">Service unavailable. Please try again later</span>
23
+ </div>
24
+ </div>
25
+ </div>
26
+ </div>
27
+
28
+ <script type="text/javascript">
29
+
30
+ (function ($) {
31
+ var isOptingOut = false
32
+
33
+ $('#analyst-opt-out-modal').appendTo($('body'))
34
+
35
+ $(document).on('click', '.analyst-opt-out', function() {
36
+ var pluginId = $(this).attr('analyst-plugin-id')
37
+
38
+ $('#analyst-opt-out-modal')
39
+ .attr({'analyst-plugin-id': pluginId})
40
+ .show()
41
+ })
42
+
43
+ $('.opt-out-modal-close').click(function () {
44
+ $('#analyst-opt-out-modal').hide()
45
+ })
46
+
47
+ $('#opt-out-action').click(function () {
48
+ if (isOptingOut) return
49
+
50
+ var $mask = $('#analyst-disable-opt-out-modal-mask')
51
+ var $error = $('#analyst-opt-out-error')
52
+
53
+ var pluginId = $('#analyst-opt-out-modal').attr('analyst-plugin-id')
54
+
55
+ $mask.show()
56
+ $error.hide()
57
+
58
+ var self = this
59
+
60
+ isOptingOut = true
61
+
62
+ $(self).text('Opting out...')
63
+
64
+ $.ajax({
65
+ url: ajaxurl,
66
+ method: 'POST',
67
+ data: {
68
+ action: 'analyst_opt_out_' + pluginId,
69
+ },
70
+ success: function (data) {
71
+ $(self).text('Opt out')
72
+
73
+ if (data && !data.success) {
74
+ $('#analyst-opt-out-modal').hide()
75
+
76
+ return
77
+ }
78
+
79
+ $error.hide()
80
+
81
+ $('#analyst-opt-out-modal').hide()
82
+
83
+ isOptingOut = false
84
+
85
+ var optInAction = $('<a />').attr({
86
+ class: 'analyst-action-opt analyst-opt-in',
87
+ 'analyst-plugin-id': pluginId,
88
+ 'analyst-plugin-signed': '1'
89
+ })
90
+ .text('Opt In')
91
+ $('.analyst-opt-out[analyst-plugin-id="'+ pluginId +'"').replaceWith(optInAction)
92
+
93
+ $('[analyst-plugin-id="' + pluginId + '"').attr('analyst-plugin-opted-in', 0)
94
+
95
+ $mask.hide()
96
+ },
97
+ error: function () {
98
+ $('#analyst-opt-out-error').show()
99
+
100
+ $(self).text('Opt out')
101
+ }
102
+ }).done(function () {
103
+ $mask.hide()
104
+
105
+ isOptingOut = false
106
+ })
107
+ })
108
+ })(jQuery)
109
+ </script>
analyst/version.php CHANGED
@@ -1,15 +1,15 @@
1
- <?php
2
-
3
- return array(
4
- // The sdk version
5
- 'sdk' => '1.3.30',
6
-
7
- // Minimum supported WordPress version
8
- 'wp' => '4.7',
9
-
10
- // Supported PHP version
11
- 'php' => '5.4',
12
-
13
- // Path to current SDK$
14
- 'path' => __DIR__,
15
- );
1
+ <?php
2
+
3
+ return array(
4
+ // The sdk version
5
+ 'sdk' => '1.3.30',
6
+
7
+ // Minimum supported WordPress version
8
+ 'wp' => '4.7',
9
+
10
+ // Supported PHP version
11
+ 'php' => '5.4',
12
+
13
+ // Path to current SDK$
14
+ 'path' => __DIR__,
15
+ );
assets/css/void-cf7-admin.css CHANGED
@@ -1,125 +1,125 @@
1
- /* void cf7 admin css */
2
-
3
- .void-cf7-review{
4
- background : #FFFFFF ;
5
- padding : 10px;
6
- margin-top : 40px;
7
- margin-bottom: 10px;
8
- line-height: 1.5;
9
- font-size: 16px;
10
- border-left: 5px solid #006799;
11
- -webkit-box-shadow: 1px 1px 1px 1px #d3d3d3;
12
- box-shadow: 1px 1px 1px 1px #d3d3d3;
13
- }
14
- .void-cf7-review-btn{
15
- padding-top: 5px;
16
- }
17
- .void-cf7-review-done{
18
- float: right;
19
- text-decoration: none;
20
- }
21
-
22
- /* notice css start */
23
- .cf7-widget-promotion-notice{
24
- background: linear-gradient(to right, #4E40F1 0%, #ffccff 100%);
25
- border-left-color: linear-gradient(to bottom, #3F2BE2 20%, #0066ff 45%);
26
- }
27
- .cf7-widget-promotion-notice .notice-dismiss:before{
28
- font-size: 22px;
29
- }
30
- .cf7-widget-message-inner {
31
- display: flex;
32
- -webkit-box-align: center;
33
- align-items: center;
34
- }
35
- .cf7-widget-message-icon,
36
- .cf7-widget-message-icon > img{
37
- max-height: 200px;
38
- width: auto;
39
- }
40
- .cf7-widget-message-content{
41
- padding: 0 20px;
42
- }
43
- .cf7-widget-message-content p{
44
- padding: 0;
45
- margin: 0;
46
- font-size: 14px;
47
- color: #000;
48
- }
49
- .cf7-widget-message-action{
50
- text-align: center;
51
- display: flex;
52
- -webkit-box-orient: vertical;
53
- -webkit-box-direction: normal;
54
- flex-direction: column;
55
- margin-left: auto;
56
- }
57
- .cf7-widget-message-action .cf7-widget-button{
58
- background-color: #d30c5c;
59
- color: #fff;
60
- border-color: #7c1337;
61
- -webkit-box-shadow: 0 1px 0 #7c1337;
62
- box-shadow: 0 1px 0 #7c1337;
63
- padding: 10px 60px;
64
- height: auto;
65
- line-height: 20px;
66
- text-transform: capitalize;
67
- text-decoration: none;
68
- border-radius: 5px;
69
- margin: 5px;
70
- font-size: 16px;
71
- }
72
- .cf7-widget-message-action .cf7-widget-button:hover{
73
- font-size: 18px;
74
- }
75
-
76
- .cf7-widget-message-action .cf7-widget-never-show{
77
- color: #D0A7FB;
78
- margin: 20px 20px 0 20px;
79
- }
80
-
81
- .cf7-widget-message-action .cf7-widget-never-show:hover{
82
- color: #D0A7FB;
83
- }
84
- /* notice css end */
85
-
86
- /* data track notice css start*/
87
-
88
- .void-cf7-widget-data-track-notice p{
89
- display: inline-block;
90
- }
91
-
92
- .void-cf7-non-sensitive {
93
- position: relative;
94
- display: inline-block;
95
- border-bottom: 1px dotted black;
96
- color: #00a0d2;
97
- }
98
-
99
- .void-cf7-non-sensitive .void-cf7-non-sensitive-tooltip {
100
- visibility: hidden;
101
- width: 300px;
102
- background-color: #00a0d2;
103
- color: #fff;
104
- text-align: left;
105
- border-radius: 6px;
106
- padding: 10px;
107
-
108
- /* Position the tooltip */
109
- position: absolute;
110
- z-index: 1;
111
- top: 100%;
112
- left: 50%;
113
- margin-left: -60px;
114
- }
115
-
116
- .void-cf7-non-sensitive-tooltip li{
117
- list-style: inside;
118
- padding: 0 0 10px 0;
119
- }
120
-
121
- .void-cf7-non-sensitive:hover .void-cf7-non-sensitive-tooltip {
122
- visibility: visible;
123
- }
124
-
125
  /* data track notice css end*/
1
+ /* void cf7 admin css */
2
+
3
+ .void-cf7-review{
4
+ background : #FFFFFF ;
5
+ padding : 10px;
6
+ margin-top : 40px;
7
+ margin-bottom: 10px;
8
+ line-height: 1.5;
9
+ font-size: 16px;
10
+ border-left: 5px solid #006799;
11
+ -webkit-box-shadow: 1px 1px 1px 1px #d3d3d3;
12
+ box-shadow: 1px 1px 1px 1px #d3d3d3;
13
+ }
14
+ .void-cf7-review-btn{
15
+ padding-top: 5px;
16
+ }
17
+ .void-cf7-review-done{
18
+ float: right;
19
+ text-decoration: none;
20
+ }
21
+
22
+ /* notice css start */
23
+ .cf7-widget-promotion-notice{
24
+ background: linear-gradient(to right, #4E40F1 0%, #ffccff 100%);
25
+ border-left-color: linear-gradient(to bottom, #3F2BE2 20%, #0066ff 45%);
26
+ }
27
+ .cf7-widget-promotion-notice .notice-dismiss:before{
28
+ font-size: 22px;
29
+ }
30
+ .cf7-widget-message-inner {
31
+ display: flex;
32
+ -webkit-box-align: center;
33
+ align-items: center;
34
+ }
35
+ .cf7-widget-message-icon,
36
+ .cf7-widget-message-icon > img{
37
+ max-height: 200px;
38
+ width: auto;
39
+ }
40
+ .cf7-widget-message-content{
41
+ padding: 0 20px;
42
+ }
43
+ .cf7-widget-message-content p{
44
+ padding: 0;
45
+ margin: 0;
46
+ font-size: 14px;
47
+ color: #000;
48
+ }
49
+ .cf7-widget-message-action{
50
+ text-align: center;
51
+ display: flex;
52
+ -webkit-box-orient: vertical;
53
+ -webkit-box-direction: normal;
54
+ flex-direction: column;
55
+ margin-left: auto;
56
+ }
57
+ .cf7-widget-message-action .cf7-widget-button{
58
+ background-color: #d30c5c;
59
+ color: #fff;
60
+ border-color: #7c1337;
61
+ -webkit-box-shadow: 0 1px 0 #7c1337;
62
+ box-shadow: 0 1px 0 #7c1337;
63
+ padding: 10px 60px;
64
+ height: auto;
65
+ line-height: 20px;
66
+ text-transform: capitalize;
67
+ text-decoration: none;
68
+ border-radius: 5px;
69
+ margin: 5px;
70
+ font-size: 16px;
71
+ }
72
+ .cf7-widget-message-action .cf7-widget-button:hover{
73
+ font-size: 18px;
74
+ }
75
+
76
+ .cf7-widget-message-action .cf7-widget-never-show{
77
+ color: #D0A7FB;
78
+ margin: 20px 20px 0 20px;
79
+ }
80
+
81
+ .cf7-widget-message-action .cf7-widget-never-show:hover{
82
+ color: #D0A7FB;
83
+ }
84
+ /* notice css end */
85
+
86
+ /* data track notice css start*/
87
+
88
+ .void-cf7-widget-data-track-notice p{
89
+ display: inline-block;
90
+ }
91
+
92
+ .void-cf7-non-sensitive {
93
+ position: relative;
94
+ display: inline-block;
95
+ border-bottom: 1px dotted black;
96
+ color: #00a0d2;
97
+ }
98
+
99
+ .void-cf7-non-sensitive .void-cf7-non-sensitive-tooltip {
100
+ visibility: hidden;
101
+ width: 300px;
102
+ background-color: #00a0d2;
103
+ color: #fff;
104
+ text-align: left;
105
+ border-radius: 6px;
106
+ padding: 10px;
107
+
108
+ /* Position the tooltip */
109
+ position: absolute;
110
+ z-index: 1;
111
+ top: 100%;
112
+ left: 50%;
113
+ margin-left: -60px;
114
+ }
115
+
116
+ .void-cf7-non-sensitive-tooltip li{
117
+ list-style: inside;
118
+ padding: 0 0 10px 0;
119
+ }
120
+
121
+ .void-cf7-non-sensitive:hover .void-cf7-non-sensitive-tooltip {
122
+ visibility: visible;
123
+ }
124
+
125
  /* data track notice css end*/
assets/js/void-cf7-admin.js CHANGED
@@ -1,83 +1,83 @@
1
- (function($) {
2
- // Hook into the "cf7-widget-promotion-notice" class we added to the notice, so
3
- // Only listen to YOUR notices being dismissed
4
- var elNotice = $('.cf7-widget-promotion-notice');
5
-
6
- $( document ).on( 'click', '.cf7-widget-promotion-notice .notice-dismiss', function () {
7
- // Read the "data-notice" information to track which notice
8
- // is being dismissed and send it via AJAX
9
- var type = $( this ).closest( '.cf7-widget-promotion-notice' ).data( 'notice' );
10
- var nonce = $( this ).closest( '.cf7-widget-promotion-notice' ).data( 'nonce' );
11
-
12
- // Make an AJAX call
13
- // Since WP 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
14
- $.ajax({
15
- // url of ajax request, value of voidCf7Admin.ajaxUrl is localized during enqueue script
16
- url: ajaxurl,
17
- type: 'POST',
18
- data: {
19
- action: 'dismissed_promotional_notice_handler',
20
- type: type,
21
- status: 'remind-me-later',
22
- },
23
- // wp verify nonce automatically after sending nonce like this
24
- headers: {
25
- 'X-WP-Nonce': nonce
26
- },
27
- dataType: 'json',
28
- });
29
- });
30
-
31
- elNotice.find( '.cf7-widget-never-show' ).on( 'click', function (e) {
32
- e.preventDefault();
33
- // Read the "data-notice" information to track which notice
34
- // is being dismissed and send it via AJAX
35
- var type = $( this ).closest( '.cf7-widget-promotion-notice' ).data( 'notice' );
36
- var nonce = $( this ).closest( '.cf7-widget-promotion-notice' ).data( 'nonce' );
37
-
38
- elNotice.hide();
39
-
40
- // Make an AJAX call
41
- // Since WP 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
42
- $.ajax({
43
- // url of ajax request, value of voidCf7Admin.ajaxUrl is localized during enqueue script
44
- url: ajaxurl,
45
- type: 'POST',
46
- data: {
47
- action: 'dismissed_promotional_notice_handler',
48
- type: type,
49
- status: 'never-show',
50
- },
51
- // wp verify nonce automatically after sending nonce like this
52
- headers: {
53
- 'X-WP-Nonce': nonce
54
- },
55
- dataType: 'json',
56
- });
57
- });
58
-
59
- $( document ).on( 'click', '.void-cf7-widget-data-track-notice .notice-dismiss', function () {
60
- // Read the "data-notice" information to track which notice
61
- // is being dismissed and send it via AJAX
62
- var type = $( this ).closest( '.void-cf7-widget-data-track-notice' ).data( 'notice' );
63
- var nonce = $( this ).closest( '.void-cf7-widget-data-track-notice' ).data( 'nonce' );
64
- // Make an AJAX call
65
- // Since WP 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
66
- $.ajax({
67
- // url of ajax request, value of voidCf7Admin.ajaxUrl is localized during enqueue script
68
- url: ajaxurl,
69
- type: 'POST',
70
- data: {
71
- action: 'dismissed_usage_data_track_void_cf7',
72
- type: type,
73
- status: 'remind-me-later',
74
- },
75
- // wp verify nonce automatically after sending nonce like this
76
- headers: {
77
- 'X-WP-Nonce': nonce
78
- },
79
- dataType: 'json',
80
- });
81
- });
82
-
83
  })(jQuery);
1
+ (function($) {
2
+ // Hook into the "cf7-widget-promotion-notice" class we added to the notice, so
3
+ // Only listen to YOUR notices being dismissed
4
+ var elNotice = $('.cf7-widget-promotion-notice');
5
+
6
+ $( document ).on( 'click', '.cf7-widget-promotion-notice .notice-dismiss', function () {
7
+ // Read the "data-notice" information to track which notice
8
+ // is being dismissed and send it via AJAX
9
+ var type = $( this ).closest( '.cf7-widget-promotion-notice' ).data( 'notice' );
10
+ var nonce = $( this ).closest( '.cf7-widget-promotion-notice' ).data( 'nonce' );
11
+
12
+ // Make an AJAX call
13
+ // Since WP 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
14
+ $.ajax({
15
+ // url of ajax request, value of voidCf7Admin.ajaxUrl is localized during enqueue script
16
+ url: ajaxurl,
17
+ type: 'POST',
18
+ data: {
19
+ action: 'dismissed_promotional_notice_handler',
20
+ type: type,
21
+ status: 'remind-me-later',
22
+ },
23
+ // wp verify nonce automatically after sending nonce like this
24
+ headers: {
25
+ 'X-WP-Nonce': nonce
26
+ },
27
+ dataType: 'json',
28
+ });
29
+ });
30
+
31
+ elNotice.find( '.cf7-widget-never-show' ).on( 'click', function (e) {
32
+ e.preventDefault();
33
+ // Read the "data-notice" information to track which notice
34
+ // is being dismissed and send it via AJAX
35
+ var type = $( this ).closest( '.cf7-widget-promotion-notice' ).data( 'notice' );
36
+ var nonce = $( this ).closest( '.cf7-widget-promotion-notice' ).data( 'nonce' );
37
+
38
+ elNotice.hide();
39
+
40
+ // Make an AJAX call
41
+ // Since WP 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
42
+ $.ajax({
43
+ // url of ajax request, value of voidCf7Admin.ajaxUrl is localized during enqueue script
44
+ url: ajaxurl,
45
+ type: 'POST',
46
+ data: {
47
+ action: 'dismissed_promotional_notice_handler',
48
+ type: type,
49
+ status: 'never-show',
50
+ },
51
+ // wp verify nonce automatically after sending nonce like this
52
+ headers: {
53
+ 'X-WP-Nonce': nonce
54
+ },
55
+ dataType: 'json',
56
+ });
57
+ });
58
+
59
+ $( document ).on( 'click', '.void-cf7-widget-data-track-notice .notice-dismiss', function () {
60
+ // Read the "data-notice" information to track which notice
61
+ // is being dismissed and send it via AJAX
62
+ var type = $( this ).closest( '.void-cf7-widget-data-track-notice' ).data( 'notice' );
63
+ var nonce = $( this ).closest( '.void-cf7-widget-data-track-notice' ).data( 'nonce' );
64
+ // Make an AJAX call
65
+ // Since WP 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
66
+ $.ajax({
67
+ // url of ajax request, value of voidCf7Admin.ajaxUrl is localized during enqueue script
68
+ url: ajaxurl,
69
+ type: 'POST',
70
+ data: {
71
+ action: 'dismissed_usage_data_track_void_cf7',
72
+ type: type,
73
+ status: 'remind-me-later',
74
+ },
75
+ // wp verify nonce automatically after sending nonce like this
76
+ headers: {
77
+ 'X-WP-Nonce': nonce
78
+ },
79
+ dataType: 'json',
80
+ });
81
+ });
82
+
83
  })(jQuery);
custom-editor/assets/css/void-cf7-elementor-editor.css CHANGED
@@ -1,112 +1,112 @@
1
- /* The Modal (background) */
2
-
3
- #cf7_widget_elementor_contact_form_control_modal {
4
- display: none; /* Hidden by default */
5
- position: fixed; /* Stay in place */
6
- z-index: 999; /* Sit on top */
7
- padding-top: 50px; /* Location of the box */
8
- left: 0;
9
- top: 0;
10
- width: 100%; /* Full width */
11
- height: 100%; /* Full height */
12
- overflow: auto; /* Enable scroll if needed */
13
- background-color: rgb(0,0,0); /* Fallback color */
14
- background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
15
- right: 0;
16
- bottom: 0;
17
- }
18
-
19
- /* Modal Content */
20
- .cf7-widget-elementor-modal-content {
21
- background-color: #fefefe;
22
- margin: auto;
23
- padding: 0px;
24
- border: 1px solid #888;
25
- width: 90%;
26
- height: 90%;
27
- overflow: hidden;
28
- border-radius: 8px;
29
- position: relative;
30
- }
31
- .cf7-widget-elementor-modal-iframe{
32
- width: 100%;
33
- height: 100%;
34
- }
35
-
36
- /* The Close Button */
37
- .cf7-widget-elementor-modal-close {
38
- float: right;
39
- font-size: 24px;
40
- font-weight: bold;
41
- background: #000;
42
- border-radius: 50%;
43
- height: 25px;
44
- width: 25px;
45
- padding: 0 0 5px 6px;
46
- color: #ffffff;
47
- position: absolute;
48
- z-index: 1;
49
- right: 0px;
50
- }
51
-
52
- .cf7-widget-elementor-modal-close:hover,
53
- .cf7-widget-elementor-modal-close:focus {
54
- color: rgb(248, 241, 241);
55
- text-decoration: none;
56
- cursor: pointer;
57
- font-size: 26px;
58
- }
59
-
60
- .cf7-widget-elementor-modal-hide-adminmenu{
61
- display: none;
62
- }
63
-
64
- /* loader start*/
65
-
66
- .cf7-widget-elementor-modal-content-loader.loading {
67
- position: absolute;
68
- left: 50%;
69
- top: 50%;
70
- z-index: 1;
71
- width: 150px;
72
- height: 150px;
73
- margin: -75px 0 0 -75px;
74
- border: 16px solid #f3f3f3;
75
- border-radius: 50%;
76
- border-top: 16px solid #3498db;
77
- width: 120px;
78
- height: 120px;
79
- -webkit-animation: spin 2s linear infinite;
80
- animation: spin 2s linear infinite;
81
- }
82
-
83
- @-webkit-keyframes spin {
84
- 0% { -webkit-transform: rotate(0deg); }
85
- 100% { -webkit-transform: rotate(360deg); }
86
- }
87
-
88
- @keyframes spin {
89
- 0% { transform: rotate(0deg); }
90
- 100% { transform: rotate(360deg); }
91
- }
92
-
93
- /* Add animation to "page content" */
94
- .animate-bottom {
95
- position: relative;
96
- -webkit-animation-name: animatebottom;
97
- -webkit-animation-duration: 1s;
98
- animation-name: animatebottom;
99
- animation-duration: 1s
100
- }
101
-
102
- @-webkit-keyframes animatebottom {
103
- from { bottom:-100px; opacity:0 }
104
- to { bottom:0px; opacity:1 }
105
- }
106
-
107
- @keyframes animatebottom {
108
- from{ bottom:-100px; opacity:0 }
109
- to{ bottom:0; opacity:1 }
110
- }
111
-
112
  /* loader end */
1
+ /* The Modal (background) */
2
+
3
+ #cf7_widget_elementor_contact_form_control_modal {
4
+ display: none; /* Hidden by default */
5
+ position: fixed; /* Stay in place */
6
+ z-index: 999; /* Sit on top */
7
+ padding-top: 50px; /* Location of the box */
8
+ left: 0;
9
+ top: 0;
10
+ width: 100%; /* Full width */
11
+ height: 100%; /* Full height */
12
+ overflow: auto; /* Enable scroll if needed */
13
+ background-color: rgb(0,0,0); /* Fallback color */
14
+ background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
15
+ right: 0;
16
+ bottom: 0;
17
+ }
18
+
19
+ /* Modal Content */
20
+ .cf7-widget-elementor-modal-content {
21
+ background-color: #fefefe;
22
+ margin: auto;
23
+ padding: 0px;
24
+ border: 1px solid #888;
25
+ width: 90%;
26
+ height: 90%;
27
+ overflow: hidden;
28
+ border-radius: 8px;
29
+ position: relative;
30
+ }
31
+ .cf7-widget-elementor-modal-iframe{
32
+ width: 100%;
33
+ height: 100%;
34
+ }
35
+
36
+ /* The Close Button */
37
+ .cf7-widget-elementor-modal-close {
38
+ float: right;
39
+ font-size: 24px;
40
+ font-weight: bold;
41
+ background: #000;
42
+ border-radius: 50%;
43
+ height: 25px;
44
+ width: 25px;
45
+ padding: 0 0 5px 6px;
46
+ color: #ffffff;
47
+ position: absolute;
48
+ z-index: 1;
49
+ right: 0px;
50
+ }
51
+
52
+ .cf7-widget-elementor-modal-close:hover,
53
+ .cf7-widget-elementor-modal-close:focus {
54
+ color: rgb(248, 241, 241);
55
+ text-decoration: none;
56
+ cursor: pointer;
57
+ font-size: 26px;
58
+ }
59
+
60
+ .cf7-widget-elementor-modal-hide-adminmenu{
61
+ display: none;
62
+ }
63
+
64
+ /* loader start*/
65
+
66
+ .cf7-widget-elementor-modal-content-loader.loading {
67
+ position: absolute;
68
+ left: 50%;
69
+ top: 50%;
70
+ z-index: 1;
71
+ width: 150px;
72
+ height: 150px;
73
+ margin: -75px 0 0 -75px;
74
+ border: 16px solid #f3f3f3;
75
+ border-radius: 50%;
76
+ border-top: 16px solid #3498db;
77
+ width: 120px;
78
+ height: 120px;
79
+ -webkit-animation: spin 2s linear infinite;
80
+ animation: spin 2s linear infinite;
81
+ }
82
+
83
+ @-webkit-keyframes spin {
84
+ 0% { -webkit-transform: rotate(0deg); }
85
+ 100% { -webkit-transform: rotate(360deg); }
86
+ }
87
+
88
+ @keyframes spin {
89
+ 0% { transform: rotate(0deg); }
90
+ 100% { transform: rotate(360deg); }
91
+ }
92
+
93
+ /* Add animation to "page content" */
94
+ .animate-bottom {
95
+ position: relative;
96
+ -webkit-animation-name: animatebottom;
97
+ -webkit-animation-duration: 1s;
98
+ animation-name: animatebottom;
99
+ animation-duration: 1s
100
+ }
101
+
102
+ @-webkit-keyframes animatebottom {
103
+ from { bottom:-100px; opacity:0 }
104
+ to { bottom:0px; opacity:1 }
105
+ }
106
+
107
+ @keyframes animatebottom {
108
+ from{ bottom:-100px; opacity:0 }
109
+ to{ bottom:0; opacity:1 }
110
+ }
111
+
112
  /* loader end */
custom-editor/assets/js/void-cf7-elementor-editor.js CHANGED
@@ -1,140 +1,140 @@
1
- (function($) {
2
-
3
- // call the the functionality of add, edit form when elementor editor panel is open for edit
4
- elementor.hooks.addAction('panel/open_editor/widget/void-section-cf7', function (panel, model, view) {
5
- // declare some global variable to avaoid multiple searching on DOM
6
- var formId;
7
- var windowParent = window.parent;
8
- var modal, modalContainer, close, iframe, elUpdatePreviewButton;
9
-
10
- addEditHandler();
11
-
12
- function addEditHandler(){
13
- //console.log('add edit handler call');
14
- // current selected form by attr of form mark up
15
- formId = model.attributes.settings.attributes.cf7;
16
- // modal elementor selector
17
- modal = windowParent.jQuery('#cf7_widget_elementor_contact_form_control_modal');
18
- modalContainer = modal.find('.cf7-widget-elementor-modal-content');
19
- modalLoading = modal.find('.cf7-widget-elementor-modal-content-loader');
20
- close = modal.find('.cf7-widget-elementor-modal-close');
21
- iframe = modal.find('.cf7-widget-elementor-modal-iframe');
22
-
23
- // elementor update preview button selector
24
- elUpdatePreviewButton = $('.elementor-update-preview');
25
- // hide button from edit panel
26
- //elUpdatePreviewButton.hide();
27
-
28
- // call initial form assign function for preventing data loose after switching widget
29
- addButtonFunction();
30
-
31
- // form edit button element selector
32
- var $elementEdit = $( '.void-cf7-edit-form-btn' ).find( '#void-cf7-edit-form-btn' );
33
-
34
- // form edit button click event function
35
- $elementEdit.on('click', function(e){
36
- e.preventDefault();
37
- editButtonFunction();
38
- });
39
-
40
- // form add new button element selector
41
- var $elementAdd = $( '.void-cf7-add-form-btn' ).find( '#void-cf7-add-form-btn' );
42
- // form add new button click event function
43
- $elementAdd.on('click', function(e){
44
- e.preventDefault();
45
- // loader add on modal
46
- modalLoading.addClass('loading');
47
- // insert src in iframe with edit link of selected form
48
- iframe.attr('src', voidCf7Admin.url+'admin.php?page=wpcf7-new');
49
- // set opacity 0 to hide iframe untill it's load contents, opacity will be 1 after it's load content from modal-editor.php scripts
50
- iframe.css('opacity', 0);
51
- // open modal with contact form add new url
52
- modal.show();
53
- // modal close button click event
54
- close.on('click', function(){
55
- addButtonFunction();
56
- // hide after completed all the actions
57
- modal.fadeOut(500);
58
- });
59
- });
60
-
61
- }
62
-
63
- //when moving from Advanced tab to content model variable is null so to pass it's data
64
- function cf7_data_pass_around_model(panel,model,view){
65
- // set timeout to load content tab's content
66
- setTimeout(function(){
67
- addEditHandler();
68
- }, 100);
69
- }
70
-
71
- // this ensures the data remains the same even after switching back from advanced tab to content tab
72
- $(".elementor-panel").mouseenter(function(){
73
-
74
- cf7_data_pass_around_model(panel,model,view);
75
-
76
- });
77
-
78
- function editButtonFunction(){
79
- // loader add on modal
80
- modalLoading.addClass('loading');
81
- // insert src in iframe with edit link of selected form
82
- iframe.attr('src', voidCf7Admin.url+'admin.php?page=wpcf7&post='+formId+'&action=edit');
83
- // set opacity 0 to hide iframe untill it's load contents, opacity will be 1 after it's load content from modal-editor.php scripts
84
- iframe.css('opacity', 0);
85
- // open modal with contact form edit url
86
- modal.show();
87
- // modal close button click event
88
- close.on('click', function(){
89
- // reload frondend panel to show updated data
90
- elUpdatePreviewButton.find('.elementor-update-preview-button').trigger('click');
91
- // modal modal after completed all the tasks
92
- modal.fadeOut(500);
93
- });
94
- }
95
-
96
- function addButtonFunction() {
97
- // element selector of form selector select2 from panel to avoid multiple search on DOM
98
- var elCf7 = panel.$el.find('[data-setting="cf7"]');
99
- // ajax request to admin-ajax for getting all contact form 7 from database
100
- $.ajax({
101
- // url of ajax request, value of voidCf7Admin.ajaxUrl is localized during enqueue script
102
- url: voidCf7Admin.ajaxUrl,
103
- type: 'POST',
104
- data: {
105
- action: 'void_cf7_data'
106
- },
107
- // wp verify nonce automatically after sending nonce like this
108
- headers: {
109
- 'X-WP-Nonce': voidCf7Admin.wpRestNonce
110
- },
111
- dataType: 'json',
112
- // success function of ajax request
113
- success: function (output) {
114
- // clear corrent option from form select select2
115
- elCf7.empty();
116
- // running loop by all from data after gettings it from ajax request
117
- $.each(output, function(index, value){
118
- // add option to form select select2 with new created from
119
- elCf7.append('<option value="'+index+'">'+value+'</option>');
120
- });
121
- //set already selected value
122
- elCf7.val( model.attributes.settings.attributes.cf7);
123
-
124
- // disable select2 of form select if there was no data
125
- if( elCf7.has('option').length == 0 ) {
126
- elCf7.attr('disabled', 'disabled');
127
- }else{
128
- elCf7.removeAttr('disabled');
129
- }
130
- },
131
- // error function of ajax request
132
- error: function (e) {
133
- console.log(e);
134
- },
135
- });
136
-
137
- }
138
- });
139
-
140
- })(jQuery);
1
+ (function($) {
2
+
3
+ // call the the functionality of add, edit form when elementor editor panel is open for edit
4
+ elementor.hooks.addAction('panel/open_editor/widget/void-section-cf7', function (panel, model, view) {
5
+ // declare some global variable to avaoid multiple searching on DOM
6
+ var formId;
7
+ var windowParent = window.parent;
8
+ var modal, modalContainer, close, iframe, elUpdatePreviewButton;
9
+
10
+ addEditHandler();
11
+
12
+ function addEditHandler(){
13
+ //console.log('add edit handler call');
14
+ // current selected form by attr of form mark up
15
+ formId = model.attributes.settings.attributes.cf7;
16
+ // modal elementor selector
17
+ modal = windowParent.jQuery('#cf7_widget_elementor_contact_form_control_modal');
18
+ modalContainer = modal.find('.cf7-widget-elementor-modal-content');
19
+ modalLoading = modal.find('.cf7-widget-elementor-modal-content-loader');
20
+ close = modal.find('.cf7-widget-elementor-modal-close');
21
+ iframe = modal.find('.cf7-widget-elementor-modal-iframe');
22
+
23
+ // elementor update preview button selector
24
+ elUpdatePreviewButton = $('.elementor-update-preview');
25
+ // hide button from edit panel
26
+ //elUpdatePreviewButton.hide();
27
+
28
+ // call initial form assign function for preventing data loose after switching widget
29
+ addButtonFunction();
30
+
31
+ // form edit button element selector
32
+ var $elementEdit = $( '.void-cf7-edit-form-btn' ).find( '#void-cf7-edit-form-btn' );
33
+
34
+ // form edit button click event function
35
+ $elementEdit.on('click', function(e){
36
+ e.preventDefault();
37
+ editButtonFunction();
38
+ });
39
+
40
+ // form add new button element selector
41
+ var $elementAdd = $( '.void-cf7-add-form-btn' ).find( '#void-cf7-add-form-btn' );
42
+ // form add new button click event function
43
+ $elementAdd.on('click', function(e){
44
+ e.preventDefault();
45
+ // loader add on modal
46
+ modalLoading.addClass('loading');
47
+ // insert src in iframe with edit link of selected form
48
+ iframe.attr('src', voidCf7Admin.url+'admin.php?page=wpcf7-new');
49
+ // set opacity 0 to hide iframe untill it's load contents, opacity will be 1 after it's load content from modal-editor.php scripts
50
+ iframe.css('opacity', 0);
51
+ // open modal with contact form add new url
52
+ modal.show();
53
+ // modal close button click event
54
+ close.on('click', function(){
55
+ addButtonFunction();
56
+ // hide after completed all the actions
57
+ modal.fadeOut(500);
58
+ });
59
+ });
60
+
61
+ }
62
+
63
+ //when moving from Advanced tab to content model variable is null so to pass it's data
64
+ function cf7_data_pass_around_model(panel,model,view){
65
+ // set timeout to load content tab's content
66
+ setTimeout(function(){
67
+ addEditHandler();
68
+ }, 100);
69
+ }
70
+
71
+ // this ensures the data remains the same even after switching back from advanced tab to content tab
72
+ $(".elementor-panel").mouseenter(function(){
73
+
74
+ cf7_data_pass_around_model(panel,model,view);
75
+
76
+ });
77
+
78
+ function editButtonFunction(){
79
+ // loader add on modal
80
+ modalLoading.addClass('loading');
81
+ // insert src in iframe with edit link of selected form
82
+ iframe.attr('src', voidCf7Admin.url+'admin.php?page=wpcf7&post='+formId+'&action=edit');
83
+ // set opacity 0 to hide iframe untill it's load contents, opacity will be 1 after it's load content from modal-editor.php scripts
84
+ iframe.css('opacity', 0);
85
+ // open modal with contact form edit url
86
+ modal.show();
87
+ // modal close button click event
88
+ close.on('click', function(){
89
+ // reload frondend panel to show updated data
90
+ elUpdatePreviewButton.find('.elementor-update-preview-button').trigger('click');
91
+ // modal modal after completed all the tasks
92
+ modal.fadeOut(500);
93
+ });
94
+ }
95
+
96
+ function addButtonFunction() {
97
+ // element selector of form selector select2 from panel to avoid multiple search on DOM
98
+ var elCf7 = panel.$el.find('[data-setting="cf7"]');
99
+ // ajax request to admin-ajax for getting all contact form 7 from database
100
+ $.ajax({
101
+ // url of ajax request, value of voidCf7Admin.ajaxUrl is localized during enqueue script
102
+ url: voidCf7Admin.ajaxUrl,
103
+ type: 'POST',
104
+ data: {
105
+ action: 'void_cf7_data'
106
+ },
107
+ // wp verify nonce automatically after sending nonce like this
108
+ headers: {
109
+ 'X-WP-Nonce': voidCf7Admin.wpRestNonce
110
+ },
111
+ dataType: 'json',
112
+ // success function of ajax request
113
+ success: function (output) {
114
+ // clear corrent option from form select select2
115
+ elCf7.empty();
116
+ // running loop by all from data after gettings it from ajax request
117
+ $.each(output, function(index, value){
118
+ // add option to form select select2 with new created from
119
+ elCf7.append('<option value="'+index+'">'+value+'</option>');
120
+ });
121
+ //set already selected value
122
+ elCf7.val( model.attributes.settings.attributes.cf7);
123
+
124
+ // disable select2 of form select if there was no data
125
+ if( elCf7.has('option').length == 0 ) {
126
+ elCf7.attr('disabled', 'disabled');
127
+ }else{
128
+ elCf7.removeAttr('disabled');
129
+ }
130
+ },
131
+ // error function of ajax request
132
+ error: function (e) {
133
+ console.log(e);
134
+ },
135
+ });
136
+
137
+ }
138
+ });
139
+
140
+ })(jQuery);
custom-editor/init.php CHANGED
@@ -1,31 +1,31 @@
1
- <?php
2
-
3
- function void_cf7_elementor_js_load(){
4
- wp_enqueue_script( 'void-cf7-elementor-js', plugins_url('assets/js/void-cf7-elementor-editor.js', __FILE__ ), array('jquery'), CF7_WIDGET_E_VERSION, true );
5
- wp_localize_script('void-cf7-elementor-js', 'voidCf7Admin',
6
- [
7
- 'ajaxUrl' => admin_url( 'admin-ajax.php' ),
8
- 'url' => get_admin_url(),
9
- 'wpRestNonce' => wp_create_nonce('wp_rest'),
10
- ]
11
- );
12
- }
13
-
14
- add_action( 'elementor/editor/after_enqueue_scripts', 'void_cf7_elementor_js_load');
15
-
16
- // function void_cf7_elementor_css_load(){
17
- // wp_register_style( 'void-cf7-elementor-css', plugins_url('assets/css/void-cf7-elementor-editor.css', __FILE__ ), [], CF7_WIDGET_E_VERSION );
18
- // }
19
-
20
- // add_action( 'elementor/frontend/before_enqueue_styles', 'void_cf7_elementor_css_load');
21
-
22
- function load_custom_editor_modal(){
23
- wp_enqueue_style( 'void-cf7-elementor-css', plugins_url('assets/css/void-cf7-elementor-editor.css', __FILE__ ), [], CF7_WIDGET_E_VERSION );
24
- ?>
25
- <div class="void-cf7-custom-editor-modal">
26
- <?php include 'modal-editor.php'; ?>
27
- </div>
28
- <?php
29
- }
30
-
31
  add_action('elementor/editor/after_enqueue_styles', 'load_custom_editor_modal' );
1
+ <?php
2
+
3
+ function void_cf7_elementor_js_load(){
4
+ wp_enqueue_script( 'void-cf7-elementor-js', plugins_url('assets/js/void-cf7-elementor-editor.js', __FILE__ ), array('jquery'), CF7_WIDGET_E_VERSION, true );
5
+ wp_localize_script('void-cf7-elementor-js', 'voidCf7Admin',
6
+ [
7
+ 'ajaxUrl' => admin_url( 'admin-ajax.php' ),
8
+ 'url' => get_admin_url(),
9
+ 'wpRestNonce' => wp_create_nonce('wp_rest'),
10
+ ]
11
+ );
12
+ }
13
+
14
+ add_action( 'elementor/editor/after_enqueue_scripts', 'void_cf7_elementor_js_load');
15
+
16
+ // function void_cf7_elementor_css_load(){
17
+ // wp_register_style( 'void-cf7-elementor-css', plugins_url('assets/css/void-cf7-elementor-editor.css', __FILE__ ), [], CF7_WIDGET_E_VERSION );
18
+ // }
19
+
20
+ // add_action( 'elementor/frontend/before_enqueue_styles', 'void_cf7_elementor_css_load');
21
+
22
+ function load_custom_editor_modal(){
23
+ wp_enqueue_style( 'void-cf7-elementor-css', plugins_url('assets/css/void-cf7-elementor-editor.css', __FILE__ ), [], CF7_WIDGET_E_VERSION );
24
+ ?>
25
+ <div class="void-cf7-custom-editor-modal">
26
+ <?php include 'modal-editor.php'; ?>
27
+ </div>
28
+ <?php
29
+ }
30
+
31
  add_action('elementor/editor/after_enqueue_styles', 'load_custom_editor_modal' );
custom-editor/modal-editor.php CHANGED
@@ -1,100 +1,100 @@
1
- <!-- The Modal -->
2
- <div id="cf7_widget_elementor_contact_form_control_modal" class="cf7_widget_elementor_contact_form_control_modal" style="display: none;">
3
-
4
- <!-- Modal content -->
5
- <div class="cf7-widget-elementor-modal-content">
6
- <div class="cf7-widget-elementor-modal-content-loader loading"></div>
7
- <span class="cf7-widget-elementor-modal-close">&times;</span>
8
- <!-- iframe to open contact form edit or add functionality -->
9
- <iframe style="opacity: 0;" onload="voidCf7IframeOnLoad()" class="cf7-widget-elementor-modal-iframe" ></iframe>
10
- </div>
11
- </div>
12
-
13
-
14
- <script type="text/javascript">
15
- // menu hide wp admin menu function after onload iframe contants
16
- function voidCf7IframeOnLoad() {
17
- // select iframe
18
- var loader = document.getElementsByClassName("cf7-widget-elementor-modal-content-loader");
19
- var iframe = document.getElementsByClassName("cf7-widget-elementor-modal-iframe");
20
- iframe[0].style.opacity = 0;
21
-
22
- // check iframe found
23
- if(iframe != null && iframe.length > 0){
24
- // select wpadminbar, wpcontent, wpadmibar, wp-toolbar for modify it
25
- var adminBar = iframe[0].contentWindow.document.getElementById("wpadminbar");
26
- var wpToolBar = iframe[0].contentWindow.document.getElementsByClassName("wp-toolbar");
27
- var adminMenu = iframe[0].contentWindow.document.getElementById("adminmenumain");
28
- var wpContent = iframe[0].contentWindow.document.getElementById("wpcontent");
29
- var addNewButton = iframe[0].contentWindow.document.querySelectorAll('a.page-title-action');
30
-
31
- // remove add new button on editor
32
- if(addNewButton != null && addNewButton.length > 0){
33
- addNewButton[0].style.display = "none";
34
- }
35
- // wp admin bar hide
36
- if(adminBar != null){
37
- adminBar.style.display = "none";
38
- }
39
-
40
- // wp toolbar padding top remove
41
- if(wpToolBar !=null && wpToolBar.length > 0){
42
- wpToolBar[0].style.paddingTop = '0px';
43
- }
44
-
45
- // wp admin menu hide
46
- if(adminMenu != null){
47
- adminMenu.style.display = "none";
48
- }
49
-
50
- // wp content margin left hide
51
- if(wpContent != null){
52
- wpContent.style.marginLeft = "0px";
53
- // loader remove on modal after removing everything
54
- loader[0].classList.remove("loading");
55
- }
56
-
57
- // set opacity 1 to show iframe after hiding all the wp bars
58
- iframe[0].style.opacity = 1;
59
-
60
- // prevent flickering after save form
61
- var saveButton = iframe[0].contentWindow.document.querySelectorAll('input.button-primary[name=wpcf7-save]');
62
- saveButton.forEach(function(item, index){
63
- saveButton[index].onclick = function(){
64
- iframe[0].style.opacity = 0;
65
- if(loader != null && loader.length > 0){
66
- // loader add again on modal
67
- loader[0].classList.add("loading");
68
- }
69
- }
70
- });
71
-
72
- // prevent flickering after copy form
73
- var copyButton = iframe[0].contentWindow.document.querySelectorAll('input.copy.button[name=wpcf7-copy]');
74
- copyButton.forEach(function(item, index){
75
- copyButton[index].onclick = function(){
76
- iframe[0].style.opacity = 0;
77
- if(loader != null && loader.length > 0){
78
- // loader add again on modal
79
- loader[0].classList.add("loading");
80
- }
81
- }
82
- });
83
-
84
- // prevent flickering after delete form
85
- var deleteButton = iframe[0].contentWindow.document.querySelectorAll('input.delete.submitdelete[name=wpcf7-delete]');
86
- deleteButton.forEach(function(item, index){
87
- deleteButton[index].onclick = function(){
88
- iframe[0].style.opacity = 0;
89
- if(loader != null && loader.length > 0){
90
- // loader add again on modal
91
- loader[0].classList.remove("loading");
92
- }
93
- }
94
- });
95
-
96
- }
97
-
98
- }
99
-
100
  </script>
1
+ <!-- The Modal -->
2
+ <div id="cf7_widget_elementor_contact_form_control_modal" class="cf7_widget_elementor_contact_form_control_modal" style="display: none;">
3
+
4
+ <!-- Modal content -->
5
+ <div class="cf7-widget-elementor-modal-content">
6
+ <div class="cf7-widget-elementor-modal-content-loader loading"></div>
7
+ <span class="cf7-widget-elementor-modal-close">&times;</span>
8
+ <!-- iframe to open contact form edit or add functionality -->
9
+ <iframe style="opacity: 0;" onload="voidCf7IframeOnLoad()" class="cf7-widget-elementor-modal-iframe" ></iframe>
10
+ </div>
11
+ </div>
12
+
13
+
14
+ <script type="text/javascript">
15
+ // menu hide wp admin menu function after onload iframe contants
16
+ function voidCf7IframeOnLoad() {
17
+ // select iframe
18
+ var loader = document.getElementsByClassName("cf7-widget-elementor-modal-content-loader");
19
+ var iframe = document.getElementsByClassName("cf7-widget-elementor-modal-iframe");
20
+ iframe[0].style.opacity = 0;
21
+
22
+ // check iframe found
23
+ if(iframe != null && iframe.length > 0){
24
+ // select wpadminbar, wpcontent, wpadmibar, wp-toolbar for modify it
25
+ var adminBar = iframe[0].contentWindow.document.getElementById("wpadminbar");
26
+ var wpToolBar = iframe[0].contentWindow.document.getElementsByClassName("wp-toolbar");
27
+ var adminMenu = iframe[0].contentWindow.document.getElementById("adminmenumain");
28
+ var wpContent = iframe[0].contentWindow.document.getElementById("wpcontent");
29
+ var addNewButton = iframe[0].contentWindow.document.querySelectorAll('a.page-title-action');
30
+
31
+ // remove add new button on editor
32
+ if(addNewButton != null && addNewButton.length > 0){
33
+ addNewButton[0].style.display = "none";
34
+ }
35
+ // wp admin bar hide
36
+ if(adminBar != null){
37
+ adminBar.style.display = "none";
38
+ }
39
+
40
+ // wp toolbar padding top remove
41
+ if(wpToolBar !=null && wpToolBar.length > 0){
42
+ wpToolBar[0].style.paddingTop = '0px';
43
+ }
44
+
45
+ // wp admin menu hide
46
+ if(adminMenu != null){
47
+ adminMenu.style.display = "none";
48
+ }
49
+
50
+ // wp content margin left hide
51
+ if(wpContent != null){
52
+ wpContent.style.marginLeft = "0px";
53
+ // loader remove on modal after removing everything
54
+ loader[0].classList.remove("loading");
55
+ }
56
+
57
+ // set opacity 1 to show iframe after hiding all the wp bars
58
+ iframe[0].style.opacity = 1;
59
+
60
+ // prevent flickering after save form
61
+ var saveButton = iframe[0].contentWindow.document.querySelectorAll('input.button-primary[name=wpcf7-save]');
62
+ saveButton.forEach(function(item, index){
63
+ saveButton[index].onclick = function(){
64
+ iframe[0].style.opacity = 0;
65
+ if(loader != null && loader.length > 0){
66
+ // loader add again on modal
67
+ loader[0].classList.add("loading");
68
+ }
69
+ }
70
+ });
71
+
72
+ // prevent flickering after copy form
73
+ var copyButton = iframe[0].contentWindow.document.querySelectorAll('input.copy.button[name=wpcf7-copy]');
74
+ copyButton.forEach(function(item, index){
75
+ copyButton[index].onclick = function(){
76
+ iframe[0].style.opacity = 0;
77
+ if(loader != null && loader.length > 0){
78
+ // loader add again on modal
79
+ loader[0].classList.add("loading");
80
+ }
81
+ }
82
+ });
83
+
84
+ // prevent flickering after delete form
85
+ var deleteButton = iframe[0].contentWindow.document.querySelectorAll('input.delete.submitdelete[name=wpcf7-delete]');
86
+ deleteButton.forEach(function(item, index){
87
+ deleteButton[index].onclick = function(){
88
+ iframe[0].style.opacity = 0;
89
+ if(loader != null && loader.length > 0){
90
+ // loader add again on modal
91
+ loader[0].classList.remove("loading");
92
+ }
93
+ }
94
+ });
95
+
96
+ }
97
+
98
+ }
99
+
100
  </script>
helper/helper.php CHANGED
@@ -1,100 +1,100 @@
1
- <?php
2
-
3
- if ( ! function_exists( 'get_contact_form_7_posts' ) ) :
4
- function get_contact_form_7_posts(){
5
-
6
- $args = array('post_type' => 'wpcf7_contact_form', 'posts_per_page' => -1);
7
-
8
- $cf7_form_list=[];
9
-
10
- if( $cf7_forms = get_posts($args)){
11
- foreach ( $cf7_forms as $form ) {
12
- (int)$cf7_form_list[$form->ID] = $form->post_title;
13
- }
14
- }
15
- else{
16
- (int)$cf7_form_list['0'] = esc_html__('No contect From 7 form found', 'void');
17
- }
18
- return $cf7_form_list;
19
- }
20
- endif;
21
-
22
-
23
- // ajax request handler
24
- if( !function_exists('get_contact_form_7_posts_by_ajax')) {
25
-
26
- function get_contact_form_7_posts_by_ajax(){
27
- $cf7_form_list = get_contact_form_7_posts();
28
- echo json_encode($cf7_form_list);
29
- wp_die();
30
- }
31
-
32
- }
33
-
34
- //ajax action
35
- add_action( 'wp_ajax_void_cf7_data', 'get_contact_form_7_posts_by_ajax' );
36
-
37
-
38
- if ( ! function_exists( 'void_get_all_pages' ) ) :
39
-
40
- function void_get_all_pages(){
41
-
42
- $args = array('post_type' => 'page', 'posts_per_page' => -1);
43
-
44
- $catlist=[];
45
-
46
- if( $categories = get_posts($args)){
47
- foreach ( $categories as $category ) {
48
- (int)$catlist[$category->ID] = $category->post_title;
49
- }
50
- }
51
- else{
52
- (int)$catlist['0'] = esc_html__('No Pages Found!', 'void');
53
- }
54
- return $catlist;
55
- }
56
-
57
- endif;
58
-
59
-
60
- if( !function_exists('promotional_notice_dismiss_handler')){
61
-
62
- function promotional_notice_dismiss_handler(){
63
- // Pick up the notice "type" - passed via jQuery (the "data-notice" attribute on the notice)
64
- $type = $_POST['type'];
65
-
66
- $status = $_POST['status'];
67
-
68
- if($status == 'remind-me-later'){
69
- // Store it in the options table
70
- update_option( 'dismissed-' . $type . "-at", date('Y-m-d') );
71
-
72
- }elseif( $status == 'never-show'){
73
-
74
- update_option( 'dismissed-'. $type . '-never', TRUE );
75
-
76
- }else{
77
- update_option( 'dismissed-'. $type . '-never', TRUE );
78
- }
79
- }
80
- }
81
-
82
- add_action('wp_ajax_dismissed_promotional_notice_handler', 'promotional_notice_dismiss_handler');
83
-
84
- if( !function_exists('dismissed_usage_data_track_void_cf7')){
85
-
86
- function dismissed_usage_data_track_void_cf7(){
87
- // Pick up the notice "type" - passed via jQuery (the "data-notice" attribute on the notice)
88
- $type = sanitize_text_field($_POST['type']);
89
-
90
- $status = sanitize_text_field($_POST['status']);
91
-
92
- if($status == 'remind-me-later'){
93
- // Store it in the options table
94
- update_option( 'dismissed-' . $type . "-at", date('Y-m-d') );
95
-
96
- }
97
- }
98
- }
99
-
100
  add_action('wp_ajax_dismissed_usage_data_track_void_cf7', 'dismissed_usage_data_track_void_cf7');
1
+ <?php
2
+
3
+ if ( ! function_exists( 'get_contact_form_7_posts' ) ) :
4
+ function get_contact_form_7_posts(){
5
+
6
+ $args = array('post_type' => 'wpcf7_contact_form', 'posts_per_page' => -1);
7
+
8
+ $cf7_form_list=[];
9
+
10
+ if( $cf7_forms = get_posts($args)){
11
+ foreach ( $cf7_forms as $form ) {
12
+ (int)$cf7_form_list[$form->ID] = $form->post_title;
13
+ }
14
+ }
15
+ else{
16
+ (int)$cf7_form_list['0'] = esc_html__('No contect From 7 form found', 'void');
17
+ }
18
+ return $cf7_form_list;
19
+ }
20
+ endif;
21
+
22
+
23
+ // ajax request handler
24
+ if( !function_exists('get_contact_form_7_posts_by_ajax')) {
25
+
26
+ function get_contact_form_7_posts_by_ajax(){
27
+ $cf7_form_list = get_contact_form_7_posts();
28
+ echo json_encode($cf7_form_list);
29
+ wp_die();
30
+ }
31
+
32
+ }
33
+
34
+ //ajax action
35
+ add_action( 'wp_ajax_void_cf7_data', 'get_contact_form_7_posts_by_ajax' );
36
+
37
+
38
+ if ( ! function_exists( 'void_get_all_pages' ) ) :
39
+
40
+ function void_get_all_pages(){
41
+
42
+ $args = array('post_type' => 'page', 'posts_per_page' => -1);
43
+
44
+ $catlist=[];
45
+
46
+ if( $categories = get_posts($args)){
47
+ foreach ( $categories as $category ) {
48
+ (int)$catlist[$category->ID] = $category->post_title;
49
+ }
50
+ }
51
+ else{
52
+ (int)$catlist['0'] = esc_html__('No Pages Found!', 'void');
53
+ }
54
+ return $catlist;
55
+ }
56
+
57
+ endif;
58
+
59
+
60
+ if( !function_exists('promotional_notice_dismiss_handler')){
61
+
62
+ function promotional_notice_dismiss_handler(){
63
+ // Pick up the notice "type" - passed via jQuery (the "data-notice" attribute on the notice)
64
+ $type = $_POST['type'];
65
+
66
+ $status = $_POST['status'];
67
+
68
+ if($status == 'remind-me-later'){
69
+ // Store it in the options table
70
+ update_option( 'dismissed-' . $type . "-at", date('Y-m-d') );
71
+
72
+ }elseif( $status == 'never-show'){
73
+
74
+ update_option( 'dismissed-'. $type . '-never', TRUE );
75
+
76
+ }else{
77
+ update_option( 'dismissed-'. $type . '-never', TRUE );
78
+ }
79
+ }
80
+ }
81
+
82
+ add_action('wp_ajax_dismissed_promotional_notice_handler', 'promotional_notice_dismiss_handler');
83
+
84
+ if( !function_exists('dismissed_usage_data_track_void_cf7')){
85
+
86
+ function dismissed_usage_data_track_void_cf7(){
87
+ // Pick up the notice "type" - passed via jQuery (the "data-notice" attribute on the notice)
88
+ $type = sanitize_text_field($_POST['type']);
89
+
90
+ $status = sanitize_text_field($_POST['status']);
91
+
92
+ if($status == 'remind-me-later'){
93
+ // Store it in the options table
94
+ update_option( 'dismissed-' . $type . "-at", date('Y-m-d') );
95
+
96
+ }
97
+ }
98
+ }
99
+
100
  add_action('wp_ajax_dismissed_usage_data_track_void_cf7', 'dismissed_usage_data_track_void_cf7');
plugin.php CHANGED
@@ -1,93 +1,93 @@
1
- <?php
2
- namespace voidelement; //main namespace
3
- use voidelement\Widgets\void_cf7; //path define same as class name of the widget
4
-
5
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
6
-
7
-
8
- // Add a custom category for panel widgets
9
- add_action( 'elementor/init', function() {
10
- \Elementor\Plugin::$instance->elements_manager->add_category(
11
- 'void-elements', // the name of the category
12
- [
13
- 'title' => esc_html__( 'VOID ELEMENTS', 'void' ),
14
- 'icon' => 'fa fa-header', //default icon
15
- ],
16
- 1 // position
17
- );
18
- } );
19
-
20
-
21
- /**
22
- * Main Plugin Class
23
- *
24
- * Register new elementor widget.
25
- *
26
- * @since 1.0.0
27
- */
28
- class Plugin {
29
-
30
- /**
31
- * Constructor
32
- *
33
- * @since 1.0.0
34
- *
35
- * @access public
36
- */
37
-
38
- public function __construct() {
39
- $this->add_actions();
40
- }
41
-
42
- /**
43
- * Add Actions
44
- *
45
- * @since 1.0.0
46
- *
47
- * @access private
48
- */
49
- private function add_actions() {
50
- add_action( 'elementor/widgets/widgets_registered', [ $this, 'on_widgets_registered' ] );
51
-
52
- }
53
-
54
- /**
55
- * On Widgets Registered
56
- *
57
- * @since 1.0.0
58
- *
59
- * @access public
60
- */
61
- public function on_widgets_registered() {
62
- $this->includes();
63
- $this->register_widget();
64
- }
65
-
66
- /**
67
- * Includes
68
- *
69
- * @since 1.0.0
70
- *
71
- * @access private
72
- */
73
- private function includes() {
74
- $void_cf7= array_map('basename', glob(dirname( __FILE__ ) . '/widgets/*.php'));
75
- require __DIR__ . '/helper/helper.php';
76
- foreach($void_cf7 as $key => $value){
77
- require __DIR__ . '/widgets/'.$value;
78
- }
79
- }
80
-
81
- /**
82
- * Register Widget
83
- *
84
- * @since 1.0.0
85
- *
86
- * @access private
87
- */
88
- private function register_widget() {
89
- \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new void_cf7() );
90
- }
91
- }
92
-
93
- new Plugin();
1
+ <?php
2
+ namespace voidelement; //main namespace
3
+ use voidelement\Widgets\void_cf7; //path define same as class name of the widget
4
+
5
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
6
+
7
+
8
+ // Add a custom category for panel widgets
9
+ add_action( 'elementor/init', function() {
10
+ \Elementor\Plugin::$instance->elements_manager->add_category(
11
+ 'void-elements', // the name of the category
12
+ [
13
+ 'title' => esc_html__( 'VOID ELEMENTS', 'void' ),
14
+ 'icon' => 'fa fa-header', //default icon
15
+ ],
16
+ 1 // position
17
+ );
18
+ } );
19
+
20
+
21
+ /**
22
+ * Main Plugin Class
23
+ *
24
+ * Register new elementor widget.
25
+ *
26
+ * @since 1.0.0
27
+ */
28
+ class Plugin {
29
+
30
+ /**
31
+ * Constructor
32
+ *
33
+ * @since 1.0.0
34
+ *
35
+ * @access public
36
+ */
37
+
38
+ public function __construct() {
39
+ $this->add_actions();
40
+ }
41
+
42
+ /**
43
+ * Add Actions
44
+ *
45
+ * @since 1.0.0
46
+ *
47
+ * @access private
48
+ */
49
+ private function add_actions() {
50
+ add_action( 'elementor/widgets/register', [ $this, 'on_widgets_registered' ] );
51
+
52
+ }
53
+
54
+ /**
55
+ * On Widgets Registered
56
+ *
57
+ * @since 1.0.0
58
+ *
59
+ * @access public
60
+ */
61
+ public function on_widgets_registered() {
62
+ $this->includes();
63
+ $this->register_widget();
64
+ }
65
+
66
+ /**
67
+ * Includes
68
+ *
69
+ * @since 1.0.0
70
+ *
71
+ * @access private
72
+ */
73
+ private function includes() {
74
+ $void_cf7= array_map('basename', glob(dirname( __FILE__ ) . '/widgets/*.php'));
75
+ require __DIR__ . '/helper/helper.php';
76
+ foreach($void_cf7 as $key => $value){
77
+ require __DIR__ . '/widgets/'.$value;
78
+ }
79
+ }
80
+
81
+ /**
82
+ * Register Widget
83
+ *
84
+ * @since 1.0.0
85
+ *
86
+ * @access private
87
+ */
88
+ private function register_widget() {
89
+ \Elementor\Plugin::instance()->widgets_manager->register( new void_cf7() );
90
+ }
91
+ }
92
+
93
+ new Plugin();
readme.txt CHANGED
@@ -1,131 +1,133 @@
1
- === Void Contact Form 7 Widget For Elementor Page Builder ===
2
- Contributors: voidthemes,voidcoders,soyket,shawon786
3
- Tags: contact form, elementor, cf7, contact-form-7, contact-form-7 widget, page-builder, widget, elementor add on, email, contact, form
4
- Requires at least: 4.4
5
- Tested up to: 5.9.1
6
- Stable tag: 2.1
7
- License: GPLv2 or later
8
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
-
10
- This WordPress Plugin Adds Contact Form 7 widget element to Elementor page builder for easy drag & drop the created contact forms with CF7 (contact form 7). It also lets you define any page as a thank you / success page / Redirect after the form has been submitted! You also can add basic custom CSS directly from elementor edit screen now !! If you are a developer who designs sites for clients you will love this because the css panel is developer fridnly as well as noob friendly.
11
-
12
- You must have [Elementor Page Builder](https://wordpress.org/plugins/elementor/) installed.
13
- You must have [Contact form 7](https://wordpress.org/plugins/contact-form-7/) installed and forms created.
14
-
15
- == Description ==
16
-
17
- This plugin adds new element / widget to Elementor Page Builder which helps you to easily drag and drop contact form 7 forms from a drop down list. No need of going in cf7 & copying the shortcode and addding to shortcode widget of elementor anymore !!
18
-
19
- * Check out our new feature to edit and create contact form from elementor editor. You don't need to leave elementor editor to modify or create contact form 7. boom!
20
- * Now only Drag and drop the widget inside elementor builder & choose your contact form.
21
- * Multiple style options, hover, focus and even custom css option if you are into it.
22
- * Want to define style for input, lable, send button, success ? No problem ! This plugin let's you do those directly from elementor screen!
23
- * Want to add custom page to redirect to when the form is submitted ? That is also possible now !
24
- Yet this is just a simple plugin for simple users :)
25
- * What's more interesting is that you can have multiple form of the same single contact form 7 form with different rules and design with this on same page !
26
-
27
- For more details :[VOID CF7 Elementor Widget](https://voidcoders.com/product/contact-form7-widget-for-elementor-free/).
28
-
29
- For our other elementor & WP works visit : [VOID CODERS](https://voidcoders.com).
30
-
31
- For updates follow us on : [Facebook](https://www.facebook.com/voidcoders).
32
-
33
- Missing a feature or Found a bug? : [Feature Request / Bug Report](https://feedback.userreport.com/87deacdd-b91b-43cb-a92d-b53a10b7f6e2/#ideas/recent).
34
-
35
- <h3>Need to design Contact form 7 Emails with Elementor? </h3> 👉[Check Elemailer - A drag & drop email builder for WordPress](https://elemailer.com?utm_source=void-cf7-repo&utm_medium=wordpressrepo&utm_id=cf7-org).
36
-
37
- Version 2.0 Preview ( New Style controls with hover, focus, gradient etc )
38
-
39
- [youtube https://youtu.be/_vMHL6doikw]
40
-
41
- Edit/Add contact from inside Elementor
42
-
43
- [youtube https://youtu.be/ZI0GMJoESaw]
44
-
45
- Another Preview
46
- [youtube https://youtu.be/MlzrZ0zXM24]
47
-
48
-
49
- What Does This plugin give you?
50
-
51
- 1. For editing or creating contact form 7, You don't have to leave elementor editor. New popup modal will be open on elementor editor. Edit or create forms on the fly!
52
- 2. Easy use of contact forms created with Contact form 7 pluing inside elementor live editor
53
- 3. Add CSS directly from elementor live preview to your contact form 7 for different field type!!
54
- 4. Add any WordPress page as thank you page with this directly from elementor edit screen when you add the VOID Contact Fom 7 Widget!
55
- 5. Use Single contact form 7 with different Style & redirect rule(Thank you page on success) on the same page with this.
56
-
57
- Note: This plugin is an addon of Elementor Page Builder (https://wordpress.org/plugins/elementor/) and will only work with Elementor Page Builder installed along with Contact form 7 plugin.
58
-
59
- == Installation ==
60
-
61
- 1. Upload the plugin folder after extracting it to the "/wp-content/plugins/(the folder of the extracted plugin)" directory, or install the plugin through the WordPress plugins screen directly.
62
- 2. Activate the plugin through the 'Plugins' screen in WordPress
63
- 3. Go to elementor page builder mode and then select our post grid widget and you will see many options when you drag and drop the widget to the live page. To see the real preview in live mode you must click apply button on top to update the layout and finally hit save in elementor and visit your page to see the changes.
64
-
65
- == Frequently Asked Questions ==
66
-
67
- = Where can to find the new element added =
68
-
69
- Our Contact Form7 Widget For Elementor Page Builder adds a new widget category in the elementor live page builder named : VOID ELEMENTS. There you will see the widget called -Void Contact form 7- which you can drag and drop and config settings
70
-
71
-
72
- == Screenshots ==
73
-
74
- 1. /assets/screenshot-4.png
75
- 2. /assets/screenshot-5.png
76
- 3. /assets/screenshot-1.jpg
77
- 4. /assets/screenshot-2.jpg
78
- 5. /assets/screenshot-3.jpg
79
-
80
- == Update Instructions ==
81
- Update the plugin either via wp dashboard or via FTP. After update make sure you clear your browser cache.
82
-
83
- == Changelog ==
84
- = 2.1 =
85
- * Tweak: Updated to new wp version support
86
- * Tweak: Change of notification.
87
- = 2.0 =
88
- * New: Added many style option in Style tab
89
- = 1.1.9 =
90
- * Fix: Tweak for banner
91
- * Fix: Compatiblity with latest Elementor & Elementor pro
92
- = 1.1.8 =
93
- * Fix: Fatal error if folder renmaned / site migration is done
94
- * Fix: Compatiblity with latest WordPress version
95
- * Fix: Compatiblity with latest Elementor & Elementor pro
96
- = 1.1.7 =
97
- * Fix: Elementor compatiability added.
98
- * New: Added opt-in system for sending updates if needed
99
- = 1.1.6 =
100
- * Fix: Elementor compatiability added.
101
- = 1.1.5 =
102
- * Fix: Elementor editor js issue during cf7 create and update on elementor editor.
103
- = 1.1.4 =
104
- * Fix: Notice dismissible issue fix.
105
- = 1.1.3 =
106
- * Fix: Compatiable with elementor 3.x.
107
- * Fix: Fix some js error with new version of wp and elementor.
108
- = 1.1.2 =
109
- * Fix: Editor panel data loose issue solved after comeback another control sections/ widgets.
110
- = 1.1.1 =
111
- * Fix: Js erros on frontend
112
- = 1.1.0 =
113
- * New: Add and Edit contact form without leaving elementor dashboard.
114
- = 1.0.9 =
115
- * Feature added - External thank you page
116
- = 1.0.6 =
117
- * Css added Number control
118
- * Any post type url from the site for redirect url
119
- = 1.0.5 =
120
- * Css added Hover button
121
- = 1.0.4 =
122
- * Css added for select box
123
- = 1.0.3 =
124
- * CSS Fix
125
- = 1.0.2 =
126
- * Define Any page as thank you page
127
- * More Comporftable Select2 for selecting Contact From
128
- = 1.0.1 =
129
- * Custom CSS Adding option
130
- = 1.0.0 =
131
- * Initial Release
 
 
1
+ === Void Contact Form 7 Widget For Elementor Page Builder ===
2
+ Contributors: voidthemes,voidcoders,soyket,shawon786
3
+ Tags: contact form, elementor, cf7, contact-form-7, contact-form-7 widget, page-builder, widget, elementor add on, email, contact, form
4
+ Requires at least: 4.4
5
+ Tested up to: 5.9.3
6
+ Stable tag: 2.1.1
7
+ License: GPLv2 or later
8
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
+
10
+ This WordPress Plugin Adds Contact Form 7 widget element to Elementor page builder for easy drag & drop the created contact forms with CF7 (contact form 7). It also lets you define any page as a thank you / success page / Redirect after the form has been submitted! You also can add basic custom CSS directly from elementor edit screen now !! If you are a developer who designs sites for clients you will love this because the css panel is developer fridnly as well as noob friendly.
11
+
12
+ You must have [Elementor Page Builder](https://wordpress.org/plugins/elementor/) installed.
13
+ You must have [Contact form 7](https://wordpress.org/plugins/contact-form-7/) installed and forms created.
14
+
15
+ == Description ==
16
+
17
+ This plugin adds new element / widget to Elementor Page Builder which helps you to easily drag and drop contact form 7 forms from a drop down list. No need of going in cf7 & copying the shortcode and addding to shortcode widget of elementor anymore !!
18
+
19
+ * Check out our new feature to edit and create contact form from elementor editor. You don't need to leave elementor editor to modify or create contact form 7. boom!
20
+ * Now only Drag and drop the widget inside elementor builder & choose your contact form.
21
+ * Multiple style options, hover, focus and even custom css option if you are into it.
22
+ * Want to define style for input, lable, send button, success ? No problem ! This plugin let's you do those directly from elementor screen!
23
+ * Want to add custom page to redirect to when the form is submitted ? That is also possible now !
24
+ Yet this is just a simple plugin for simple users :)
25
+ * What's more interesting is that you can have multiple form of the same single contact form 7 form with different rules and design with this on same page !
26
+
27
+ For more details :[VOID CF7 Elementor Widget](https://voidcoders.com/product/contact-form7-widget-for-elementor-free/).
28
+
29
+ For our other elementor & WP works visit : [VOID CODERS](https://voidcoders.com).
30
+
31
+ For updates follow us on : [Facebook](https://www.facebook.com/voidcoders).
32
+
33
+ Missing a feature or Found a bug? : [Feature Request / Bug Report](https://feedback.userreport.com/87deacdd-b91b-43cb-a92d-b53a10b7f6e2/#ideas/recent).
34
+
35
+ <h3>Need to design Contact form 7 Emails with Elementor? </h3> 👉[Check Elemailer - A drag & drop email builder for WordPress](https://elemailer.com?utm_source=void-cf7-repo&utm_medium=wordpressrepo&utm_id=cf7-org).
36
+
37
+ Version 2.0 Preview ( New Style controls with hover, focus, gradient etc )
38
+
39
+ [youtube https://youtu.be/_vMHL6doikw]
40
+
41
+ Edit/Add contact from inside Elementor
42
+
43
+ [youtube https://youtu.be/ZI0GMJoESaw]
44
+
45
+ Another Preview
46
+ [youtube https://youtu.be/MlzrZ0zXM24]
47
+
48
+
49
+ What Does This plugin give you?
50
+
51
+ 1. For editing or creating contact form 7, You don't have to leave elementor editor. New popup modal will be open on elementor editor. Edit or create forms on the fly!
52
+ 2. Easy use of contact forms created with Contact form 7 pluing inside elementor live editor
53
+ 3. Add CSS directly from elementor live preview to your contact form 7 for different field type!!
54
+ 4. Add any WordPress page as thank you page with this directly from elementor edit screen when you add the VOID Contact Fom 7 Widget!
55
+ 5. Use Single contact form 7 with different Style & redirect rule(Thank you page on success) on the same page with this.
56
+
57
+ Note: This plugin is an addon of Elementor Page Builder (https://wordpress.org/plugins/elementor/) and will only work with Elementor Page Builder installed along with Contact form 7 plugin.
58
+
59
+ == Installation ==
60
+
61
+ 1. Upload the plugin folder after extracting it to the "/wp-content/plugins/(the folder of the extracted plugin)" directory, or install the plugin through the WordPress plugins screen directly.
62
+ 2. Activate the plugin through the 'Plugins' screen in WordPress
63
+ 3. Go to elementor page builder mode and then select our post grid widget and you will see many options when you drag and drop the widget to the live page. To see the real preview in live mode you must click apply button on top to update the layout and finally hit save in elementor and visit your page to see the changes.
64
+
65
+ == Frequently Asked Questions ==
66
+
67
+ = Where can to find the new element added =
68
+
69
+ Our Contact Form7 Widget For Elementor Page Builder adds a new widget category in the elementor live page builder named : VOID ELEMENTS. There you will see the widget called -Void Contact form 7- which you can drag and drop and config settings
70
+
71
+
72
+ == Screenshots ==
73
+
74
+ 1. /assets/screenshot-4.png
75
+ 2. /assets/screenshot-5.png
76
+ 3. /assets/screenshot-1.jpg
77
+ 4. /assets/screenshot-2.jpg
78
+ 5. /assets/screenshot-3.jpg
79
+
80
+ == Update Instructions ==
81
+ Update the plugin either via wp dashboard or via FTP. After update make sure you clear your browser cache.
82
+
83
+ == Changelog ==
84
+ = 2.1.1 =
85
+ * Fix: Elementor latest version compatibility
86
+ = 2.1 =
87
+ * Tweak: Updated to new wp version support
88
+ * Tweak: Change of notification.
89
+ = 2.0 =
90
+ * New: Added many style option in Style tab
91
+ = 1.1.9 =
92
+ * Fix: Tweak for banner
93
+ * Fix: Compatiblity with latest Elementor & Elementor pro
94
+ = 1.1.8 =
95
+ * Fix: Fatal error if folder renmaned / site migration is done
96
+ * Fix: Compatiblity with latest WordPress version
97
+ * Fix: Compatiblity with latest Elementor & Elementor pro
98
+ = 1.1.7 =
99
+ * Fix: Elementor compatiability added.
100
+ * New: Added opt-in system for sending updates if needed
101
+ = 1.1.6 =
102
+ * Fix: Elementor compatiability added.
103
+ = 1.1.5 =
104
+ * Fix: Elementor editor js issue during cf7 create and update on elementor editor.
105
+ = 1.1.4 =
106
+ * Fix: Notice dismissible issue fix.
107
+ = 1.1.3 =
108
+ * Fix: Compatiable with elementor 3.x.
109
+ * Fix: Fix some js error with new version of wp and elementor.
110
+ = 1.1.2 =
111
+ * Fix: Editor panel data loose issue solved after comeback another control sections/ widgets.
112
+ = 1.1.1 =
113
+ * Fix: Js erros on frontend
114
+ = 1.1.0 =
115
+ * New: Add and Edit contact form without leaving elementor dashboard.
116
+ = 1.0.9 =
117
+ * Feature added - External thank you page
118
+ = 1.0.6 =
119
+ * Css added Number control
120
+ * Any post type url from the site for redirect url
121
+ = 1.0.5 =
122
+ * Css added Hover button
123
+ = 1.0.4 =
124
+ * Css added for select box
125
+ = 1.0.3 =
126
+ * CSS Fix
127
+ = 1.0.2 =
128
+ * Define Any page as thank you page
129
+ * More Comporftable Select2 for selecting Contact From
130
+ = 1.0.1 =
131
+ * Custom CSS Adding option
132
+ = 1.0.0 =
133
+ * Initial Release
void-cf7-widget-elementor.php CHANGED
@@ -1,360 +1,360 @@
1
- <?php
2
-
3
- /**
4
- * Plugin Name: Void Contact Form 7 Widget For Elementor Page Builder
5
- * Description: Adds Contact Form 7 widget element to Elementor page builder for easy drag & drop the created contact forms with Contact Form 7
6
- * Version: 2.1
7
- * Author: voidCoders
8
- * Plugin URI: https://voidcoders.com/product/contact-form7-widget-for-elementor-free/
9
- * Author URI: https://voidcoders.com
10
- * Text Domain: void
11
- * Elementor tested up to: 3.6
12
- * Elementor Pro tested up to: 3.6
13
- */
14
-
15
- use Account\AccountDataFactory;
16
-
17
- if (!defined('ABSPATH')) exit; // Exit if accessed directly
18
-
19
- define('CF7_WIDGET_E_VERSION', '2.1');
20
- define('CF7_WIDGET_E_PLUGIN_URL', trailingslashit(plugin_dir_url(__FILE__)));
21
- define('CF7_WIDGET_E_PLUGIN_DIR', trailingslashit(plugin_dir_path(__FILE__)));
22
-
23
- function void_cf7_widget()
24
- {
25
- // Load localization file
26
- load_plugin_textdomain('void');
27
-
28
- // Notice if the Elementor is not active
29
- if (!did_action('elementor/loaded')) {
30
- return;
31
- }
32
-
33
- // Check version required
34
- $elementor_version_required = '3.0';
35
- if (!version_compare(ELEMENTOR_VERSION, $elementor_version_required, '>=')) {
36
- return;
37
- }
38
-
39
- // Require the main plugin file
40
- require(__DIR__ . '/plugin.php'); //loading the main plugin
41
- include CF7_WIDGET_E_PLUGIN_DIR . 'custom-editor/init.php';
42
- // helper file for this plugin. currently used for gettings all contact form of cf7. also used for ajax request handle
43
- require __DIR__ . '/helper/helper.php';
44
- }
45
- add_action('plugins_loaded', 'void_cf7_widget');
46
-
47
- // display activation notice for depended plugin
48
- function void_cf7_widget_notice()
49
- { ?>
50
-
51
- <?php if (!is_plugin_active('contact-form-7/wp-contact-form-7.php') || !did_action('elementor/loaded')) : ?>
52
- <div class="notice notice-warning is-dismissible">
53
-
54
- <?php if (file_exists(WP_PLUGIN_DIR . '/elementor/elementor.php') && !did_action('elementor/loaded')) : ?>
55
- <p><?php echo sprintf(__('<a href="%s" class="button button-primary">Active</a> <b>Elementor Page Builder</b> now for working with <b>"Void Contact Form 7 Widget"</b>'), wp_nonce_url('plugins.php?action=activate&plugin=elementor/elementor.php&plugin_status=all&paged=1', 'activate-plugin_elementor/elementor.php')); ?></p>
56
- <?php elseif (!file_exists(WP_PLUGIN_DIR . '/elementor/elementor.php')) : ?>
57
- <p><?php echo sprintf(__('<b>Elementor Page Builder</b> must be installed for <b>"Void Contact Form 7 Widget"</b> to work. <a href="%s" class="button button-primary">Install Now</a>'), wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=elementor'), 'install-plugin_elementor')); ?></p>
58
- <?php endif; ?>
59
-
60
- <?php if (file_exists(WP_PLUGIN_DIR . '/contact-form-7/wp-contact-form-7.php') && !is_plugin_active('contact-form-7/wp-contact-form-7.php')) : ?>
61
- <p><?php echo sprintf(__('<a href="%s" class="button button-primary">Active</a> <b>Contact Form 7</b> now to start working with <b>"Void Contact Form 7 Widget"</b>'), wp_nonce_url('plugins.php?action=activate&plugin=contact-form-7/wp-contact-form-7.php&plugin_status=all&paged=1', 'activate-plugin_contact-form-7/wp-contact-form-7.php')); ?></p>
62
- <?php elseif (!file_exists(WP_PLUGIN_DIR . '/contact-form-7/wp-contact-form-7.php')) : ?>
63
- <p><?php echo sprintf(__('<b>Contact Form 7</b> must be installed and activated for <b>"Void Contact Form 7 Widget"</b> to work. <a href="%s" class="button button-primary">Install Now</a>'), wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=contact-form-7'), 'install-plugin_contact-form-7')); ?></p>
64
- <?php endif; ?>
65
-
66
- </div>
67
- <?php endif; ?>
68
-
69
- <?php }
70
- add_action('admin_notices', 'void_cf7_widget_notice');
71
-
72
- function void_cf7_widget_promotional_notice()
73
- {
74
- // notice dismiss date form database
75
- $db_dismiss_date = get_option('dismissed-void-cf7-promotion-notice-ele-query-at');
76
- // create a date object from database date
77
- $dismiss_date = date_create($db_dismiss_date);
78
- // create a current date object
79
- $current_date = date_create(date('Y-m-d'));
80
- // get difference of both date
81
- $diff = date_diff($dismiss_date, $current_date);
82
- // make conditional days. if date found in database, it will be 30.
83
- // otherwise it will be 0. Becase difference return 0 if there was no data on database
84
- $conditional_days = ($db_dismiss_date) ? 15 : 0;
85
- // elementor pro install check
86
- if (file_exists(WP_PLUGIN_DIR . '/elementor-pro/elementor-pro.php') || did_action('elementor_pro/init')) :
87
- $url = 'https://elequerybuilder.com?click=cf7-promo';
88
- // different day condition. notice will again show if dismiss interval is more than equal 30 days
89
- if (!get_option('dismissed-void-cf7-promotion-notice-ele-query-never', FALSE)) :
90
-
91
- // different day condition. notice will again show if dismiss interval is more than equal 30 days
92
- if ($diff->days >= $conditional_days) :
93
- $url .= (($conditional_days == 15) ? '&discount=INSIDE10E' : '');
94
- ?>
95
- <div class="cf7-widget-promotion-notice notice is-dismissible" data-notice="void-cf7-promotion-notice-ele-query" data-nonce="<?php echo wp_create_nonce('wp_rest'); ?>">
96
- <div class="cf7-widget-message-inner">
97
- <div class="cf7-widget-message-icon">
98
- <img class="cf7-widget-notice-icon" src="https://elequerybuilder.com/wp-content/uploads/2020/05/EQ-Banner.png" alt="voidCoders promotional banner">
99
- </div>
100
- <div class="cf7-widget-message-content">
101
- <?php if ($conditional_days == 15) : ?>
102
- <p><?php esc_html_e('Here is a Little gift for you!', 'void'); ?></p>
103
- <p><?php esc_html_e('Get', 'void'); ?> <strong><?php esc_html_e('Ele Query Builder', 'void'); ?></strong> <?php esc_html_e('to build custom query without code with', 'void'); ?> <strong><?php esc_html_e('10% Discount', 'void'); ?></strong>. <strong><?php esc_html_e('Use Coupon - INSIDE10E', 'void'); ?></strong></p>
104
- <?php else : ?>
105
- <p><?php esc_html_e('We noticed you have', 'void'); ?> <strong><?php esc_html_e('Elementor Pro', 'void'); ?></strong> <?php esc_html_e('on your site.', 'void'); ?></p>
106
- <p><?php esc_html_e('Get our', 'void'); ?> <strong><?php esc_html_e('Ele Query Builder', 'void'); ?></strong> <?php esc_html_e('to use custom query by using postmeta, ACF/PODS', 'void'); ?></p>
107
- <p><?php esc_html_e('Woocommerce meta and events calendar with no CODE', 'void'); ?></p>
108
- <?php endif; ?>
109
- </div>
110
- <div class="cf7-widget-message-action">
111
- <a class="cf7-widget-button" target="__blank" href="<?php echo esc_url($url); ?>"><?php esc_html_e('Check Now', 'void'); ?></a>
112
- <!-- <a class="cf7-widget-remind-later" href="#">Remind me later -> </a> -->
113
- <a class="cf7-widget-never-show" href="#"><?php esc_html_e('Never show again ->', 'void'); ?> </a>
114
- </div>
115
- </div>
116
- </div>
117
- <?php endif;
118
- endif;
119
- endif;
120
- }
121
- add_action('admin_notices', 'void_cf7_widget_promotional_notice');
122
-
123
- // add plugin activation time
124
-
125
- function void_cf7_activation_time()
126
- {
127
- $get_installation_time = strtotime("now");
128
- update_option('void_cf7_elementor_activation_time', $get_installation_time);
129
- }
130
- register_activation_hook(__FILE__, 'void_cf7_activation_time');
131
-
132
- //check if review notice should be shown or not
133
-
134
- function void_cf7_check_installation_time()
135
- {
136
-
137
- $spare_me = get_option('void_cf7_spare_me');
138
- if (!$spare_me) {
139
- $install_date = get_option('void_cf7_elementor_activation_time');
140
- $past_date = strtotime('-7 days');
141
-
142
- if ($past_date >= $install_date) {
143
-
144
- add_action('admin_notices', 'void_cf7_display_admin_notice');
145
- }
146
- }
147
-
148
- if ( 'yes' !== get_option( 'void_cf7_with_elementor_ran_never' ) ) {
149
- if ( strtotime( '-15 days' ) >= get_option( 'void_cf7_with_elementor_ran_time', strtotime( '-15 days' ) ) ) {
150
- add_action( 'admin_notices', 'void_cf7_with_elementor_recomended_admin_notice' );
151
- }
152
- }
153
- }
154
- add_action('admin_init', 'void_cf7_check_installation_time');
155
-
156
- /**
157
- * Display Admin Notice, asking for a review
158
- **/
159
- function void_cf7_display_admin_notice()
160
- {
161
- // wordpress global variable
162
- global $pagenow;
163
- if ($pagenow == 'index.php') {
164
-
165
- $dont_disturb = esc_url( get_admin_url() . '?spare_me2=1' );
166
- $plugin_info = get_plugin_data( __FILE__, true, true );
167
- $reviewurl = esc_url( 'https://wordpress.org/support/plugin/cf7-widget-elementor/reviews/#new-post' );
168
- $void_url = esc_url( 'https://voidcoders.com/shop/' );
169
-
170
- printf(__('<div class="void-cf7-review wrap">You have been using <b> %s </b> for a while. We hope you liked it ! Please give us a quick rating, it works as a boost for us to keep working on the plugin ! Also you can visit our <a href="%s" target="_blank">site</a> to get more themes & Plugins<div class="void-cf7-review-btn"><a href="%s" class="button button-primary" target=
171
- "_blank">Rate Now!</a><a href="%s" class="void-cf7-review-done"> Already Done !</a></div></div>', $plugin_info['TextDomain']), $plugin_info['Name'], $void_url, $reviewurl, $dont_disturb);
172
- }
173
- }
174
-
175
- /**
176
- * Display Admin Notice, for elemailer banner
177
- */
178
- function void_cf7_with_elementor_recomended_admin_notice()
179
- {
180
- $temporary_hide = esc_url( get_admin_url() . '?void_cf7_with_elementor_ran=1' );
181
- $dont_disturb = esc_url( get_admin_url() . '?void_cf7_with_elementor_ran_never=1' );
182
-
183
- if ( is_plugin_active( 'elemailer-lite/elemailer-lite.php' ) || is_plugin_active( 'elemailer/elemailer.php' ) ) {
184
- return true;
185
- }
186
-
187
- $install_url = wp_nonce_url( add_query_arg( array( 'action' => 'activate', 'plugin' => urlencode( 'elemailer-lite/elemailer-lite.php' ) ), admin_url( 'plugins.php' ) ), 'activate-plugin_elemailer-lite/elemailer-lite.php' );
188
- $text = esc_html__( 'Active Elemailer Lite', 'void' );
189
-
190
- if ( is_wp_error( validate_plugin( 'elemailer-lite/elemailer-lite.php' ) ) ) {
191
- $install_url = wp_nonce_url( add_query_arg( array( 'action' => 'install-plugin', 'plugin' => 'elemailer-lite' ), admin_url( 'update.php' ) ), 'install-plugin_elemailer-lite' );
192
- $text = esc_html__( 'Install Elemailer Lite', 'void' );
193
- }
194
- ?>
195
- <div class="notice error void-cf7-license-notice">
196
- <div class="void-cf7-license-notice__logo">
197
- <img src="<?php echo CF7_WIDGET_E_PLUGIN_URL; ?>/assets/elemailer-logo.png" alt="Elemailer Logo">
198
- </div>
199
- <div class="void-cf7-license-notice__message">
200
- <h3><?php esc_html_e( 'Design your contact form 7 emails with Elementor', 'void' ); ?></h3>
201
-
202
- <a class="button" target="_blank" href="<?php echo esc_url( 'https://wordpress.org/plugins/elemailer-lite/' ); ?>"><?php esc_html_e( 'View Details', 'void' ); ?></a>
203
- </div>
204
-
205
- <div class="void-cf7-license-notice__button">
206
- <a class="button" href="<?php echo $install_url; ?>"><?php echo esc_html( $text ); ?></a>
207
- </div>
208
-
209
- <a href="<?php echo $temporary_hide; ?>">
210
- <button type="button" class="notice-dismiss"><span class="screen-reader-text"> <?php esc_html_e( 'Dismiss this notice.', 'void' ); ?></span></button>
211
- </a>
212
- <a href="<?php echo $dont_disturb; ?>"><span class="void-cf7-elemailer-promotion-never-show" style="position: absolute; right: 37px; bottom: 10px; color: #696969a8;"><?php esc_html_e( 'Never show again', 'void' ) ?></span></a>
213
- </div>
214
-
215
- <style>
216
- .notice.void-cf7-license-notice {
217
- display: flex;
218
- align-items: center;
219
- padding: 15px 10px;
220
- border: 1px solid #e4e4e4;
221
- border-left: 4px solid #fb6e76;
222
- background-repeat: no-repeat;
223
- background-position: bottom right;
224
- position: relative;
225
- }
226
-
227
- .void-cf7-license-notice__logo {
228
- margin-right: 50px;
229
- }
230
-
231
- .void-cf7-license-notice__logo img {
232
- width: 200px;
233
- height: auto;
234
- }
235
-
236
- .void-cf7-license-notice__message {
237
- flex-basis: 100%;
238
- }
239
-
240
- .void-cf7-license-notice__button {
241
- padding: 0 25px;
242
- }
243
-
244
- .void-cf7-license-notice__button .button {
245
- background: #071C74;
246
- color: #fff;
247
- border-color: #071C74;
248
- font-size: 15px;
249
- padding: 3px 15px;
250
- }
251
-
252
- .void-cf7-license-notice__button .button:hover {
253
- background: #1538cb;
254
- color: #fff;
255
- border-color: #1538cb;
256
- }
257
- </style>
258
- <?php
259
- }
260
-
261
- // remove the notice for the user if review already done or if the user does not want to
262
- function void_cf7_spare_me()
263
- {
264
- if (isset($_GET['spare_me2']) && !empty($_GET['spare_me2'])) {
265
- $spare_me = $_GET['spare_me2'];
266
- if ($spare_me == 1) {
267
- update_option( 'void_cf7_spare_me', TRUE);
268
- }
269
- }
270
-
271
- if ( isset( $_GET['void_cf7_with_elementor_ran'] ) && ! empty( $_GET['void_cf7_with_elementor_ran'] ) ) {
272
- if ( 1 === absint( $_GET['void_cf7_with_elementor_ran'] ) ) {
273
- update_option( 'void_cf7_with_elementor_ran', 'yes' );
274
- update_option( 'void_cf7_with_elementor_ran_time', strtotime("now") );
275
- }
276
- }
277
-
278
- if ( isset( $_GET['void_cf7_with_elementor_ran_never'] ) && ! empty( $_GET['void_cf7_with_elementor_ran_never'] ) ) {
279
- if ( 1 === absint( $_GET['void_cf7_with_elementor_ran_never'] ) ) {
280
- update_option( 'void_cf7_with_elementor_ran_never', 'yes' );
281
- }
282
- }
283
-
284
- delete_option( 'void_cf7_elep_2021_temporary' );
285
- delete_option( 'void_cf7_elep_2021_temporary_time' );
286
- delete_option( 'void_cf7_elep_2021_never' );
287
- delete_option( 'void_cf7_email_with_elementor_never' );
288
- delete_option( 'void_cf7_email_with_elementor' );
289
- delete_option( 'void_cf7_email_with_elementor_time' );
290
- }
291
- add_action('admin_init', 'void_cf7_spare_me', 5);
292
-
293
- //add admin css
294
- function void_cf7_admin_css()
295
- {
296
-
297
- global $pagenow;
298
- if ($pagenow == 'index.php' || file_exists(WP_PLUGIN_DIR . '/elementor-pro/elementor-pro.php') || did_action('elementor_pro/init') || !get_option('dismissed-void-cf7-promotion-notice-ele-query-never', FALSE)) {
299
- wp_enqueue_style('void-cf7-admin', CF7_WIDGET_E_PLUGIN_URL . 'assets/css/void-cf7-admin.css', [], CF7_WIDGET_E_VERSION, 'all');
300
- wp_enqueue_script('void-cf7-admin', CF7_WIDGET_E_PLUGIN_URL . 'assets/js/void-cf7-admin.js', ['jquery'], CF7_WIDGET_E_VERSION, true);
301
- }
302
- }
303
- add_action('admin_enqueue_scripts', 'void_cf7_admin_css');
304
-
305
- // opt in track
306
- require_once 'analyst/main.php';
307
-
308
- analyst_init(array(
309
- 'client-id' => 'nwmkv57dvw5blag6',
310
- 'client-secret' => 'd76789221c6c0faec9b684a1ad75cb970a89a8df',
311
- 'base-dir' => __FILE__
312
- ));
313
-
314
- // notice for track
315
- function void_cf7_opt_in_user_data_track()
316
- {
317
- // get data factory instance
318
- $account_data_factory = AccountDataFactory::instance();
319
- // get account data by using datafactory object
320
- $account_data = $account_data_factory->getAccountDataByBasePath(plugin_basename( __FILE__ ));
321
- // retrun if account data is not present for this folder
322
- if(!isset($account_data)){ return; }
323
- // account has private property
324
- // so, use this object to get those by it's public method
325
- $opted_in = $account_data->isOptedIn();
326
- $is_signed = $account_data->isSigned();
327
- $id = $account_data->getId();
328
-
329
- // notice dismiss date form database
330
- $db_dismiss_date = get_option('dismissed-void-cf7-usage-data-track-at');
331
- // create a date object from database date
332
- $dismiss_date = date_create($db_dismiss_date);
333
- // create a current date object
334
- $current_date = date_create(date('Y-m-d'));
335
- // get difference of both date
336
- $diff = date_diff($dismiss_date, $current_date);
337
- // make conditional days. if date found in database, it will be 30.
338
- // otherwise it will be 0. Becase difference return 0 if there was no data on database
339
- $conditional_days = ($db_dismiss_date) ? 15 : 0;
340
-
341
- if (!$opted_in && $diff->days >= $conditional_days) : ?>
342
- <div class="notice notice-warning is-dismissible void-cf7-widget-data-track-notice" data-notice="void-cf7-usage-data-track" data-nonce="<?php echo wp_create_nonce('wp_rest'); ?>">
343
- <p class="void-cf7-notice-text"><?php esc_html_e('We hope that you enjoy using our plugin Contact Form 7 Widget For Elementor Page Builder. If you agree we want to get some', 'void'); ?></p>
344
- <div class="void-cf7-non-sensitive"><?php esc_html_e('non sensitive', 'void'); ?>
345
- <span class="void-cf7-non-sensitive-tooltip">
346
- <ul>
347
- <li><?php esc_html_e('Your profile information (name and email).', 'void'); ?></li>
348
- <li><?php esc_html_e('Your site information (URL, WP version, PHP info, plugins & themes).', 'void'); ?></li>
349
- <li><?php esc_html_e('Plugin notices (updates, announcements, marketing, no spam)', 'void'); ?></li>
350
- <li><?php esc_html_e('Plugin events (activation, deactivation and uninstall)', 'void'); ?></li>
351
- </ul> ​
352
- ​</span>
353
- </div>
354
- <p class="void-cf7-notice-text"><?php esc_html_e('data from you to improve our plugin and keep you updated with security and other fixes time to time.', 'void'); ?></p>
355
- <p class="void-cf7-notice-text"><a class="analyst-action-opt analyst-opt-in" analyst-plugin-id="<?php echo esc_attr($id); ?>" analyst-plugin-signed="<?php echo esc_attr($is_signed); ?>"><?php esc_html_e('Opt In', 'void'); ?></a></p>
356
- </div>
357
- <?php endif;
358
- }
359
-
360
- add_action('admin_notices', 'void_cf7_opt_in_user_data_track');
1
+ <?php
2
+
3
+ /**
4
+ * Plugin Name: Void Contact Form 7 Widget For Elementor Page Builder
5
+ * Description: Adds Contact Form 7 widget element to Elementor page builder for easy drag & drop the created contact forms with Contact Form 7
6
+ * Version: 2.1.1
7
+ * Author: voidCoders
8
+ * Plugin URI: https://voidcoders.com/product/contact-form7-widget-for-elementor-free/
9
+ * Author URI: https://voidcoders.com
10
+ * Text Domain: void
11
+ * Elementor tested up to: 3.6.4
12
+ * Elementor Pro tested up to: 3.6.5
13
+ */
14
+
15
+ use Account\AccountDataFactory;
16
+
17
+ if (!defined('ABSPATH')) exit; // Exit if accessed directly
18
+
19
+ define('CF7_WIDGET_E_VERSION', '2.1');
20
+ define('CF7_WIDGET_E_PLUGIN_URL', trailingslashit(plugin_dir_url(__FILE__)));
21
+ define('CF7_WIDGET_E_PLUGIN_DIR', trailingslashit(plugin_dir_path(__FILE__)));
22
+
23
+ function void_cf7_widget()
24
+ {
25
+ // Load localization file
26
+ load_plugin_textdomain('void');
27
+
28
+ // Notice if the Elementor is not active
29
+ if (!did_action('elementor/loaded')) {
30
+ return;
31
+ }
32
+
33
+ // Check version required
34
+ $elementor_version_required = '3.0';
35
+ if (!version_compare(ELEMENTOR_VERSION, $elementor_version_required, '>=')) {
36
+ return;
37
+ }
38
+
39
+ // Require the main plugin file
40
+ require(__DIR__ . '/plugin.php'); //loading the main plugin
41
+ include CF7_WIDGET_E_PLUGIN_DIR . 'custom-editor/init.php';
42
+ // helper file for this plugin. currently used for gettings all contact form of cf7. also used for ajax request handle
43
+ require __DIR__ . '/helper/helper.php';
44
+ }
45
+ add_action('plugins_loaded', 'void_cf7_widget');
46
+
47
+ // display activation notice for depended plugin
48
+ function void_cf7_widget_notice()
49
+ { ?>
50
+
51
+ <?php if (!is_plugin_active('contact-form-7/wp-contact-form-7.php') || !did_action('elementor/loaded')) : ?>
52
+ <div class="notice notice-warning is-dismissible">
53
+
54
+ <?php if (file_exists(WP_PLUGIN_DIR . '/elementor/elementor.php') && !did_action('elementor/loaded')) : ?>
55
+ <p><?php echo sprintf(__('<a href="%s" class="button button-primary">Active</a> <b>Elementor Page Builder</b> now for working with <b>"Void Contact Form 7 Widget"</b>'), wp_nonce_url('plugins.php?action=activate&plugin=elementor/elementor.php&plugin_status=all&paged=1', 'activate-plugin_elementor/elementor.php')); ?></p>
56
+ <?php elseif (!file_exists(WP_PLUGIN_DIR . '/elementor/elementor.php')) : ?>
57
+ <p><?php echo sprintf(__('<b>Elementor Page Builder</b> must be installed for <b>"Void Contact Form 7 Widget"</b> to work. <a href="%s" class="button button-primary">Install Now</a>'), wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=elementor'), 'install-plugin_elementor')); ?></p>
58
+ <?php endif; ?>
59
+
60
+ <?php if (file_exists(WP_PLUGIN_DIR . '/contact-form-7/wp-contact-form-7.php') && !is_plugin_active('contact-form-7/wp-contact-form-7.php')) : ?>
61
+ <p><?php echo sprintf(__('<a href="%s" class="button button-primary">Active</a> <b>Contact Form 7</b> now to start working with <b>"Void Contact Form 7 Widget"</b>'), wp_nonce_url('plugins.php?action=activate&plugin=contact-form-7/wp-contact-form-7.php&plugin_status=all&paged=1', 'activate-plugin_contact-form-7/wp-contact-form-7.php')); ?></p>
62
+ <?php elseif (!file_exists(WP_PLUGIN_DIR . '/contact-form-7/wp-contact-form-7.php')) : ?>
63
+ <p><?php echo sprintf(__('<b>Contact Form 7</b> must be installed and activated for <b>"Void Contact Form 7 Widget"</b> to work. <a href="%s" class="button button-primary">Install Now</a>'), wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=contact-form-7'), 'install-plugin_contact-form-7')); ?></p>
64
+ <?php endif; ?>
65
+
66
+ </div>
67
+ <?php endif; ?>
68
+
69
+ <?php }
70
+ add_action('admin_notices', 'void_cf7_widget_notice');
71
+
72
+ function void_cf7_widget_promotional_notice()
73
+ {
74
+ // notice dismiss date form database
75
+ $db_dismiss_date = get_option('dismissed-void-cf7-promotion-notice-ele-query-at');
76
+ // create a date object from database date
77
+ $dismiss_date = date_create($db_dismiss_date);
78
+ // create a current date object
79
+ $current_date = date_create(date('Y-m-d'));
80
+ // get difference of both date
81
+ $diff = date_diff($dismiss_date, $current_date);
82
+ // make conditional days. if date found in database, it will be 30.
83
+ // otherwise it will be 0. Becase difference return 0 if there was no data on database
84
+ $conditional_days = ($db_dismiss_date) ? 15 : 0;
85
+ // elementor pro install check
86
+ if (file_exists(WP_PLUGIN_DIR . '/elementor-pro/elementor-pro.php') || did_action('elementor_pro/init')) :
87
+ $url = 'https://elequerybuilder.com?click=cf7-promo';
88
+ // different day condition. notice will again show if dismiss interval is more than equal 30 days
89
+ if (!get_option('dismissed-void-cf7-promotion-notice-ele-query-never', FALSE)) :
90
+
91
+ // different day condition. notice will again show if dismiss interval is more than equal 30 days
92
+ if ($diff->days >= $conditional_days) :
93
+ $url .= (($conditional_days == 15) ? '&discount=INSIDE10E' : '');
94
+ ?>
95
+ <div class="cf7-widget-promotion-notice notice is-dismissible" data-notice="void-cf7-promotion-notice-ele-query" data-nonce="<?php echo wp_create_nonce('wp_rest'); ?>">
96
+ <div class="cf7-widget-message-inner">
97
+ <div class="cf7-widget-message-icon">
98
+ <img class="cf7-widget-notice-icon" src="https://elequerybuilder.com/wp-content/uploads/2020/05/EQ-Banner.png" alt="voidCoders promotional banner">
99
+ </div>
100
+ <div class="cf7-widget-message-content">
101
+ <?php if ($conditional_days == 15) : ?>
102
+ <p><?php esc_html_e('Here is a Little gift for you!', 'void'); ?></p>
103
+ <p><?php esc_html_e('Get', 'void'); ?> <strong><?php esc_html_e('Ele Query Builder', 'void'); ?></strong> <?php esc_html_e('to build custom query without code with', 'void'); ?> <strong><?php esc_html_e('10% Discount', 'void'); ?></strong>. <strong><?php esc_html_e('Use Coupon - INSIDE10E', 'void'); ?></strong></p>
104
+ <?php else : ?>
105
+ <p><?php esc_html_e('We noticed you have', 'void'); ?> <strong><?php esc_html_e('Elementor Pro', 'void'); ?></strong> <?php esc_html_e('on your site.', 'void'); ?></p>
106
+ <p><?php esc_html_e('Get our', 'void'); ?> <strong><?php esc_html_e('Ele Query Builder', 'void'); ?></strong> <?php esc_html_e('to use custom query by using postmeta, ACF/PODS', 'void'); ?></p>
107
+ <p><?php esc_html_e('Woocommerce meta and events calendar with no CODE', 'void'); ?></p>
108
+ <?php endif; ?>
109
+ </div>
110
+ <div class="cf7-widget-message-action">
111
+ <a class="cf7-widget-button" target="__blank" href="<?php echo esc_url($url); ?>"><?php esc_html_e('Check Now', 'void'); ?></a>
112
+ <!-- <a class="cf7-widget-remind-later" href="#">Remind me later -> </a> -->
113
+ <a class="cf7-widget-never-show" href="#"><?php esc_html_e('Never show again ->', 'void'); ?> </a>
114
+ </div>
115
+ </div>
116
+ </div>
117
+ <?php endif;
118
+ endif;
119
+ endif;
120
+ }
121
+ add_action('admin_notices', 'void_cf7_widget_promotional_notice');
122
+
123
+ // add plugin activation time
124
+
125
+ function void_cf7_activation_time()
126
+ {
127
+ $get_installation_time = strtotime("now");
128
+ update_option('void_cf7_elementor_activation_time', $get_installation_time);
129
+ }
130
+ register_activation_hook(__FILE__, 'void_cf7_activation_time');
131
+
132
+ //check if review notice should be shown or not
133
+
134
+ function void_cf7_check_installation_time()
135
+ {
136
+
137
+ $spare_me = get_option('void_cf7_spare_me');
138
+ if (!$spare_me) {
139
+ $install_date = get_option('void_cf7_elementor_activation_time');
140
+ $past_date = strtotime('-7 days');
141
+
142
+ if ($past_date >= $install_date) {
143
+
144
+ add_action('admin_notices', 'void_cf7_display_admin_notice');
145
+ }
146
+ }
147
+
148
+ if ( 'yes' !== get_option( 'void_cf7_with_elementor_ran_never' ) ) {
149
+ if ( strtotime( '-15 days' ) >= get_option( 'void_cf7_with_elementor_ran_time', strtotime( '-15 days' ) ) ) {
150
+ add_action( 'admin_notices', 'void_cf7_with_elementor_recomended_admin_notice' );
151
+ }
152
+ }
153
+ }
154
+ add_action('admin_init', 'void_cf7_check_installation_time');
155
+
156
+ /**
157
+ * Display Admin Notice, asking for a review
158
+ **/
159
+ function void_cf7_display_admin_notice()
160
+ {
161
+ // wordpress global variable
162
+ global $pagenow;
163
+ if ($pagenow == 'index.php') {
164
+
165
+ $dont_disturb = esc_url( get_admin_url() . '?spare_me2=1' );
166
+ $plugin_info = get_plugin_data( __FILE__, true, true );
167
+ $reviewurl = esc_url( 'https://wordpress.org/support/plugin/cf7-widget-elementor/reviews/#new-post' );
168
+ $void_url = esc_url( 'https://voidcoders.com/shop/' );
169
+
170
+ printf(__('<div class="void-cf7-review wrap">You have been using <b> %s </b> for a while. We hope you liked it ! Please give us a quick rating, it works as a boost for us to keep working on the plugin ! Also you can visit our <a href="%s" target="_blank">site</a> to get more themes & Plugins<div class="void-cf7-review-btn"><a href="%s" class="button button-primary" target=
171
+ "_blank">Rate Now!</a><a href="%s" class="void-cf7-review-done"> Already Done !</a></div></div>', $plugin_info['TextDomain']), $plugin_info['Name'], $void_url, $reviewurl, $dont_disturb);
172
+ }
173
+ }
174
+
175
+ /**
176
+ * Display Admin Notice, for elemailer banner
177
+ */
178
+ function void_cf7_with_elementor_recomended_admin_notice()
179
+ {
180
+ $temporary_hide = esc_url( get_admin_url() . '?void_cf7_with_elementor_ran=1' );
181
+ $dont_disturb = esc_url( get_admin_url() . '?void_cf7_with_elementor_ran_never=1' );
182
+
183
+ if ( is_plugin_active( 'elemailer-lite/elemailer-lite.php' ) || is_plugin_active( 'elemailer/elemailer.php' ) ) {
184
+ return true;
185
+ }
186
+
187
+ $install_url = wp_nonce_url( add_query_arg( array( 'action' => 'activate', 'plugin' => urlencode( 'elemailer-lite/elemailer-lite.php' ) ), admin_url( 'plugins.php' ) ), 'activate-plugin_elemailer-lite/elemailer-lite.php' );
188
+ $text = esc_html__( 'Active Elemailer Lite', 'void' );
189
+
190
+ if ( is_wp_error( validate_plugin( 'elemailer-lite/elemailer-lite.php' ) ) ) {
191
+ $install_url = wp_nonce_url( add_query_arg( array( 'action' => 'install-plugin', 'plugin' => 'elemailer-lite' ), admin_url( 'update.php' ) ), 'install-plugin_elemailer-lite' );
192
+ $text = esc_html__( 'Install Elemailer Lite', 'void' );
193
+ }
194
+ ?>
195
+ <div class="notice error void-cf7-license-notice">
196
+ <div class="void-cf7-license-notice__logo">
197
+ <img src="<?php echo CF7_WIDGET_E_PLUGIN_URL; ?>/assets/elemailer-logo.png" alt="Elemailer Logo">
198
+ </div>
199
+ <div class="void-cf7-license-notice__message">
200
+ <h3><?php esc_html_e( 'Design your contact form 7 emails with Elementor', 'void' ); ?></h3>
201
+
202
+ <a class="button" target="_blank" href="<?php echo esc_url( 'https://wordpress.org/plugins/elemailer-lite/' ); ?>"><?php esc_html_e( 'View Details', 'void' ); ?></a>
203
+ </div>
204
+
205
+ <div class="void-cf7-license-notice__button">
206
+ <a class="button" href="<?php echo $install_url; ?>"><?php echo esc_html( $text ); ?></a>
207
+ </div>
208
+
209
+ <a href="<?php echo $temporary_hide; ?>">
210
+ <button type="button" class="notice-dismiss"><span class="screen-reader-text"> <?php esc_html_e( 'Dismiss this notice.', 'void' ); ?></span></button>
211
+ </a>
212
+ <a href="<?php echo $dont_disturb; ?>"><span class="void-cf7-elemailer-promotion-never-show" style="position: absolute; right: 37px; bottom: 10px; color: #696969a8;"><?php esc_html_e( 'Never show again', 'void' ) ?></span></a>
213
+ </div>
214
+
215
+ <style>
216
+ .notice.void-cf7-license-notice {
217
+ display: flex;
218
+ align-items: center;
219
+ padding: 15px 10px;
220
+ border: 1px solid #e4e4e4;
221
+ border-left: 4px solid #fb6e76;
222
+ background-repeat: no-repeat;
223
+ background-position: bottom right;
224
+ position: relative;
225
+ }
226
+
227
+ .void-cf7-license-notice__logo {
228
+ margin-right: 50px;
229
+ }
230
+
231
+ .void-cf7-license-notice__logo img {
232
+ width: 200px;
233
+ height: auto;
234
+ }
235
+
236
+ .void-cf7-license-notice__message {
237
+ flex-basis: 100%;
238
+ }
239
+
240
+ .void-cf7-license-notice__button {
241
+ padding: 0 25px;
242
+ }
243
+
244
+ .void-cf7-license-notice__button .button {
245
+ background: #071C74;
246
+ color: #fff;
247
+ border-color: #071C74;
248
+ font-size: 15px;
249
+ padding: 3px 15px;
250
+ }
251
+
252
+ .void-cf7-license-notice__button .button:hover {
253
+ background: #1538cb;
254
+ color: #fff;
255
+ border-color: #1538cb;
256
+ }
257
+ </style>
258
+ <?php
259
+ }
260
+
261
+ // remove the notice for the user if review already done or if the user does not want to
262
+ function void_cf7_spare_me()
263
+ {
264
+ if (isset($_GET['spare_me2']) && !empty($_GET['spare_me2'])) {
265
+ $spare_me = $_GET['spare_me2'];
266
+ if ($spare_me == 1) {
267
+ update_option( 'void_cf7_spare_me', TRUE);
268
+ }
269
+ }
270
+
271
+ if ( isset( $_GET['void_cf7_with_elementor_ran'] ) && ! empty( $_GET['void_cf7_with_elementor_ran'] ) ) {
272
+ if ( 1 === absint( $_GET['void_cf7_with_elementor_ran'] ) ) {
273
+ update_option( 'void_cf7_with_elementor_ran', 'yes' );
274
+ update_option( 'void_cf7_with_elementor_ran_time', strtotime("now") );
275
+ }
276
+ }
277
+
278
+ if ( isset( $_GET['void_cf7_with_elementor_ran_never'] ) && ! empty( $_GET['void_cf7_with_elementor_ran_never'] ) ) {
279
+ if ( 1 === absint( $_GET['void_cf7_with_elementor_ran_never'] ) ) {
280
+ update_option( 'void_cf7_with_elementor_ran_never', 'yes' );
281
+ }
282
+ }
283
+
284
+ delete_option( 'void_cf7_elep_2021_temporary' );
285
+ delete_option( 'void_cf7_elep_2021_temporary_time' );
286
+ delete_option( 'void_cf7_elep_2021_never' );
287
+ delete_option( 'void_cf7_email_with_elementor_never' );
288
+ delete_option( 'void_cf7_email_with_elementor' );
289
+ delete_option( 'void_cf7_email_with_elementor_time' );
290
+ }
291
+ add_action('admin_init', 'void_cf7_spare_me', 5);
292
+
293
+ //add admin css
294
+ function void_cf7_admin_css()
295
+ {
296
+
297
+ global $pagenow;
298
+ if ($pagenow == 'index.php' || file_exists(WP_PLUGIN_DIR . '/elementor-pro/elementor-pro.php') || did_action('elementor_pro/init') || !get_option('dismissed-void-cf7-promotion-notice-ele-query-never', FALSE)) {
299
+ wp_enqueue_style('void-cf7-admin', CF7_WIDGET_E_PLUGIN_URL . 'assets/css/void-cf7-admin.css', [], CF7_WIDGET_E_VERSION, 'all');
300
+ wp_enqueue_script('void-cf7-admin', CF7_WIDGET_E_PLUGIN_URL . 'assets/js/void-cf7-admin.js', ['jquery'], CF7_WIDGET_E_VERSION, true);
301
+ }
302
+ }
303
+ add_action('admin_enqueue_scripts', 'void_cf7_admin_css');
304
+
305
+ // opt in track
306
+ require_once 'analyst/main.php';
307
+
308
+ analyst_init(array(
309
+ 'client-id' => 'nwmkv57dvw5blag6',
310
+ 'client-secret' => 'd76789221c6c0faec9b684a1ad75cb970a89a8df',
311
+ 'base-dir' => __FILE__
312
+ ));
313
+
314
+ // notice for track
315
+ function void_cf7_opt_in_user_data_track()
316
+ {
317
+ // get data factory instance
318
+ $account_data_factory = AccountDataFactory::instance();
319
+ // get account data by using datafactory object
320
+ $account_data = $account_data_factory->getAccountDataByBasePath(plugin_basename( __FILE__ ));
321
+ // retrun if account data is not present for this folder
322
+ if(!isset($account_data)){ return; }
323
+ // account has private property
324
+ // so, use this object to get those by it's public method
325
+ $opted_in = $account_data->isOptedIn();
326
+ $is_signed = $account_data->isSigned();
327
+ $id = $account_data->getId();
328
+
329
+ // notice dismiss date form database
330
+ $db_dismiss_date = get_option('dismissed-void-cf7-usage-data-track-at');
331
+ // create a date object from database date
332
+ $dismiss_date = date_create($db_dismiss_date);
333
+ // create a current date object
334
+ $current_date = date_create(date('Y-m-d'));
335
+ // get difference of both date
336
+ $diff = date_diff($dismiss_date, $current_date);
337
+ // make conditional days. if date found in database, it will be 30.
338
+ // otherwise it will be 0. Becase difference return 0 if there was no data on database
339
+ $conditional_days = ($db_dismiss_date) ? 15 : 0;
340
+
341
+ if (!$opted_in && $diff->days >= $conditional_days) : ?>
342
+ <div class="notice notice-warning is-dismissible void-cf7-widget-data-track-notice" data-notice="void-cf7-usage-data-track" data-nonce="<?php echo wp_create_nonce('wp_rest'); ?>">
343
+ <p class="void-cf7-notice-text"><?php esc_html_e('We hope that you enjoy using our plugin Contact Form 7 Widget For Elementor Page Builder. If you agree we want to get some', 'void'); ?></p>
344
+ <div class="void-cf7-non-sensitive"><?php esc_html_e('non sensitive', 'void'); ?>
345
+ <span class="void-cf7-non-sensitive-tooltip">
346
+ <ul>
347
+ <li><?php esc_html_e('Your profile information (name and email).', 'void'); ?></li>
348
+ <li><?php esc_html_e('Your site information (URL, WP version, PHP info, plugins & themes).', 'void'); ?></li>
349
+ <li><?php esc_html_e('Plugin notices (updates, announcements, marketing, no spam)', 'void'); ?></li>
350
+ <li><?php esc_html_e('Plugin events (activation, deactivation and uninstall)', 'void'); ?></li>
351
+ </ul> ​
352
+ ​</span>
353
+ </div>
354
+ <p class="void-cf7-notice-text"><?php esc_html_e('data from you to improve our plugin and keep you updated with security and other fixes time to time.', 'void'); ?></p>
355
+ <p class="void-cf7-notice-text"><a class="analyst-action-opt analyst-opt-in" analyst-plugin-id="<?php echo esc_attr($id); ?>" analyst-plugin-signed="<?php echo esc_attr($is_signed); ?>"><?php esc_html_e('Opt In', 'void'); ?></a></p>
356
+ </div>
357
+ <?php endif;
358
+ }
359
+
360
+ add_action('admin_notices', 'void_cf7_opt_in_user_data_track');
widgets/void-section-cf7.php CHANGED
@@ -1,1686 +1,1686 @@
1
- <?php
2
- namespace voidelement\Widgets;
3
-
4
- use Elementor\Widget_Base;
5
- use Elementor\Controls_Manager;
6
- use Elementor\Group_Control_Image_Size;
7
- use Elementor\Utils;
8
- use Elementor\Core\Schemes\Color as Scheme_Color;
9
- use Elementor\Core\Schemes\Typography as Scheme_Typography;
10
-
11
-
12
-
13
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
14
-
15
- /**
16
- * Elementor Style for header
17
- *
18
- *
19
- * @since 1.0.0
20
- */
21
-
22
- class void_cf7 extends Widget_Base {
23
-
24
- // public function __construct( $data = [], $args = null ) {
25
- // parent::__construct( $data, $args );
26
- // $this->add_style_depends('void-cf7-elementor-js');
27
- // $this->add_script_depends('void-cf7-elementor-css');
28
- // }
29
-
30
- //this name is added to plugin.php of the root folder
31
-
32
- public function get_name() {
33
- return 'void-section-cf7';
34
- }
35
-
36
- public function get_title() {
37
- return 'Void Contact From 7'; // title to show on elementor
38
- }
39
-
40
- public function get_icon() {
41
- return 'eicon-mail'; // eicon-posts-ticker-> eicon ow asche icon to show on elelmentor
42
- }
43
-
44
- public function get_categories() {
45
- return [ 'void-elements' ]; // category of the widget
46
- }
47
- public function get_keywords()
48
- {
49
- return [
50
- 'contact form',
51
- 'form styler',
52
- 'cf7',
53
- 'void',
54
- 'void contact form 7',
55
- ];
56
- }
57
-
58
- public function is_reload_preview_required() {
59
- return true;
60
- }
61
-
62
- /**
63
- * A list of scripts that the widgets is depended in
64
- * @since 1.3.0
65
- **/
66
- protected function _register_controls() {
67
-
68
- //start of a control box
69
- $this->start_controls_section(
70
- 'section_content',
71
- [
72
- 'label' => esc_html__( 'Contact Form 7', 'void' ), //section name for controler view
73
- 'tab' => Controls_Manager::TAB_CONTENT,
74
- ]
75
- );
76
-
77
- $this->add_control(
78
- 'cf7',
79
- [
80
- 'label' => esc_html__( 'Select Contact Form', 'void' ),
81
- 'description' => esc_html__('Contact form 7 - plugin must be installed and there must be some contact forms made with the contact form 7','void'),
82
- 'type' => Controls_Manager::SELECT2,
83
- 'multiple' => false,
84
- 'label_block' => 1,
85
- 'options' => get_contact_form_7_posts(),
86
- ]
87
- );
88
-
89
- $this->add_control(
90
- 'void_cf7_form_action_edit',
91
- [
92
- 'type' => \Elementor\Controls_Manager::RAW_HTML,
93
- 'raw' => sprintf( '<a href="#" id="void-cf7-edit-form-btn" style="color:#d30c5c; float: right;">Edit form</a>', 'void' ),
94
- 'content_classes' => 'void-cf7-edit-form-btn',
95
- ]
96
- );
97
-
98
- $this->add_control(
99
- 'void_cf7_form_action_add',
100
- [
101
- 'type' => \Elementor\Controls_Manager::RAW_HTML,
102
- 'raw' => sprintf( '<a href="#" id="void-cf7-add-form-btn" style="color:#d30c5c; float: right;">+ Add new form</a>', 'void' ),
103
- 'content_classes' => 'void-cf7-add-form-btn',
104
- ]
105
- );
106
-
107
- $this->end_controls_section();
108
-
109
- $this->start_controls_section(
110
- 'section_stype',
111
- [
112
- 'label' => esc_html__( 'Advanced Style (legacy)', 'void' ), //section name for controler view
113
- 'description' => esc_html__( 'This area is intended for developers who knows CSS or for users who already have used this feature before. You should move to Style tab and use given controls to do the style more easily', 'void' ),
114
- 'tab' => Controls_Manager::TAB_CONTENT,
115
- ]
116
- );
117
-
118
-
119
- $this->add_control(
120
- 'vcf7_depri',
121
- [
122
- 'type' => \Elementor\Controls_Manager::RAW_HTML,
123
- 'raw' => __('This area is intended for developers who knows CSS or for users who already have used this feature before. You should move to Style tab and use given controls to do the style more easily','void'),
124
- 'content_classes' => 'elementor-panel-alert elementor-panel-alert-warning',
125
- ]
126
- );
127
-
128
-
129
- $this->add_control(
130
- 'cf7_direct_css',
131
- [
132
- 'label' => __( 'Global CSS For all fields', 'void' ),
133
- 'description' => __( 'This is the global css for all fields of cf7. It will not effect the other fileds but if you want to define things such as color, background color use this.', 'void' ),
134
- 'type' => Controls_Manager::TEXTAREA,
135
- 'placeholder' => 'color:#000;',
136
- 'selectors' => [
137
- '{{WRAPPER}} ' => '{{VALUE}}',
138
- ],
139
- ]
140
- );
141
-
142
- $this->add_control(
143
- 'alllabel',
144
- [
145
- 'label' => __( 'All Label CSS', 'void' ),
146
- 'description' => __( 'Changes might not sometimes show in the live preview but check in the front end to see the changes.', 'void' ),
147
- 'type' => Controls_Manager::TEXTAREA,
148
- 'placeholder' => 'color:#fff;',
149
- 'selectors' => [
150
- '{{WRAPPER}} label' => '{{VALUE}}',
151
- ],
152
- ]
153
- );
154
- $this->add_control(
155
- 'allinput',
156
- [
157
- 'label' => __( 'All Input CSS', 'void' ),
158
- 'description' => __( 'Changes might not sometimes show in the live preview but check in the front end to see the changes.', 'void' ),
159
- 'type' => Controls_Manager::TEXTAREA,
160
- 'placeholder' => 'width:100%;
161
- background:red;',
162
- 'selectors' => [
163
- '{{WRAPPER}} input' => 'height:auto;',
164
- '{{WRAPPER}} input' => '{{VALUE}}',
165
-
166
- ],
167
- ]
168
- );
169
-
170
- $this->add_control(
171
- 'textinput',
172
- [
173
- 'label' => __( 'Input Type Text CSS', 'void' ),
174
- 'description' => __( 'Changes might not sometimes show in the live preview but check in the front end to see the changes.', 'void' ),
175
- 'type' => Controls_Manager::TEXTAREA,
176
- 'placeholder' => 'width:100%;
177
- background:red;',
178
- 'selectors' => [
179
- '{{WRAPPER}} .wpcf7-text' => 'height:auto;',
180
- '{{WRAPPER}} .wpcf7-text' => '{{VALUE}}',
181
- ],
182
- ]
183
- );
184
- $this->add_control(
185
- 'textarea',
186
- [
187
- 'label' => __( 'Textarea CSS', 'void' ),
188
- 'description' => __( 'Changes might not sometimes show in the live preview but check in the front end to see the changes.', 'void' ),
189
- 'type' => Controls_Manager::TEXTAREA,
190
- 'placeholder' => 'height:100px;
191
- width:100%;',
192
- 'selectors' => [
193
- '{{WRAPPER}} textarea' => 'height:auto;',
194
- '{{WRAPPER}} textarea' => '{{VALUE}}',
195
- ],
196
- ]
197
- );
198
-
199
- $this->add_control(
200
- 'checkbox',
201
- [
202
- 'label' => __( 'Checkbox/ Radio CSS', 'void' ),
203
- 'type' => Controls_Manager::TEXTAREA,
204
- 'placeholder' => 'display: block;',
205
- 'selectors' => [
206
- '{{WRAPPER}} .wpcf7-list-item' => '{{VALUE}}',
207
- ],
208
- ]
209
- );
210
-
211
- $this->add_control(
212
- 'selectcss',
213
- [
214
- 'label' => __( 'Dropdown/ Select Box css', 'void' ),
215
- 'type' => Controls_Manager::TEXTAREA,
216
- 'placeholder' => 'width: 100;',
217
- 'selectors' => [
218
- '{{WRAPPER}} select' => '{{VALUE}}',
219
- ],
220
- ]
221
- );
222
- $this->add_control(
223
- 'selectoptionscss',
224
- [
225
- 'label' => __( 'Select Options Css', 'void' ),
226
- 'type' => Controls_Manager::TEXTAREA,
227
- 'placeholder' => 'color: red;',
228
- 'selectors' => [
229
- '{{WRAPPER}} select option' => '{{VALUE}}',
230
- ],
231
- ]
232
- );
233
-
234
- $this->add_control(
235
- 'file',
236
- [
237
- 'label' => __( 'File CSS', 'void' ),
238
- 'type' => Controls_Manager::TEXTAREA,
239
- 'placeholder' => 'display: block;',
240
- 'selectors' => [
241
- '{{WRAPPER}} input[type="file"]' => '{{VALUE}}',
242
- ],
243
- ]
244
- );
245
- $this->add_control(
246
- 'date',
247
- [
248
- 'label' => __( 'Date CSS', 'void' ),
249
- 'type' => Controls_Manager::TEXTAREA,
250
- 'placeholder' => 'display: block;',
251
- 'selectors' => [
252
- '{{WRAPPER}} .wpcf7-date' => '{{VALUE}}',
253
- ],
254
- ]
255
- );
256
- $this->add_control(
257
- 'inputsubmit',
258
- [
259
- 'label' => __( 'Submit Button CSS', 'void' ),
260
- 'description' => __( 'Changes might not sometimes show in the live preview but check in the front end to see the changes.', 'void' ),
261
- 'type' => Controls_Manager::TEXTAREA,
262
- 'placeholder' => 'width:100%;
263
- background:red;',
264
- 'selectors' => [
265
- '{{WRAPPER}} input[type="submit"]' => '{{VALUE}}',
266
- ],
267
- ]
268
- );
269
- $this->add_control(
270
- 'inputsubmithover',
271
- [
272
- 'label' => __( 'Submit Button Hover CSS', 'void' ),
273
- 'type' => Controls_Manager::TEXTAREA,
274
- 'placeholder' => 'background:#fff;',
275
- 'selectors' => [
276
- '{{WRAPPER}} input[type="submit"]:hover' => '{{VALUE}}',
277
- ],
278
- ]
279
- );
280
-
281
- $this->add_control(
282
- 'responce',
283
- [
284
- 'label' => __( 'Responce CSS', 'void' ),
285
- 'type' => Controls_Manager::TEXTAREA,
286
- 'placeholder' => 'color:red;',
287
- 'selectors' => [
288
- '{{WRAPPER}} .wpcf7-response-output' => '{{VALUE}}',
289
- ],
290
- ]
291
- );
292
-
293
-
294
- $this->end_controls_section();
295
-
296
-
297
-
298
- $this->start_controls_section(
299
- 'section_redirect',
300
- [
301
- 'label' => esc_html__( 'After Submit Redirect Setting', 'void' ), //section name for controler view
302
- 'tab' => Controls_Manager::TAB_CONTENT,
303
- ]
304
- );
305
-
306
- $this->add_control(
307
- 'cf7_redirect_external',
308
- [
309
- 'label' => __( 'On Success External URL Redirect', 'void' ),
310
- 'description' => esc_html__('Insert the external URL where you want users to redirect to when the contact form is submitted and is successful. Leave Blank to Disable','void'),
311
- 'type' => \Elementor\Controls_Manager::TEXT,
312
- 'placeholder' => __( 'https://voidcoders.com', 'void' ),
313
- 'label_block' => 1,
314
- ]
315
- );
316
-
317
- $this->add_control(
318
- 'cf7_redirect_page',
319
- [
320
- 'label' => esc_html__( 'On Success Internal Redirect', 'void' ),
321
- 'description' => esc_html__('Select a page within the site which you want users to redirect to when the contact form is submitted and is successful. Leave Blank to Disable','void'),
322
- 'type' => Controls_Manager::SELECT2,
323
- 'multiple' => false,
324
- 'label_block' => 1,
325
- 'options' => void_get_all_pages(),
326
- 'condition' =>
327
- [
328
- 'cf7_redirect_external' => '',
329
- ],
330
- ]
331
- );
332
-
333
-
334
- $this->end_controls_section();
335
-
336
- $this->start_controls_section(
337
- 'vcf7_section_email',
338
- [
339
- 'label' => esc_html__( 'Design Email', 'void' ), //section name for controler view
340
- 'tab' => Controls_Manager::TAB_CONTENT,
341
- ]
342
- );
343
-
344
- $this->add_control(
345
- 'vcf7_elemailer_promo',
346
- [
347
- 'type' => \Elementor\Controls_Manager::RAW_HTML,
348
- 'raw' => 'Drag & Drop Elementor Email builder for contact form 7 for free with <a target="_blank" href="https://elemailer.com/now-you-can-edit-your-contact-form-7-email-using-elementor/">Elemailer Lite </a><br><br>
349
- ✨Elemailer Gives you more✨ <br><br>
350
- <ul>
351
- <li>🔥Subscriber</li>
352
- <li>🔥Campaign</li>
353
- <li>🔥Lists</li>
354
- <li>🔥Woocommerce emails(coming..)</li>
355
- <li>🔥Campaign</li>
356
- <li>🔥Welcome emails</li>
357
- <li>🔥Many more..</li>
358
- </ul><br>
359
- <a target="_blank" href="https://elemailer.com?utm_source=site&utm_medium=editor&utm_campaign=editor_inside&utm_id=cf7elemailer"><img src="https://elemailer.com/wp-content/uploads/2021/11/element_02.png"></a>. <br>',
360
- ]
361
- );
362
-
363
-
364
- $this->end_controls_section();
365
-
366
-
367
- // Our style tab
368
- $this->start_controls_section(
369
- 'vcf7_form_section_style',
370
- [
371
- 'label' => __( 'General Style', 'void' ),
372
- 'tab' => Controls_Manager::TAB_STYLE,
373
- ]
374
- );
375
-
376
-
377
- $this->add_responsive_control(
378
- 'vcf7_form_section_align',
379
- [
380
- 'label' => __( 'Alignment', 'void' ),
381
- 'type' => Controls_Manager::CHOOSE,
382
- 'options' => [
383
- 'left' => [
384
- 'title' => __( 'Left', 'void' ),
385
- 'icon' => 'eicon-text-align-left',
386
- ],
387
- 'center' => [
388
- 'title' => __( 'Center', 'void' ),
389
- 'icon' => 'eicon-text-align-center',
390
- ],
391
- 'right' => [
392
- 'title' => __( 'Right', 'void' ),
393
- 'icon' => 'eicon-text-align-right',
394
- ],
395
- 'justify' => [
396
- 'title' => __( 'Justified', 'void' ),
397
- 'icon' => 'eicon-text-align-justify',
398
- ],
399
- ],
400
- 'selectors' => [
401
- '{{WRAPPER}}' => 'text-align: {{VALUE}};',
402
- ],
403
- 'separator' =>'before',
404
- ]
405
- );
406
-
407
- $this->end_controls_section();
408
-
409
- // Input Field style tab start
410
- $this->start_controls_section(
411
- 'vcf7_vcf7_input_style',
412
- [
413
- 'label' => __( 'Input', 'void' ),
414
- 'tab' => Controls_Manager::TAB_STYLE,
415
- ]
416
- );
417
-
418
-
419
- $this->start_controls_tabs('input_style_tabs'); //start input area Normal/focus tabs
420
-
421
- // Input Normal tab start
422
- $this->start_controls_tab(
423
- 'input_style_normal_tab',
424
- [
425
- 'label' => __( 'Normal', 'void' ),
426
- ]
427
- );
428
-
429
- $this->add_responsive_control(
430
- 'vcf7_input_box_height',
431
- [
432
- 'label' => __( 'Height', 'void' ),
433
- 'type' => Controls_Manager::SLIDER,
434
- 'size_units' => [ 'px', 'vh', 'vw' ],
435
- 'range' => [
436
- 'px' => [
437
- 'max' => 400,
438
- ],
439
- ],
440
-
441
-
442
- 'selectors' => [
443
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"]' => 'height: {{SIZE}}{{UNIT}};',
444
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"]' => 'height: {{SIZE}}{{UNIT}};',
445
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"]' => 'height: {{SIZE}}{{UNIT}};',
446
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"]' => 'height: {{SIZE}}{{UNIT}};',
447
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"]' => 'height: {{SIZE}}{{UNIT}};',
448
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"]' => 'height: {{SIZE}}{{UNIT}};',
449
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap .wpcf7-select' => 'height: {{SIZE}}{{UNIT}};',
450
- ],
451
- ]
452
- );
453
-
454
- $this->add_responsive_control(
455
- 'vcf7_input_box_width',
456
- [
457
- 'label' => __( 'Width', 'void' ),
458
- 'type' => Controls_Manager::SLIDER,
459
- 'size_units' => [ 'px', 'vw', 'vh' ],
460
- 'range' => [
461
- 'px' => [
462
- 'max' => 2000,
463
- ],
464
- ],
465
-
466
-
467
- 'selectors' => [
468
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"]' => 'width: {{SIZE}}{{UNIT}};',
469
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"]' => 'width: {{SIZE}}{{UNIT}};',
470
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"]' => 'width: {{SIZE}}{{UNIT}};',
471
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"]' => 'width: {{SIZE}}{{UNIT}};',
472
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"]' => 'width: {{SIZE}}{{UNIT}};',
473
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"]' => 'width: {{SIZE}}{{UNIT}};',
474
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap .wpcf7-select' => 'width: {{SIZE}}{{UNIT}};',
475
- ],
476
- ]
477
- );
478
-
479
- $this->add_group_control(
480
- \Elementor\Group_Control_Background::get_type(),
481
- [
482
- 'name' => 'vcf7_input_box_bg_grd',
483
- 'types' => [ 'classic', 'gradient'],
484
- 'label' => esc_html__( 'Background', 'void' ),
485
- 'selector' =>
486
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"],
487
- {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"],
488
- {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"],
489
- {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"],
490
- {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"],
491
- {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"],
492
- {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap .wpcf7-select',
493
-
494
- ]
495
- );
496
-
497
- $this->add_control(
498
- 'vcf7_input_box_text_color',
499
- [
500
- 'label' => __( 'Text Color', 'void' ),
501
- 'type' => Controls_Manager::COLOR,
502
- 'selectors' => [
503
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"]' => 'color: {{VALUE}};',
504
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"]' => 'color: {{VALUE}};',
505
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"]' => 'color: {{VALUE}};',
506
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"]' => 'color: {{VALUE}};',
507
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"]' => 'color: {{VALUE}};',
508
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"]' => 'color: {{VALUE}};',
509
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap .wpcf7-select' => 'color: {{VALUE}};',
510
- ],
511
- ]
512
- );
513
-
514
- $this->add_group_control(
515
- \Elementor\Group_Control_Border::get_type(),
516
- [
517
- 'name' => 'vcf7_input_box_border',
518
- 'label' => __( 'Border', 'void' ),
519
- 'selector' => '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"], {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"], {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"], {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"], {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"], {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"], {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap .wpcf7-select',
520
- ]
521
- );
522
-
523
- $this->add_responsive_control(
524
- 'vcf7_input_box_border_radius',
525
- [
526
- 'label' => __( 'Border Radius', 'void' ),
527
- 'type' => Controls_Manager::DIMENSIONS,
528
- 'selectors' => [
529
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"]' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
530
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"]' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
531
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"]' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
532
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"]' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
533
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"]' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
534
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"]' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
535
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap .wpcf7-select' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
536
- ],
537
- 'separator' =>'after',
538
- ]
539
- );
540
-
541
- $this->end_controls_tab(); // input Normal tab end
542
-
543
- // Input Focus tab start
544
- $this->start_controls_tab(
545
- 'input_style_focus_tab',
546
- [
547
- 'label' => __( 'Focus', 'void' ),
548
- ]
549
- );
550
-
551
- $this->add_responsive_control(
552
- 'vcf7_input_box_height_f',
553
- [
554
- 'label' => __( 'Height', 'void' ),
555
- 'type' => Controls_Manager::SLIDER,
556
- 'size_units' => [ 'px', 'vh', 'vw' ],
557
- 'range' => [
558
- 'px' => [
559
- 'max' => 400,
560
- ],
561
- ],
562
-
563
-
564
- 'selectors' => [
565
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"]:focus' => 'height: {{SIZE}}{{UNIT}};',
566
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"]:focus' => 'height: {{SIZE}}{{UNIT}};',
567
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"]:focus' => 'height: {{SIZE}}{{UNIT}};',
568
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"]:focus' => 'height: {{SIZE}}{{UNIT}};',
569
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"]:focus' => 'height: {{SIZE}}{{UNIT}};',
570
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"]:focus' => 'height: {{SIZE}}{{UNIT}};',
571
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap .wpcf7-select:focus' => 'height: {{SIZE}}{{UNIT}};',
572
- ],
573
- ]
574
- );
575
-
576
- $this->add_responsive_control(
577
- 'vcf7_input_box_width_f',
578
- [
579
- 'label' => __( 'Width', 'void' ),
580
- 'type' => Controls_Manager::SLIDER,
581
- 'size_units' => [ 'px', 'vw', 'vh' ],
582
- 'range' => [
583
- 'px' => [
584
- 'max' => 2000,
585
- ],
586
- ],
587
-
588
-
589
- 'selectors' => [
590
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"]:focus' => 'width: {{SIZE}}{{UNIT}};',
591
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"]:focus' => 'width: {{SIZE}}{{UNIT}};',
592
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"]:focus' => 'width: {{SIZE}}{{UNIT}};',
593
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"]:focus' => 'width: {{SIZE}}{{UNIT}};',
594
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"]:focus' => 'width: {{SIZE}}{{UNIT}};',
595
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"]:focus' => 'width: {{SIZE}}{{UNIT}};',
596
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap .wpcf7-select:focus' => 'width: {{SIZE}}{{UNIT}};',
597
- ],
598
- ]
599
- );
600
-
601
- $this->add_group_control(
602
- \Elementor\Group_Control_Background::get_type(),
603
- [
604
- 'name' => 'vcf7_input_box_bg_grd_f',
605
- 'types' => [ 'classic', 'gradient'],
606
- 'label' => esc_html__( 'Background', 'plugin-name' ),
607
- 'selector' =>
608
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"]:focus,
609
- {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"]:focus,
610
- {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"]:focus,
611
- {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"]:focus,
612
- {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"]:focus,
613
- {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"]:focus,
614
- {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap .wpcf7-select:focus',
615
-
616
- ]
617
- );
618
-
619
- $this->add_control(
620
- 'vcf7_input_box_text_color_f',
621
- [
622
- 'label' => __( 'Text Color', 'void' ),
623
- 'type' => Controls_Manager::COLOR,
624
- 'selectors' => [
625
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"]:focus' => 'color: {{VALUE}};',
626
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"]:focus' => 'color: {{VALUE}};',
627
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"]:focus' => 'color: {{VALUE}};',
628
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"]:focus' => 'color: {{VALUE}};',
629
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"]:focus' => 'color: {{VALUE}};',
630
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"]:focus' => 'color: {{VALUE}};',
631
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap .wpcf7-select:focus' => 'color: {{VALUE}};',
632
- ],
633
- ]
634
- );
635
-
636
- $this->add_group_control(
637
- \Elementor\Group_Control_Border::get_type(),
638
- [
639
- 'name' => 'vcf7_input_box_border_f',
640
- 'label' => __( 'Border', 'void' ),
641
- 'selector' => '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"]:focus, {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"]:focus, {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"]:focus, {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"]:focus, {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"]:focus, {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"]:focus, {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap .wpcf7-select:focus',
642
- ]
643
- );
644
-
645
- $this->add_responsive_control(
646
- 'vcf7_input_box_border_radius_f',
647
- [
648
- 'label' => __( 'Border Radius', 'void' ),
649
- 'type' => Controls_Manager::DIMENSIONS,
650
- 'selectors' => [
651
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"]:focus' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
652
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"]:focus' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
653
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"]:focus' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
654
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"]:focus' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
655
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"]:focus' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
656
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"]:focus' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
657
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap .wpcf7-select:focus' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
658
- ],
659
- ]
660
- );
661
-
662
- $this->add_control(
663
- 'vcf7_input_transition',
664
- [
665
- 'label' => __( 'Transition Control', 'void' ),
666
- 'type' => Controls_Manager::TEXT,
667
- 'placeholder' => 'width .35s ease-in-out',
668
- 'description' => __( 'input your desired transition effect for focus. Remember one single line can set all types of transition values. <a target="_blank" href="https://css-tricks.com/almanac/properties/t/transition/">Example</a>', 'void' ),
669
- 'selectors' => [
670
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"], {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"], {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"], {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"], {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"], {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"], {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap .wpcf7-select' =>'transition:{{VALUE}};-webkit-transition:{{VALUE}};-o-transition:{{VALUE}}',
671
-
672
-
673
- ],
674
- 'separator' =>'after',
675
-
676
- ]
677
- );
678
-
679
- $this->end_controls_tab(); // input Focus tab end
680
-
681
- $this->end_controls_tabs(); // end text area Normal/focus tabs
682
-
683
-
684
- $this->add_group_control(
685
- \Elementor\Group_Control_Typography::get_type(),
686
- [
687
- 'name' => 'vcf7_input_box_typography',
688
-
689
- 'selector' => '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"], {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"], {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"], {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"], {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"], {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"], {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap .wpcf7-select',
690
- ]
691
- );
692
-
693
-
694
- $this->add_control(
695
- 'vcf7_input_box_placeholder_color',
696
- [
697
- 'label' => __( 'Placeholder Color', 'void' ),
698
- 'type' => Controls_Manager::COLOR,
699
- 'selectors' => [
700
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"]::-webkit-input-placeholder' => 'color: {{VALUE}};',
701
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"]::-moz-placeholder' => 'color: {{VALUE}};',
702
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"]:-ms-input-placeholder' => 'color: {{VALUE}};',
703
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"]::-webkit-input-placeholder' => 'color: {{VALUE}};',
704
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"]::-moz-placeholder' => 'color: {{VALUE}};',
705
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"]:-ms-input-placeholder' => 'color: {{VALUE}};',
706
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"]::-webkit-input-placeholder' => 'color: {{VALUE}};',
707
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"]::-moz-placeholder' => 'color: {{VALUE}};',
708
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"]:-ms-input-placeholder' => 'color: {{VALUE}};',
709
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"]::-webkit-input-placeholder' => 'color: {{VALUE}};',
710
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"]::-moz-placeholder' => 'color: {{VALUE}};',
711
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"]:-ms-input-placeholder' => 'color: {{VALUE}};',
712
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"]::-webkit-input-placeholder' => 'color: {{VALUE}};',
713
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"]::-moz-placeholder' => 'color: {{VALUE}};',
714
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"]:-ms-input-placeholder' => 'color: {{VALUE}};',
715
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"]::-webkit-input-placeholder' => 'color: {{VALUE}};',
716
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"]::-moz-placeholder' => 'color: {{VALUE}};',
717
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"]:-ms-input-placeholder' => 'color: {{VALUE}};',
718
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap .wpcf7-select' => 'color: {{VALUE}};',
719
- ],
720
- ]
721
- );
722
-
723
-
724
- $this->add_responsive_control(
725
- 'vcf7_input_box_padding',
726
- [
727
- 'label' => __( 'Padding', 'void' ),
728
- 'type' => Controls_Manager::DIMENSIONS,
729
- 'size_units' => [ 'px', '%', 'em' ],
730
- 'selectors' => [
731
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"]' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
732
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"]' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
733
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"]' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
734
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"]' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
735
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"]' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
736
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"]' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
737
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap .wpcf7-select' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
738
- ],
739
- 'separator' =>'before',
740
- ]
741
- );
742
-
743
- $this->add_responsive_control(
744
- 'vcf7_input_box_margin',
745
- [
746
- 'label' => __( 'Margin', 'void' ),
747
- 'type' => Controls_Manager::DIMENSIONS,
748
- 'size_units' => [ 'px', '%', 'em' ],
749
- 'selectors' => [
750
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"]' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
751
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"]' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
752
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"]' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
753
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"]' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
754
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"]' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
755
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"]' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
756
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap .wpcf7-select' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
757
- ],
758
- 'separator' =>'before',
759
- ]
760
- );
761
-
762
- $this->end_controls_section(); // Input Field style tab end
763
-
764
- // Textarea style tab start
765
- $this->start_controls_section(
766
- 'vcf7_textarea_style',
767
- [
768
- 'label' => __( 'Textarea', 'void' ),
769
- 'tab' => Controls_Manager::TAB_STYLE,
770
- ]
771
- );
772
-
773
- $this->start_controls_tabs('textarea_style_tabs'); //start text area Normal/focus tabs
774
-
775
- // Input Normal tab start
776
- $this->start_controls_tab(
777
- 'text_normal_tab',
778
- [
779
- 'label' => __( 'Normal', 'void' ),
780
- ]
781
- );
782
-
783
- $this->add_responsive_control(
784
- 'vcf7_textarea_box_height',
785
- [
786
- 'label' => __( 'Height', 'void' ),
787
- 'type' => Controls_Manager::SLIDER,
788
- 'size_units' => [ 'px', 'vh', 'vw' ],
789
- 'range' => [
790
- 'px' => [
791
- 'max' => 900,
792
- ],
793
- ],
794
-
795
- 'selectors' => [
796
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea' => 'height: {{SIZE}}{{UNIT}};',
797
- ],
798
- ]
799
- );
800
- $this->add_responsive_control(
801
- 'vcf7_textarea_box_width',
802
- [
803
- 'label' => __( 'Width', 'void' ),
804
- 'type' => Controls_Manager::SLIDER,
805
- 'size_units' => [ 'px', 'vw', 'vh' ],
806
- 'range' => [
807
- 'px' => [
808
- 'max' => 2000,
809
- ],
810
- ],
811
-
812
- 'selectors' => [
813
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea' => 'width: {{SIZE}}{{UNIT}};',
814
- ],
815
- ]
816
-
817
- );
818
-
819
- $this->add_group_control(
820
- \Elementor\Group_Control_Background::get_type(),
821
- [
822
- 'name' => 'vcf7_textarea_box_bg_grd',
823
- 'types' => [ 'classic', 'gradient'],
824
- 'label' => esc_html__( 'Background', 'void' ),
825
- 'selector' =>
826
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea',
827
- ]
828
-
829
- );
830
-
831
- $this->add_control(
832
- 'vcf7_textarea_box_text_color',
833
- [
834
- 'label' => __( 'Text Color', 'void' ),
835
- 'type' => Controls_Manager::COLOR,
836
- 'selectors' => [
837
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea' => 'color: {{VALUE}};',
838
- ],
839
- ]
840
- );
841
-
842
- $this->add_group_control(
843
- \Elementor\Group_Control_Border::get_type(),
844
- [
845
- 'name' => 'vcf7_textarea_box_border',
846
- 'label' => __( 'Border', 'void' ),
847
- 'selector' => '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea',
848
- ]
849
- );
850
-
851
- $this->add_responsive_control(
852
- 'vcf7_textarea_box_border_radius',
853
- [
854
- 'label' => __( 'Border Radius', 'void' ),
855
- 'type' => Controls_Manager::DIMENSIONS,
856
- 'selectors' => [
857
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
858
- ],
859
- 'separator' =>'after',
860
- ]
861
- );
862
-
863
-
864
- $this->end_controls_tab(); // Textarea Normal tab end
865
-
866
-
867
- // Input Focus tab start
868
- $this->start_controls_tab(
869
- 'text_focus_tab',
870
- [
871
- 'label' => __( 'Focus', 'void' ),
872
- ]
873
- );
874
- $this->add_responsive_control(
875
- 'vcf7_textarea_box_height_f',
876
- [
877
- 'label' => __( 'Height', 'void' ),
878
- 'type' => Controls_Manager::SLIDER,
879
- 'size_units' => [ 'px', 'vh', 'vw' ],
880
- 'range' => [
881
- 'px' => [
882
- 'max' => 900,
883
- ],
884
- ],
885
-
886
- 'selectors' => [
887
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea:focus' => 'height: {{SIZE}}{{UNIT}};',
888
- ],
889
- ]
890
- );
891
- $this->add_responsive_control(
892
- 'vcf7_textarea_box_width_f',
893
- [
894
- 'label' => __( 'Width', 'void' ),
895
- 'type' => Controls_Manager::SLIDER,
896
- 'size_units' => [ 'px', 'vw', 'vh' ],
897
- 'range' => [
898
- 'px' => [
899
- 'max' => 2000,
900
- ],
901
- ],
902
-
903
- 'selectors' => [
904
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea:focus' => 'width: {{SIZE}}{{UNIT}};',
905
- ],
906
- ]
907
-
908
- );
909
-
910
- $this->add_group_control(
911
- \Elementor\Group_Control_Background::get_type(),
912
- [
913
- 'name' => 'vcf7_textarea_box_bg_grd_f',
914
- 'types' => [ 'classic', 'gradient'],
915
- 'label' => esc_html__( 'Background', 'void' ),
916
- 'selector' =>
917
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea:focus',
918
- ]
919
-
920
- );
921
-
922
- $this->add_control(
923
- 'vcf7_textarea_box_text_color_f',
924
- [
925
- 'label' => __( 'Text Color', 'void' ),
926
- 'type' => Controls_Manager::COLOR,
927
- 'selectors' => [
928
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea:focus' => 'color: {{VALUE}};',
929
- ],
930
- ]
931
- );
932
-
933
- $this->add_group_control(
934
- \Elementor\Group_Control_Border::get_type(),
935
- [
936
- 'name' => 'vcf7_textarea_box_border_f',
937
- 'label' => __( 'Border', 'void' ),
938
- 'selector' => '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea:focus',
939
- ]
940
- );
941
-
942
- $this->add_responsive_control(
943
- 'vcf7_textarea_box_border_radius_f',
944
- [
945
- 'label' => __( 'Border Radius', 'void' ),
946
- 'type' => Controls_Manager::DIMENSIONS,
947
- 'selectors' => [
948
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea:focus' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
949
- ],
950
- 'separator' =>'after',
951
- ]
952
- );
953
-
954
- $this->add_control(
955
- 'vcf7_textarea_transition',
956
- [
957
- 'label' => __( 'Transition Control', 'void' ),
958
- 'type' => Controls_Manager::TEXT,
959
- 'placeholder' => 'width .35s ease-in-out',
960
- 'description' => __( 'input your desired transition effect for focus. Remember one single line can set all types of transition values. <a target="_blank" href="https://css-tricks.com/almanac/properties/t/transition/">Example</a>', 'void' ),
961
- 'selectors' => [
962
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea' =>'transition:{{VALUE}};-webkit-transition:{{VALUE}}',
963
-
964
-
965
- ],
966
- 'separator' =>'after',
967
-
968
- ]
969
- );
970
-
971
- $this->end_controls_tab(); // Textarea Focus tab end
972
-
973
- $this->end_controls_tabs(); //end text area Normal/focus tabs
974
-
975
-
976
- $this->add_group_control(
977
- \Elementor\Group_Control_Typography::get_type(),
978
- [
979
- 'name' => 'vcf7_textarea_box_typography',
980
- 'selector' => '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea',
981
- ]
982
- );
983
-
984
-
985
-
986
- $this->add_control(
987
- 'vcf7_textarea_box_placeholder_color',
988
- [
989
- 'label' => __( 'Placeholder Color', 'void' ),
990
- 'type' => Controls_Manager::COLOR,
991
- 'selectors' => [
992
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea::-webkit-input-placeholder' => 'color: {{VALUE}};',
993
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea::-moz-placeholder' => 'color: {{VALUE}};',
994
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea:-ms-input-placeholder' => 'color: {{VALUE}};',
995
- ],
996
- ]
997
- );
998
-
999
-
1000
- $this->add_responsive_control(
1001
- 'vcf7_textarea_box_padding',
1002
- [
1003
- 'label' => __( 'Padding', 'void' ),
1004
- 'type' => Controls_Manager::DIMENSIONS,
1005
- 'size_units' => [ 'px', '%', 'em' ],
1006
- 'selectors' => [
1007
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1008
- ],
1009
- 'separator' =>'before',
1010
- ]
1011
- );
1012
-
1013
- $this->add_responsive_control(
1014
- 'vcf7_textarea_box_margin',
1015
- [
1016
- 'label' => __( 'Margin', 'void' ),
1017
- 'type' => Controls_Manager::DIMENSIONS,
1018
- 'size_units' => [ 'px', '%', 'em' ],
1019
- 'selectors' => [
1020
- '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1021
- ],
1022
- 'separator' =>'before',
1023
- ]
1024
- );
1025
-
1026
- $this->end_controls_section(); // Textarea style tab end
1027
-
1028
- // Label style tab start
1029
- $this->start_controls_section(
1030
- 'vcf7_cf7_label_style',
1031
- [
1032
- 'label' => __( 'Label', 'void' ),
1033
- 'tab' => Controls_Manager::TAB_STYLE,
1034
- ]
1035
- );
1036
-
1037
- $this->add_control(
1038
- 'vcf7_label_background',
1039
- [
1040
- 'label' => __( 'Background Color', 'void' ),
1041
- 'type' => Controls_Manager::COLOR,
1042
- 'selectors' => [
1043
- '{{WRAPPER}} form.wpcf7-form label' => 'background-color: {{VALUE}};',
1044
- ],
1045
- ]
1046
- );
1047
-
1048
- $this->add_control(
1049
- 'vcf7_label_text_color',
1050
- [
1051
- 'label' => __( 'Text Color', 'void' ),
1052
- 'type' => Controls_Manager::COLOR,
1053
- 'selectors' => [
1054
- '{{WRAPPER}} form.wpcf7-form label' => 'color: {{VALUE}};',
1055
- ],
1056
- ]
1057
- );
1058
-
1059
- $this->add_group_control(
1060
- \Elementor\Group_Control_Typography::get_type(),
1061
- [
1062
- 'name' => 'vcf7_label_typography',
1063
- 'selector' => '{{WRAPPER}} form.wpcf7-form label',
1064
- ]
1065
- );
1066
-
1067
- $this->add_group_control(
1068
- \Elementor\Group_Control_Border::get_type(),
1069
- [
1070
- 'name' => 'vcf7_label_border',
1071
- 'label' => __( 'Border', 'void' ),
1072
- 'selector' => '{{WRAPPER}} form.wpcf7-form label',
1073
- ]
1074
- );
1075
-
1076
- $this->add_responsive_control(
1077
- 'vcf7_label_border_radius',
1078
- [
1079
- 'label' => __( 'Border Radius', 'void' ),
1080
- 'type' => Controls_Manager::DIMENSIONS,
1081
- 'selectors' => [
1082
- '{{WRAPPER}} form.wpcf7-form label' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
1083
- ],
1084
- 'separator' =>'before',
1085
- ]
1086
- );
1087
-
1088
- $this->add_responsive_control(
1089
- 'vcf7_label_padding',
1090
- [
1091
- 'label' => __( 'Padding', 'void' ),
1092
- 'type' => Controls_Manager::DIMENSIONS,
1093
- 'size_units' => [ 'px', '%', 'em' ],
1094
- 'selectors' => [
1095
- '{{WRAPPER}} form.wpcf7-form label' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1096
- ],
1097
- 'separator' =>'before',
1098
- ]
1099
- );
1100
-
1101
- $this->add_responsive_control(
1102
- 'vcf7_label_margin',
1103
- [
1104
- 'label' => __( 'Margin', 'void' ),
1105
- 'type' => Controls_Manager::DIMENSIONS,
1106
- 'size_units' => [ 'px', '%', 'em' ],
1107
- 'selectors' => [
1108
- '{{WRAPPER}} form.wpcf7-form label' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1109
- ],
1110
- 'separator' =>'before',
1111
- ]
1112
- );
1113
-
1114
- $this->end_controls_section(); //
1115
- // Label style tab end
1116
-
1117
- // Input submit button style tab start
1118
- $this->start_controls_section(
1119
- 'vcf7_inputsubmit_style',
1120
- [
1121
- 'label' => __( 'Button', 'void' ),
1122
- 'tab' => Controls_Manager::TAB_STYLE,
1123
- ]
1124
- );
1125
-
1126
-
1127
- $this->add_responsive_control(
1128
- 'vcf7_button_text_align',
1129
- [
1130
- 'label' => __( 'Text Alignment', 'void' ),
1131
- 'type' => Controls_Manager::CHOOSE,
1132
- 'options' => [
1133
- 'left' => [
1134
- 'title' => __( 'Left', 'void' ),
1135
- 'icon' => 'eicon-text-align-left',
1136
- ],
1137
- 'center' => [
1138
- 'title' => __( 'Center', 'void' ),
1139
- 'icon' => 'eicon-text-align-center',
1140
- ],
1141
- 'right' => [
1142
- 'title' => __( 'Right', 'void' ),
1143
- 'icon' => 'eicon-text-align-right',
1144
- ],
1145
- 'justify' => [
1146
- 'title' => __( 'Justified', 'void' ),
1147
- 'icon' => 'eicon-text-align-justify',
1148
- ],
1149
- ],
1150
- 'selectors' => [
1151
- '{{WRAPPER}} .wpcf7-form input[type=submit]' => 'text-align: {{VALUE}};',
1152
- ],
1153
- 'separator' =>'before',
1154
- ]
1155
- );
1156
-
1157
-
1158
- $this->add_responsive_control(
1159
- 'vcf7_button_align',
1160
- [
1161
- 'label' => __( 'Button Float', 'void' ),
1162
- 'type' => Controls_Manager::CHOOSE,
1163
- 'options' => [
1164
- 'left' => [
1165
- 'title' => __( 'Left', 'void' ),
1166
- 'icon' => 'eicon-text-align-left',
1167
- ],
1168
-
1169
- 'right' => [
1170
- 'title' => __( 'Right', 'void' ),
1171
- 'icon' => 'eicon-text-align-right',
1172
- ],
1173
- ],
1174
- 'selectors' => [
1175
- '{{WRAPPER}} .wpcf7-form input[type=submit]' => 'float: {{VALUE}};',
1176
- ],
1177
- 'separator' =>'after',
1178
- ]
1179
- );
1180
-
1181
- $this->start_controls_tabs('submit_style_tabs');
1182
-
1183
- // Button Normal tab start
1184
- $this->start_controls_tab(
1185
- 'submit_style_normal_tab',
1186
- [
1187
- 'label' => __( 'Normal', 'void' ),
1188
- ]
1189
- );
1190
-
1191
- $this->add_responsive_control(
1192
- 'input_submit_height',
1193
- [
1194
- 'label' => __( 'Height', 'void' ),
1195
- 'type' => Controls_Manager::SLIDER,
1196
- 'size_units' => [ 'px', 'vh', 'vw' ],
1197
- 'range' => [
1198
- 'px' => [
1199
- 'max' => 900,
1200
- ],
1201
- ],
1202
-
1203
- 'selectors' => [
1204
- '{{WRAPPER}} .wpcf7-form input[type=submit]' => 'height: {{SIZE}}{{UNIT}};',
1205
- ],
1206
- ]
1207
- );
1208
- $this->add_responsive_control(
1209
- 'input_submit_width',
1210
- [
1211
- 'label' => __( 'Width', 'void' ),
1212
- 'type' => Controls_Manager::SLIDER,
1213
- 'size_units' => [ '%','px', 'vw' ],
1214
- 'range' => [
1215
- 'px' => [
1216
- 'max' => 1000,
1217
- ],
1218
- ],
1219
-
1220
- 'selectors' => [
1221
- '{{WRAPPER}} .wpcf7-form input[type=submit]' => 'width: {{SIZE}}{{UNIT}};',
1222
- ],
1223
- ]
1224
- );
1225
-
1226
- $this->add_group_control(
1227
- \Elementor\Group_Control_Typography::get_type(),
1228
- [
1229
- 'name' => 'input_submit_typography',
1230
- 'selector' => '{{WRAPPER}} .wpcf7-form .wpcf7-submit',
1231
- ]
1232
- );
1233
-
1234
- $this->add_control(
1235
- 'input_submit_text_color',
1236
- [
1237
- 'label' => __( 'Text Color', 'void' ),
1238
- 'type' => Controls_Manager::COLOR,
1239
- 'selectors' => [
1240
- '{{WRAPPER}} .wpcf7-form input[type=submit]' => 'color: {{VALUE}};',
1241
- ],
1242
- ]
1243
- );
1244
-
1245
-
1246
-
1247
- $this->add_group_control(
1248
- \Elementor\Group_Control_Background::get_type(),
1249
- [
1250
- 'name' => 'input_submit_bg_grd',
1251
- 'types' => [ 'classic', 'gradient'],
1252
- 'label' => esc_html__( 'Background', 'void' ),
1253
- 'selector' =>
1254
- '{{WRAPPER}} .wpcf7-form input[type=submit]',
1255
- ]
1256
- );
1257
-
1258
- $this->add_responsive_control(
1259
- 'input_submit_padding',
1260
- [
1261
- 'label' => __( 'Padding', 'void' ),
1262
- 'type' => Controls_Manager::DIMENSIONS,
1263
- 'size_units' => [ 'px', '%', 'em' ],
1264
- 'selectors' => [
1265
- '{{WRAPPER}} .wpcf7-form input[type=submit]' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1266
- ],
1267
- 'separator' =>'before',
1268
- ]
1269
- );
1270
-
1271
- $this->add_responsive_control(
1272
- 'input_submit_margin',
1273
- [
1274
- 'label' => __( 'Margin', 'void' ),
1275
- 'type' => Controls_Manager::DIMENSIONS,
1276
- 'size_units' => [ 'px', '%', 'em' ],
1277
- 'selectors' => [
1278
- '{{WRAPPER}} .wpcf7-form input[type=submit]' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1279
- ],
1280
- 'separator' =>'before',
1281
- ]
1282
- );
1283
-
1284
- $this->add_group_control(
1285
- \Elementor\Group_Control_Border::get_type(),
1286
- [
1287
- 'name' => 'input_submit_border',
1288
- 'label' => __( 'Border', 'void' ),
1289
- 'selector' => '{{WRAPPER}} .wpcf7-form input[type=submit]',
1290
- ]
1291
- );
1292
-
1293
- $this->add_responsive_control(
1294
- 'input_submit_border_radius',
1295
- [
1296
- 'label' => __( 'Border Radius', 'void' ),
1297
- 'type' => Controls_Manager::DIMENSIONS,
1298
- 'selectors' => [
1299
- '{{WRAPPER}} .wpcf7-form input[type=submit]' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
1300
- ],
1301
- 'separator' =>'before',
1302
- ]
1303
- );
1304
-
1305
- $this->add_group_control(
1306
- \Elementor\Group_Control_Box_Shadow::get_type(),
1307
- [
1308
- 'name' => 'vcf7_input_submit_box_shadow',
1309
- 'label' => __( 'Box Shadow', 'void' ),
1310
- 'selector' => '{{WRAPPER}} .wpcf7-form input[type=submit]',
1311
- ]
1312
- );
1313
-
1314
- $this->end_controls_tab(); // Button Normal tab end
1315
-
1316
- // Button Hover tab start
1317
- $this->start_controls_tab(
1318
- 'submit_style_hover_tab',
1319
- [
1320
- 'label' => __( 'Hover', 'void' ),
1321
- ]
1322
- );
1323
-
1324
- $this->add_responsive_control(
1325
- 'input_submit_height_h',
1326
- [
1327
- 'label' => __( 'Height', 'void' ),
1328
- 'type' => Controls_Manager::SLIDER,
1329
- 'size_units' => [ 'px', 'vh', 'vw' ],
1330
- 'range' => [
1331
- 'px' => [
1332
- 'max' => 900,
1333
- ],
1334
- ],
1335
-
1336
- 'selectors' => [
1337
- '{{WRAPPER}} .wpcf7-form input[type=submit]:hover' => 'height: {{SIZE}}{{UNIT}};',
1338
- ],
1339
- ]
1340
- );
1341
- $this->add_responsive_control(
1342
- 'input_submit_width_h',
1343
- [
1344
- 'label' => __( 'Width', 'void' ),
1345
- 'type' => Controls_Manager::SLIDER,
1346
- 'size_units' => [ '%','px', 'vw' ],
1347
- 'range' => [
1348
- 'px' => [
1349
- 'max' => 1000,
1350
- ],
1351
- ],
1352
-
1353
- 'selectors' => [
1354
- '{{WRAPPER}} .wpcf7-form input[type=submit]:hover' => 'width: {{SIZE}}{{UNIT}};',
1355
- ],
1356
- ]
1357
- );
1358
-
1359
- $this->add_group_control(
1360
- \Elementor\Group_Control_Typography::get_type(),
1361
- [
1362
- 'name' => 'input_submit_typography_h',
1363
- 'selector' => '{{WRAPPER}} .wpcf7-form input[type=submit]:hover',
1364
- ]
1365
- );
1366
-
1367
- $this->add_control(
1368
- 'input_submit_text_color_h',
1369
- [
1370
- 'label' => __( 'Text Color', 'void' ),
1371
- 'type' => Controls_Manager::COLOR,
1372
- 'selectors' => [
1373
- '{{WRAPPER}} .wpcf7-form input[type=submit]:hover' => 'color: {{VALUE}};',
1374
- ],
1375
- ]
1376
- );
1377
-
1378
-
1379
-
1380
- $this->add_group_control(
1381
- \Elementor\Group_Control_Background::get_type(),
1382
- [
1383
- 'name' => 'input_submit_bg_grd_h',
1384
- 'types' => [ 'classic', 'gradient'],
1385
- 'label' => esc_html__( 'Background', 'void' ),
1386
- 'selector' =>
1387
- '{{WRAPPER}} .wpcf7-form input[type=submit]:hover',
1388
- ]
1389
- );
1390
-
1391
- $this->add_responsive_control(
1392
- 'input_submit_padding_h',
1393
- [
1394
- 'label' => __( 'Padding', 'void' ),
1395
- 'type' => Controls_Manager::DIMENSIONS,
1396
- 'size_units' => [ 'px', '%', 'em' ],
1397
- 'selectors' => [
1398
- '{{WRAPPER}} .wpcf7-form input[type=submit]:hover' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1399
- ],
1400
- 'separator' =>'before',
1401
- ]
1402
- );
1403
-
1404
- $this->add_responsive_control(
1405
- 'input_submit_margin_h',
1406
- [
1407
- 'label' => __( 'Margin', 'void' ),
1408
- 'type' => Controls_Manager::DIMENSIONS,
1409
- 'size_units' => [ 'px', '%', 'em' ],
1410
- 'selectors' => [
1411
- '{{WRAPPER}} .wpcf7-form input[type=submit]:hover' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1412
- ],
1413
- 'separator' =>'before',
1414
- ]
1415
- );
1416
-
1417
- $this->add_group_control(
1418
- \Elementor\Group_Control_Border::get_type(),
1419
- [
1420
- 'name' => 'input_submit_border_h',
1421
- 'label' => __( 'Border', 'void' ),
1422
- 'selector' => '{{WRAPPER}} .wpcf7-form input[type=submit]:hover',
1423
- ]
1424
- );
1425
-
1426
- $this->add_responsive_control(
1427
- 'input_submit_border_radius_h',
1428
- [
1429
- 'label' => __( 'Border Radius', 'void' ),
1430
- 'type' => Controls_Manager::DIMENSIONS,
1431
- 'selectors' => [
1432
- '{{WRAPPER}} .wpcf7-form input[type=submit]:hover' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
1433
- ],
1434
- 'separator' =>'before',
1435
- ]
1436
- );
1437
-
1438
- $this->add_group_control(
1439
- \Elementor\Group_Control_Box_Shadow::get_type(),
1440
- [
1441
- 'name' => 'vcf7_input_submit_box_shadow_h',
1442
- 'label' => __( 'Box Shadow', 'void' ),
1443
- 'selector' => '{{WRAPPER}} .wpcf7-form input[type=submit]:hover',
1444
- ]
1445
- );
1446
-
1447
- $this->add_control(
1448
- 'vcf7_button_h_animation',
1449
- [
1450
- 'label' => __( 'Hover Animation', 'void' ),
1451
- 'type' => Controls_Manager::TEXT,
1452
- 'placeholder' => 'all .25s linear 0s',
1453
- 'default' => 'all .25s linear 0s',
1454
- 'description' => __( 'input your desired transition effect for focus. Remember one single line can set all types of transition values. <a target="_blank" href="https://css-tricks.com/almanac/properties/t/transition/">Example</a>', 'void' ),
1455
- 'selectors' => [
1456
- '{{WRAPPER}} .wpcf7-form input[type=submit]' =>'transition:{{VALUE}};-webkit-transition:{{VALUE}};-o-transition:{{VALUE}}',
1457
- ],
1458
- 'separator' =>'after',
1459
-
1460
- ]
1461
- );
1462
-
1463
- $this->end_controls_tab(); // Button Hover tab end
1464
-
1465
- $this->end_controls_tabs(); //ens submit style tabs
1466
-
1467
- $this->end_controls_section();
1468
- // end out style tab
1469
-
1470
- // After submit styles
1471
-
1472
- $this->start_controls_section(
1473
- 'vcf7_section_after_submit',
1474
- [
1475
- 'label' => __('After Submit message', 'void'),
1476
- 'tab' => Controls_Manager::TAB_STYLE,
1477
- ]
1478
- );
1479
-
1480
- $this->start_controls_tabs('vcf7_after_s_style_tabs');
1481
- // Success tab start
1482
- $this->start_controls_tab(
1483
- 'vcf7_after_submit_su_tab',
1484
- [
1485
- 'label' => __( 'Success', 'void' ),
1486
- ]
1487
- );
1488
-
1489
- $this->add_control(
1490
- 'contact_form_after_submit_s_color',
1491
- [
1492
- 'label' => __('Success Text Color', 'void'),
1493
- 'type' => Controls_Manager::COLOR,
1494
- 'selectors' => [
1495
- '{{WRAPPER}} .wpcf7 form.sent .wpcf7-response-output' => 'color: {{VALUE}}',
1496
- ],
1497
- ]
1498
- );
1499
-
1500
- $this->add_group_control(
1501
- \Elementor\Group_Control_Background::get_type(),
1502
- [
1503
- 'name' => 'vcf7_after_submit_background',
1504
- 'label' => __('Background', 'void'),
1505
- 'types' => ['classic', 'gradient'],
1506
- 'selector' => '{{WRAPPER}} .wpcf7 form.sent .wpcf7-response-output',
1507
- ]
1508
- );
1509
-
1510
- $this->add_group_control(
1511
- \Elementor\Group_Control_Border::get_type(),
1512
- [
1513
- 'name' => 'vcf7_after_submit_border',
1514
- 'label' => __('Border', 'void'),
1515
- 'placeholder' => '1px',
1516
- 'default' => '1px',
1517
- 'selector' => '{{WRAPPER}} .wpcf7 form.sent .wpcf7-response-output',
1518
- ]
1519
- );
1520
-
1521
- $this->add_responsive_control(
1522
- 'vcf7_after_submit_border_radius',
1523
- [
1524
- 'label' => esc_html__('Radius', 'void'),
1525
- 'type' => Controls_Manager::SLIDER,
1526
- 'size_units' => ['px', 'em', '%'],
1527
- 'range' => [
1528
- 'px' => [
1529
- 'min' => 10,
1530
- 'max' => 1500,
1531
- ],
1532
- 'em' => [
1533
- 'min' => 1,
1534
- 'max' => 80,
1535
- ],
1536
- ],
1537
- 'selectors' => [
1538
- '{{WRAPPER}} .wpcf7 form.sent .wpcf7-response-output' => 'border-radius: {{SIZE}}{{UNIT}};',
1539
- ],
1540
- 'separator' =>'after',
1541
-
1542
- ]
1543
- );
1544
- $this->end_controls_tab();
1545
-
1546
- // Fail tab start
1547
- $this->start_controls_tab(
1548
- 'vcf7_after_submit_fa_tab',
1549
- [
1550
- 'label' => __( 'Failed', 'void' ),
1551
- ]
1552
- );
1553
-
1554
- $this->add_control(
1555
- 'contact_form_after_submit_n_color',
1556
- [
1557
- 'label' => __('Fail Text Color', 'void'),
1558
- 'type' => Controls_Manager::COLOR,
1559
- 'selectors' => [
1560
- '{{WRAPPER}} .wpcf7 form.invalid .wpcf7-response-output, {{WRAPPER}} .wpcf7 form.unaccepted .wpcf7-response-output, {{WRAPPER}} .wpcf7 form.payment-required .wpcf7-response-output' => 'color: {{VALUE}}',
1561
- ],
1562
- ]
1563
- );
1564
-
1565
- $this->add_group_control(
1566
- \Elementor\Group_Control_Background::get_type(),
1567
- [
1568
- 'name' => 'vcf7_after_submit_er_background',
1569
- 'label' => __('Background', 'void'),
1570
- 'types' => ['classic', 'gradient'],
1571
- 'selector' => '.wpcf7 form.invalid .wpcf7-response-output, {{WRAPPER}} .wpcf7 form.unaccepted .wpcf7-response-output, {{WRAPPER}} .wpcf7 form.payment-required .wpcf7-response-output',
1572
- ]
1573
- );
1574
-
1575
- $this->add_group_control(
1576
- \Elementor\Group_Control_Border::get_type(),
1577
- [
1578
- 'name' => 'vcf7_after_submit_er_border',
1579
- 'label' => __('Border', 'void'),
1580
- 'placeholder' => '1px',
1581
- 'default' => '1px',
1582
- 'selector' => '.wpcf7 form.invalid .wpcf7-response-output, {{WRAPPER}} .wpcf7 form.unaccepted .wpcf7-response-output, {{WRAPPER}} .wpcf7 form.payment-required .wpcf7-response-output',
1583
- ]
1584
- );
1585
-
1586
- $this->add_responsive_control(
1587
- 'vcf7_after_submit_er_border_radius',
1588
- [
1589
- 'label' => esc_html__('Radius', 'void'),
1590
- 'type' => Controls_Manager::SLIDER,
1591
- 'size_units' => ['px', 'em', '%'],
1592
- 'range' => [
1593
- 'px' => [
1594
- 'min' => 10,
1595
- 'max' => 1500,
1596
- ],
1597
- 'em' => [
1598
- 'min' => 1,
1599
- 'max' => 80,
1600
- ],
1601
- ],
1602
- 'selectors' => [
1603
- '.wpcf7 form.invalid .wpcf7-response-output, {{WRAPPER}} .wpcf7 form.unaccepted .wpcf7-response-output, {{WRAPPER}} .wpcf7 form.payment-required .wpcf7-response-output' => 'border-radius: {{SIZE}}{{UNIT}};',
1604
- ],
1605
- 'separator' =>'after',
1606
-
1607
- ]
1608
- );
1609
-
1610
- $this->end_controls_tab();
1611
-
1612
- $this->end_controls_tabs();
1613
-
1614
- $this->add_group_control(
1615
- \Elementor\Group_Control_Typography::get_type(),
1616
- [
1617
- 'name' => 'vcf7_after_submit_typography',
1618
- 'label' => __('Typography', 'void'),
1619
- 'selector' => '{{WRAPPER}} .wpcf7-mail-sent-ng, {{WRAPPER}} .wpcf7-mail-sent-ok, {{WRAPPER}} .wpcf7-response-output',
1620
- 'separator' => 'before',
1621
- ]
1622
- );
1623
-
1624
- $this->add_responsive_control(
1625
- 'vcf7_after_submit_margin',
1626
- [
1627
- 'label' => esc_html__('Margin', 'void'),
1628
- 'type' => Controls_Manager::DIMENSIONS,
1629
- 'size_units' => ['px', 'em', '%'],
1630
- 'selectors' => [
1631
- '{{WRAPPER}} .wpcf7-mail-sent-ng' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1632
- '{{WRAPPER}} wpcf7-mail-sent-ok' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1633
- '{{WRAPPER}} .wpcf7-response-output' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1634
- ],
1635
- ]
1636
- );
1637
-
1638
- $this->add_responsive_control(
1639
- 'vcf7_after_submit_padding',
1640
- [
1641
- 'label' => esc_html__('Padding', 'void'),
1642
- 'type' => Controls_Manager::DIMENSIONS,
1643
- 'size_units' => ['px', 'em', '%'],
1644
- 'selectors' => [
1645
- '{{WRAPPER}} .wpcf7-mail-sent-ng' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1646
- '{{WRAPPER}} .wpcf7-mail-sent-ok' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1647
- '{{WRAPPER}} .wpcf7-response-output' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1648
- ],
1649
- ]
1650
- );
1651
-
1652
- $this->end_controls_section();
1653
-
1654
-
1655
- }
1656
-
1657
-
1658
- protected function render() { //to show on the fontend
1659
- static $v_veriable=0;
1660
-
1661
- $settings = $this->get_settings();
1662
-
1663
- if(!empty($settings['cf7'])){
1664
- echo'<div class="void-cf7-form-widget-wrapper elementor-shortcode void-cf7-'.$v_veriable.'" data-void-cf7-contact-form-id="'. $settings['cf7'] .'">';
1665
- echo do_shortcode('[contact-form-7 id="'.$settings['cf7'].'"]');
1666
- echo '</div>';
1667
- }
1668
-
1669
- if(!empty($settings['cf7_redirect_page']) || !empty($settings['cf7_redirect_external']) ) { ?>
1670
- <script>
1671
- var theform = document.querySelector('.void-cf7-<?php echo $v_veriable; ?>');
1672
- theform.addEventListener( 'wpcf7mailsent', function( event ) {
1673
- location = '<?php
1674
- if( !empty($settings['cf7_redirect_external']) ){
1675
- echo $settings['cf7_redirect_external'];
1676
- }else{
1677
- echo get_permalink( $settings['cf7_redirect_page'] );
1678
- }
1679
- ?>';
1680
- }, false );
1681
- </script>
1682
-
1683
- <?php $v_veriable++;
1684
- }
1685
- }
1686
- }
1
+ <?php
2
+ namespace voidelement\Widgets;
3
+
4
+ use Elementor\Widget_Base;
5
+ use Elementor\Controls_Manager;
6
+ use Elementor\Group_Control_Image_Size;
7
+ use Elementor\Utils;
8
+ use Elementor\Core\Schemes\Color as Scheme_Color;
9
+ use Elementor\Core\Schemes\Typography as Scheme_Typography;
10
+
11
+
12
+
13
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
14
+
15
+ /**
16
+ * Elementor Style for header
17
+ *
18
+ *
19
+ * @since 1.0.0
20
+ */
21
+
22
+ class void_cf7 extends Widget_Base {
23
+
24
+ // public function __construct( $data = [], $args = null ) {
25
+ // parent::__construct( $data, $args );
26
+ // $this->add_style_depends('void-cf7-elementor-js');
27
+ // $this->add_script_depends('void-cf7-elementor-css');
28
+ // }
29
+
30
+ //this name is added to plugin.php of the root folder
31
+
32
+ public function get_name() {
33
+ return 'void-section-cf7';
34
+ }
35
+
36
+ public function get_title() {
37
+ return 'Void Contact From 7'; // title to show on elementor
38
+ }
39
+
40
+ public function get_icon() {
41
+ return 'eicon-mail'; // eicon-posts-ticker-> eicon ow asche icon to show on elelmentor
42
+ }
43
+
44
+ public function get_categories() {
45
+ return [ 'void-elements' ]; // category of the widget
46
+ }
47
+ public function get_keywords()
48
+ {
49
+ return [
50
+ 'contact form',
51
+ 'form styler',
52
+ 'cf7',
53
+ 'void',
54
+ 'void contact form 7',
55
+ ];
56
+ }
57
+
58
+ public function is_reload_preview_required() {
59
+ return true;
60
+ }
61
+
62
+ /**
63
+ * A list of scripts that the widgets is depended in
64
+ * @since 1.3.0
65
+ **/
66
+ protected function register_controls() {
67
+
68
+ //start of a control box
69
+ $this->start_controls_section(
70
+ 'section_content',
71
+ [
72
+ 'label' => esc_html__( 'Contact Form 7', 'void' ), //section name for controler view
73
+ 'tab' => Controls_Manager::TAB_CONTENT,
74
+ ]
75
+ );
76
+
77
+ $this->add_control(
78
+ 'cf7',
79
+ [
80
+ 'label' => esc_html__( 'Select Contact Form', 'void' ),
81
+ 'description' => esc_html__('Contact form 7 - plugin must be installed and there must be some contact forms made with the contact form 7','void'),
82
+ 'type' => Controls_Manager::SELECT2,
83
+ 'multiple' => false,
84
+ 'label_block' => 1,
85
+ 'options' => get_contact_form_7_posts(),
86
+ ]
87
+ );
88
+
89
+ $this->add_control(
90
+ 'void_cf7_form_action_edit',
91
+ [
92
+ 'type' => \Elementor\Controls_Manager::RAW_HTML,
93
+ 'raw' => sprintf( '<a href="#" id="void-cf7-edit-form-btn" style="color:#d30c5c; float: right;">Edit form</a>', 'void' ),
94
+ 'content_classes' => 'void-cf7-edit-form-btn',
95
+ ]
96
+ );
97
+
98
+ $this->add_control(
99
+ 'void_cf7_form_action_add',
100
+ [
101
+ 'type' => \Elementor\Controls_Manager::RAW_HTML,
102
+ 'raw' => sprintf( '<a href="#" id="void-cf7-add-form-btn" style="color:#d30c5c; float: right;">+ Add new form</a>', 'void' ),
103
+ 'content_classes' => 'void-cf7-add-form-btn',
104
+ ]
105
+ );
106
+
107
+ $this->end_controls_section();
108
+
109
+ $this->start_controls_section(
110
+ 'section_stype',
111
+ [
112
+ 'label' => esc_html__( 'Advanced Style (legacy)', 'void' ), //section name for controler view
113
+ 'description' => esc_html__( 'This area is intended for developers who knows CSS or for users who already have used this feature before. You should move to Style tab and use given controls to do the style more easily', 'void' ),
114
+ 'tab' => Controls_Manager::TAB_CONTENT,
115
+ ]
116
+ );
117
+
118
+
119
+ $this->add_control(
120
+ 'vcf7_depri',
121
+ [
122
+ 'type' => \Elementor\Controls_Manager::RAW_HTML,
123
+ 'raw' => __('This area is intended for developers who knows CSS or for users who already have used this feature before. You should move to Style tab and use given controls to do the style more easily','void'),
124
+ 'content_classes' => 'elementor-panel-alert elementor-panel-alert-warning',
125
+ ]
126
+ );
127
+
128
+
129
+ $this->add_control(
130
+ 'cf7_direct_css',
131
+ [
132
+ 'label' => __( 'Global CSS For all fields', 'void' ),
133
+ 'description' => __( 'This is the global css for all fields of cf7. It will not effect the other fileds but if you want to define things such as color, background color use this.', 'void' ),
134
+ 'type' => Controls_Manager::TEXTAREA,
135
+ 'placeholder' => 'color:#000;',
136
+ 'selectors' => [
137
+ '{{WRAPPER}} ' => '{{VALUE}}',
138
+ ],
139
+ ]
140
+ );
141
+
142
+ $this->add_control(
143
+ 'alllabel',
144
+ [
145
+ 'label' => __( 'All Label CSS', 'void' ),
146
+ 'description' => __( 'Changes might not sometimes show in the live preview but check in the front end to see the changes.', 'void' ),
147
+ 'type' => Controls_Manager::TEXTAREA,
148
+ 'placeholder' => 'color:#fff;',
149
+ 'selectors' => [
150
+ '{{WRAPPER}} label' => '{{VALUE}}',
151
+ ],
152
+ ]
153
+ );
154
+ $this->add_control(
155
+ 'allinput',
156
+ [
157
+ 'label' => __( 'All Input CSS', 'void' ),
158
+ 'description' => __( 'Changes might not sometimes show in the live preview but check in the front end to see the changes.', 'void' ),
159
+ 'type' => Controls_Manager::TEXTAREA,
160
+ 'placeholder' => 'width:100%;
161
+ background:red;',
162
+ 'selectors' => [
163
+ '{{WRAPPER}} input' => 'height:auto;',
164
+ '{{WRAPPER}} input' => '{{VALUE}}',
165
+
166
+ ],
167
+ ]
168
+ );
169
+
170
+ $this->add_control(
171
+ 'textinput',
172
+ [
173
+ 'label' => __( 'Input Type Text CSS', 'void' ),
174
+ 'description' => __( 'Changes might not sometimes show in the live preview but check in the front end to see the changes.', 'void' ),
175
+ 'type' => Controls_Manager::TEXTAREA,
176
+ 'placeholder' => 'width:100%;
177
+ background:red;',
178
+ 'selectors' => [
179
+ '{{WRAPPER}} .wpcf7-text' => 'height:auto;',
180
+ '{{WRAPPER}} .wpcf7-text' => '{{VALUE}}',
181
+ ],
182
+ ]
183
+ );
184
+ $this->add_control(
185
+ 'textarea',
186
+ [
187
+ 'label' => __( 'Textarea CSS', 'void' ),
188
+ 'description' => __( 'Changes might not sometimes show in the live preview but check in the front end to see the changes.', 'void' ),
189
+ 'type' => Controls_Manager::TEXTAREA,
190
+ 'placeholder' => 'height:100px;
191
+ width:100%;',
192
+ 'selectors' => [
193
+ '{{WRAPPER}} textarea' => 'height:auto;',
194
+ '{{WRAPPER}} textarea' => '{{VALUE}}',
195
+ ],
196
+ ]
197
+ );
198
+
199
+ $this->add_control(
200
+ 'checkbox',
201
+ [
202
+ 'label' => __( 'Checkbox/ Radio CSS', 'void' ),
203
+ 'type' => Controls_Manager::TEXTAREA,
204
+ 'placeholder' => 'display: block;',
205
+ 'selectors' => [
206
+ '{{WRAPPER}} .wpcf7-list-item' => '{{VALUE}}',
207
+ ],
208
+ ]
209
+ );
210
+
211
+ $this->add_control(
212
+ 'selectcss',
213
+ [
214
+ 'label' => __( 'Dropdown/ Select Box css', 'void' ),
215
+ 'type' => Controls_Manager::TEXTAREA,
216
+ 'placeholder' => 'width: 100;',
217
+ 'selectors' => [
218
+ '{{WRAPPER}} select' => '{{VALUE}}',
219
+ ],
220
+ ]
221
+ );
222
+ $this->add_control(
223
+ 'selectoptionscss',
224
+ [
225
+ 'label' => __( 'Select Options Css', 'void' ),
226
+ 'type' => Controls_Manager::TEXTAREA,
227
+ 'placeholder' => 'color: red;',
228
+ 'selectors' => [
229
+ '{{WRAPPER}} select option' => '{{VALUE}}',
230
+ ],
231
+ ]
232
+ );
233
+
234
+ $this->add_control(
235
+ 'file',
236
+ [
237
+ 'label' => __( 'File CSS', 'void' ),
238
+ 'type' => Controls_Manager::TEXTAREA,
239
+ 'placeholder' => 'display: block;',
240
+ 'selectors' => [
241
+ '{{WRAPPER}} input[type="file"]' => '{{VALUE}}',
242
+ ],
243
+ ]
244
+ );
245
+ $this->add_control(
246
+ 'date',
247
+ [
248
+ 'label' => __( 'Date CSS', 'void' ),
249
+ 'type' => Controls_Manager::TEXTAREA,
250
+ 'placeholder' => 'display: block;',
251
+ 'selectors' => [
252
+ '{{WRAPPER}} .wpcf7-date' => '{{VALUE}}',
253
+ ],
254
+ ]
255
+ );
256
+ $this->add_control(
257
+ 'inputsubmit',
258
+ [
259
+ 'label' => __( 'Submit Button CSS', 'void' ),
260
+ 'description' => __( 'Changes might not sometimes show in the live preview but check in the front end to see the changes.', 'void' ),
261
+ 'type' => Controls_Manager::TEXTAREA,
262
+ 'placeholder' => 'width:100%;
263
+ background:red;',
264
+ 'selectors' => [
265
+ '{{WRAPPER}} input[type="submit"]' => '{{VALUE}}',
266
+ ],
267
+ ]
268
+ );
269
+ $this->add_control(
270
+ 'inputsubmithover',
271
+ [
272
+ 'label' => __( 'Submit Button Hover CSS', 'void' ),
273
+ 'type' => Controls_Manager::TEXTAREA,
274
+ 'placeholder' => 'background:#fff;',
275
+ 'selectors' => [
276
+ '{{WRAPPER}} input[type="submit"]:hover' => '{{VALUE}}',
277
+ ],
278
+ ]
279
+ );
280
+
281
+ $this->add_control(
282
+ 'responce',
283
+ [
284
+ 'label' => __( 'Responce CSS', 'void' ),
285
+ 'type' => Controls_Manager::TEXTAREA,
286
+ 'placeholder' => 'color:red;',
287
+ 'selectors' => [
288
+ '{{WRAPPER}} .wpcf7-response-output' => '{{VALUE}}',
289
+ ],
290
+ ]
291
+ );
292
+
293
+
294
+ $this->end_controls_section();
295
+
296
+
297
+
298
+ $this->start_controls_section(
299
+ 'section_redirect',
300
+ [
301
+ 'label' => esc_html__( 'After Submit Redirect Setting', 'void' ), //section name for controler view
302
+ 'tab' => Controls_Manager::TAB_CONTENT,
303
+ ]
304
+ );
305
+
306
+ $this->add_control(
307
+ 'cf7_redirect_external',
308
+ [
309
+ 'label' => __( 'On Success External URL Redirect', 'void' ),
310
+ 'description' => esc_html__('Insert the external URL where you want users to redirect to when the contact form is submitted and is successful. Leave Blank to Disable','void'),
311
+ 'type' => \Elementor\Controls_Manager::TEXT,
312
+ 'placeholder' => __( 'https://voidcoders.com', 'void' ),
313
+ 'label_block' => 1,
314
+ ]
315
+ );
316
+
317
+ $this->add_control(
318
+ 'cf7_redirect_page',
319
+ [
320
+ 'label' => esc_html__( 'On Success Internal Redirect', 'void' ),
321
+ 'description' => esc_html__('Select a page within the site which you want users to redirect to when the contact form is submitted and is successful. Leave Blank to Disable','void'),
322
+ 'type' => Controls_Manager::SELECT2,
323
+ 'multiple' => false,
324
+ 'label_block' => 1,
325
+ 'options' => void_get_all_pages(),
326
+ 'condition' =>
327
+ [
328
+ 'cf7_redirect_external' => '',
329
+ ],
330
+ ]
331
+ );
332
+
333
+
334
+ $this->end_controls_section();
335
+
336
+ $this->start_controls_section(
337
+ 'vcf7_section_email',
338
+ [
339
+ 'label' => esc_html__( 'Design Email', 'void' ), //section name for controler view
340
+ 'tab' => Controls_Manager::TAB_CONTENT,
341
+ ]
342
+ );
343
+
344
+ $this->add_control(
345
+ 'vcf7_elemailer_promo',
346
+ [
347
+ 'type' => \Elementor\Controls_Manager::RAW_HTML,
348
+ 'raw' => 'Drag & Drop Elementor Email builder for contact form 7 for free with <a target="_blank" href="https://elemailer.com/now-you-can-edit-your-contact-form-7-email-using-elementor/">Elemailer Lite </a><br><br>
349
+ ✨Elemailer Gives you more✨ <br><br>
350
+ <ul>
351
+ <li>🔥Subscriber</li>
352
+ <li>🔥Campaign</li>
353
+ <li>🔥Lists</li>
354
+ <li>🔥Woocommerce emails(coming..)</li>
355
+ <li>🔥Campaign</li>
356
+ <li>🔥Welcome emails</li>
357
+ <li>🔥Many more..</li>
358
+ </ul><br>
359
+ <a target="_blank" href="https://elemailer.com?utm_source=site&utm_medium=editor&utm_campaign=editor_inside&utm_id=cf7elemailer"><img src="https://elemailer.com/wp-content/uploads/2021/11/element_02.png"></a>. <br>',
360
+ ]
361
+ );
362
+
363
+
364
+ $this->end_controls_section();
365
+
366
+
367
+ // Our style tab
368
+ $this->start_controls_section(
369
+ 'vcf7_form_section_style',
370
+ [
371
+ 'label' => __( 'General Style', 'void' ),
372
+ 'tab' => Controls_Manager::TAB_STYLE,
373
+ ]
374
+ );
375
+
376
+
377
+ $this->add_responsive_control(
378
+ 'vcf7_form_section_align',
379
+ [
380
+ 'label' => __( 'Alignment', 'void' ),
381
+ 'type' => Controls_Manager::CHOOSE,
382
+ 'options' => [
383
+ 'left' => [
384
+ 'title' => __( 'Left', 'void' ),
385
+ 'icon' => 'eicon-text-align-left',
386
+ ],
387
+ 'center' => [
388
+ 'title' => __( 'Center', 'void' ),
389
+ 'icon' => 'eicon-text-align-center',
390
+ ],
391
+ 'right' => [
392
+ 'title' => __( 'Right', 'void' ),
393
+ 'icon' => 'eicon-text-align-right',
394
+ ],
395
+ 'justify' => [
396
+ 'title' => __( 'Justified', 'void' ),
397
+ 'icon' => 'eicon-text-align-justify',
398
+ ],
399
+ ],
400
+ 'selectors' => [
401
+ '{{WRAPPER}}' => 'text-align: {{VALUE}};',
402
+ ],
403
+ 'separator' =>'before',
404
+ ]
405
+ );
406
+
407
+ $this->end_controls_section();
408
+
409
+ // Input Field style tab start
410
+ $this->start_controls_section(
411
+ 'vcf7_vcf7_input_style',
412
+ [
413
+ 'label' => __( 'Input', 'void' ),
414
+ 'tab' => Controls_Manager::TAB_STYLE,
415
+ ]
416
+ );
417
+
418
+
419
+ $this->start_controls_tabs('input_style_tabs'); //start input area Normal/focus tabs
420
+
421
+ // Input Normal tab start
422
+ $this->start_controls_tab(
423
+ 'input_style_normal_tab',
424
+ [
425
+ 'label' => __( 'Normal', 'void' ),
426
+ ]
427
+ );
428
+
429
+ $this->add_responsive_control(
430
+ 'vcf7_input_box_height',
431
+ [
432
+ 'label' => __( 'Height', 'void' ),
433
+ 'type' => Controls_Manager::SLIDER,
434
+ 'size_units' => [ 'px', 'vh', 'vw' ],
435
+ 'range' => [
436
+ 'px' => [
437
+ 'max' => 400,
438
+ ],
439
+ ],
440
+
441
+
442
+ 'selectors' => [
443
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"]' => 'height: {{SIZE}}{{UNIT}};',
444
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"]' => 'height: {{SIZE}}{{UNIT}};',
445
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"]' => 'height: {{SIZE}}{{UNIT}};',
446
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"]' => 'height: {{SIZE}}{{UNIT}};',
447
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"]' => 'height: {{SIZE}}{{UNIT}};',
448
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"]' => 'height: {{SIZE}}{{UNIT}};',
449
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap .wpcf7-select' => 'height: {{SIZE}}{{UNIT}};',
450
+ ],
451
+ ]
452
+ );
453
+
454
+ $this->add_responsive_control(
455
+ 'vcf7_input_box_width',
456
+ [
457
+ 'label' => __( 'Width', 'void' ),
458
+ 'type' => Controls_Manager::SLIDER,
459
+ 'size_units' => [ 'px', 'vw', 'vh' ],
460
+ 'range' => [
461
+ 'px' => [
462
+ 'max' => 2000,
463
+ ],
464
+ ],
465
+
466
+
467
+ 'selectors' => [
468
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"]' => 'width: {{SIZE}}{{UNIT}};',
469
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"]' => 'width: {{SIZE}}{{UNIT}};',
470
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"]' => 'width: {{SIZE}}{{UNIT}};',
471
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"]' => 'width: {{SIZE}}{{UNIT}};',
472
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"]' => 'width: {{SIZE}}{{UNIT}};',
473
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"]' => 'width: {{SIZE}}{{UNIT}};',
474
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap .wpcf7-select' => 'width: {{SIZE}}{{UNIT}};',
475
+ ],
476
+ ]
477
+ );
478
+
479
+ $this->add_group_control(
480
+ \Elementor\Group_Control_Background::get_type(),
481
+ [
482
+ 'name' => 'vcf7_input_box_bg_grd',
483
+ 'types' => [ 'classic', 'gradient'],
484
+ 'label' => esc_html__( 'Background', 'void' ),
485
+ 'selector' =>
486
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"],
487
+ {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"],
488
+ {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"],
489
+ {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"],
490
+ {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"],
491
+ {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"],
492
+ {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap .wpcf7-select',
493
+
494
+ ]
495
+ );
496
+
497
+ $this->add_control(
498
+ 'vcf7_input_box_text_color',
499
+ [
500
+ 'label' => __( 'Text Color', 'void' ),
501
+ 'type' => Controls_Manager::COLOR,
502
+ 'selectors' => [
503
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"]' => 'color: {{VALUE}};',
504
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"]' => 'color: {{VALUE}};',
505
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"]' => 'color: {{VALUE}};',
506
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"]' => 'color: {{VALUE}};',
507
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"]' => 'color: {{VALUE}};',
508
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"]' => 'color: {{VALUE}};',
509
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap .wpcf7-select' => 'color: {{VALUE}};',
510
+ ],
511
+ ]
512
+ );
513
+
514
+ $this->add_group_control(
515
+ \Elementor\Group_Control_Border::get_type(),
516
+ [
517
+ 'name' => 'vcf7_input_box_border',
518
+ 'label' => __( 'Border', 'void' ),
519
+ 'selector' => '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"], {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"], {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"], {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"], {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"], {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"], {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap .wpcf7-select',
520
+ ]
521
+ );
522
+
523
+ $this->add_responsive_control(
524
+ 'vcf7_input_box_border_radius',
525
+ [
526
+ 'label' => __( 'Border Radius', 'void' ),
527
+ 'type' => Controls_Manager::DIMENSIONS,
528
+ 'selectors' => [
529
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"]' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
530
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"]' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
531
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"]' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
532
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"]' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
533
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"]' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
534
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"]' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
535
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap .wpcf7-select' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
536
+ ],
537
+ 'separator' =>'after',
538
+ ]
539
+ );
540
+
541
+ $this->end_controls_tab(); // input Normal tab end
542
+
543
+ // Input Focus tab start
544
+ $this->start_controls_tab(
545
+ 'input_style_focus_tab',
546
+ [
547
+ 'label' => __( 'Focus', 'void' ),
548
+ ]
549
+ );
550
+
551
+ $this->add_responsive_control(
552
+ 'vcf7_input_box_height_f',
553
+ [
554
+ 'label' => __( 'Height', 'void' ),
555
+ 'type' => Controls_Manager::SLIDER,
556
+ 'size_units' => [ 'px', 'vh', 'vw' ],
557
+ 'range' => [
558
+ 'px' => [
559
+ 'max' => 400,
560
+ ],
561
+ ],
562
+
563
+
564
+ 'selectors' => [
565
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"]:focus' => 'height: {{SIZE}}{{UNIT}};',
566
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"]:focus' => 'height: {{SIZE}}{{UNIT}};',
567
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"]:focus' => 'height: {{SIZE}}{{UNIT}};',
568
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"]:focus' => 'height: {{SIZE}}{{UNIT}};',
569
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"]:focus' => 'height: {{SIZE}}{{UNIT}};',
570
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"]:focus' => 'height: {{SIZE}}{{UNIT}};',
571
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap .wpcf7-select:focus' => 'height: {{SIZE}}{{UNIT}};',
572
+ ],
573
+ ]
574
+ );
575
+
576
+ $this->add_responsive_control(
577
+ 'vcf7_input_box_width_f',
578
+ [
579
+ 'label' => __( 'Width', 'void' ),
580
+ 'type' => Controls_Manager::SLIDER,
581
+ 'size_units' => [ 'px', 'vw', 'vh' ],
582
+ 'range' => [
583
+ 'px' => [
584
+ 'max' => 2000,
585
+ ],
586
+ ],
587
+
588
+
589
+ 'selectors' => [
590
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"]:focus' => 'width: {{SIZE}}{{UNIT}};',
591
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"]:focus' => 'width: {{SIZE}}{{UNIT}};',
592
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"]:focus' => 'width: {{SIZE}}{{UNIT}};',
593
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"]:focus' => 'width: {{SIZE}}{{UNIT}};',
594
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"]:focus' => 'width: {{SIZE}}{{UNIT}};',
595
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"]:focus' => 'width: {{SIZE}}{{UNIT}};',
596
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap .wpcf7-select:focus' => 'width: {{SIZE}}{{UNIT}};',
597
+ ],
598
+ ]
599
+ );
600
+
601
+ $this->add_group_control(
602
+ \Elementor\Group_Control_Background::get_type(),
603
+ [
604
+ 'name' => 'vcf7_input_box_bg_grd_f',
605
+ 'types' => [ 'classic', 'gradient'],
606
+ 'label' => esc_html__( 'Background', 'plugin-name' ),
607
+ 'selector' =>
608
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"]:focus,
609
+ {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"]:focus,
610
+ {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"]:focus,
611
+ {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"]:focus,
612
+ {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"]:focus,
613
+ {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"]:focus,
614
+ {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap .wpcf7-select:focus',
615
+
616
+ ]
617
+ );
618
+
619
+ $this->add_control(
620
+ 'vcf7_input_box_text_color_f',
621
+ [
622
+ 'label' => __( 'Text Color', 'void' ),
623
+ 'type' => Controls_Manager::COLOR,
624
+ 'selectors' => [
625
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"]:focus' => 'color: {{VALUE}};',
626
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"]:focus' => 'color: {{VALUE}};',
627
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"]:focus' => 'color: {{VALUE}};',
628
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"]:focus' => 'color: {{VALUE}};',
629
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"]:focus' => 'color: {{VALUE}};',
630
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"]:focus' => 'color: {{VALUE}};',
631
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap .wpcf7-select:focus' => 'color: {{VALUE}};',
632
+ ],
633
+ ]
634
+ );
635
+
636
+ $this->add_group_control(
637
+ \Elementor\Group_Control_Border::get_type(),
638
+ [
639
+ 'name' => 'vcf7_input_box_border_f',
640
+ 'label' => __( 'Border', 'void' ),
641
+ 'selector' => '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"]:focus, {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"]:focus, {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"]:focus, {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"]:focus, {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"]:focus, {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"]:focus, {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap .wpcf7-select:focus',
642
+ ]
643
+ );
644
+
645
+ $this->add_responsive_control(
646
+ 'vcf7_input_box_border_radius_f',
647
+ [
648
+ 'label' => __( 'Border Radius', 'void' ),
649
+ 'type' => Controls_Manager::DIMENSIONS,
650
+ 'selectors' => [
651
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"]:focus' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
652
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"]:focus' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
653
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"]:focus' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
654
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"]:focus' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
655
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"]:focus' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
656
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"]:focus' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
657
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap .wpcf7-select:focus' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
658
+ ],
659
+ ]
660
+ );
661
+
662
+ $this->add_control(
663
+ 'vcf7_input_transition',
664
+ [
665
+ 'label' => __( 'Transition Control', 'void' ),
666
+ 'type' => Controls_Manager::TEXT,
667
+ 'placeholder' => 'width .35s ease-in-out',
668
+ 'description' => __( 'input your desired transition effect for focus. Remember one single line can set all types of transition values. <a target="_blank" href="https://css-tricks.com/almanac/properties/t/transition/">Example</a>', 'void' ),
669
+ 'selectors' => [
670
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"], {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"], {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"], {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"], {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"], {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"], {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap .wpcf7-select' =>'transition:{{VALUE}};-webkit-transition:{{VALUE}};-o-transition:{{VALUE}}',
671
+
672
+
673
+ ],
674
+ 'separator' =>'after',
675
+
676
+ ]
677
+ );
678
+
679
+ $this->end_controls_tab(); // input Focus tab end
680
+
681
+ $this->end_controls_tabs(); // end text area Normal/focus tabs
682
+
683
+
684
+ $this->add_group_control(
685
+ \Elementor\Group_Control_Typography::get_type(),
686
+ [
687
+ 'name' => 'vcf7_input_box_typography',
688
+
689
+ 'selector' => '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"], {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"], {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"], {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"], {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"], {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"], {{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap .wpcf7-select',
690
+ ]
691
+ );
692
+
693
+
694
+ $this->add_control(
695
+ 'vcf7_input_box_placeholder_color',
696
+ [
697
+ 'label' => __( 'Placeholder Color', 'void' ),
698
+ 'type' => Controls_Manager::COLOR,
699
+ 'selectors' => [
700
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"]::-webkit-input-placeholder' => 'color: {{VALUE}};',
701
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"]::-moz-placeholder' => 'color: {{VALUE}};',
702
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"]:-ms-input-placeholder' => 'color: {{VALUE}};',
703
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"]::-webkit-input-placeholder' => 'color: {{VALUE}};',
704
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"]::-moz-placeholder' => 'color: {{VALUE}};',
705
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"]:-ms-input-placeholder' => 'color: {{VALUE}};',
706
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"]::-webkit-input-placeholder' => 'color: {{VALUE}};',
707
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"]::-moz-placeholder' => 'color: {{VALUE}};',
708
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"]:-ms-input-placeholder' => 'color: {{VALUE}};',
709
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"]::-webkit-input-placeholder' => 'color: {{VALUE}};',
710
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"]::-moz-placeholder' => 'color: {{VALUE}};',
711
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"]:-ms-input-placeholder' => 'color: {{VALUE}};',
712
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"]::-webkit-input-placeholder' => 'color: {{VALUE}};',
713
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"]::-moz-placeholder' => 'color: {{VALUE}};',
714
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"]:-ms-input-placeholder' => 'color: {{VALUE}};',
715
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"]::-webkit-input-placeholder' => 'color: {{VALUE}};',
716
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"]::-moz-placeholder' => 'color: {{VALUE}};',
717
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"]:-ms-input-placeholder' => 'color: {{VALUE}};',
718
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap .wpcf7-select' => 'color: {{VALUE}};',
719
+ ],
720
+ ]
721
+ );
722
+
723
+
724
+ $this->add_responsive_control(
725
+ 'vcf7_input_box_padding',
726
+ [
727
+ 'label' => __( 'Padding', 'void' ),
728
+ 'type' => Controls_Manager::DIMENSIONS,
729
+ 'size_units' => [ 'px', '%', 'em' ],
730
+ 'selectors' => [
731
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"]' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
732
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"]' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
733
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"]' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
734
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"]' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
735
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"]' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
736
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"]' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
737
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap .wpcf7-select' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
738
+ ],
739
+ 'separator' =>'before',
740
+ ]
741
+ );
742
+
743
+ $this->add_responsive_control(
744
+ 'vcf7_input_box_margin',
745
+ [
746
+ 'label' => __( 'Margin', 'void' ),
747
+ 'type' => Controls_Manager::DIMENSIONS,
748
+ 'size_units' => [ 'px', '%', 'em' ],
749
+ 'selectors' => [
750
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="text"]' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
751
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="email"]' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
752
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="url"]' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
753
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="number"]' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
754
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="tel"]' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
755
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap input[type*="date"]' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
756
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap .wpcf7-select' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
757
+ ],
758
+ 'separator' =>'before',
759
+ ]
760
+ );
761
+
762
+ $this->end_controls_section(); // Input Field style tab end
763
+
764
+ // Textarea style tab start
765
+ $this->start_controls_section(
766
+ 'vcf7_textarea_style',
767
+ [
768
+ 'label' => __( 'Textarea', 'void' ),
769
+ 'tab' => Controls_Manager::TAB_STYLE,
770
+ ]
771
+ );
772
+
773
+ $this->start_controls_tabs('textarea_style_tabs'); //start text area Normal/focus tabs
774
+
775
+ // Input Normal tab start
776
+ $this->start_controls_tab(
777
+ 'text_normal_tab',
778
+ [
779
+ 'label' => __( 'Normal', 'void' ),
780
+ ]
781
+ );
782
+
783
+ $this->add_responsive_control(
784
+ 'vcf7_textarea_box_height',
785
+ [
786
+ 'label' => __( 'Height', 'void' ),
787
+ 'type' => Controls_Manager::SLIDER,
788
+ 'size_units' => [ 'px', 'vh', 'vw' ],
789
+ 'range' => [
790
+ 'px' => [
791
+ 'max' => 900,
792
+ ],
793
+ ],
794
+
795
+ 'selectors' => [
796
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea' => 'height: {{SIZE}}{{UNIT}};',
797
+ ],
798
+ ]
799
+ );
800
+ $this->add_responsive_control(
801
+ 'vcf7_textarea_box_width',
802
+ [
803
+ 'label' => __( 'Width', 'void' ),
804
+ 'type' => Controls_Manager::SLIDER,
805
+ 'size_units' => [ 'px', 'vw', 'vh' ],
806
+ 'range' => [
807
+ 'px' => [
808
+ 'max' => 2000,
809
+ ],
810
+ ],
811
+
812
+ 'selectors' => [
813
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea' => 'width: {{SIZE}}{{UNIT}};',
814
+ ],
815
+ ]
816
+
817
+ );
818
+
819
+ $this->add_group_control(
820
+ \Elementor\Group_Control_Background::get_type(),
821
+ [
822
+ 'name' => 'vcf7_textarea_box_bg_grd',
823
+ 'types' => [ 'classic', 'gradient'],
824
+ 'label' => esc_html__( 'Background', 'void' ),
825
+ 'selector' =>
826
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea',
827
+ ]
828
+
829
+ );
830
+
831
+ $this->add_control(
832
+ 'vcf7_textarea_box_text_color',
833
+ [
834
+ 'label' => __( 'Text Color', 'void' ),
835
+ 'type' => Controls_Manager::COLOR,
836
+ 'selectors' => [
837
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea' => 'color: {{VALUE}};',
838
+ ],
839
+ ]
840
+ );
841
+
842
+ $this->add_group_control(
843
+ \Elementor\Group_Control_Border::get_type(),
844
+ [
845
+ 'name' => 'vcf7_textarea_box_border',
846
+ 'label' => __( 'Border', 'void' ),
847
+ 'selector' => '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea',
848
+ ]
849
+ );
850
+
851
+ $this->add_responsive_control(
852
+ 'vcf7_textarea_box_border_radius',
853
+ [
854
+ 'label' => __( 'Border Radius', 'void' ),
855
+ 'type' => Controls_Manager::DIMENSIONS,
856
+ 'selectors' => [
857
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
858
+ ],
859
+ 'separator' =>'after',
860
+ ]
861
+ );
862
+
863
+
864
+ $this->end_controls_tab(); // Textarea Normal tab end
865
+
866
+
867
+ // Input Focus tab start
868
+ $this->start_controls_tab(
869
+ 'text_focus_tab',
870
+ [
871
+ 'label' => __( 'Focus', 'void' ),
872
+ ]
873
+ );
874
+ $this->add_responsive_control(
875
+ 'vcf7_textarea_box_height_f',
876
+ [
877
+ 'label' => __( 'Height', 'void' ),
878
+ 'type' => Controls_Manager::SLIDER,
879
+ 'size_units' => [ 'px', 'vh', 'vw' ],
880
+ 'range' => [
881
+ 'px' => [
882
+ 'max' => 900,
883
+ ],
884
+ ],
885
+
886
+ 'selectors' => [
887
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea:focus' => 'height: {{SIZE}}{{UNIT}};',
888
+ ],
889
+ ]
890
+ );
891
+ $this->add_responsive_control(
892
+ 'vcf7_textarea_box_width_f',
893
+ [
894
+ 'label' => __( 'Width', 'void' ),
895
+ 'type' => Controls_Manager::SLIDER,
896
+ 'size_units' => [ 'px', 'vw', 'vh' ],
897
+ 'range' => [
898
+ 'px' => [
899
+ 'max' => 2000,
900
+ ],
901
+ ],
902
+
903
+ 'selectors' => [
904
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea:focus' => 'width: {{SIZE}}{{UNIT}};',
905
+ ],
906
+ ]
907
+
908
+ );
909
+
910
+ $this->add_group_control(
911
+ \Elementor\Group_Control_Background::get_type(),
912
+ [
913
+ 'name' => 'vcf7_textarea_box_bg_grd_f',
914
+ 'types' => [ 'classic', 'gradient'],
915
+ 'label' => esc_html__( 'Background', 'void' ),
916
+ 'selector' =>
917
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea:focus',
918
+ ]
919
+
920
+ );
921
+
922
+ $this->add_control(
923
+ 'vcf7_textarea_box_text_color_f',
924
+ [
925
+ 'label' => __( 'Text Color', 'void' ),
926
+ 'type' => Controls_Manager::COLOR,
927
+ 'selectors' => [
928
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea:focus' => 'color: {{VALUE}};',
929
+ ],
930
+ ]
931
+ );
932
+
933
+ $this->add_group_control(
934
+ \Elementor\Group_Control_Border::get_type(),
935
+ [
936
+ 'name' => 'vcf7_textarea_box_border_f',
937
+ 'label' => __( 'Border', 'void' ),
938
+ 'selector' => '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea:focus',
939
+ ]
940
+ );
941
+
942
+ $this->add_responsive_control(
943
+ 'vcf7_textarea_box_border_radius_f',
944
+ [
945
+ 'label' => __( 'Border Radius', 'void' ),
946
+ 'type' => Controls_Manager::DIMENSIONS,
947
+ 'selectors' => [
948
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea:focus' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
949
+ ],
950
+ 'separator' =>'after',
951
+ ]
952
+ );
953
+
954
+ $this->add_control(
955
+ 'vcf7_textarea_transition',
956
+ [
957
+ 'label' => __( 'Transition Control', 'void' ),
958
+ 'type' => Controls_Manager::TEXT,
959
+ 'placeholder' => 'width .35s ease-in-out',
960
+ 'description' => __( 'input your desired transition effect for focus. Remember one single line can set all types of transition values. <a target="_blank" href="https://css-tricks.com/almanac/properties/t/transition/">Example</a>', 'void' ),
961
+ 'selectors' => [
962
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea' =>'transition:{{VALUE}};-webkit-transition:{{VALUE}}',
963
+
964
+
965
+ ],
966
+ 'separator' =>'after',
967
+
968
+ ]
969
+ );
970
+
971
+ $this->end_controls_tab(); // Textarea Focus tab end
972
+
973
+ $this->end_controls_tabs(); //end text area Normal/focus tabs
974
+
975
+
976
+ $this->add_group_control(
977
+ \Elementor\Group_Control_Typography::get_type(),
978
+ [
979
+ 'name' => 'vcf7_textarea_box_typography',
980
+ 'selector' => '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea',
981
+ ]
982
+ );
983
+
984
+
985
+
986
+ $this->add_control(
987
+ 'vcf7_textarea_box_placeholder_color',
988
+ [
989
+ 'label' => __( 'Placeholder Color', 'void' ),
990
+ 'type' => Controls_Manager::COLOR,
991
+ 'selectors' => [
992
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea::-webkit-input-placeholder' => 'color: {{VALUE}};',
993
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea::-moz-placeholder' => 'color: {{VALUE}};',
994
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea:-ms-input-placeholder' => 'color: {{VALUE}};',
995
+ ],
996
+ ]
997
+ );
998
+
999
+
1000
+ $this->add_responsive_control(
1001
+ 'vcf7_textarea_box_padding',
1002
+ [
1003
+ 'label' => __( 'Padding', 'void' ),
1004
+ 'type' => Controls_Manager::DIMENSIONS,
1005
+ 'size_units' => [ 'px', '%', 'em' ],
1006
+ 'selectors' => [
1007
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1008
+ ],
1009
+ 'separator' =>'before',
1010
+ ]
1011
+ );
1012
+
1013
+ $this->add_responsive_control(
1014
+ 'vcf7_textarea_box_margin',
1015
+ [
1016
+ 'label' => __( 'Margin', 'void' ),
1017
+ 'type' => Controls_Manager::DIMENSIONS,
1018
+ 'size_units' => [ 'px', '%', 'em' ],
1019
+ 'selectors' => [
1020
+ '{{WRAPPER}} .wpcf7-form .wpcf7-form-control-wrap textarea' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1021
+ ],
1022
+ 'separator' =>'before',
1023
+ ]
1024
+ );
1025
+
1026
+ $this->end_controls_section(); // Textarea style tab end
1027
+
1028
+ // Label style tab start
1029
+ $this->start_controls_section(
1030
+ 'vcf7_cf7_label_style',
1031
+ [
1032
+ 'label' => __( 'Label', 'void' ),
1033
+ 'tab' => Controls_Manager::TAB_STYLE,
1034
+ ]
1035
+ );
1036
+
1037
+ $this->add_control(
1038
+ 'vcf7_label_background',
1039
+ [
1040
+ 'label' => __( 'Background Color', 'void' ),
1041
+ 'type' => Controls_Manager::COLOR,
1042
+ 'selectors' => [
1043
+ '{{WRAPPER}} form.wpcf7-form label' => 'background-color: {{VALUE}};',
1044
+ ],
1045
+ ]
1046
+ );
1047
+
1048
+ $this->add_control(
1049
+ 'vcf7_label_text_color',
1050
+ [
1051
+ 'label' => __( 'Text Color', 'void' ),
1052
+ 'type' => Controls_Manager::COLOR,
1053
+ 'selectors' => [
1054
+ '{{WRAPPER}} form.wpcf7-form label' => 'color: {{VALUE}};',
1055
+ ],
1056
+ ]
1057
+ );
1058
+
1059
+ $this->add_group_control(
1060
+ \Elementor\Group_Control_Typography::get_type(),
1061
+ [
1062
+ 'name' => 'vcf7_label_typography',
1063
+ 'selector' => '{{WRAPPER}} form.wpcf7-form label',
1064
+ ]
1065
+ );
1066
+
1067
+ $this->add_group_control(
1068
+ \Elementor\Group_Control_Border::get_type(),
1069
+ [
1070
+ 'name' => 'vcf7_label_border',
1071
+ 'label' => __( 'Border', 'void' ),
1072
+ 'selector' => '{{WRAPPER}} form.wpcf7-form label',
1073
+ ]
1074
+ );
1075
+
1076
+ $this->add_responsive_control(
1077
+ 'vcf7_label_border_radius',
1078
+ [
1079
+ 'label' => __( 'Border Radius', 'void' ),
1080
+ 'type' => Controls_Manager::DIMENSIONS,
1081
+ 'selectors' => [
1082
+ '{{WRAPPER}} form.wpcf7-form label' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
1083
+ ],
1084
+ 'separator' =>'before',
1085
+ ]
1086
+ );
1087
+
1088
+ $this->add_responsive_control(
1089
+ 'vcf7_label_padding',
1090
+ [
1091
+ 'label' => __( 'Padding', 'void' ),
1092
+ 'type' => Controls_Manager::DIMENSIONS,
1093
+ 'size_units' => [ 'px', '%', 'em' ],
1094
+ 'selectors' => [
1095
+ '{{WRAPPER}} form.wpcf7-form label' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1096
+ ],
1097
+ 'separator' =>'before',
1098
+ ]
1099
+ );
1100
+
1101
+ $this->add_responsive_control(
1102
+ 'vcf7_label_margin',
1103
+ [
1104
+ 'label' => __( 'Margin', 'void' ),
1105
+ 'type' => Controls_Manager::DIMENSIONS,
1106
+ 'size_units' => [ 'px', '%', 'em' ],
1107
+ 'selectors' => [
1108
+ '{{WRAPPER}} form.wpcf7-form label' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1109
+ ],
1110
+ 'separator' =>'before',
1111
+ ]
1112
+ );
1113
+
1114
+ $this->end_controls_section(); //
1115
+ // Label style tab end
1116
+
1117
+ // Input submit button style tab start
1118
+ $this->start_controls_section(
1119
+ 'vcf7_inputsubmit_style',
1120
+ [
1121
+ 'label' => __( 'Button', 'void' ),
1122
+ 'tab' => Controls_Manager::TAB_STYLE,
1123
+ ]
1124
+ );
1125
+
1126
+
1127
+ $this->add_responsive_control(
1128
+ 'vcf7_button_text_align',
1129
+ [
1130
+ 'label' => __( 'Text Alignment', 'void' ),
1131
+ 'type' => Controls_Manager::CHOOSE,
1132
+ 'options' => [
1133
+ 'left' => [
1134
+ 'title' => __( 'Left', 'void' ),
1135
+ 'icon' => 'eicon-text-align-left',
1136
+ ],
1137
+ 'center' => [
1138
+ 'title' => __( 'Center', 'void' ),
1139
+ 'icon' => 'eicon-text-align-center',
1140
+ ],
1141
+ 'right' => [
1142
+ 'title' => __( 'Right', 'void' ),
1143
+ 'icon' => 'eicon-text-align-right',
1144
+ ],
1145
+ 'justify' => [
1146
+ 'title' => __( 'Justified', 'void' ),
1147
+ 'icon' => 'eicon-text-align-justify',
1148
+ ],
1149
+ ],
1150
+ 'selectors' => [
1151
+ '{{WRAPPER}} .wpcf7-form input[type=submit]' => 'text-align: {{VALUE}};',
1152
+ ],
1153
+ 'separator' =>'before',
1154
+ ]
1155
+ );
1156
+
1157
+
1158
+ $this->add_responsive_control(
1159
+ 'vcf7_button_align',
1160
+ [
1161
+ 'label' => __( 'Button Float', 'void' ),
1162
+ 'type' => Controls_Manager::CHOOSE,
1163
+ 'options' => [
1164
+ 'left' => [
1165
+ 'title' => __( 'Left', 'void' ),
1166
+ 'icon' => 'eicon-text-align-left',
1167
+ ],
1168
+
1169
+ 'right' => [
1170
+ 'title' => __( 'Right', 'void' ),
1171
+ 'icon' => 'eicon-text-align-right',
1172
+ ],
1173
+ ],
1174
+ 'selectors' => [
1175
+ '{{WRAPPER}} .wpcf7-form input[type=submit]' => 'float: {{VALUE}};',
1176
+ ],
1177
+ 'separator' =>'after',
1178
+ ]
1179
+ );
1180
+
1181
+ $this->start_controls_tabs('submit_style_tabs');
1182
+
1183
+ // Button Normal tab start
1184
+ $this->start_controls_tab(
1185
+ 'submit_style_normal_tab',
1186
+ [
1187
+ 'label' => __( 'Normal', 'void' ),
1188
+ ]
1189
+ );
1190
+
1191
+ $this->add_responsive_control(
1192
+ 'input_submit_height',
1193
+ [
1194
+ 'label' => __( 'Height', 'void' ),
1195
+ 'type' => Controls_Manager::SLIDER,
1196
+ 'size_units' => [ 'px', 'vh', 'vw' ],
1197
+ 'range' => [
1198
+ 'px' => [
1199
+ 'max' => 900,
1200
+ ],
1201
+ ],
1202
+
1203
+ 'selectors' => [
1204
+ '{{WRAPPER}} .wpcf7-form input[type=submit]' => 'height: {{SIZE}}{{UNIT}};',
1205
+ ],
1206
+ ]
1207
+ );
1208
+ $this->add_responsive_control(
1209
+ 'input_submit_width',
1210
+ [
1211
+ 'label' => __( 'Width', 'void' ),
1212
+ 'type' => Controls_Manager::SLIDER,
1213
+ 'size_units' => [ '%','px', 'vw' ],
1214
+ 'range' => [
1215
+ 'px' => [
1216
+ 'max' => 1000,
1217
+ ],
1218
+ ],
1219
+
1220
+ 'selectors' => [
1221
+ '{{WRAPPER}} .wpcf7-form input[type=submit]' => 'width: {{SIZE}}{{UNIT}};',
1222
+ ],
1223
+ ]
1224
+ );
1225
+
1226
+ $this->add_group_control(
1227
+ \Elementor\Group_Control_Typography::get_type(),
1228
+ [
1229
+ 'name' => 'input_submit_typography',
1230
+ 'selector' => '{{WRAPPER}} .wpcf7-form .wpcf7-submit',
1231
+ ]
1232
+ );
1233
+
1234
+ $this->add_control(
1235
+ 'input_submit_text_color',
1236
+ [
1237
+ 'label' => __( 'Text Color', 'void' ),
1238
+ 'type' => Controls_Manager::COLOR,
1239
+ 'selectors' => [
1240
+ '{{WRAPPER}} .wpcf7-form input[type=submit]' => 'color: {{VALUE}};',
1241
+ ],
1242
+ ]
1243
+ );
1244
+
1245
+
1246
+
1247
+ $this->add_group_control(
1248
+ \Elementor\Group_Control_Background::get_type(),
1249
+ [
1250
+ 'name' => 'input_submit_bg_grd',
1251
+ 'types' => [ 'classic', 'gradient'],
1252
+ 'label' => esc_html__( 'Background', 'void' ),
1253
+ 'selector' =>
1254
+ '{{WRAPPER}} .wpcf7-form input[type=submit]',
1255
+ ]
1256
+ );
1257
+
1258
+ $this->add_responsive_control(
1259
+ 'input_submit_padding',
1260
+ [
1261
+ 'label' => __( 'Padding', 'void' ),
1262
+ 'type' => Controls_Manager::DIMENSIONS,
1263
+ 'size_units' => [ 'px', '%', 'em' ],
1264
+ 'selectors' => [
1265
+ '{{WRAPPER}} .wpcf7-form input[type=submit]' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1266
+ ],
1267
+ 'separator' =>'before',
1268
+ ]
1269
+ );
1270
+
1271
+ $this->add_responsive_control(
1272
+ 'input_submit_margin',
1273
+ [
1274
+ 'label' => __( 'Margin', 'void' ),
1275
+ 'type' => Controls_Manager::DIMENSIONS,
1276
+ 'size_units' => [ 'px', '%', 'em' ],
1277
+ 'selectors' => [
1278
+ '{{WRAPPER}} .wpcf7-form input[type=submit]' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1279
+ ],
1280
+ 'separator' =>'before',
1281
+ ]
1282
+ );
1283
+
1284
+ $this->add_group_control(
1285
+ \Elementor\Group_Control_Border::get_type(),
1286
+ [
1287
+ 'name' => 'input_submit_border',
1288
+ 'label' => __( 'Border', 'void' ),
1289
+ 'selector' => '{{WRAPPER}} .wpcf7-form input[type=submit]',
1290
+ ]
1291
+ );
1292
+
1293
+ $this->add_responsive_control(
1294
+ 'input_submit_border_radius',
1295
+ [
1296
+ 'label' => __( 'Border Radius', 'void' ),
1297
+ 'type' => Controls_Manager::DIMENSIONS,
1298
+ 'selectors' => [
1299
+ '{{WRAPPER}} .wpcf7-form input[type=submit]' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
1300
+ ],
1301
+ 'separator' =>'before',
1302
+ ]
1303
+ );
1304
+
1305
+ $this->add_group_control(
1306
+ \Elementor\Group_Control_Box_Shadow::get_type(),
1307
+ [
1308
+ 'name' => 'vcf7_input_submit_box_shadow',
1309
+ 'label' => __( 'Box Shadow', 'void' ),
1310
+ 'selector' => '{{WRAPPER}} .wpcf7-form input[type=submit]',
1311
+ ]
1312
+ );
1313
+
1314
+ $this->end_controls_tab(); // Button Normal tab end
1315
+
1316
+ // Button Hover tab start
1317
+ $this->start_controls_tab(
1318
+ 'submit_style_hover_tab',
1319
+ [
1320
+ 'label' => __( 'Hover', 'void' ),
1321
+ ]
1322
+ );
1323
+
1324
+ $this->add_responsive_control(
1325
+ 'input_submit_height_h',
1326
+ [
1327
+ 'label' => __( 'Height', 'void' ),
1328
+ 'type' => Controls_Manager::SLIDER,
1329
+ 'size_units' => [ 'px', 'vh', 'vw' ],
1330
+ 'range' => [
1331
+ 'px' => [
1332
+ 'max' => 900,
1333
+ ],
1334
+ ],
1335
+
1336
+ 'selectors' => [
1337
+ '{{WRAPPER}} .wpcf7-form input[type=submit]:hover' => 'height: {{SIZE}}{{UNIT}};',
1338
+ ],
1339
+ ]
1340
+ );
1341
+ $this->add_responsive_control(
1342
+ 'input_submit_width_h',
1343
+ [
1344
+ 'label' => __( 'Width', 'void' ),
1345
+ 'type' => Controls_Manager::SLIDER,
1346
+ 'size_units' => [ '%','px', 'vw' ],
1347
+ 'range' => [
1348
+ 'px' => [
1349
+ 'max' => 1000,
1350
+ ],
1351
+ ],
1352
+
1353
+ 'selectors' => [
1354
+ '{{WRAPPER}} .wpcf7-form input[type=submit]:hover' => 'width: {{SIZE}}{{UNIT}};',
1355
+ ],
1356
+ ]
1357
+ );
1358
+
1359
+ $this->add_group_control(
1360
+ \Elementor\Group_Control_Typography::get_type(),
1361
+ [
1362
+ 'name' => 'input_submit_typography_h',
1363
+ 'selector' => '{{WRAPPER}} .wpcf7-form input[type=submit]:hover',
1364
+ ]
1365
+ );
1366
+
1367
+ $this->add_control(
1368
+ 'input_submit_text_color_h',
1369
+ [
1370
+ 'label' => __( 'Text Color', 'void' ),
1371
+ 'type' => Controls_Manager::COLOR,
1372
+ 'selectors' => [
1373
+ '{{WRAPPER}} .wpcf7-form input[type=submit]:hover' => 'color: {{VALUE}};',
1374
+ ],
1375
+ ]
1376
+ );
1377
+
1378
+
1379
+
1380
+ $this->add_group_control(
1381
+ \Elementor\Group_Control_Background::get_type(),
1382
+ [
1383
+ 'name' => 'input_submit_bg_grd_h',
1384
+ 'types' => [ 'classic', 'gradient'],
1385
+ 'label' => esc_html__( 'Background', 'void' ),
1386
+ 'selector' =>
1387
+ '{{WRAPPER}} .wpcf7-form input[type=submit]:hover',
1388
+ ]
1389
+ );
1390
+
1391
+ $this->add_responsive_control(
1392
+ 'input_submit_padding_h',
1393
+ [
1394
+ 'label' => __( 'Padding', 'void' ),
1395
+ 'type' => Controls_Manager::DIMENSIONS,
1396
+ 'size_units' => [ 'px', '%', 'em' ],
1397
+ 'selectors' => [
1398
+ '{{WRAPPER}} .wpcf7-form input[type=submit]:hover' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1399
+ ],
1400
+ 'separator' =>'before',
1401
+ ]
1402
+ );
1403
+
1404
+ $this->add_responsive_control(
1405
+ 'input_submit_margin_h',
1406
+ [
1407
+ 'label' => __( 'Margin', 'void' ),
1408
+ 'type' => Controls_Manager::DIMENSIONS,
1409
+ 'size_units' => [ 'px', '%', 'em' ],
1410
+ 'selectors' => [
1411
+ '{{WRAPPER}} .wpcf7-form input[type=submit]:hover' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1412
+ ],
1413
+ 'separator' =>'before',
1414
+ ]
1415
+ );
1416
+
1417
+ $this->add_group_control(
1418
+ \Elementor\Group_Control_Border::get_type(),
1419
+ [
1420
+ 'name' => 'input_submit_border_h',
1421
+ 'label' => __( 'Border', 'void' ),
1422
+ 'selector' => '{{WRAPPER}} .wpcf7-form input[type=submit]:hover',
1423
+ ]
1424
+ );
1425
+
1426
+ $this->add_responsive_control(
1427
+ 'input_submit_border_radius_h',
1428
+ [
1429
+ 'label' => __( 'Border Radius', 'void' ),
1430
+ 'type' => Controls_Manager::DIMENSIONS,
1431
+ 'selectors' => [
1432
+ '{{WRAPPER}} .wpcf7-form input[type=submit]:hover' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px;',
1433
+ ],
1434
+ 'separator' =>'before',
1435
+ ]
1436
+ );
1437
+
1438
+ $this->add_group_control(
1439
+ \Elementor\Group_Control_Box_Shadow::get_type(),
1440
+ [
1441
+ 'name' => 'vcf7_input_submit_box_shadow_h',
1442
+ 'label' => __( 'Box Shadow', 'void' ),
1443
+ 'selector' => '{{WRAPPER}} .wpcf7-form input[type=submit]:hover',
1444
+ ]
1445
+ );
1446
+
1447
+ $this->add_control(
1448
+ 'vcf7_button_h_animation',
1449
+ [
1450
+ 'label' => __( 'Hover Animation', 'void' ),
1451
+ 'type' => Controls_Manager::TEXT,
1452
+ 'placeholder' => 'all .25s linear 0s',
1453
+ 'default' => 'all .25s linear 0s',
1454
+ 'description' => __( 'input your desired transition effect for focus. Remember one single line can set all types of transition values. <a target="_blank" href="https://css-tricks.com/almanac/properties/t/transition/">Example</a>', 'void' ),
1455
+ 'selectors' => [
1456
+ '{{WRAPPER}} .wpcf7-form input[type=submit]' =>'transition:{{VALUE}};-webkit-transition:{{VALUE}};-o-transition:{{VALUE}}',
1457
+ ],
1458
+ 'separator' =>'after',
1459
+
1460
+ ]
1461
+ );
1462
+
1463
+ $this->end_controls_tab(); // Button Hover tab end
1464
+
1465
+ $this->end_controls_tabs(); //ens submit style tabs
1466
+
1467
+ $this->end_controls_section();
1468
+ // end out style tab
1469
+
1470
+ // After submit styles
1471
+
1472
+ $this->start_controls_section(
1473
+ 'vcf7_section_after_submit',
1474
+ [
1475
+ 'label' => __('After Submit message', 'void'),
1476
+ 'tab' => Controls_Manager::TAB_STYLE,
1477
+ ]
1478
+ );
1479
+
1480
+ $this->start_controls_tabs('vcf7_after_s_style_tabs');
1481
+ // Success tab start
1482
+ $this->start_controls_tab(
1483
+ 'vcf7_after_submit_su_tab',
1484
+ [
1485
+ 'label' => __( 'Success', 'void' ),
1486
+ ]
1487
+ );
1488
+
1489
+ $this->add_control(
1490
+ 'contact_form_after_submit_s_color',
1491
+ [
1492
+ 'label' => __('Success Text Color', 'void'),
1493
+ 'type' => Controls_Manager::COLOR,
1494
+ 'selectors' => [
1495
+ '{{WRAPPER}} .wpcf7 form.sent .wpcf7-response-output' => 'color: {{VALUE}}',
1496
+ ],
1497
+ ]
1498
+ );
1499
+
1500
+ $this->add_group_control(
1501
+ \Elementor\Group_Control_Background::get_type(),
1502
+ [
1503
+ 'name' => 'vcf7_after_submit_background',
1504
+ 'label' => __('Background', 'void'),
1505
+ 'types' => ['classic', 'gradient'],
1506
+ 'selector' => '{{WRAPPER}} .wpcf7 form.sent .wpcf7-response-output',
1507
+ ]
1508
+ );
1509
+
1510
+ $this->add_group_control(
1511
+ \Elementor\Group_Control_Border::get_type(),
1512
+ [
1513
+ 'name' => 'vcf7_after_submit_border',
1514
+ 'label' => __('Border', 'void'),
1515
+ 'placeholder' => '1px',
1516
+ 'default' => '1px',
1517
+ 'selector' => '{{WRAPPER}} .wpcf7 form.sent .wpcf7-response-output',
1518
+ ]
1519
+ );
1520
+
1521
+ $this->add_responsive_control(
1522
+ 'vcf7_after_submit_border_radius',
1523
+ [
1524
+ 'label' => esc_html__('Radius', 'void'),
1525
+ 'type' => Controls_Manager::SLIDER,
1526
+ 'size_units' => ['px', 'em', '%'],
1527
+ 'range' => [
1528
+ 'px' => [
1529
+ 'min' => 10,
1530
+ 'max' => 1500,
1531
+ ],
1532
+ 'em' => [
1533
+ 'min' => 1,
1534
+ 'max' => 80,
1535
+ ],
1536
+ ],
1537
+ 'selectors' => [
1538
+ '{{WRAPPER}} .wpcf7 form.sent .wpcf7-response-output' => 'border-radius: {{SIZE}}{{UNIT}};',
1539
+ ],
1540
+ 'separator' =>'after',
1541
+
1542
+ ]
1543
+ );
1544
+ $this->end_controls_tab();
1545
+
1546
+ // Fail tab start
1547
+ $this->start_controls_tab(
1548
+ 'vcf7_after_submit_fa_tab',
1549
+ [
1550
+ 'label' => __( 'Failed', 'void' ),
1551
+ ]
1552
+ );
1553
+
1554
+ $this->add_control(
1555
+ 'contact_form_after_submit_n_color',
1556
+ [
1557
+ 'label' => __('Fail Text Color', 'void'),
1558
+ 'type' => Controls_Manager::COLOR,
1559
+ 'selectors' => [
1560
+ '{{WRAPPER}} .wpcf7 form.invalid .wpcf7-response-output, {{WRAPPER}} .wpcf7 form.unaccepted .wpcf7-response-output, {{WRAPPER}} .wpcf7 form.payment-required .wpcf7-response-output' => 'color: {{VALUE}}',
1561
+ ],
1562
+ ]
1563
+ );
1564
+
1565
+ $this->add_group_control(
1566
+ \Elementor\Group_Control_Background::get_type(),
1567
+ [
1568
+ 'name' => 'vcf7_after_submit_er_background',
1569
+ 'label' => __('Background', 'void'),
1570
+ 'types' => ['classic', 'gradient'],
1571
+ 'selector' => '.wpcf7 form.invalid .wpcf7-response-output, {{WRAPPER}} .wpcf7 form.unaccepted .wpcf7-response-output, {{WRAPPER}} .wpcf7 form.payment-required .wpcf7-response-output',
1572
+ ]
1573
+ );
1574
+
1575
+ $this->add_group_control(
1576
+ \Elementor\Group_Control_Border::get_type(),
1577
+ [
1578
+ 'name' => 'vcf7_after_submit_er_border',
1579
+ 'label' => __('Border', 'void'),
1580
+ 'placeholder' => '1px',
1581
+ 'default' => '1px',
1582
+ 'selector' => '.wpcf7 form.invalid .wpcf7-response-output, {{WRAPPER}} .wpcf7 form.unaccepted .wpcf7-response-output, {{WRAPPER}} .wpcf7 form.payment-required .wpcf7-response-output',
1583
+ ]
1584
+ );
1585
+
1586
+ $this->add_responsive_control(
1587
+ 'vcf7_after_submit_er_border_radius',
1588
+ [
1589
+ 'label' => esc_html__('Radius', 'void'),
1590
+ 'type' => Controls_Manager::SLIDER,
1591
+ 'size_units' => ['px', 'em', '%'],
1592
+ 'range' => [
1593
+ 'px' => [
1594
+ 'min' => 10,
1595
+ 'max' => 1500,
1596
+ ],
1597
+ 'em' => [
1598
+ 'min' => 1,
1599
+ 'max' => 80,
1600
+ ],
1601
+ ],
1602
+ 'selectors' => [
1603
+ '.wpcf7 form.invalid .wpcf7-response-output, {{WRAPPER}} .wpcf7 form.unaccepted .wpcf7-response-output, {{WRAPPER}} .wpcf7 form.payment-required .wpcf7-response-output' => 'border-radius: {{SIZE}}{{UNIT}};',
1604
+ ],
1605
+ 'separator' =>'after',
1606
+
1607
+ ]
1608
+ );
1609
+
1610
+ $this->end_controls_tab();
1611
+
1612
+ $this->end_controls_tabs();
1613
+
1614
+ $this->add_group_control(
1615
+ \Elementor\Group_Control_Typography::get_type(),
1616
+ [
1617
+ 'name' => 'vcf7_after_submit_typography',
1618
+ 'label' => __('Typography', 'void'),
1619
+ 'selector' => '{{WRAPPER}} .wpcf7-mail-sent-ng, {{WRAPPER}} .wpcf7-mail-sent-ok, {{WRAPPER}} .wpcf7-response-output',
1620
+ 'separator' => 'before',
1621
+ ]
1622
+ );
1623
+
1624
+ $this->add_responsive_control(
1625
+ 'vcf7_after_submit_margin',
1626
+ [
1627
+ 'label' => esc_html__('Margin', 'void'),
1628
+ 'type' => Controls_Manager::DIMENSIONS,
1629
+ 'size_units' => ['px', 'em', '%'],
1630
+ 'selectors' => [
1631
+ '{{WRAPPER}} .wpcf7-mail-sent-ng' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1632
+ '{{WRAPPER}} wpcf7-mail-sent-ok' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1633
+ '{{WRAPPER}} .wpcf7-response-output' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1634
+ ],
1635
+ ]
1636
+ );
1637
+
1638
+ $this->add_responsive_control(
1639
+ 'vcf7_after_submit_padding',
1640
+ [
1641
+ 'label' => esc_html__('Padding', 'void'),
1642
+ 'type' => Controls_Manager::DIMENSIONS,
1643
+ 'size_units' => ['px', 'em', '%'],
1644
+ 'selectors' => [
1645
+ '{{WRAPPER}} .wpcf7-mail-sent-ng' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1646
+ '{{WRAPPER}} .wpcf7-mail-sent-ok' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1647
+ '{{WRAPPER}} .wpcf7-response-output' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1648
+ ],
1649
+ ]
1650
+ );
1651
+
1652
+ $this->end_controls_section();
1653
+
1654
+
1655
+ }
1656
+
1657
+
1658
+ protected function render() { //to show on the fontend
1659
+ static $v_veriable=0;
1660
+
1661
+ $settings = $this->get_settings();
1662
+
1663
+ if(!empty($settings['cf7'])){
1664
+ echo'<div class="void-cf7-form-widget-wrapper elementor-shortcode void-cf7-'.$v_veriable.'" data-void-cf7-contact-form-id="'. $settings['cf7'] .'">';
1665
+ echo do_shortcode('[contact-form-7 id="'.$settings['cf7'].'"]');
1666
+ echo '</div>';
1667
+ }
1668
+
1669
+ if(!empty($settings['cf7_redirect_page']) || !empty($settings['cf7_redirect_external']) ) { ?>
1670
+ <script>
1671
+ var theform = document.querySelector('.void-cf7-<?php echo $v_veriable; ?>');
1672
+ theform.addEventListener( 'wpcf7mailsent', function( event ) {
1673
+ location = '<?php
1674
+ if( !empty($settings['cf7_redirect_external']) ){
1675
+ echo $settings['cf7_redirect_external'];
1676
+ }else{
1677
+ echo get_permalink( $settings['cf7_redirect_page'] );
1678
+ }
1679
+ ?>';
1680
+ }, false );
1681
+ </script>
1682
+
1683
+ <?php $v_veriable++;
1684
+ }
1685
+ }
1686
+ }