Contact Form7 Widget For Elementor Page Builder - Version 1.1.4

Version Description

  • Fix: Notice dismissible issue fix.
Download this release

Release Info

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

Code changes from version 1.1.3 to 1.1.4

assets/css/void-cf7-admin.css CHANGED
@@ -1,85 +1,85 @@
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
-
85
  /* 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
+
85
  /* notice css end */
assets/js/void-cf7-admin.js CHANGED
@@ -1,64 +1,64 @@
1
- (function($) {
2
- // Hook into the "void-query-promotion-notice" class we added to the notice, so
3
- // Only listen to YOUR notices being dismissed
4
- var elNotice = $('.void-query-promotion-notice');
5
-
6
- $( document ).on( 'click', '.void-query-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( '.void-query-promotion-notice' ).data( 'notice' );
10
- var nonce = $( this ).closest( '.void-query-promotion-notice' ).data( 'nonce' );
11
-
12
- //elNotice.hide();
13
- console.log('cross button click');
14
-
15
- // Make an AJAX call
16
- // Since WP 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
17
- $.ajax({
18
- // url of ajax request, value of voidCf7Admin.ajaxUrl is localized during enqueue script
19
- url: ajaxurl,
20
- type: 'POST',
21
- data: {
22
- action: 'dismissed_promotional_notice_handler',
23
- type: type,
24
- status: 'remind-me-later',
25
- },
26
- // wp verify nonce automatically after sending nonce like this
27
- headers: {
28
- 'X-WP-Nonce': nonce
29
- },
30
- dataType: 'json',
31
- });
32
- });
33
-
34
- elNotice.find( '.void-query-never-show' ).on( 'click', function (e) {
35
- e.preventDefault();
36
- // Read the "data-notice" information to track which notice
37
- // is being dismissed and send it via AJAX
38
- var type = $( this ).closest( '.void-query-promotion-notice' ).data( 'notice' );
39
- var nonce = $( this ).closest( '.void-query-promotion-notice' ).data( 'nonce' );
40
-
41
- elNotice.hide();
42
-
43
- // console.log('never click');
44
-
45
- // Make an AJAX call
46
- // Since WP 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
47
- $.ajax({
48
- // url of ajax request, value of voidCf7Admin.ajaxUrl is localized during enqueue script
49
- url: ajaxurl,
50
- type: 'POST',
51
- data: {
52
- action: 'dismissed_promotional_notice_handler',
53
- type: type,
54
- status: 'never-show',
55
- },
56
- // wp verify nonce automatically after sending nonce like this
57
- headers: {
58
- 'X-WP-Nonce': nonce
59
- },
60
- dataType: 'json',
61
- });
62
- });
63
-
64
  })(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
+ //elNotice.hide();
13
+ console.log('cross button click');
14
+
15
+ // Make an AJAX call
16
+ // Since WP 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
17
+ $.ajax({
18
+ // url of ajax request, value of voidCf7Admin.ajaxUrl is localized during enqueue script
19
+ url: ajaxurl,
20
+ type: 'POST',
21
+ data: {
22
+ action: 'dismissed_promotional_notice_handler',
23
+ type: type,
24
+ status: 'remind-me-later',
25
+ },
26
+ // wp verify nonce automatically after sending nonce like this
27
+ headers: {
28
+ 'X-WP-Nonce': nonce
29
+ },
30
+ dataType: 'json',
31
+ });
32
+ });
33
+
34
+ elNotice.find( '.cf7-widget-never-show' ).on( 'click', function (e) {
35
+ e.preventDefault();
36
+ // Read the "data-notice" information to track which notice
37
+ // is being dismissed and send it via AJAX
38
+ var type = $( this ).closest( '.cf7-widget-promotion-notice' ).data( 'notice' );
39
+ var nonce = $( this ).closest( '.cf7-widget-promotion-notice' ).data( 'nonce' );
40
+
41
+ elNotice.hide();
42
+
43
+ // console.log('never click');
44
+
45
+ // Make an AJAX call
46
+ // Since WP 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
47
+ $.ajax({
48
+ // url of ajax request, value of voidCf7Admin.ajaxUrl is localized during enqueue script
49
+ url: ajaxurl,
50
+ type: 'POST',
51
+ data: {
52
+ action: 'dismissed_promotional_notice_handler',
53
+ type: type,
54
+ status: 'never-show',
55
+ },
56
+ // wp verify nonce automatically after sending nonce like this
57
+ headers: {
58
+ 'X-WP-Nonce': nonce
59
+ },
60
+ dataType: 'json',
61
+ });
62
+ });
63
+
64
  })(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,151 +1,151 @@
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
- $(".elementor-tab-control-content").mouseenter(function(){
75
-
76
- // this ensures the data remains the same even after switching back from advanced tab to content tab
77
- $( '.elementor-tab-control-content a' ).on( 'click', function(event){
78
- cf7_data_pass_around_model(panel,model,view);
79
- });
80
- });
81
-
82
- // fix datalose after switching control section
83
- $(".elementor-control-section_content").on("click", function (event) {
84
- cf7_data_pass_around_model(panel,model,view);
85
- });
86
-
87
- });
88
-
89
- function editButtonFunction(){
90
- // loader add on modal
91
- modalLoading.addClass('loading');
92
- // insert src in iframe with edit link of selected form
93
- iframe.attr('src', voidCf7Admin.url+'admin.php?page=wpcf7&post='+formId+'&action=edit');
94
- // 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
95
- iframe.css('opacity', 0);
96
- // open modal with contact form edit url
97
- modal.show();
98
- // modal close button click event
99
- close.on('click', function(){
100
- // reload frondend panel to show updated data
101
- elUpdatePreviewButton.find('.elementor-update-preview-button').trigger('click');
102
- // modal modal after completed all the tasks
103
- modal.fadeOut(500);
104
- });
105
- }
106
-
107
- function addButtonFunction() {
108
- // element selector of form selector select2 from panel to avoid multiple search on DOM
109
- var elCf7 = panel.$el.find('[data-setting="cf7"]');
110
- // ajax request to admin-ajax for getting all contact form 7 from database
111
- $.ajax({
112
- // url of ajax request, value of voidCf7Admin.ajaxUrl is localized during enqueue script
113
- url: voidCf7Admin.ajaxUrl,
114
- type: 'POST',
115
- data: {
116
- action: 'void_cf7_data'
117
- },
118
- // wp verify nonce automatically after sending nonce like this
119
- headers: {
120
- 'X-WP-Nonce': voidCf7Admin.wpRestNonce
121
- },
122
- dataType: 'json',
123
- // success function of ajax request
124
- success: function (output) {
125
- // clear corrent option from form select select2
126
- elCf7.empty();
127
- // running loop by all from data after gettings it from ajax request
128
- $.each(output, function(index, value){
129
- // add option to form select select2 with new created from
130
- elCf7.append('<option value="'+index+'">'+value+'</option>');
131
- });
132
- //set already selected value
133
- elCf7.val( model.attributes.settings.attributes.cf7);
134
-
135
- // disable select2 of form select if there was no data
136
- if( elCf7.has('option').length == 0 ) {
137
- elCf7.attr('disabled', 'disabled');
138
- }else{
139
- elCf7.removeAttr('disabled');
140
- }
141
- },
142
- // error function of ajax request
143
- error: function (e) {
144
- console.log(e);
145
- },
146
- });
147
-
148
- }
149
- });
150
-
151
- })(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
+ $(".elementor-tab-control-content").mouseenter(function(){
75
+
76
+ // this ensures the data remains the same even after switching back from advanced tab to content tab
77
+ $( '.elementor-tab-control-content a' ).on( 'click', function(event){
78
+ cf7_data_pass_around_model(panel,model,view);
79
+ });
80
+ });
81
+
82
+ // fix datalose after switching control section
83
+ $(".elementor-control-section_content").on("click", function (event) {
84
+ cf7_data_pass_around_model(panel,model,view);
85
+ });
86
+
87
+ });
88
+
89
+ function editButtonFunction(){
90
+ // loader add on modal
91
+ modalLoading.addClass('loading');
92
+ // insert src in iframe with edit link of selected form
93
+ iframe.attr('src', voidCf7Admin.url+'admin.php?page=wpcf7&post='+formId+'&action=edit');
94
+ // 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
95
+ iframe.css('opacity', 0);
96
+ // open modal with contact form edit url
97
+ modal.show();
98
+ // modal close button click event
99
+ close.on('click', function(){
100
+ // reload frondend panel to show updated data
101
+ elUpdatePreviewButton.find('.elementor-update-preview-button').trigger('click');
102
+ // modal modal after completed all the tasks
103
+ modal.fadeOut(500);
104
+ });
105
+ }
106
+
107
+ function addButtonFunction() {
108
+ // element selector of form selector select2 from panel to avoid multiple search on DOM
109
+ var elCf7 = panel.$el.find('[data-setting="cf7"]');
110
+ // ajax request to admin-ajax for getting all contact form 7 from database
111
+ $.ajax({
112
+ // url of ajax request, value of voidCf7Admin.ajaxUrl is localized during enqueue script
113
+ url: voidCf7Admin.ajaxUrl,
114
+ type: 'POST',
115
+ data: {
116
+ action: 'void_cf7_data'
117
+ },
118
+ // wp verify nonce automatically after sending nonce like this
119
+ headers: {
120
+ 'X-WP-Nonce': voidCf7Admin.wpRestNonce
121
+ },
122
+ dataType: 'json',
123
+ // success function of ajax request
124
+ success: function (output) {
125
+ // clear corrent option from form select select2
126
+ elCf7.empty();
127
+ // running loop by all from data after gettings it from ajax request
128
+ $.each(output, function(index, value){
129
+ // add option to form select select2 with new created from
130
+ elCf7.append('<option value="'+index+'">'+value+'</option>');
131
+ });
132
+ //set already selected value
133
+ elCf7.val( model.attributes.settings.attributes.cf7);
134
+
135
+ // disable select2 of form select if there was no data
136
+ if( elCf7.has('option').length == 0 ) {
137
+ elCf7.attr('disabled', 'disabled');
138
+ }else{
139
+ elCf7.removeAttr('disabled');
140
+ }
141
+ },
142
+ // error function of ajax request
143
+ error: function (e) {
144
+ console.log(e);
145
+ },
146
+ });
147
+
148
+ }
149
+ });
150
+
151
+ })(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,82 +1,82 @@
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');
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');
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/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();
readme.txt CHANGED
@@ -1,106 +1,108 @@
1
- === Void Contact Form 7 Widget For Elementor Page Builder ===
2
- Contributors: voidthemes,voidcoders,soyket,shawon786
3
- Tags: page-builder, elementor, cf7, contact-form-7, contact-form-7 widget, widget, elementor add on, email, contact, form
4
- Requires at least: 4.4
5
- Tested up to: 5.5.1
6
- Stable tag: 1.1.3
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 ! Done !
21
- * Want to define style for input, lable, send button, success ? No problem ! This plugin let's you do those directly from elementor screen!
22
- * Want to add custom page to redirect to when the form is submitted ? That is also possible now !
23
- Yet this is just a simple plugin for simple users :)
24
- * 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 !
25
-
26
- For more details :[VOID CF7 Elementor Widget](https://voidcoders.com/product/contact-form7-widget-for-elementor-free/).
27
-
28
- For our other elementor & WP works visit : [VOID CODERS](https://voidcoders.com).
29
-
30
- For updates follow us on : [Facebook](https://www.facebook.com/voidcoders).
31
-
32
- Follow us on: [Github](https://github.com/soyket/cf7-widget-elementor/).
33
-
34
- New updates ( Edit/Add contact from inside Elementor )
35
- [youtube https://youtu.be/ZI0GMJoESaw]
36
-
37
- Latest Version Preview
38
- [youtube https://youtu.be/MlzrZ0zXM24]
39
-
40
- Older Version Preview
41
- [youtube https://youtu.be/sAHspWvhjNg]
42
-
43
-
44
-
45
- What Does This plugin give you?
46
-
47
- 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!
48
- 2. Easy use of contact forms created with Contact form 7 pluing inside elementor live editor
49
- 3. Add CSS directly from elementor live preview to your contact form 7 for different field type!!
50
- 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!
51
- 5. Use Single contact form 7 with different Style & redirect rule(Thank you page on success) on the same page with this.
52
-
53
- 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.
54
-
55
- == Installation ==
56
-
57
- 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.
58
- 2. Activate the plugin through the 'Plugins' screen in WordPress
59
- 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.
60
-
61
- == Frequently Asked Questions ==
62
-
63
- = Where can to find the new element added =
64
-
65
- Our Contact Form7 Widget For Elementor Page Builder adds a new section 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
66
-
67
-
68
- == Screenshots ==
69
-
70
- 1. /assets/screenshot-4.png
71
- 2. /assets/screenshot-5.png
72
- 3. /assets/screenshot-1.jpg
73
- 4. /assets/screenshot-2.jpg
74
- 5. /assets/screenshot-3.jpg
75
-
76
- == Update Instructions ==
77
- Update the plugin either via wp dashboard or via FTP. After update make sure you clear your browser cache.
78
-
79
- == Changelog ==
80
- = 1.1.3 =
81
- * Fix: Compatiable with elementor 3.x.
82
- * Fix: Fix some js error with new version of wp and elementor.
83
- = 1.1.2 =
84
- * Fix: Editor panel data loose issue solved after comeback another control sections/ widgets.
85
- = 1.1.1 =
86
- * Fix: Js erros on frontend
87
- = 1.1.0 =
88
- * New: Add and Edit contact form without leaving elementor dashboard.
89
- = 1.0.9 =
90
- * Feature added - External thank you page
91
- = 1.0.6 =
92
- * Css added Number control
93
- * Any post type url from the site for redirect url
94
- = 1.0.5 =
95
- * Css added Hover button
96
- = 1.0.4 =
97
- * Css added for select box
98
- = 1.0.3 =
99
- * CSS Fix
100
- = 1.0.2 =
101
- * Define Any page as thank you page
102
- * More Comporftable Select2 for selecting Contact From
103
- = 1.0.1 =
104
- * Custom CSS Adding option
105
- = 1.0.0 =
106
- * Initial Launch
 
 
1
+ === Void Contact Form 7 Widget For Elementor Page Builder ===
2
+ Contributors: voidthemes,voidcoders,soyket,shawon786
3
+ Tags: page-builder, elementor, cf7, contact-form-7, contact-form-7 widget, widget, elementor add on, email, contact, form
4
+ Requires at least: 4.4
5
+ Tested up to: 5.5.1
6
+ Stable tag: 1.1.4
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 ! Done !
21
+ * Want to define style for input, lable, send button, success ? No problem ! This plugin let's you do those directly from elementor screen!
22
+ * Want to add custom page to redirect to when the form is submitted ? That is also possible now !
23
+ Yet this is just a simple plugin for simple users :)
24
+ * 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 !
25
+
26
+ For more details :[VOID CF7 Elementor Widget](https://voidcoders.com/product/contact-form7-widget-for-elementor-free/).
27
+
28
+ For our other elementor & WP works visit : [VOID CODERS](https://voidcoders.com).
29
+
30
+ For updates follow us on : [Facebook](https://www.facebook.com/voidcoders).
31
+
32
+ Follow us on: [Github](https://github.com/soyket/cf7-widget-elementor/).
33
+
34
+ New updates ( Edit/Add contact from inside Elementor )
35
+ [youtube https://youtu.be/ZI0GMJoESaw]
36
+
37
+ Latest Version Preview
38
+ [youtube https://youtu.be/MlzrZ0zXM24]
39
+
40
+ Older Version Preview
41
+ [youtube https://youtu.be/sAHspWvhjNg]
42
+
43
+
44
+
45
+ What Does This plugin give you?
46
+
47
+ 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!
48
+ 2. Easy use of contact forms created with Contact form 7 pluing inside elementor live editor
49
+ 3. Add CSS directly from elementor live preview to your contact form 7 for different field type!!
50
+ 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!
51
+ 5. Use Single contact form 7 with different Style & redirect rule(Thank you page on success) on the same page with this.
52
+
53
+ 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.
54
+
55
+ == Installation ==
56
+
57
+ 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.
58
+ 2. Activate the plugin through the 'Plugins' screen in WordPress
59
+ 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.
60
+
61
+ == Frequently Asked Questions ==
62
+
63
+ = Where can to find the new element added =
64
+
65
+ Our Contact Form7 Widget For Elementor Page Builder adds a new section 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
66
+
67
+
68
+ == Screenshots ==
69
+
70
+ 1. /assets/screenshot-4.png
71
+ 2. /assets/screenshot-5.png
72
+ 3. /assets/screenshot-1.jpg
73
+ 4. /assets/screenshot-2.jpg
74
+ 5. /assets/screenshot-3.jpg
75
+
76
+ == Update Instructions ==
77
+ Update the plugin either via wp dashboard or via FTP. After update make sure you clear your browser cache.
78
+
79
+ == Changelog ==
80
+ = 1.1.4 =
81
+ * Fix: Notice dismissible issue fix.
82
+ = 1.1.3 =
83
+ * Fix: Compatiable with elementor 3.x.
84
+ * Fix: Fix some js error with new version of wp and elementor.
85
+ = 1.1.2 =
86
+ * Fix: Editor panel data loose issue solved after comeback another control sections/ widgets.
87
+ = 1.1.1 =
88
+ * Fix: Js erros on frontend
89
+ = 1.1.0 =
90
+ * New: Add and Edit contact form without leaving elementor dashboard.
91
+ = 1.0.9 =
92
+ * Feature added - External thank you page
93
+ = 1.0.6 =
94
+ * Css added Number control
95
+ * Any post type url from the site for redirect url
96
+ = 1.0.5 =
97
+ * Css added Hover button
98
+ = 1.0.4 =
99
+ * Css added for select box
100
+ = 1.0.3 =
101
+ * CSS Fix
102
+ = 1.0.2 =
103
+ * Define Any page as thank you page
104
+ * More Comporftable Select2 for selecting Contact From
105
+ = 1.0.1 =
106
+ * Custom CSS Adding option
107
+ = 1.0.0 =
108
+ * Initial Launch
void-cf7-widget-elementor.php CHANGED
@@ -1,180 +1,180 @@
1
- <?php
2
- /**
3
- * Plugin Name: Void Contact Form 7 Widget For Elementor Page Builder
4
- * Description: Adds Contact Form 7 widget element to Elementor page builder for easy drag & drop the created contact forms with CF7 (contact form 7).
5
- * Version: 1.1.3
6
- * Author: voidCoders
7
- * Plugin URI: https://demo.voidcoders.com/plugins/contact-form7-widget-for-elementor/
8
- * Author URI: https://voidcoders.com
9
- * Text Domain: void
10
- */
11
-
12
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
13
-
14
- define('CF7_WIDGET_E_VERSION', '1.1.3');
15
- define('CF7_WIDGET_E_PLUGIN_URL', trailingslashit(plugin_dir_url( __FILE__ )));
16
- define('CF7_WIDGET_E_PLUGIN_DIR', trailingslashit(plugin_dir_path( __FILE__ )));
17
-
18
- function void_cf7_widget() {
19
- // Load localization file
20
- load_plugin_textdomain( 'void' );
21
-
22
- // Notice if the Elementor is not active
23
- if ( ! did_action( 'elementor/loaded' ) ) {
24
- return;
25
- }
26
-
27
- // Check version required
28
- $elementor_version_required = '2.8.5';
29
- if ( ! version_compare( ELEMENTOR_VERSION, $elementor_version_required, '>=' ) ) {
30
- return;
31
- }
32
-
33
- // Require the main plugin file
34
- require( __DIR__ . '/plugin.php' ); //loading the main plugin
35
- include CF7_WIDGET_E_PLUGIN_DIR.'custom-editor/init.php';
36
- // helper file for this plugin. currently used for gettings all contact form of cf7. also used for ajax request handle
37
- require __DIR__ . '/helper/helper.php';
38
-
39
- }
40
- add_action( 'plugins_loaded', 'void_cf7_widget' );
41
-
42
- // display activation notice for depended plugin
43
- function void_cf7_widget_notice() { ?>
44
-
45
- <?php if ( !is_plugin_active( 'contact-form-7/wp-contact-form-7.php' ) || ! did_action( 'elementor/loaded' ) ) : ?>
46
- <div class="notice notice-warning is-dismissible">
47
-
48
- <?php if ( file_exists( WP_PLUGIN_DIR . '/elementor/elementor.php' ) && ! did_action( 'elementor/loaded' ) ) : ?>
49
- <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>
50
- <?php elseif ( !file_exists( WP_PLUGIN_DIR . '/elementor/elementor.php' ) ) : ?>
51
- <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>
52
- <?php endif; ?>
53
-
54
- <?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' ) ) : ?>
55
- <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>
56
- <?php elseif ( !file_exists( WP_PLUGIN_DIR . '/contact-form-7/wp-contact-form-7.php' ) ) : ?>
57
- <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>
58
- <?php endif; ?>
59
-
60
- </div>
61
- <?php endif; ?>
62
-
63
- <?php }
64
- add_action('admin_notices', 'void_cf7_widget_notice');
65
-
66
- function void_cf7_widget_promotional_notice(){
67
- // notice dismiss date form database
68
- $db_dismiss_date = get_option('dismissed-void-cf7-promotion-notice-ele-query-at');
69
- // create a date object from database date
70
- $dismiss_date = date_create($db_dismiss_date);
71
- // create a current date object
72
- $current_date = date_create(date('Y-m-d'));
73
- // get difference of both date
74
- $diff = date_diff($dismiss_date, $current_date);
75
- // make conditional days. if date found in database, it will be 30.
76
- // otherwise it will be 0. Becase difference return 0 if there was no data on database
77
- $conditional_days = ($db_dismiss_date) ? 15 : 0;
78
- // elementor pro install check
79
- if ( file_exists( WP_PLUGIN_DIR . '/elementor-pro/elementor-pro.php' ) || did_action( 'elementor_pro/init' ) ) :
80
- $url = 'https://elequerybuilder.com?click=cf7-promo';
81
- // different day condition. notice will again show if dismiss interval is more than equal 30 days
82
- if( !get_option('dismissed-void-cf7-promotion-notice-ele-query-never', FALSE )):
83
-
84
- // different day condition. notice will again show if dismiss interval is more than equal 30 days
85
- if($diff->days >= $conditional_days ):
86
- $url .= (($conditional_days == 15) ? '&discount=INSIDE10E' : '');
87
- ?>
88
- <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'); ?>">
89
- <div class="cf7-widget-message-inner">
90
- <div class="cf7-widget-message-icon">
91
- <img class="cf7-widget-notice-icon" src="https://elequerybuilder.com/wp-content/uploads/2020/05/EQ-Banner.png" alt="voidCoders promotional banner">
92
- </div>
93
- <div class="cf7-widget-message-content">
94
- <?php if ($conditional_days == 15) :?>
95
- <p>Here is a Little gift for you!</p>
96
- <p>Get <strong>Ele Query Builder</strong> to build custom query without code with <strong>10% Discount</strong>. <strong>Use Coupon - INSIDE10E</strong></p>
97
- <?php else: ?>
98
- <p>We noticed you have <strong>Elementor Pro</strong> on your site.</p>
99
- <p>Get our <strong>Ele Query Builder</strong> to use custom query by using postmeta, ACF/PODS</p>
100
- <p>Woocommerce meta and events calendar with no CODE</p>
101
- <?php endif; ?>
102
- </div>
103
- <div class="cf7-widget-message-action">
104
- <a class="cf7-widget-button" target="__blank" href="<?php echo esc_url($url); ?>">Check Now</a>
105
- <!-- <a class="cf7-widget-remind-later" href="#">Remind me later -> </a> -->
106
- <a class="cf7-widget-never-show" href="#">Never show again -> </a>
107
- </div>
108
- </div>
109
- </div>
110
- <?php endif;
111
- endif;
112
- endif;
113
- }
114
- add_action('admin_notices', 'void_cf7_widget_promotional_notice');
115
-
116
-
117
- // add plugin activation time
118
-
119
- function void_cf7_activation_time(){
120
- $get_installation_time = strtotime("now");
121
- add_option('void_cf7_elementor_activation_time', $get_installation_time );
122
- }
123
- register_activation_hook( __FILE__, 'void_cf7_activation_time' );
124
-
125
- //check if review notice should be shown or not
126
-
127
- function void_cf7_check_installation_time() {
128
-
129
- $spare_me = get_option('void_cf7_spare_me');
130
- if( !$spare_me ){
131
- $install_date = get_option( 'void_cf7_elementor_activation_time' );
132
- $past_date = strtotime( '-7 days' );
133
-
134
- if ( $past_date >= $install_date ) {
135
-
136
- add_action( 'admin_notices', 'void_cf7_display_admin_notice' );
137
-
138
- }
139
- }
140
- }
141
- add_action( 'admin_init', 'void_cf7_check_installation_time' );
142
-
143
- /**
144
- * Display Admin Notice, asking for a review
145
- **/
146
- function void_cf7_display_admin_notice() {
147
- // wordpress global variable
148
- global $pagenow;
149
- if( $pagenow == 'index.php' ){
150
-
151
- $dont_disturb = esc_url( get_admin_url() . '?spare_me2=1' );
152
- $plugin_info = get_plugin_data( __FILE__ , true, true );
153
- $reviewurl = esc_url( 'https://wordpress.org/support/plugin/cf7-widget-elementor/reviews/#new-post' );
154
- $void_url = esc_url( 'https://voidcoders.com/shop/' );
155
-
156
- 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=
157
- "_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 );
158
- }
159
- }
160
- // remove the notice for the user if review already done or if the user does not want to
161
- function void_cf7_spare_me(){
162
- if( isset( $_GET['spare_me2'] ) && !empty( $_GET['spare_me2'] ) ){
163
- $spare_me = $_GET['spare_me2'];
164
- if( $spare_me == 1 ){
165
- add_option( 'void_cf7_spare_me' , TRUE );
166
- }
167
- }
168
- }
169
- add_action( 'admin_init', 'void_cf7_spare_me', 5 );
170
-
171
- //add admin css
172
- function void_cf7_admin_css(){
173
-
174
- global $pagenow;
175
- 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 ) ){
176
- wp_enqueue_style( 'void-cf7-admin', CF7_WIDGET_E_PLUGIN_URL . 'assets/css/void-cf7-admin.css', [], CF7_WIDGET_E_VERSION, 'all' );
177
- wp_enqueue_script('void-cf7-admin', CF7_WIDGET_E_PLUGIN_URL . 'assets/js/void-cf7-admin.js', ['jquery'], CF7_WIDGET_E_VERSION, true);
178
- }
179
- }
180
- add_action( 'admin_enqueue_scripts', 'void_cf7_admin_css' );
1
+ <?php
2
+ /**
3
+ * Plugin Name: Void Contact Form 7 Widget For Elementor Page Builder
4
+ * Description: Adds Contact Form 7 widget element to Elementor page builder for easy drag & drop the created contact forms with CF7 (contact form 7).
5
+ * Version: 1.1.4
6
+ * Author: voidCoders
7
+ * Plugin URI: https://demo.voidcoders.com/plugins/contact-form7-widget-for-elementor/
8
+ * Author URI: https://voidcoders.com
9
+ * Text Domain: void
10
+ */
11
+
12
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
13
+
14
+ define('CF7_WIDGET_E_VERSION', '1.1.4');
15
+ define('CF7_WIDGET_E_PLUGIN_URL', trailingslashit(plugin_dir_url( __FILE__ )));
16
+ define('CF7_WIDGET_E_PLUGIN_DIR', trailingslashit(plugin_dir_path( __FILE__ )));
17
+
18
+ function void_cf7_widget() {
19
+ // Load localization file
20
+ load_plugin_textdomain( 'void' );
21
+
22
+ // Notice if the Elementor is not active
23
+ if ( ! did_action( 'elementor/loaded' ) ) {
24
+ return;
25
+ }
26
+
27
+ // Check version required
28
+ $elementor_version_required = '2.8.5';
29
+ if ( ! version_compare( ELEMENTOR_VERSION, $elementor_version_required, '>=' ) ) {
30
+ return;
31
+ }
32
+
33
+ // Require the main plugin file
34
+ require( __DIR__ . '/plugin.php' ); //loading the main plugin
35
+ include CF7_WIDGET_E_PLUGIN_DIR.'custom-editor/init.php';
36
+ // helper file for this plugin. currently used for gettings all contact form of cf7. also used for ajax request handle
37
+ require __DIR__ . '/helper/helper.php';
38
+
39
+ }
40
+ add_action( 'plugins_loaded', 'void_cf7_widget' );
41
+
42
+ // display activation notice for depended plugin
43
+ function void_cf7_widget_notice() { ?>
44
+
45
+ <?php if ( !is_plugin_active( 'contact-form-7/wp-contact-form-7.php' ) || ! did_action( 'elementor/loaded' ) ) : ?>
46
+ <div class="notice notice-warning is-dismissible">
47
+
48
+ <?php if ( file_exists( WP_PLUGIN_DIR . '/elementor/elementor.php' ) && ! did_action( 'elementor/loaded' ) ) : ?>
49
+ <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>
50
+ <?php elseif ( !file_exists( WP_PLUGIN_DIR . '/elementor/elementor.php' ) ) : ?>
51
+ <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>
52
+ <?php endif; ?>
53
+
54
+ <?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' ) ) : ?>
55
+ <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>
56
+ <?php elseif ( !file_exists( WP_PLUGIN_DIR . '/contact-form-7/wp-contact-form-7.php' ) ) : ?>
57
+ <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>
58
+ <?php endif; ?>
59
+
60
+ </div>
61
+ <?php endif; ?>
62
+
63
+ <?php }
64
+ add_action('admin_notices', 'void_cf7_widget_notice');
65
+
66
+ function void_cf7_widget_promotional_notice(){
67
+ // notice dismiss date form database
68
+ $db_dismiss_date = get_option('dismissed-void-cf7-promotion-notice-ele-query-at');
69
+ // create a date object from database date
70
+ $dismiss_date = date_create($db_dismiss_date);
71
+ // create a current date object
72
+ $current_date = date_create(date('Y-m-d'));
73
+ // get difference of both date
74
+ $diff = date_diff($dismiss_date, $current_date);
75
+ // make conditional days. if date found in database, it will be 30.
76
+ // otherwise it will be 0. Becase difference return 0 if there was no data on database
77
+ $conditional_days = ($db_dismiss_date) ? 15 : 0;
78
+ // elementor pro install check
79
+ if ( file_exists( WP_PLUGIN_DIR . '/elementor-pro/elementor-pro.php' ) || did_action( 'elementor_pro/init' ) ) :
80
+ $url = 'https://elequerybuilder.com?click=cf7-promo';
81
+ // different day condition. notice will again show if dismiss interval is more than equal 30 days
82
+ if( !get_option('dismissed-void-cf7-promotion-notice-ele-query-never', FALSE )):
83
+
84
+ // different day condition. notice will again show if dismiss interval is more than equal 30 days
85
+ if($diff->days >= $conditional_days ):
86
+ $url .= (($conditional_days == 15) ? '&discount=INSIDE10E' : '');
87
+ ?>
88
+ <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'); ?>">
89
+ <div class="cf7-widget-message-inner">
90
+ <div class="cf7-widget-message-icon">
91
+ <img class="cf7-widget-notice-icon" src="https://elequerybuilder.com/wp-content/uploads/2020/05/EQ-Banner.png" alt="voidCoders promotional banner">
92
+ </div>
93
+ <div class="cf7-widget-message-content">
94
+ <?php if ($conditional_days == 15) :?>
95
+ <p>Here is a Little gift for you!</p>
96
+ <p>Get <strong>Ele Query Builder</strong> to build custom query without code with <strong>10% Discount</strong>. <strong>Use Coupon - INSIDE10E</strong></p>
97
+ <?php else: ?>
98
+ <p>We noticed you have <strong>Elementor Pro</strong> on your site.</p>
99
+ <p>Get our <strong>Ele Query Builder</strong> to use custom query by using postmeta, ACF/PODS</p>
100
+ <p>Woocommerce meta and events calendar with no CODE</p>
101
+ <?php endif; ?>
102
+ </div>
103
+ <div class="cf7-widget-message-action">
104
+ <a class="cf7-widget-button" target="__blank" href="<?php echo esc_url($url); ?>">Check Now</a>
105
+ <!-- <a class="cf7-widget-remind-later" href="#">Remind me later -> </a> -->
106
+ <a class="cf7-widget-never-show" href="#">Never show again -> </a>
107
+ </div>
108
+ </div>
109
+ </div>
110
+ <?php endif;
111
+ endif;
112
+ endif;
113
+ }
114
+ add_action('admin_notices', 'void_cf7_widget_promotional_notice');
115
+
116
+
117
+ // add plugin activation time
118
+
119
+ function void_cf7_activation_time(){
120
+ $get_installation_time = strtotime("now");
121
+ add_option('void_cf7_elementor_activation_time', $get_installation_time );
122
+ }
123
+ register_activation_hook( __FILE__, 'void_cf7_activation_time' );
124
+
125
+ //check if review notice should be shown or not
126
+
127
+ function void_cf7_check_installation_time() {
128
+
129
+ $spare_me = get_option('void_cf7_spare_me');
130
+ if( !$spare_me ){
131
+ $install_date = get_option( 'void_cf7_elementor_activation_time' );
132
+ $past_date = strtotime( '-7 days' );
133
+
134
+ if ( $past_date >= $install_date ) {
135
+
136
+ add_action( 'admin_notices', 'void_cf7_display_admin_notice' );
137
+
138
+ }
139
+ }
140
+ }
141
+ add_action( 'admin_init', 'void_cf7_check_installation_time' );
142
+
143
+ /**
144
+ * Display Admin Notice, asking for a review
145
+ **/
146
+ function void_cf7_display_admin_notice() {
147
+ // wordpress global variable
148
+ global $pagenow;
149
+ if( $pagenow == 'index.php' ){
150
+
151
+ $dont_disturb = esc_url( get_admin_url() . '?spare_me2=1' );
152
+ $plugin_info = get_plugin_data( __FILE__ , true, true );
153
+ $reviewurl = esc_url( 'https://wordpress.org/support/plugin/cf7-widget-elementor/reviews/#new-post' );
154
+ $void_url = esc_url( 'https://voidcoders.com/shop/' );
155
+
156
+ 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=
157
+ "_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 );
158
+ }
159
+ }
160
+ // remove the notice for the user if review already done or if the user does not want to
161
+ function void_cf7_spare_me(){
162
+ if( isset( $_GET['spare_me2'] ) && !empty( $_GET['spare_me2'] ) ){
163
+ $spare_me = $_GET['spare_me2'];
164
+ if( $spare_me == 1 ){
165
+ add_option( 'void_cf7_spare_me' , TRUE );
166
+ }
167
+ }
168
+ }
169
+ add_action( 'admin_init', 'void_cf7_spare_me', 5 );
170
+
171
+ //add admin css
172
+ function void_cf7_admin_css(){
173
+
174
+ global $pagenow;
175
+ 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 ) ){
176
+ wp_enqueue_style( 'void-cf7-admin', CF7_WIDGET_E_PLUGIN_URL . 'assets/css/void-cf7-admin.css', [], CF7_WIDGET_E_VERSION, 'all' );
177
+ wp_enqueue_script('void-cf7-admin', CF7_WIDGET_E_PLUGIN_URL . 'assets/js/void-cf7-admin.js', ['jquery'], CF7_WIDGET_E_VERSION, true);
178
+ }
179
+ }
180
+ add_action( 'admin_enqueue_scripts', 'void_cf7_admin_css' );
widgets/void-section-cf7.php CHANGED
@@ -1,341 +1,341 @@
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
-
9
-
10
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
11
-
12
- /**
13
- * Elementor Style for header
14
- *
15
- *
16
- * @since 1.0.0
17
- */
18
-
19
- class void_cf7 extends Widget_Base {
20
-
21
- // public function __construct( $data = [], $args = null ) {
22
- // parent::__construct( $data, $args );
23
- // $this->add_style_depends('void-cf7-elementor-js');
24
- // $this->add_script_depends('void-cf7-elementor-css');
25
- // }
26
-
27
- //this name is added to plugin.php of the root folder
28
-
29
- public function get_name() {
30
- return 'void-section-cf7';
31
- }
32
-
33
- public function get_title() {
34
- return 'Void Contact From 7'; // title to show on elementor
35
- }
36
-
37
- public function get_icon() {
38
- return 'eicon-mail'; // eicon-posts-ticker-> eicon ow asche icon to show on elelmentor
39
- }
40
-
41
- public function get_categories() {
42
- return [ 'void-elements' ]; // category of the widget
43
- }
44
-
45
- public function is_reload_preview_required() {
46
- return true;
47
- }
48
-
49
- /**
50
- * A list of scripts that the widgets is depended in
51
- * @since 1.3.0
52
- **/
53
- protected function _register_controls() {
54
-
55
- //start of a control box
56
- $this->start_controls_section(
57
- 'section_content',
58
- [
59
- 'label' => esc_html__( 'Contact Form 7', 'void' ), //section name for controler view
60
- 'tab' => Controls_Manager::TAB_CONTENT,
61
- ]
62
- );
63
-
64
- $this->add_control(
65
- 'cf7',
66
- [
67
- 'label' => esc_html__( 'Select Contact Form', 'void' ),
68
- 'description' => esc_html__('Contact form 7 - plugin must be installed and there must be some contact forms made with the contact form 7','void'),
69
- 'type' => Controls_Manager::SELECT2,
70
- 'multiple' => false,
71
- 'label_block' => 1,
72
- 'options' => get_contact_form_7_posts(),
73
- ]
74
- );
75
-
76
- $this->add_control(
77
- 'void_cf7_form_action_edit',
78
- [
79
- 'type' => \Elementor\Controls_Manager::RAW_HTML,
80
- 'raw' => sprintf( '<a href="#" id="void-cf7-edit-form-btn" style="color:#d30c5c; float: right;">Edit form</a>', 'void' ),
81
- 'content_classes' => 'void-cf7-edit-form-btn',
82
- ]
83
- );
84
-
85
- $this->add_control(
86
- 'void_cf7_form_action_add',
87
- [
88
- 'type' => \Elementor\Controls_Manager::RAW_HTML,
89
- 'raw' => sprintf( '<a href="#" id="void-cf7-add-form-btn" style="color:#d30c5c; float: right;">+ Add new form</a>', 'void' ),
90
- 'content_classes' => 'void-cf7-add-form-btn',
91
- ]
92
- );
93
-
94
- $this->end_controls_section();
95
-
96
- $this->start_controls_section(
97
- 'section_stype',
98
- [
99
- 'label' => esc_html__( 'Style Contact Form', 'void' ), //section name for controler view
100
- 'tab' => Controls_Manager::TAB_CONTENT,
101
- ]
102
- );
103
-
104
- $this->add_control(
105
- 'cf7_direct_css',
106
- [
107
- 'label' => __( 'Global CSS For all fields', 'void' ),
108
- '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' ),
109
- 'type' => Controls_Manager::TEXTAREA,
110
- 'placeholder' => 'color:#000;',
111
- 'selectors' => [
112
- '{{WRAPPER}} ' => '{{VALUE}}',
113
- ],
114
- ]
115
- );
116
-
117
- $this->add_control(
118
- 'alllabel',
119
- [
120
- 'label' => __( 'All Label CSS', 'void' ),
121
- 'description' => __( 'Changes might not sometimes show in the live preview but check in the front end to see the changes.', 'void' ),
122
- 'type' => Controls_Manager::TEXTAREA,
123
- 'placeholder' => 'color:#fff;',
124
- 'selectors' => [
125
- '{{WRAPPER}} label' => '{{VALUE}}',
126
- ],
127
- ]
128
- );
129
- $this->add_control(
130
- 'allinput',
131
- [
132
- 'label' => __( 'All Input CSS', 'void' ),
133
- 'description' => __( 'Changes might not sometimes show in the live preview but check in the front end to see the changes.', 'void' ),
134
- 'type' => Controls_Manager::TEXTAREA,
135
- 'placeholder' => 'width:100%;
136
- background:red;',
137
- 'selectors' => [
138
- '{{WRAPPER}} input' => 'height:auto;',
139
- '{{WRAPPER}} input' => '{{VALUE}}',
140
-
141
- ],
142
- ]
143
- );
144
-
145
- $this->add_control(
146
- 'textinput',
147
- [
148
- 'label' => __( 'Input Type Text CSS', 'void' ),
149
- 'description' => __( 'Changes might not sometimes show in the live preview but check in the front end to see the changes.', 'void' ),
150
- 'type' => Controls_Manager::TEXTAREA,
151
- 'placeholder' => 'width:100%;
152
- background:red;',
153
- 'selectors' => [
154
- '{{WRAPPER}} .wpcf7-text' => 'height:auto;',
155
- '{{WRAPPER}} .wpcf7-text' => '{{VALUE}}',
156
- ],
157
- ]
158
- );
159
- $this->add_control(
160
- 'textarea',
161
- [
162
- 'label' => __( 'Textarea CSS', 'void' ),
163
- 'description' => __( 'Changes might not sometimes show in the live preview but check in the front end to see the changes.', 'void' ),
164
- 'type' => Controls_Manager::TEXTAREA,
165
- 'placeholder' => 'height:100px;
166
- width:100%;',
167
- 'selectors' => [
168
- '{{WRAPPER}} textarea' => 'height:auto;',
169
- '{{WRAPPER}} textarea' => '{{VALUE}}',
170
- ],
171
- ]
172
- );
173
-
174
- $this->add_control(
175
- 'checkbox',
176
- [
177
- 'label' => __( 'Checkbox/ Radio CSS', 'void' ),
178
- 'type' => Controls_Manager::TEXTAREA,
179
- 'placeholder' => 'display: block;',
180
- 'selectors' => [
181
- '{{WRAPPER}} .wpcf7-list-item' => '{{VALUE}}',
182
- ],
183
- ]
184
- );
185
-
186
- $this->add_control(
187
- 'selectcss',
188
- [
189
- 'label' => __( 'Dropdown/ Select Box css', 'void' ),
190
- 'type' => Controls_Manager::TEXTAREA,
191
- 'placeholder' => 'width: 100;',
192
- 'selectors' => [
193
- '{{WRAPPER}} select' => '{{VALUE}}',
194
- ],
195
- ]
196
- );
197
- $this->add_control(
198
- 'selectoptionscss',
199
- [
200
- 'label' => __( 'Select Options Css', 'void' ),
201
- 'type' => Controls_Manager::TEXTAREA,
202
- 'placeholder' => 'color: red;',
203
- 'selectors' => [
204
- '{{WRAPPER}} select option' => '{{VALUE}}',
205
- ],
206
- ]
207
- );
208
-
209
- $this->add_control(
210
- 'file',
211
- [
212
- 'label' => __( 'File CSS', 'void' ),
213
- 'type' => Controls_Manager::TEXTAREA,
214
- 'placeholder' => 'display: block;',
215
- 'selectors' => [
216
- '{{WRAPPER}} input[type="file"]' => '{{VALUE}}',
217
- ],
218
- ]
219
- );
220
- $this->add_control(
221
- 'date',
222
- [
223
- 'label' => __( 'Date CSS', 'void' ),
224
- 'type' => Controls_Manager::TEXTAREA,
225
- 'placeholder' => 'display: block;',
226
- 'selectors' => [
227
- '{{WRAPPER}} .wpcf7-date' => '{{VALUE}}',
228
- ],
229
- ]
230
- );
231
- $this->add_control(
232
- 'inputsubmit',
233
- [
234
- 'label' => __( 'Submit Button CSS', 'void' ),
235
- 'description' => __( 'Changes might not sometimes show in the live preview but check in the front end to see the changes.', 'void' ),
236
- 'type' => Controls_Manager::TEXTAREA,
237
- 'placeholder' => 'width:100%;
238
- background:red;',
239
- 'selectors' => [
240
- '{{WRAPPER}} input[type="submit"]' => '{{VALUE}}',
241
- ],
242
- ]
243
- );
244
- $this->add_control(
245
- 'inputsubmithover',
246
- [
247
- 'label' => __( 'Submit Button Hover CSS', 'void' ),
248
- 'type' => Controls_Manager::TEXTAREA,
249
- 'placeholder' => 'background:#fff;',
250
- 'selectors' => [
251
- '{{WRAPPER}} input[type="submit"]:hover' => '{{VALUE}}',
252
- ],
253
- ]
254
- );
255
-
256
- $this->add_control(
257
- 'responce',
258
- [
259
- 'label' => __( 'Responce CSS', 'void' ),
260
- 'type' => Controls_Manager::TEXTAREA,
261
- 'placeholder' => 'color:red;',
262
- 'selectors' => [
263
- '{{WRAPPER}} .wpcf7-response-output' => '{{VALUE}}',
264
- ],
265
- ]
266
- );
267
-
268
-
269
- $this->end_controls_section();
270
-
271
-
272
-
273
- $this->start_controls_section(
274
- 'section_redirect',
275
- [
276
- 'label' => esc_html__( 'After Submit Redirect Setting', 'void' ), //section name for controler view
277
- 'tab' => Controls_Manager::TAB_CONTENT,
278
- ]
279
- );
280
-
281
- $this->add_control(
282
- 'cf7_redirect_external',
283
- [
284
- 'label' => __( 'On Success External URL Redirect', 'void' ),
285
- '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'),
286
- 'type' => \Elementor\Controls_Manager::TEXT,
287
- 'placeholder' => __( 'https://voidcoders.com', 'void' ),
288
- 'label_block' => 1,
289
- ]
290
- );
291
-
292
- $this->add_control(
293
- 'cf7_redirect_page',
294
- [
295
- 'label' => esc_html__( 'On Success Internal Redirect', 'void' ),
296
- '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'),
297
- 'type' => Controls_Manager::SELECT2,
298
- 'multiple' => false,
299
- 'label_block' => 1,
300
- 'options' => void_get_all_pages(),
301
- 'condition' =>
302
- [
303
- 'cf7_redirect_external' => '',
304
- ],
305
- ]
306
- );
307
-
308
-
309
- $this->end_controls_section();
310
- }
311
-
312
-
313
- protected function render() { //to show on the fontend
314
- static $v_veriable=0;
315
-
316
- $settings = $this->get_settings();
317
-
318
- if(!empty($settings['cf7'])){
319
- echo'<div class="void-cf7-form-widget-wrapper elementor-shortcode void-cf7-'.$v_veriable.'" data-void-cf7-contact-form-id="'. $settings['cf7'] .'">';
320
- echo do_shortcode('[contact-form-7 id="'.$settings['cf7'].'"]');
321
- echo '</div>';
322
- }
323
-
324
- if(!empty($settings['cf7_redirect_page']) || !empty($settings['cf7_redirect_external']) ) { ?>
325
- <script>
326
- var theform = document.querySelector('.void-cf7-<?php echo $v_veriable; ?>');
327
- theform.addEventListener( 'wpcf7mailsent', function( event ) {
328
- location = '<?php
329
- if( !empty($settings['cf7_redirect_external']) ){
330
- echo $settings['cf7_redirect_external'];
331
- }else{
332
- echo get_permalink( $settings['cf7_redirect_page'] );
333
- }
334
- ?>';
335
- }, false );
336
- </script>
337
-
338
- <?php $v_veriable++;
339
- }
340
- }
341
- }
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
+
9
+
10
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
11
+
12
+ /**
13
+ * Elementor Style for header
14
+ *
15
+ *
16
+ * @since 1.0.0
17
+ */
18
+
19
+ class void_cf7 extends Widget_Base {
20
+
21
+ // public function __construct( $data = [], $args = null ) {
22
+ // parent::__construct( $data, $args );
23
+ // $this->add_style_depends('void-cf7-elementor-js');
24
+ // $this->add_script_depends('void-cf7-elementor-css');
25
+ // }
26
+
27
+ //this name is added to plugin.php of the root folder
28
+
29
+ public function get_name() {
30
+ return 'void-section-cf7';
31
+ }
32
+
33
+ public function get_title() {
34
+ return 'Void Contact From 7'; // title to show on elementor
35
+ }
36
+
37
+ public function get_icon() {
38
+ return 'eicon-mail'; // eicon-posts-ticker-> eicon ow asche icon to show on elelmentor
39
+ }
40
+
41
+ public function get_categories() {
42
+ return [ 'void-elements' ]; // category of the widget
43
+ }
44
+
45
+ public function is_reload_preview_required() {
46
+ return true;
47
+ }
48
+
49
+ /**
50
+ * A list of scripts that the widgets is depended in
51
+ * @since 1.3.0
52
+ **/
53
+ protected function _register_controls() {
54
+
55
+ //start of a control box
56
+ $this->start_controls_section(
57
+ 'section_content',
58
+ [
59
+ 'label' => esc_html__( 'Contact Form 7', 'void' ), //section name for controler view
60
+ 'tab' => Controls_Manager::TAB_CONTENT,
61
+ ]
62
+ );
63
+
64
+ $this->add_control(
65
+ 'cf7',
66
+ [
67
+ 'label' => esc_html__( 'Select Contact Form', 'void' ),
68
+ 'description' => esc_html__('Contact form 7 - plugin must be installed and there must be some contact forms made with the contact form 7','void'),
69
+ 'type' => Controls_Manager::SELECT2,
70
+ 'multiple' => false,
71
+ 'label_block' => 1,
72
+ 'options' => get_contact_form_7_posts(),
73
+ ]
74
+ );
75
+
76
+ $this->add_control(
77
+ 'void_cf7_form_action_edit',
78
+ [
79
+ 'type' => \Elementor\Controls_Manager::RAW_HTML,
80
+ 'raw' => sprintf( '<a href="#" id="void-cf7-edit-form-btn" style="color:#d30c5c; float: right;">Edit form</a>', 'void' ),
81
+ 'content_classes' => 'void-cf7-edit-form-btn',
82
+ ]
83
+ );
84
+
85
+ $this->add_control(
86
+ 'void_cf7_form_action_add',
87
+ [
88
+ 'type' => \Elementor\Controls_Manager::RAW_HTML,
89
+ 'raw' => sprintf( '<a href="#" id="void-cf7-add-form-btn" style="color:#d30c5c; float: right;">+ Add new form</a>', 'void' ),
90
+ 'content_classes' => 'void-cf7-add-form-btn',
91
+ ]
92
+ );
93
+
94
+ $this->end_controls_section();
95
+
96
+ $this->start_controls_section(
97
+ 'section_stype',
98
+ [
99
+ 'label' => esc_html__( 'Style Contact Form', 'void' ), //section name for controler view
100
+ 'tab' => Controls_Manager::TAB_CONTENT,
101
+ ]
102
+ );
103
+
104
+ $this->add_control(
105
+ 'cf7_direct_css',
106
+ [
107
+ 'label' => __( 'Global CSS For all fields', 'void' ),
108
+ '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' ),
109
+ 'type' => Controls_Manager::TEXTAREA,
110
+ 'placeholder' => 'color:#000;',
111
+ 'selectors' => [
112
+ '{{WRAPPER}} ' => '{{VALUE}}',
113
+ ],
114
+ ]
115
+ );
116
+
117
+ $this->add_control(
118
+ 'alllabel',
119
+ [
120
+ 'label' => __( 'All Label CSS', 'void' ),
121
+ 'description' => __( 'Changes might not sometimes show in the live preview but check in the front end to see the changes.', 'void' ),
122
+ 'type' => Controls_Manager::TEXTAREA,
123
+ 'placeholder' => 'color:#fff;',
124
+ 'selectors' => [
125
+ '{{WRAPPER}} label' => '{{VALUE}}',
126
+ ],
127
+ ]
128
+ );
129
+ $this->add_control(
130
+ 'allinput',
131
+ [
132
+ 'label' => __( 'All Input CSS', 'void' ),
133
+ 'description' => __( 'Changes might not sometimes show in the live preview but check in the front end to see the changes.', 'void' ),
134
+ 'type' => Controls_Manager::TEXTAREA,
135
+ 'placeholder' => 'width:100%;
136
+ background:red;',
137
+ 'selectors' => [
138
+ '{{WRAPPER}} input' => 'height:auto;',
139
+ '{{WRAPPER}} input' => '{{VALUE}}',
140
+
141
+ ],
142
+ ]
143
+ );
144
+
145
+ $this->add_control(
146
+ 'textinput',
147
+ [
148
+ 'label' => __( 'Input Type Text CSS', 'void' ),
149
+ 'description' => __( 'Changes might not sometimes show in the live preview but check in the front end to see the changes.', 'void' ),
150
+ 'type' => Controls_Manager::TEXTAREA,
151
+ 'placeholder' => 'width:100%;
152
+ background:red;',
153
+ 'selectors' => [
154
+ '{{WRAPPER}} .wpcf7-text' => 'height:auto;',
155
+ '{{WRAPPER}} .wpcf7-text' => '{{VALUE}}',
156
+ ],
157
+ ]
158
+ );
159
+ $this->add_control(
160
+ 'textarea',
161
+ [
162
+ 'label' => __( 'Textarea CSS', 'void' ),
163
+ 'description' => __( 'Changes might not sometimes show in the live preview but check in the front end to see the changes.', 'void' ),
164
+ 'type' => Controls_Manager::TEXTAREA,
165
+ 'placeholder' => 'height:100px;
166
+ width:100%;',
167
+ 'selectors' => [
168
+ '{{WRAPPER}} textarea' => 'height:auto;',
169
+ '{{WRAPPER}} textarea' => '{{VALUE}}',
170
+ ],
171
+ ]
172
+ );
173
+
174
+ $this->add_control(
175
+ 'checkbox',
176
+ [
177
+ 'label' => __( 'Checkbox/ Radio CSS', 'void' ),
178
+ 'type' => Controls_Manager::TEXTAREA,
179
+ 'placeholder' => 'display: block;',
180
+ 'selectors' => [
181
+ '{{WRAPPER}} .wpcf7-list-item' => '{{VALUE}}',
182
+ ],
183
+ ]
184
+ );
185
+
186
+ $this->add_control(
187
+ 'selectcss',
188
+ [
189
+ 'label' => __( 'Dropdown/ Select Box css', 'void' ),
190
+ 'type' => Controls_Manager::TEXTAREA,
191
+ 'placeholder' => 'width: 100;',
192
+ 'selectors' => [
193
+ '{{WRAPPER}} select' => '{{VALUE}}',
194
+ ],
195
+ ]
196
+ );
197
+ $this->add_control(
198
+ 'selectoptionscss',
199
+ [
200
+ 'label' => __( 'Select Options Css', 'void' ),
201
+ 'type' => Controls_Manager::TEXTAREA,
202
+ 'placeholder' => 'color: red;',
203
+ 'selectors' => [
204
+ '{{WRAPPER}} select option' => '{{VALUE}}',
205
+ ],
206
+ ]
207
+ );
208
+
209
+ $this->add_control(
210
+ 'file',
211
+ [
212
+ 'label' => __( 'File CSS', 'void' ),
213
+ 'type' => Controls_Manager::TEXTAREA,
214
+ 'placeholder' => 'display: block;',
215
+ 'selectors' => [
216
+ '{{WRAPPER}} input[type="file"]' => '{{VALUE}}',
217
+ ],
218
+ ]
219
+ );
220
+ $this->add_control(
221
+ 'date',
222
+ [
223
+ 'label' => __( 'Date CSS', 'void' ),
224
+ 'type' => Controls_Manager::TEXTAREA,
225
+ 'placeholder' => 'display: block;',
226
+ 'selectors' => [
227
+ '{{WRAPPER}} .wpcf7-date' => '{{VALUE}}',
228
+ ],
229
+ ]
230
+ );
231
+ $this->add_control(
232
+ 'inputsubmit',
233
+ [
234
+ 'label' => __( 'Submit Button CSS', 'void' ),
235
+ 'description' => __( 'Changes might not sometimes show in the live preview but check in the front end to see the changes.', 'void' ),
236
+ 'type' => Controls_Manager::TEXTAREA,
237
+ 'placeholder' => 'width:100%;
238
+ background:red;',
239
+ 'selectors' => [
240
+ '{{WRAPPER}} input[type="submit"]' => '{{VALUE}}',
241
+ ],
242
+ ]
243
+ );
244
+ $this->add_control(
245
+ 'inputsubmithover',
246
+ [
247
+ 'label' => __( 'Submit Button Hover CSS', 'void' ),
248
+ 'type' => Controls_Manager::TEXTAREA,
249
+ 'placeholder' => 'background:#fff;',
250
+ 'selectors' => [
251
+ '{{WRAPPER}} input[type="submit"]:hover' => '{{VALUE}}',
252
+ ],
253
+ ]
254
+ );
255
+
256
+ $this->add_control(
257
+ 'responce',
258
+ [
259
+ 'label' => __( 'Responce CSS', 'void' ),
260
+ 'type' => Controls_Manager::TEXTAREA,
261
+ 'placeholder' => 'color:red;',
262
+ 'selectors' => [
263
+ '{{WRAPPER}} .wpcf7-response-output' => '{{VALUE}}',
264
+ ],
265
+ ]
266
+ );
267
+
268
+
269
+ $this->end_controls_section();
270
+
271
+
272
+
273
+ $this->start_controls_section(
274
+ 'section_redirect',
275
+ [
276
+ 'label' => esc_html__( 'After Submit Redirect Setting', 'void' ), //section name for controler view
277
+ 'tab' => Controls_Manager::TAB_CONTENT,
278
+ ]
279
+ );
280
+
281
+ $this->add_control(
282
+ 'cf7_redirect_external',
283
+ [
284
+ 'label' => __( 'On Success External URL Redirect', 'void' ),
285
+ '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'),
286
+ 'type' => \Elementor\Controls_Manager::TEXT,
287
+ 'placeholder' => __( 'https://voidcoders.com', 'void' ),
288
+ 'label_block' => 1,
289
+ ]
290
+ );
291
+
292
+ $this->add_control(
293
+ 'cf7_redirect_page',
294
+ [
295
+ 'label' => esc_html__( 'On Success Internal Redirect', 'void' ),
296
+ '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'),
297
+ 'type' => Controls_Manager::SELECT2,
298
+ 'multiple' => false,
299
+ 'label_block' => 1,
300
+ 'options' => void_get_all_pages(),
301
+ 'condition' =>
302
+ [
303
+ 'cf7_redirect_external' => '',
304
+ ],
305
+ ]
306
+ );
307
+
308
+
309
+ $this->end_controls_section();
310
+ }
311
+
312
+
313
+ protected function render() { //to show on the fontend
314
+ static $v_veriable=0;
315
+
316
+ $settings = $this->get_settings();
317
+
318
+ if(!empty($settings['cf7'])){
319
+ echo'<div class="void-cf7-form-widget-wrapper elementor-shortcode void-cf7-'.$v_veriable.'" data-void-cf7-contact-form-id="'. $settings['cf7'] .'">';
320
+ echo do_shortcode('[contact-form-7 id="'.$settings['cf7'].'"]');
321
+ echo '</div>';
322
+ }
323
+
324
+ if(!empty($settings['cf7_redirect_page']) || !empty($settings['cf7_redirect_external']) ) { ?>
325
+ <script>
326
+ var theform = document.querySelector('.void-cf7-<?php echo $v_veriable; ?>');
327
+ theform.addEventListener( 'wpcf7mailsent', function( event ) {
328
+ location = '<?php
329
+ if( !empty($settings['cf7_redirect_external']) ){
330
+ echo $settings['cf7_redirect_external'];
331
+ }else{
332
+ echo get_permalink( $settings['cf7_redirect_page'] );
333
+ }
334
+ ?>';
335
+ }, false );
336
+ </script>
337
+
338
+ <?php $v_veriable++;
339
+ }
340
+ }
341
+ }