Contact Form 7 Style - Version 3.0.4

Version Description

  • Major Fix Fixed CSS editor "\" multiplier removed
  • [Major Fix] Collection data functionality to prevent fatal error for various server setups
  • [Major Fix] Prevent existing style data loss based on a new versioning system functionality
  • [Improvement] Publish or Update Style button
  • New feature - System Status page with the possibility to ask for help from the Contact Form 7 Style team by email
  • New feature - Settings page - Install predefined templates or Allow collection data
  • General bugfixing
Download this release

Release Info

Developer mlehelsz
Plugin Icon 128x128 Contact Form 7 Style
Version 3.0.4
Comparing to
See all releases

Code changes from version 3.0.3 to 3.0.4

admin/css/admin.css CHANGED
@@ -209,7 +209,7 @@
209
  }
210
 
211
  .cf7style-welcome-panel img {
212
- max-width : 160px;
213
  height: auto;
214
  }
215
 
@@ -580,4 +580,43 @@ input.cf7style_template {
580
  .generate-preview-option,
581
  .multiple-form-generated-preview {
582
  display: none;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
583
  }
209
  }
210
 
211
  .cf7style-welcome-panel img {
212
+ max-width: 160px;
213
  height: auto;
214
  }
215
 
580
  .generate-preview-option,
581
  .multiple-form-generated-preview {
582
  display: none;
583
+ }
584
+
585
+ .parser-message {
586
+ margin-bottom: 20px;
587
+ color: red;
588
+ }
589
+
590
+ .cf7style-welcome-panel {
591
+ background-color: #fff;
592
+ border: 1px solid #e5e5e5;
593
+ -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, .04);
594
+ box-shadow: 0 1px 1px rgba(0, 0, 0, .04);
595
+ width: 100%;
596
+ padding: 10px;
597
+ }
598
+ /* System Status */
599
+
600
+ .cf7style-status-table {
601
+ display: none;
602
+ }
603
+
604
+ .cf7style-status-form {
605
+ margin-bottom: 20px;
606
+ }
607
+
608
+ .cf7style-input {
609
+ width: 250px;
610
+ }
611
+
612
+ .wp-core-ui .button-primary.cf7style-status-submit,
613
+ .wp-core-ui .button.cf7style-status-info,
614
+ .wp-core-ui input:focus,
615
+ .wp-core-ui input['disabled'] {
616
+ display: inline-block;
617
+ margin-top: 10px;
618
+ }
619
+
620
+ .wp-core-ui .button.cf7style-status-info {
621
+ margin-right: 10px;
622
  }
admin/js/admin.js CHANGED
@@ -2,6 +2,101 @@
2
  jQuery functions for the Admin area
3
  */
4
  jQuery(document).ready(function($) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  String.prototype.filename = function(extension) {
6
  var s = this.replace(/\\/g, '/');
7
  s = s.substring(s.lastIndexOf('/') + 1);
@@ -369,50 +464,10 @@ jQuery(document).ready(function($) {
369
  removePreviewfields(previewForm.find('input[type="hidden"]'));
370
  /*disable submit*/
371
  disableSubmit(previewForm.find('input[type="submit"]'));
372
- $(document).on('click', '.editinline', function() {
373
- setTimeout(function() { $('.special-colspan').attr('colspan', 4); }, 60);
374
- });
375
  }
376
  if (sliderWrapper.length > 0) {
377
  sliderInit(sliderWrapper);
378
  }
379
- $('input[name="custom_template_check"]').on('change', function() {
380
- if ($(this).is(':checked')) {
381
- $('.double-check').hide();
382
- } else {
383
- $('.double-check').show();
384
- }
385
- });
386
- $('.confirm-remove-template').on('click', function(e) {
387
- e.preventDefault();
388
- var curParent = $(this).parent();
389
- if ($('input[name="double_check_template"]:checked').val() == "no") {
390
- curParent.hide();
391
- $('input[name="custom_template_check"]').attr('checked', 'checked');
392
- } else {
393
- dismissRemoveMessage();
394
- $.ajax({
395
- 'url': ajaxurl,
396
- 'method': 'POST',
397
- 'data': {
398
- 'action': 'cf7_style_remove_templates'
399
- },
400
- 'success': function(data) {
401
- if (data) {
402
- $('<p class="succeded">Predefined templates successfully removed.</p>').appendTo(curParent);
403
- setTimeout(function() {
404
- curParent.fadeOut('slow');
405
- curParent.parent().fadeOut('slow', function() {
406
- setTimeout(function() {
407
- window.location.reload(false);
408
- }, 300);
409
- });
410
- }, 2000);
411
- }
412
- }
413
- });
414
- }
415
- });
416
  $('.close-cf7-panel').on('click', function(e) {
417
  e.preventDefault();
418
  $.ajax({
2
  jQuery functions for the Admin area
3
  */
4
  jQuery(document).ready(function($) {
5
+
6
+ /* System Status */
7
+
8
+ /* Email address validation */
9
+
10
+ function isValidEmailAddress( emailAddress ) {
11
+ var pattern = /^([a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+(\.[a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)*|"((([ \t]*\r\n)?[ \t]+)?([\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*(([ \t]*\r\n)?[ \t]+)?")@(([a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.)+([a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.?$/i;
12
+ return pattern.test(emailAddress);
13
+ }
14
+
15
+ /* Validation border color */
16
+
17
+ function validateInput( elem, result ) {
18
+
19
+ if( result == 'valid' ) {
20
+ elem.css( 'border-color', '#ddd' );
21
+ } else {
22
+ elem.css( 'border-color', 'red' );
23
+ }
24
+ }
25
+
26
+ /* Send Report */
27
+
28
+ var cf7s_status_name = $( '.cf7style-name' ),
29
+ cf7s_status_email = $( '.cf7style-email' ),
30
+ cf7s_status_message = $( '.cf7style-message' ),
31
+ cf7s_status_submit = $( '.cf7style-status-submit' );
32
+
33
+ cf7s_status_submit.on( 'click', function( e ) {
34
+ e.preventDefault();
35
+
36
+ $( '.cf7style-input' ).each( function( index, value ) {
37
+ if( $( this ).val() == '' ) {
38
+ validateInput( $( this ), 'error' );
39
+ } else {
40
+ validateInput( $( this ), 'valid' );
41
+ }
42
+ } );
43
+
44
+ if( cf7s_status_name.val() !== '' && cf7s_status_email.val() !== '' ) {
45
+ if( ! isValidEmailAddress( cf7s_status_email.val() ) ) {
46
+ console.log( 'error 2' );
47
+ validateInput( cf7s_status_email, 'error' );
48
+ } else {
49
+ validateInput( cf7s_status_email, 'valid' );
50
+
51
+ var status = $( '<div />' );
52
+
53
+ $( '.cf7style-status-table' ).each( function( index, value ) {
54
+ var table = $( "<table />" );
55
+ table.html( $( this ).html() );
56
+ status.append( table );
57
+ } );
58
+
59
+ $.ajax( {
60
+ 'url': ajaxurl,
61
+ 'method': 'POST',
62
+ 'data': {
63
+ 'action': 'cf7_style_send_status_report',
64
+ 'name': cf7s_status_name.val(),
65
+ 'email': cf7s_status_email.val(),
66
+ 'message': cf7s_status_message.val(),
67
+ 'report': status.html()
68
+ },
69
+ 'beforeSend': function() {
70
+ cf7s_status_submit.text( 'Sending...' );
71
+ },
72
+ 'success': function( data ) {
73
+ if ( $.trim( data ) == 'success' ) {
74
+ cf7s_status_submit.text( 'Report sent' ).removeClass( 'cf7style-status-submit' ).attr( 'disabled', 'disabled' );
75
+ } else {
76
+ cf7s_status_submit.text( 'Something went wrong!' ).removeClass( 'cf7style-status-submit' ).attr( 'disabled', 'disabled' );
77
+ }
78
+ }
79
+ } );
80
+ }
81
+
82
+ } else {
83
+ console.log( 'error 1' );
84
+ }
85
+ } );
86
+
87
+ /* Show info */
88
+
89
+ $( '.cf7style-status-info' ).on( 'click', function( e ) {
90
+ e.preventDefault();
91
+
92
+ $( '.cf7style-status-table' ).toggle();
93
+
94
+ } );
95
+
96
+
97
+
98
+
99
+
100
  String.prototype.filename = function(extension) {
101
  var s = this.replace(/\\/g, '/');
102
  s = s.substring(s.lastIndexOf('/') + 1);
464
  removePreviewfields(previewForm.find('input[type="hidden"]'));
465
  /*disable submit*/
466
  disableSubmit(previewForm.find('input[type="submit"]'));
 
 
 
467
  }
468
  if (sliderWrapper.length > 0) {
469
  sliderInit(sliderWrapper);
470
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
471
  $('.close-cf7-panel').on('click', function(e) {
472
  e.preventDefault();
473
  $.ajax({
admin/js/overall.js CHANGED
@@ -1,25 +1,62 @@
1
  jQuery(document).ready(function($) {
2
- function dismissRemoveMessage() {
3
- $.ajax({
4
- 'url': ajaxurl,
5
- 'method': 'POST',
6
- 'data': {
7
- 'action': 'cf7_style_remove_box'
8
- },
9
- 'success': function(data) {}
10
- });
11
- }
12
  $('.remove_template_notice').on('click', function(e) {
13
  e.preventDefault();
14
  $('.template-message-box').fadeOut('slow');
15
  dismissRemoveMessage();
16
  });
17
  $(document).on('click', '.cf7style-pointer a.close', function(e) {
18
- e.preventDefault();
19
- if( $('#cf7_style_allow_tracking').is(':checked') ){
20
- $.post(ajaxurl, "action=cf7_style_allow_tracking&cf7_style_allow_tracking=1", function(res) {});
21
- } else {
22
- $.post(ajaxurl, "action=cf7_style_show_tracking&cf7_style_allow_tracking=0", function(res) {});
23
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  });
25
  });
1
  jQuery(document).ready(function($) {
2
+ function dismissRemoveMessage() {
3
+ $.ajax({
4
+ 'url': ajaxurl,
5
+ 'method': 'POST',
6
+ 'data': {
7
+ 'action': 'cf7_style_remove_box'
8
+ },
9
+ 'success': function(data) {}
10
+ });
11
+ }
12
  $('.remove_template_notice').on('click', function(e) {
13
  e.preventDefault();
14
  $('.template-message-box').fadeOut('slow');
15
  dismissRemoveMessage();
16
  });
17
  $(document).on('click', '.cf7style-pointer a.close', function(e) {
18
+ e.preventDefault();
19
+ if ($('#cf7_style_allow_tracking').is(':checked')) {
20
+ $.post(ajaxurl, "action=cf7_style_allow_tracking&cf7_style_allow_tracking=1", function(res) {});
21
+ } else {
22
+ $.post(ajaxurl, "action=cf7_style_show_tracking&cf7_style_allow_tracking=0", function(res) {});
23
+ }
24
+ });
25
+ $('input[name="custom_template_check"]').on('change', function() {
26
+ if ($(this).is(':checked')) {
27
+ $('.double-check').hide();
28
+ } else {
29
+ $('.double-check').show();
30
+ }
31
+ });
32
+ $('.confirm-remove-template').on('click', function(e) {
33
+ e.preventDefault();
34
+ var curParent = $(this).parent();
35
+ if ($('input[name="double_check_template"]:checked').val() == "no") {
36
+ curParent.hide();
37
+ $('input[name="custom_template_check"]').attr('checked', 'checked');
38
+ } else {
39
+ dismissRemoveMessage();
40
+ $.ajax({
41
+ 'url': ajaxurl,
42
+ 'method': 'POST',
43
+ 'data': {
44
+ 'action': 'cf7_style_remove_templates'
45
+ },
46
+ 'success': function(data) {
47
+ if (data) {
48
+ $('<p class="succeded">Predefined templates successfully removed.</p>').appendTo(curParent);
49
+ setTimeout(function() {
50
+ curParent.fadeOut('slow');
51
+ curParent.parent().fadeOut('slow', function() {
52
+ setTimeout(function() {
53
+ window.location.reload(false);
54
+ }, 300);
55
+ });
56
+ }, 2000);
57
+ }
58
+ }
59
+ });
60
+ }
61
  });
62
  });
cf7-style-meta-box.php CHANGED
@@ -44,7 +44,7 @@ class cf7_style_meta_boxes {
44
  if ( in_array( $post_type, $post_types )) {
45
  add_meta_box(
46
  'cf7_style_meta_box_form_selector'
47
- ,__( 'Select forms for current style', 'myplugin_textdomain' )
48
  ,array( $this, 'render_meta_box_selector' )
49
  ,$post_type
50
  ,'advanced'
@@ -60,7 +60,7 @@ class cf7_style_meta_boxes {
60
  if ( in_array( $post_type, $post_types ) && ( $custom_name == "custom style" ) ) {
61
  add_meta_box(
62
  'cf7_style_meta_box_style_customizer'
63
- ,__( 'Custom style settings', 'myplugin_textdomain' )
64
  ,array( $this, 'render_meta_box_style_customizer' )
65
  ,$post_type
66
  ,'advanced'
@@ -107,8 +107,7 @@ class cf7_style_meta_boxes {
107
  update_post_meta( $post_id, 'cf7_style_active_panel', $active_pane, "");
108
  }
109
  if ( is_array( $posted_data ) && isset( $posted_data ) ) {
110
- $serialized_result = serialize( $posted_data );
111
- update_post_meta( $post_id, 'cf7_style_custom_styler', $serialized_result, "");
112
  }
113
 
114
  }
@@ -181,15 +180,14 @@ class cf7_style_meta_boxes {
181
  'posts_per_page' => -1
182
  );
183
  $currentpostid = get_the_ID();
184
-
185
- //wp_die( 'aaaa' );
186
  $query = new WP_Query( $args );
187
  echo '<table class="wp-list-table fixed pages widefat">';
188
  echo '<thead>';
189
  echo '<tr>';
190
- echo '<th class="manage-column">' . __('Contact form 7 forms') . '</th>';
191
- echo '<th class="manage-column different-style"><input type="checkbox" id="select_all"/><label for="select_all">' . __('Select all') . '</label></th>';
192
- echo '<th class="generate-preview-option">' . __( "Generate preview", "cf7style" ) . '</th>';
193
  echo '</tr>';
194
  echo '</thead>';
195
  echo '<tbody class="cf7style_body_select_all">';
@@ -205,13 +203,13 @@ class cf7_style_meta_boxes {
205
  <input type="checkbox" id="<?php echo cf7_style_the_slug(); ?>" name="<?php echo cf7_style_the_slug(); ?>" value="<?php echo get_the_ID(); ?>" <?php if ( $currentpostid == $cf7stylehas ) { echo 'checked'; } ?> />
206
  </td>
207
  <td class="generate-preview-option">
208
- <button class="button-primary generate-preview-button" data-attr-title="<?php the_title(); ?>" data-attr-id="<?php the_ID(); ?>"><?php _e( "Generate preview", "cf7style" ); ?></button>
209
  </td>
210
  </tr>
211
  <tr>
212
  <td colspan="2">
213
  <?php if ( $currentpostid != $cf7stylehas && !empty( $cf7stylehas ) ) {
214
- echo '<p class="description">' . __('Notice: This form allready has a selected style. Checking this one will overwrite the ') . '<a href="' . get_admin_url() . 'post.php?post_type=cf7_style&post=' . $cf7stylehas . '&action=edit">' . __('other one.') . '</a></p>';
215
  } ?>
216
  </td>
217
  <td class="generate-preview-option">&nbsp;</td>
@@ -220,7 +218,7 @@ class cf7_style_meta_boxes {
220
  echo '</tbody>';
221
  echo '</table>';
222
  } else {
223
- echo '<tr><td><p class="description">' . __( 'Please create a form. You can do it by clicking') . '<a href="' . admin_url() . 'admin.php?page=wpcf7-new" target="_blank">' . __(' here') . '</a></p></td></tr></table>';
224
  }
225
  }
226
  /**
@@ -237,7 +235,7 @@ class cf7_style_meta_boxes {
237
  if ( in_array( $post_type, $post_types )) {
238
  add_meta_box(
239
  'cf7_style_meta_box_image'
240
- ,__( 'Preview', 'myplugin_textdomain' )
241
  ,array( $this, 'render_meta_box_image' )
242
  ,$post_type
243
  ,'side'
@@ -271,7 +269,7 @@ class cf7_style_meta_boxes {
271
  if ( in_array( $post_type, $post_types )) {
272
  add_meta_box(
273
  'cf7_style_meta_box_font_selector'
274
- ,__( 'Select a Google Font', 'myplugin_textdomain' )
275
  ,array( $this, 'render_font_selector' )
276
  ,$post_type
277
  ,'advanced'
@@ -289,13 +287,13 @@ class cf7_style_meta_boxes {
289
  $cf7_style_font = get_post_meta( $post->ID, 'cf7_style_font', true );
290
  $selected = '';
291
  echo '<select name="cf7_style_font_selector">';
292
- echo '<option value="none">None</option>';
293
  foreach ( $font_obj->items as $font) {
294
  echo '<option value="' . $font->family . '"' . ( $cf7_style_font == $font->family ? 'selected="selected"' : '' ) . '>' . $font->family . '</option>';
295
  }
296
  echo '</select>'; ?>
297
  <div class="cf7-style preview-zone">
298
- <h4>Preview Selected font:</h4>
299
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur rhoncus ultrices neque sit amet consequat. Aenean facilisis massa convallis nisl viverra eleifend. Nam fermentum mauris eu eleifend posuere.</p>
300
  </div>
301
  <div class="clear"></div>
@@ -343,7 +341,7 @@ class cf7_style_meta_boxes {
343
  if ( in_array( $post_type, $post_types )) {
344
  add_meta_box(
345
  'cf7_style_meta_box_paypal'
346
- ,__( 'Donate', 'myplugin_textdomain' )
347
  ,array( $this, 'render_meta_paypal' )
348
  ,$post_type
349
  ,'side'
@@ -355,7 +353,7 @@ class cf7_style_meta_boxes {
355
  * renders the image
356
  */
357
  public function render_meta_paypal( $post ) { ?>
358
- <p>Your donation will motivate us to work more and improve this plugin.</p>
359
  <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=ionut.iclanzan.reea@gmail.com&item_name=Donation+for+Contact+Form+Style" target="_blank">
360
  <img src="https://www.paypalobjects.com/webstatic/i/logo/rebrand/ppcom.svg">
361
  </a>
@@ -438,11 +436,9 @@ function manage_wp_posts_qe_bulk_quick_edit_custom_box( $column_name, $post_type
438
 
439
  switch ( $post_type ) {
440
  case 'cf7_style': ?>
441
- </td>
442
- <td class="special-colspan">
443
  <fieldset class="inline-edit-col-left cf7-quick-edit" style="clear:both">
444
  <div class="hidden-fields"></div>
445
- <h4><?php _e( "Activate this template on the following forms:", "cf7_style" ); ?></h4>
446
  <div class="inline-edit-col">
447
  <span class="data">
448
  <?php
@@ -464,7 +460,7 @@ function manage_wp_posts_qe_bulk_quick_edit_custom_box( $column_name, $post_type
464
  if( ! empty( $form_style ) && $id != $form_style ) {
465
  $template = get_the_title( $form_style );
466
  $permalink = admin_url() . "post.php?post={$form_style}&action=edit";
467
- echo "<span class='notice'>Notice: This form allready has a selected style. Checking this one will overwrite the <a href='{$permalink}' title='{$template}'>other one</a>.</span>";
468
  }
469
  endwhile;
470
  wp_reset_postdata();
44
  if ( in_array( $post_type, $post_types )) {
45
  add_meta_box(
46
  'cf7_style_meta_box_form_selector'
47
+ ,__( 'Select forms for current style', 'contact-form-7-style' )
48
  ,array( $this, 'render_meta_box_selector' )
49
  ,$post_type
50
  ,'advanced'
60
  if ( in_array( $post_type, $post_types ) && ( $custom_name == "custom style" ) ) {
61
  add_meta_box(
62
  'cf7_style_meta_box_style_customizer'
63
+ ,__( 'Custom style settings', 'contact-form-7-style' )
64
  ,array( $this, 'render_meta_box_style_customizer' )
65
  ,$post_type
66
  ,'advanced'
107
  update_post_meta( $post_id, 'cf7_style_active_panel', $active_pane, "");
108
  }
109
  if ( is_array( $posted_data ) && isset( $posted_data ) ) {
110
+ update_post_meta( $post_id, 'cf7_style_custom_styler', $posted_data , "");
 
111
  }
112
 
113
  }
180
  'posts_per_page' => -1
181
  );
182
  $currentpostid = get_the_ID();
183
+
 
184
  $query = new WP_Query( $args );
185
  echo '<table class="wp-list-table fixed pages widefat">';
186
  echo '<thead>';
187
  echo '<tr>';
188
+ echo '<th class="manage-column">' . __('Contact form 7 forms', 'contact-form-7-style' ) . '</th>';
189
+ echo '<th class="manage-column different-style"><input type="checkbox" id="select_all"/><label for="select_all">' . __('Select all','contact-form-7-style' ) . '</label></th>';
190
+ echo '<th class="generate-preview-option">' . __( "Generate preview", 'contact-form-7-style' ) . '</th>';
191
  echo '</tr>';
192
  echo '</thead>';
193
  echo '<tbody class="cf7style_body_select_all">';
203
  <input type="checkbox" id="<?php echo cf7_style_the_slug(); ?>" name="<?php echo cf7_style_the_slug(); ?>" value="<?php echo get_the_ID(); ?>" <?php if ( $currentpostid == $cf7stylehas ) { echo 'checked'; } ?> />
204
  </td>
205
  <td class="generate-preview-option">
206
+ <button class="button-primary generate-preview-button" data-attr-title="<?php the_title(); ?>" data-attr-id="<?php the_ID(); ?>"><?php _e( "Generate preview", 'contact-form-7-style' ); ?></button>
207
  </td>
208
  </tr>
209
  <tr>
210
  <td colspan="2">
211
  <?php if ( $currentpostid != $cf7stylehas && !empty( $cf7stylehas ) ) {
212
+ echo '<p class="description">' . __('Notice: This form allready has a selected style. Checking this one will overwrite the ', 'contact-form-7-style' ) . '<a href="' . get_admin_url() . 'post.php?post_type=cf7_style&post=' . $cf7stylehas . '&action=edit">' . __('other one.', 'contact-form-7-style' ) . '</a></p>';
213
  } ?>
214
  </td>
215
  <td class="generate-preview-option">&nbsp;</td>
218
  echo '</tbody>';
219
  echo '</table>';
220
  } else {
221
+ echo '<tr><td><p class="description">' . __( 'Please create a form. You can do it by clicking', 'contact-form-7-style' ) . '<a href="' . admin_url() . 'admin.php?page=wpcf7-new" target="_blank">' . __(' here', 'contact-form-7-style' ) . '</a></p></td></tr></table>';
222
  }
223
  }
224
  /**
235
  if ( in_array( $post_type, $post_types )) {
236
  add_meta_box(
237
  'cf7_style_meta_box_image'
238
+ ,__( 'Preview', 'contact-form-7-style' )
239
  ,array( $this, 'render_meta_box_image' )
240
  ,$post_type
241
  ,'side'
269
  if ( in_array( $post_type, $post_types )) {
270
  add_meta_box(
271
  'cf7_style_meta_box_font_selector'
272
+ ,__( 'Select a Google Font', 'contact-form-7-style' )
273
  ,array( $this, 'render_font_selector' )
274
  ,$post_type
275
  ,'advanced'
287
  $cf7_style_font = get_post_meta( $post->ID, 'cf7_style_font', true );
288
  $selected = '';
289
  echo '<select name="cf7_style_font_selector">';
290
+ echo '<option value="none">'.__( 'None', 'contact-form-7-style' ).'</option>';
291
  foreach ( $font_obj->items as $font) {
292
  echo '<option value="' . $font->family . '"' . ( $cf7_style_font == $font->family ? 'selected="selected"' : '' ) . '>' . $font->family . '</option>';
293
  }
294
  echo '</select>'; ?>
295
  <div class="cf7-style preview-zone">
296
+ <h4><?php _e( "Preview Selected font:", "contact-form-7-style" ) ?></h4>
297
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur rhoncus ultrices neque sit amet consequat. Aenean facilisis massa convallis nisl viverra eleifend. Nam fermentum mauris eu eleifend posuere.</p>
298
  </div>
299
  <div class="clear"></div>
341
  if ( in_array( $post_type, $post_types )) {
342
  add_meta_box(
343
  'cf7_style_meta_box_paypal'
344
+ ,__( 'Donate', 'contact-form-7-style' )
345
  ,array( $this, 'render_meta_paypal' )
346
  ,$post_type
347
  ,'side'
353
  * renders the image
354
  */
355
  public function render_meta_paypal( $post ) { ?>
356
+ <p><?php _e( "Your donation will motivate us to work more and improve this plugin.", "contact-form-7-style" ); ?></p>
357
  <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=ionut.iclanzan.reea@gmail.com&item_name=Donation+for+Contact+Form+Style" target="_blank">
358
  <img src="https://www.paypalobjects.com/webstatic/i/logo/rebrand/ppcom.svg">
359
  </a>
436
 
437
  switch ( $post_type ) {
438
  case 'cf7_style': ?>
 
 
439
  <fieldset class="inline-edit-col-left cf7-quick-edit" style="clear:both">
440
  <div class="hidden-fields"></div>
441
+ <h4><?php _e( "Activate this template on the following forms:", "contact-form-7-style" ); ?></h4>
442
  <div class="inline-edit-col">
443
  <span class="data">
444
  <?php
460
  if( ! empty( $form_style ) && $id != $form_style ) {
461
  $template = get_the_title( $form_style );
462
  $permalink = admin_url() . "post.php?post={$form_style}&action=edit";
463
+ echo "<span class='notice'>".__( "Notice: This form allready has a selected style. Checking this one will overwrite the", "contact-form-7-style" )." <a href='{$permalink}' title='{$template}'>".__( "other one", "contact-form-7-style" )."</a>.</span>";
464
  }
465
  endwhile;
466
  wp_reset_postdata();
cf7-style.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Contact Form 7 Style
4
  Plugin URI: http://wordpress.reea.net/contact-form-7-style/
5
  Description: Simple style customization and templating for Contact Form 7 forms. Requires Contact Form 7 plugin installed.
6
- Version: 3.0.3
7
  Author: Johnny, dorumarginean, mlehelsz, MirceaR
8
  Author URI: http://cf7style.com
9
  License: GPL2
@@ -15,10 +15,8 @@ License: GPL2
15
  */
16
  define( 'WPCF7S_PLUGIN', __FILE__ );
17
  define( 'WPCF7S_PLUGIN_DIR', untrailingslashit( dirname( WPCF7S_PLUGIN ) ) );
 
18
 
19
- function set_styleversion(){
20
- return "3.0.3";
21
- }
22
 
23
  function get_predefined_cf7_style_template_data() {
24
  require 'predefined-templates.php';
@@ -109,7 +107,8 @@ function cf7_style_custom_css_generator(){
109
  $forms = new WP_Query( $args );
110
  $total_num_posts = $forms->found_posts;
111
  $style = "";
112
- $cf7s_manual_style = get_option( 'cf7_style_manual_style', true );
 
113
  $active_styles = array();
114
  $style_number = 0;
115
  if( $forms->have_posts() ) :
@@ -118,9 +117,9 @@ function cf7_style_custom_css_generator(){
118
  $cf7s_id = get_post_meta( $id, 'cf7_style_id', true );
119
  $form_title = get_the_title($cf7s_id);
120
  if ( ( ! empty( $cf7s_id ) || $cf7s_id !== 0 ) && ! in_array( $cf7s_id, $active_styles ) ) {
121
- if( empty( $active_styles ) ) {
122
  $style .= "\n<style class='cf7-style' media='screen' type='text/css'>\n";
123
- }
124
  array_push( $active_styles, $cf7s_id );
125
  $cf7_style_data = get_post( $cf7s_id, OBJECT );
126
  $check_custom_style = has_term( 'custom-style', 'style_category', $cf7_style_data );
@@ -128,7 +127,8 @@ function cf7_style_custom_css_generator(){
128
  $cf7s_slug = ( $check_custom_style ) ? $cf7s_id : sanitize_title( $form_title);
129
  /*check if custom again*/
130
  if( $check_custom_style ){
131
- $cf7s_custom_settings = unserialize( get_post_meta( $cf7s_id, 'cf7_style_custom_styler', true ) );
 
132
  $cf7s_custom_settings = ( empty($cf7s_custom_settings) ) ? array() : $cf7s_custom_settings;
133
  $groundzero = "";
134
  $groundzero_hover = "";
@@ -212,18 +212,24 @@ function cf7_style_custom_css_generator(){
212
  }
213
  $style .= "\n".'body .cf7-style.' . $cf7s_slug . ",\nbody .cf7-style." . $cf7s_slug . " input[type='submit'] {\n\t font-family: '" . $font_family . "',sans-serif;\n} ";
214
  }
215
- if( !empty( $cf7s_manual_style ) ){
216
- $style.= "\n".$cf7s_manual_style."\n";
217
- }
218
-
219
  $style_number++;
220
  }/*Main if ends here*/
221
-
222
  endwhile;
 
 
 
 
 
 
 
 
 
 
 
223
  if( ( $style_number !== 0 ) && $style_number == count( $active_styles ) ) {
224
- $style .= "\n</style>\n";
225
- }
226
- echo $style;
227
  wp_reset_postdata();
228
  endif;
229
  }// end of cf7_style_custom_css_generator
@@ -233,12 +239,12 @@ function cf7_style_admin_scripts($hook){
233
  if (!wp_script_is( 'jquery', 'enqueued' )) {
234
  wp_enqueue_script('jquery');
235
  }
236
- wp_enqueue_style( "cf7-style-bar-style", $cur_plug_url . "css/admin-bar.css", array(), set_styleversion(), "all");
237
- wp_enqueue_script( "cf7_style_overall", $cur_plug_url . "admin/js/overall.js", array('jquery'), false, true );
238
  if( 'cf7_style_page_cf7style-css-editor' == $hook ){
239
- wp_enqueue_script( "cf7_style_codemirror_js", $cur_plug_url . "admin/js/codemirror.js", array( 'jquery' ), false, true );
240
- wp_enqueue_style( "cf7-style-codemirror-style", $cur_plug_url . "admin/css/codemirror.css", array(), set_styleversion(), "all" );
241
- wp_enqueue_script( "cf7-style-codemirror-mode", $cur_plug_url . "admin/js/mode/css/css.js", array( 'jquery' ), false, true );
242
  }
243
  if( 'cf7_style' == $post_type){
244
  wp_enqueue_style( 'wp-color-picker' );
@@ -246,10 +252,10 @@ function cf7_style_admin_scripts($hook){
246
  wp_enqueue_style( 'thickbox' );
247
  wp_enqueue_script( 'media-upload' );
248
  }
249
- if( 'plugins.php'== $hook || 'cf7_style' == $post_type || 'toplevel_page_wpcf7' == $hook || 'cf7_style_page_cf7style-css-editor' == $hook){
250
  wp_enqueue_style('cf7-style-font-awesome', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.6.2/css/font-awesome.min.css');
251
- wp_enqueue_style( "cf7-style-admin-style", $cur_plug_url . "admin/css/admin.css", false, "1.0", "all");
252
- wp_enqueue_script( "cf7_style_admin_js", $cur_plug_url . "admin/js/admin.js", array( 'wp-color-picker' ), false, true );
253
  }
254
  }
255
  function cf7_style_add_class( $class ){
@@ -273,7 +279,7 @@ function contact_form_7_check() {
273
 
274
  $html = '<div class="error">';
275
  $html .= '<p>';
276
- $html .= 'Contact form 7 - Style is an addon. Please install <a href="http://wordpress.org/plugins/contact-form-7/" target="_blank">Contact form 7</a>.';
277
  $html .= '</p>';
278
  $html .= '</div><!-- /.updated -->';
279
  echo $html;
@@ -284,7 +290,7 @@ function contact_form_7_check() {
284
 
285
  $html = '<div class="updated">';
286
  $html .= '<p>';
287
- $html .= 'Contact Form 7 - Style addon is now activated. Navigate to <a href="' . get_bloginfo( "url" ) . '/wp-admin/edit.php?post_type=cf7_style">Contact Style</a> to get started.';
288
  $html .= '</p>';
289
  $html .= '</div><!-- /.updated -->';
290
  echo $html;
@@ -293,17 +299,22 @@ function contact_form_7_check() {
293
  $cf7_style_templates = get_option( 'cf7_style_no_temps' );
294
  if($cf7_style_templates != "hide_box"){
295
  $box = '<div class="updated template-message-box">';
296
- $box .= '<p><label><input type="checkbox" name="custom_template_check" checked="checked" />Keep predefined Contact Form 7 Style templates ?</label></p>';
 
297
  $box .= '<div class="double-check hidden">';
298
- $box .= '<label>Are you sure you want to remove the predefined templates? ';
299
- $box .= '<span>Yes</span><input type="radio" name="double_check_template" value="yes" />';
 
300
  $box .= '</label><label>';
301
- $box .= '<span>No</span><input type="radio" name="double_check_template" value="no" checked="checked" /></label>';
302
- $box .= '<a href="#" class="confirm-remove-template button">Confirm</a>';
303
- $box .= '</div><a href="#" class="remove_template_notice">Dismiss</a>';
304
  $box .= '<div style="clear:both;"></div>';
305
  $box .= '</div>';
306
- echo $box;
 
 
 
307
  }
308
  }
309
  } // end if $active_plugins
@@ -313,7 +324,8 @@ add_action( 'admin_notices', 'contact_form_7_check' );
313
  function cf7_style_create_post( $slug, $title, $image) {
314
  // Initialize the page ID to -1. This indicates no action has been taken.
315
  $post_id = -1;
316
- if( null == get_page_by_title( $title, "OBJECT", "cf7_style" ) ) {
 
317
  // Set the post ID so that we know the post was created successfully
318
  $post_id = wp_insert_post(
319
  array(
@@ -377,34 +389,34 @@ function cf7_style_set_style_category_on_publish( $ID, $post ) {
377
  }
378
  } // end cf7_style_set_style_category_on_publish
379
  function cf7_style_create_posts(){
380
- update_option( 'cf7_style_no_temps', 'hide_box' );
381
  update_option( 'cf7_style_welcome', 'show_box' );
382
  update_option( 'cf7_style_update_saved', 'yes' );
383
  update_option( 'cf7_style_allow_tracking', '5' );
384
  }
385
  // Hook into the 'cf7_style_create_posts' action
386
- register_activation_hook( __FILE__, 'cf7_style_create_posts' );
387
 
388
  function cf7style_load_elements(){
389
 
390
  $labels = array(
391
- 'name' => _x( 'Contact Styles', 'Post Type General Name', 'cf7_style' ),
392
- 'singular_name' => _x( 'Contact Style', 'Post Type Singular Name', 'cf7_style' ),
393
- 'menu_name' => __( 'Contact Style', 'cf7_style' ),
394
- 'parent_item_colon' => __( 'Parent Style:', 'cf7_style' ),
395
- 'all_items' => __( 'All Styles', 'cf7_style' ),
396
- 'view_item' => __( 'View Style', 'cf7_style' ),
397
- 'add_new_item' => __( 'Add New', 'cf7_style' ),
398
- 'add_new' => __( 'Add New', 'cf7_style' ),
399
- 'edit_item' => __( 'Edit Style', 'cf7_style' ),
400
- 'update_item' => __( 'Update Style', 'cf7_style' ),
401
- 'search_items' => __( 'Search Style', 'cf7_style' ),
402
- 'not_found' => __( 'Not found', 'cf7_style' ),
403
- 'not_found_in_trash' => __( 'Not found in Trash', 'cf7_style' )
404
  );
405
  $args = array(
406
- 'label' => __( 'cf7_style', 'cf7_style' ),
407
- 'description' => __( 'Add/remove contact style', 'cf7_style' ),
408
  'labels' => $labels,
409
  'supports' => array( 'title' ),
410
  'hierarchical' => false,
@@ -426,21 +438,21 @@ function cf7style_load_elements(){
426
  register_post_type( 'cf7_style', $args );
427
 
428
  $labels = array(
429
- 'name' => _x( 'Categories', 'Taxonomy General Name', 'cf7_style' ),
430
- 'singular_name' => _x( 'Categories', 'Taxonomy Singular Name', 'cf7_style' ),
431
- 'menu_name' => __( 'Categories', 'cf7_style' ),
432
- 'all_items' => __( 'All Categories', 'cf7_style' ),
433
- 'parent_item' => __( 'Parent Categories', 'cf7_style' ),
434
- 'parent_item_colon' => __( 'Parent Categories:', 'cf7_style' ),
435
- 'new_item_name' => __( 'New Categories Name', 'cf7_style' ),
436
- 'add_new_item' => __( 'Add New Categories', 'cf7_style' ),
437
- 'edit_item' => __( 'Edit Categories', 'cf7_style' ),
438
- 'update_item' => __( 'Update Categories', 'cf7_style' ),
439
- 'separate_items_with_commas' => __( 'Separate Categories with commas', 'cf7_style' ),
440
- 'search_items' => __( 'Search Categories', 'cf7_style' ),
441
- 'add_or_remove_items' => __( 'Add or remove Categories', 'cf7_style' ),
442
- 'choose_from_most_used' => __( 'Choose from the most used Categories', 'cf7_style' ),
443
- 'not_found' => __( 'Not Found', 'cf7_style' ),
444
  );
445
  $args = array(
446
  'labels' => $labels,
@@ -454,31 +466,30 @@ function cf7style_load_elements(){
454
  //register tax
455
  register_taxonomy( 'style_category', array( 'cf7_style' ), $args );
456
  $cf7_style_templates = get_option( 'cf7_style_no_temps' );
457
- if( $cf7_style_templates == 'hide_box'){
458
- //die();
459
- foreach ( get_predefined_cf7_style_template_data() as $style ) {
460
- cf7_style_create_post( strtolower( str_replace( " ", "-", $style['title'] ) ), $style['title'], $style['image'] );
461
- }
462
- if( get_option( 'cf7_style_add_categories', 0 ) == 0 ){
463
- $cf7_style_args = array(
464
- 'post_type' => 'cf7_style'
465
- );
466
-
467
- $cf7_style_query = new WP_Query( $cf7_style_args );
468
- if ( $cf7_style_query->have_posts() ) {
469
- while ( $cf7_style_query->have_posts() ) {
470
- $cf7_style_query->the_post();
471
- $temp_title = get_the_title();
472
- $temp_ID = get_the_ID();
473
 
474
- foreach ( get_predefined_cf7_style_template_data() as $style ) {
475
- if( $temp_title == wptexturize( $style[ 'title' ] ) ) {
476
- wp_set_object_terms( $temp_ID, $style[ 'category' ], 'style_category' );
477
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
478
  }
479
  }
480
- update_option( 'cf7_style_add_categories', 1 );
481
  }
 
 
482
  }
483
  }
484
  $cf7_style_update_saved = get_option( 'cf7_style_update_saved' );
@@ -496,20 +507,21 @@ function cf7style_load_elements(){
496
  $cf7_style_query->the_post();
497
  $cur_style_id = get_the_ID();
498
  $cur_manual_style = get_post_meta( $cur_style_id, 'cf7_style_manual_style', true );
499
- $cur_custom_styles = get_post_meta( $cur_style_id, 'cf7_style_custom_styles', true );
500
  if($cur_manual_style){
501
  $cf7s_manual_old_style .= $cur_manual_style;
502
  update_post_meta( $cur_style_id, 'cf7_style_manual_style', '' );
503
  }
504
  if($cur_custom_styles){
505
- $cf7s_custom_old_settings = unserialize($cur_custom_styles);
506
  require_once( 'cf7-style-match-old.php' );
507
  $new_settings = get_new_styler_data( $cf7s_custom_old_settings );
508
  update_post_meta( $cur_style_id, 'cf7_style_manual_styles', '');
509
  update_post_meta( $cur_style_id, 'cf7_style_custom_styles', '');
510
- update_post_meta( $cur_style_id, 'cf7_style_custom_styler', serialize( $new_settings ), "");
511
  }
512
  }
 
513
  if($cf7s_manual_old_style){
514
  update_option( 'cf7_style_manual_style', $cf7s_manual_old_style );
515
  }
@@ -528,34 +540,70 @@ function cf7_style_frontend_scripts(){
528
  if (!wp_script_is( 'jquery', 'enqueued' )) {
529
  wp_enqueue_script('jquery');
530
  }
531
- wp_enqueue_style( "cf7-style-bar-style", $plug_dir_url . "css/admin-bar.css", array(), set_styleversion(), "all");
532
- wp_enqueue_style( "cf7-style-frontend-style", $plug_dir_url . "css/frontend.css", array(), set_styleversion(), "all");
533
- wp_enqueue_style( "cf7-style-responsive-style", $plug_dir_url . "css/responsive.css", array(), set_styleversion(), "all");
534
- wp_enqueue_script( "cf7-style-frontend-script", $plug_dir_url . "js/frontend.js", array( 'jquery' ), set_styleversion(), true);
 
 
535
  }
536
  function cf7style_toolbar_link($wp_admin_bar) {
537
  $args = array(
538
  'id' => 'cf7-style',
539
- 'title' => 'Contact Form Style',
540
  'href' => admin_url("edit.php?post_type=cf7_style"),
541
  'meta' => array(
542
  'class' => 'contact-style',
543
- 'title' => 'Contact Form Style',
544
  'html' => '<span class="admin-style-icon"><i class="dashicons-before dashicons-twitter" aria-hidden="true"></i></span>'
545
  )
546
  );
547
  $wp_admin_bar->add_node($args);
548
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
549
  add_action('admin_bar_menu', 'cf7style_toolbar_link', 999);
550
 
551
  add_action( 'admin_enqueue_scripts', 'cf7_style_admin_scripts' );
552
  add_action( 'wp_enqueue_scripts', 'cf7_style_frontend_scripts' );
553
  add_action( 'init', 'cf7style_load_elements' );
554
  add_action( 'restrict_manage_posts', 'cf7_style_add_taxonomy_filters' );
555
- add_action( 'publish_cf7_style', 'cf7_style_set_style_category_on_publish', 10, 2 );
556
  add_filter( 'wpcf7_form_class_attr', 'cf7_style_add_class' );
557
- add_filter('manage_cf7_style_posts_columns', 'cf7_style_event_table_head');
558
  add_action( 'manage_cf7_style_posts_custom_column', 'cf7_style_event_table_content', 10, 2 );
 
 
559
 
560
  function cf7_style_event_table_head( $defaults ) {
561
  $new = array();
@@ -602,7 +650,7 @@ add_action('admin_init', 'deactivate_contact_form_7_designer_plugin');
602
  */
603
  function cf7_designer_deactivation_notice() { ?>
604
  <div class="error">
605
- <p>You cannot activate CF7 Designer while CF7 Style is activated!</p>
606
  </div>
607
  <?php }
608
 
@@ -622,11 +670,19 @@ require_once( 'inc/slider_meta_box.php' );
622
  * global css page
623
  */
624
  require_once( 'inc/editor_page.php' );
 
 
 
 
 
 
 
625
  /*
626
  * Remove Predefined templates
627
  */
628
  function cf7_style_remove_templates() {
629
  global $wpdb;
 
630
  $del_args = array(
631
  'posts_per_page' => -1,
632
  'post_type' => 'cf7_style',
@@ -643,8 +699,25 @@ function cf7_style_remove_templates() {
643
  if ( $del_query->have_posts() ) {
644
  while ( $del_query->have_posts() ) {
645
  $del_query->the_post();
646
- wp_delete_post(get_the_ID(),false);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
647
  }
 
648
  print_r('success');
649
  }
650
  wp_die();
@@ -676,10 +749,10 @@ function cf7_style_frontend_edit_link( $form ) {
676
  $cf7_style_id = get_post_meta( $form_id, 'cf7_style_id', true );
677
 
678
  if( empty( $cf7_style_id ) ) {
679
- $form .= "<a href='" . admin_url( 'edit.php?post_type=cf7_style' ) . "' class='frontend-edit-style-link'>" . __( 'Add Style', 'cf7_style' ) . "</a>";
680
  } else {
681
  $cf7_style_data = get_post( $cf7_style_id, OBJECT );
682
- $template_type = ( has_term( 'custom-style', 'style_category', $cf7_style_data ) ) ? __( 'Edit custom style', 'cf7_style' ) : __( 'Edit predifined template', 'cf7_style' );
683
  $form .= "<a href='" . admin_url( 'post.php?post=' . $cf7_style_id . '&action=edit' ) . "' class='frontend-edit-style-link'>" . $template_type . "</a>";
684
  }
685
  }
3
  Plugin Name: Contact Form 7 Style
4
  Plugin URI: http://wordpress.reea.net/contact-form-7-style/
5
  Description: Simple style customization and templating for Contact Form 7 forms. Requires Contact Form 7 plugin installed.
6
+ Version: 3.0.4
7
  Author: Johnny, dorumarginean, mlehelsz, MirceaR
8
  Author URI: http://cf7style.com
9
  License: GPL2
15
  */
16
  define( 'WPCF7S_PLUGIN', __FILE__ );
17
  define( 'WPCF7S_PLUGIN_DIR', untrailingslashit( dirname( WPCF7S_PLUGIN ) ) );
18
+ define( 'WPCF7S_PLUGIN_VER', '3.0.4' );
19
 
 
 
 
20
 
21
  function get_predefined_cf7_style_template_data() {
22
  require 'predefined-templates.php';
107
  $forms = new WP_Query( $args );
108
  $total_num_posts = $forms->found_posts;
109
  $style = "";
110
+ $cf7s_manual_style = html_entity_decode(stripslashes(get_option( 'cf7_style_manual_style', true )),ENT_QUOTES);
111
+ $cf7s_manual_style = ( $cf7s_manual_style == '1' ) ? "" : $cf7s_manual_style;
112
  $active_styles = array();
113
  $style_number = 0;
114
  if( $forms->have_posts() ) :
117
  $cf7s_id = get_post_meta( $id, 'cf7_style_id', true );
118
  $form_title = get_the_title($cf7s_id);
119
  if ( ( ! empty( $cf7s_id ) || $cf7s_id !== 0 ) && ! in_array( $cf7s_id, $active_styles ) ) {
120
+ /*if( empty( $active_styles ) ) {
121
  $style .= "\n<style class='cf7-style' media='screen' type='text/css'>\n";
122
+ }*/
123
  array_push( $active_styles, $cf7s_id );
124
  $cf7_style_data = get_post( $cf7s_id, OBJECT );
125
  $check_custom_style = has_term( 'custom-style', 'style_category', $cf7_style_data );
127
  $cf7s_slug = ( $check_custom_style ) ? $cf7s_id : sanitize_title( $form_title);
128
  /*check if custom again*/
129
  if( $check_custom_style ){
130
+ $cf7s_custom_settings = maybe_unserialize( get_post_meta( $cf7s_id, 'cf7_style_custom_styler', true ));
131
+
132
  $cf7s_custom_settings = ( empty($cf7s_custom_settings) ) ? array() : $cf7s_custom_settings;
133
  $groundzero = "";
134
  $groundzero_hover = "";
212
  }
213
  $style .= "\n".'body .cf7-style.' . $cf7s_slug . ",\nbody .cf7-style." . $cf7s_slug . " input[type='submit'] {\n\t font-family: '" . $font_family . "',sans-serif;\n} ";
214
  }
 
 
 
 
215
  $style_number++;
216
  }/*Main if ends here*/
 
217
  endwhile;
218
+ $style_manual = "";
219
+ $style_start = "\n<style class='cf7-style' media='screen' type='text/css'>\n";
220
+ if( !empty( $cf7s_manual_style ) ){
221
+ $style_manual = "\n".$cf7s_manual_style."\n";
222
+ }
223
+ $cur_css = $style_start;
224
+ require_once 'inc/cssparser.php';
225
+ $css = new CSSParser();
226
+ $cssIndex = $css->ParseCSS($style);
227
+ $cur_css .= $css->GetCSS($cssIndex);
228
+ $cur_css .= $style_manual;
229
  if( ( $style_number !== 0 ) && $style_number == count( $active_styles ) ) {
230
+ $cur_css .= "\n</style>\n";
231
+ }
232
+ echo $cur_css;
233
  wp_reset_postdata();
234
  endif;
235
  }// end of cf7_style_custom_css_generator
239
  if (!wp_script_is( 'jquery', 'enqueued' )) {
240
  wp_enqueue_script('jquery');
241
  }
242
+ wp_enqueue_style( "cf7-style-bar-style", $cur_plug_url . "css/admin-bar.css", array(), WPCF7S_PLUGIN_VER, "all");
243
+ wp_enqueue_script( "cf7_style_overall", $cur_plug_url . "admin/js/overall.js", array('jquery'), WPCF7S_PLUGIN_VER, true );
244
  if( 'cf7_style_page_cf7style-css-editor' == $hook ){
245
+ wp_enqueue_script( "cf7_style_codemirror_js", $cur_plug_url . "admin/js/codemirror.js", array( 'jquery' ), WPCF7S_PLUGIN_VER, true );
246
+ wp_enqueue_style( "cf7-style-codemirror-style", $cur_plug_url . "admin/css/codemirror.css", array(), WPCF7S_PLUGIN_VER, "all" );
247
+ wp_enqueue_script( "cf7-style-codemirror-mode", $cur_plug_url . "admin/js/mode/css/css.js", array( 'jquery' ), WPCF7S_PLUGIN_VER, true );
248
  }
249
  if( 'cf7_style' == $post_type){
250
  wp_enqueue_style( 'wp-color-picker' );
252
  wp_enqueue_style( 'thickbox' );
253
  wp_enqueue_script( 'media-upload' );
254
  }
255
+ if( 'plugins.php'== $hook || 'cf7_style' == $post_type || 'toplevel_page_wpcf7' == $hook || 'cf7_style_page_cf7style-css-editor' == $hook || 'cf7_style_page_system-status' == $hook ){
256
  wp_enqueue_style('cf7-style-font-awesome', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.6.2/css/font-awesome.min.css');
257
+ wp_enqueue_style( "cf7-style-admin-style", $cur_plug_url . "admin/css/admin.css", false, WPCF7S_PLUGIN_VER, "all");
258
+ wp_enqueue_script( "cf7_style_admin_js", $cur_plug_url . "admin/js/admin.js", array( 'wp-color-picker', 'jquery' ), WPCF7S_PLUGIN_VER, true );
259
  }
260
  }
261
  function cf7_style_add_class( $class ){
279
 
280
  $html = '<div class="error">';
281
  $html .= '<p>';
282
+ $html .= __( "Contact form 7 - Style is an addon. Please install", "contact-form-7-style" ).' <a href="http://wordpress.org/plugins/contact-form-7/" target="_blank">Contact form 7</a>.';
283
  $html .= '</p>';
284
  $html .= '</div><!-- /.updated -->';
285
  echo $html;
290
 
291
  $html = '<div class="updated">';
292
  $html .= '<p>';
293
+ $html .= __( "Contact Form 7 - Style addon is now activated. Navigate to", "contact-form-7-style" ).' <a href="' . get_bloginfo( "url" ) . '/wp-admin/edit.php?post_type=cf7_style">'.__( "Contact Style", "contact-form-7-style" ).'</a> '.__( "to get started.", "contact-form-7-style" );
294
  $html .= '</p>';
295
  $html .= '</div><!-- /.updated -->';
296
  echo $html;
299
  $cf7_style_templates = get_option( 'cf7_style_no_temps' );
300
  if($cf7_style_templates != "hide_box"){
301
  $box = '<div class="updated template-message-box">';
302
+ $box .= '<p><label><input type="checkbox" name="custom_template_check" checked="checked" />'.__( "Click here, if you want to delete ALL predefined Contact Form 7 Style templates.", "contact-form-7-style" ).'</label></p>';
303
+ $box .= '<p><small>'.__( "This works only if the predefined templates are not in the", "contact-form-7-style" ).' <a href="'.admin_url('edit.php?post_status=trash&post_type=cf7_style').'">'.__( "Trash", "contact-form-7-style" ).'</a>.</small></p>';
304
  $box .= '<div class="double-check hidden">';
305
+ $box .= '<label>'.__( "Are you sure you want to remove? ", "contact-form-7-style" );
306
+ $box .= '<br/><span>( '.__( "All Contact Form 7 Style predefined templates attached to your Contact Form 7 form will be removed", "contact-form-7-style" ).' ) &nbsp;&nbsp;</span>';
307
+ $box .= '<span> '.__( "Yes", "contact-form-7-style" ).'</span><input type="radio" name="double_check_template" value="yes" />';
308
  $box .= '</label><label>';
309
+ $box .= '<span> '.__( "No", "contact-form-7-style" ).'</span><input type="radio" name="double_check_template" value="no" checked="checked" /></label>';
310
+ $box .= '<a href="#" class="confirm-remove-template button"> '.__( "Confirm", "contact-form-7-style" ).'</a>';
311
+ $box .= '</div><a href="#" class="remove_template_notice">'.__( "Dismiss", "contact-form-7-style" ).'</a>';
312
  $box .= '<div style="clear:both;"></div>';
313
  $box .= '</div>';
314
+ $screen = get_current_screen();
315
+ if($screen->id == 'edit-cf7_style' || $screen->id == 'cf7_style'){
316
+ echo $box;
317
+ }
318
  }
319
  }
320
  } // end if $active_plugins
324
  function cf7_style_create_post( $slug, $title, $image) {
325
  // Initialize the page ID to -1. This indicates no action has been taken.
326
  $post_id = -1;
327
+ $was_deleted = get_option('cf7_style_deleted');
328
+ if( null == get_page_by_title( $title, "OBJECT", "cf7_style" ) && $was_deleted != "yes" ) {
329
  // Set the post ID so that we know the post was created successfully
330
  $post_id = wp_insert_post(
331
  array(
389
  }
390
  } // end cf7_style_set_style_category_on_publish
391
  function cf7_style_create_posts(){
392
+ update_option( 'cf7_style_no_temps', 'show_box' );
393
  update_option( 'cf7_style_welcome', 'show_box' );
394
  update_option( 'cf7_style_update_saved', 'yes' );
395
  update_option( 'cf7_style_allow_tracking', '5' );
396
  }
397
  // Hook into the 'cf7_style_create_posts' action
398
+ // register_activation_hook( __FILE__, 'cf7_style_create_posts' );
399
 
400
  function cf7style_load_elements(){
401
 
402
  $labels = array(
403
+ 'name' => _x( 'Contact Styles', 'Post Type General Name', 'contact-form-7-style' ),
404
+ 'singular_name' => _x( 'Contact Style', 'Post Type Singular Name', 'contact-form-7-style' ),
405
+ 'menu_name' => __( 'Contact Style', 'contact-form-7-style' ),
406
+ 'parent_item_colon' => __( 'Parent Style:', 'contact-form-7-style' ),
407
+ 'all_items' => __( 'All Styles', 'contact-form-7-style' ),
408
+ 'view_item' => __( 'View Style', 'contact-form-7-style' ),
409
+ 'add_new_item' => __( 'Add New', 'contact-form-7-style' ),
410
+ 'add_new' => __( 'Add New', 'contact-form-7-style' ),
411
+ 'edit_item' => __( 'Edit Style', 'contact-form-7-style' ),
412
+ 'update_item' => __( 'Update Style', 'contact-form-7-style' ),
413
+ 'search_items' => __( 'Search Style', 'contact-form-7-style' ),
414
+ 'not_found' => __( 'Not found', 'contact-form-7-style' ),
415
+ 'not_found_in_trash' => __( 'Not found in Trash', 'contact-form-7-style' )
416
  );
417
  $args = array(
418
+ 'label' => __( 'cf7_style', 'contact-form-7-style' ),
419
+ 'description' => __( 'Add/remove contact style', 'contact-form-7-style' ),
420
  'labels' => $labels,
421
  'supports' => array( 'title' ),
422
  'hierarchical' => false,
438
  register_post_type( 'cf7_style', $args );
439
 
440
  $labels = array(
441
+ 'name' => _x( 'Categories', 'Taxonomy General Name', 'contact-form-7-style' ),
442
+ 'singular_name' => _x( 'Categories', 'Taxonomy Singular Name', 'contact-form-7-style' ),
443
+ 'menu_name' => __( 'Categories', 'contact-form-7-style' ),
444
+ 'all_items' => __( 'All Categories', 'contact-form-7-style' ),
445
+ 'parent_item' => __( 'Parent Categories', 'contact-form-7-style' ),
446
+ 'parent_item_colon' => __( 'Parent Categories:', 'contact-form-7-style' ),
447
+ 'new_item_name' => __( 'New Categories Name', 'contact-form-7-style' ),
448
+ 'add_new_item' => __( 'Add New Categories', 'contact-form-7-style' ),
449
+ 'edit_item' => __( 'Edit Categories', 'contact-form-7-style' ),
450
+ 'update_item' => __( 'Update Categories', 'contact-form-7-style' ),
451
+ 'separate_items_with_commas' => __( 'Separate Categories with commas', 'contact-form-7-style' ),
452
+ 'search_items' => __( 'Search Categories', 'contact-form-7-style' ),
453
+ 'add_or_remove_items' => __( 'Add or remove Categories', 'contact-form-7-style' ),
454
+ 'choose_from_most_used' => __( 'Choose from the most used Categories', 'contact-form-7-style' ),
455
+ 'not_found' => __( 'Not Found', 'contact-form-7-style' ),
456
  );
457
  $args = array(
458
  'labels' => $labels,
466
  //register tax
467
  register_taxonomy( 'style_category', array( 'cf7_style' ), $args );
468
  $cf7_style_templates = get_option( 'cf7_style_no_temps' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
469
 
470
+ foreach ( get_predefined_cf7_style_template_data() as $style ) {
471
+ cf7_style_create_post( strtolower( str_replace( " ", "-", $style['title'] ) ), $style['title'], $style['image'] );
472
+ }
473
+ if( get_option( 'cf7_style_add_categories', 0 ) == 0 ){
474
+ $cf7_style_args = array(
475
+ 'post_type' => 'cf7_style'
476
+ );
477
+
478
+ $cf7_style_query = new WP_Query( $cf7_style_args );
479
+ if ( $cf7_style_query->have_posts() ) {
480
+ while ( $cf7_style_query->have_posts() ) {
481
+ $cf7_style_query->the_post();
482
+ $temp_title = get_the_title();
483
+ $temp_ID = get_the_ID();
484
+
485
+ foreach ( get_predefined_cf7_style_template_data() as $style ) {
486
+ if( $temp_title == wptexturize( $style[ 'title' ] ) ) {
487
+ wp_set_object_terms( $temp_ID, $style[ 'category' ], 'style_category' );
488
  }
489
  }
 
490
  }
491
+ wp_reset_postdata();
492
+ update_option( 'cf7_style_add_categories', 1 );
493
  }
494
  }
495
  $cf7_style_update_saved = get_option( 'cf7_style_update_saved' );
507
  $cf7_style_query->the_post();
508
  $cur_style_id = get_the_ID();
509
  $cur_manual_style = get_post_meta( $cur_style_id, 'cf7_style_manual_style', true );
510
+ $cur_custom_styles = maybe_unserialize( get_post_meta( $cur_style_id, 'cf7_style_custom_styles', true ));
511
  if($cur_manual_style){
512
  $cf7s_manual_old_style .= $cur_manual_style;
513
  update_post_meta( $cur_style_id, 'cf7_style_manual_style', '' );
514
  }
515
  if($cur_custom_styles){
516
+ $cf7s_custom_old_settings = $cur_custom_styles;
517
  require_once( 'cf7-style-match-old.php' );
518
  $new_settings = get_new_styler_data( $cf7s_custom_old_settings );
519
  update_post_meta( $cur_style_id, 'cf7_style_manual_styles', '');
520
  update_post_meta( $cur_style_id, 'cf7_style_custom_styles', '');
521
+ update_post_meta( $cur_style_id, 'cf7_style_custom_styler', $new_settings, "");
522
  }
523
  }
524
+ wp_reset_postdata();
525
  if($cf7s_manual_old_style){
526
  update_option( 'cf7_style_manual_style', $cf7s_manual_old_style );
527
  }
540
  if (!wp_script_is( 'jquery', 'enqueued' )) {
541
  wp_enqueue_script('jquery');
542
  }
543
+ if(is_user_logged_in()){
544
+ wp_enqueue_style( "cf7-style-bar-style", $plug_dir_url . "css/admin-bar.css", array(), WPCF7S_PLUGIN_VER, "all");
545
+ }
546
+ wp_enqueue_style( "cf7-style-frontend-style", $plug_dir_url . "css/frontend.css", array(), WPCF7S_PLUGIN_VER, "all");
547
+ wp_enqueue_style( "cf7-style-responsive-style", $plug_dir_url . "css/responsive.css", array(), WPCF7S_PLUGIN_VER, "all");
548
+ wp_enqueue_script( "cf7-style-frontend-script", $plug_dir_url . "js/frontend.js", array( 'jquery' ), WPCF7S_PLUGIN_VER, true);
549
  }
550
  function cf7style_toolbar_link($wp_admin_bar) {
551
  $args = array(
552
  'id' => 'cf7-style',
553
+ 'title' => 'Contact Form 7 Style',
554
  'href' => admin_url("edit.php?post_type=cf7_style"),
555
  'meta' => array(
556
  'class' => 'contact-style',
557
+ 'title' => 'Contact Form 7 Style',
558
  'html' => '<span class="admin-style-icon"><i class="dashicons-before dashicons-twitter" aria-hidden="true"></i></span>'
559
  )
560
  );
561
  $wp_admin_bar->add_node($args);
562
  }
563
+ function cf7style_update_db_check() {
564
+ if (get_option( 'cf7_style_plugin_version' ) != WPCF7S_PLUGIN_VER) {
565
+ cf7_style_create_posts();
566
+ update_option( 'cf7_style_plugin_version', WPCF7S_PLUGIN_VER );
567
+ }
568
+ }
569
+
570
+ function cf7style_check_deleted( $postid ){
571
+ global $post_type;
572
+ if ( $post_type != 'cf7_style' ) return;
573
+ $check_deleted = get_option('cf7_style_deleted');
574
+ $clr_form_args = array(
575
+ 'post_type' => 'wpcf7_contact_form',
576
+ 'posts_per_page' => -1,
577
+ 'meta_key' => 'cf7_style_id',
578
+ 'meta_value' => $postid
579
+ );
580
+ $form_query = new WP_Query( $clr_form_args );
581
+ if ( $form_query->have_posts() ) {
582
+ while ( $form_query->have_posts() ) {
583
+ $form_query->the_post();
584
+ /*form id*/
585
+ update_post_meta( get_the_ID(), 'cf7_style_id', '');
586
+ }
587
+ wp_reset_postdata();
588
+ }
589
+ if("yes" != $check_deleted){
590
+ update_option( 'cf7_style_no_temps', 'hide_box' );
591
+ update_option('cf7_style_deleted','yes');
592
+ }
593
+ }
594
+
595
  add_action('admin_bar_menu', 'cf7style_toolbar_link', 999);
596
 
597
  add_action( 'admin_enqueue_scripts', 'cf7_style_admin_scripts' );
598
  add_action( 'wp_enqueue_scripts', 'cf7_style_frontend_scripts' );
599
  add_action( 'init', 'cf7style_load_elements' );
600
  add_action( 'restrict_manage_posts', 'cf7_style_add_taxonomy_filters' );
601
+ add_action( 'publish_cf7_style', 'cf7_style_set_style_category_on_publish', 10, 2 );
602
  add_filter( 'wpcf7_form_class_attr', 'cf7_style_add_class' );
603
+ add_filter( 'manage_cf7_style_posts_columns', 'cf7_style_event_table_head');
604
  add_action( 'manage_cf7_style_posts_custom_column', 'cf7_style_event_table_content', 10, 2 );
605
+ add_action( 'plugins_loaded', 'cf7style_update_db_check' );
606
+ add_action( 'before_delete_post', 'cf7style_check_deleted' );
607
 
608
  function cf7_style_event_table_head( $defaults ) {
609
  $new = array();
650
  */
651
  function cf7_designer_deactivation_notice() { ?>
652
  <div class="error">
653
+ <p><?php _e( "You cannot activate CF7 Designer while CF7 Style is activated!", "contact-form-7-style" ) ?></p>
654
  </div>
655
  <?php }
656
 
670
  * global css page
671
  */
672
  require_once( 'inc/editor_page.php' );
673
+
674
+ /**
675
+ * System status
676
+ */
677
+ require_once( 'inc/system_status.php' );
678
+
679
+
680
  /*
681
  * Remove Predefined templates
682
  */
683
  function cf7_style_remove_templates() {
684
  global $wpdb;
685
+ update_option( 'cf7_style_deleted', 'yes' );
686
  $del_args = array(
687
  'posts_per_page' => -1,
688
  'post_type' => 'cf7_style',
699
  if ( $del_query->have_posts() ) {
700
  while ( $del_query->have_posts() ) {
701
  $del_query->the_post();
702
+ $style_id = get_the_ID();
703
+ $clr_form_args = array(
704
+ 'post_type' => 'wpcf7_contact_form',
705
+ 'posts_per_page' => -1,
706
+ 'meta_key' => 'cf7_style_id',
707
+ 'meta_value' => $style_id
708
+ );
709
+ $form_query = new WP_Query( $clr_form_args );
710
+ if ( $form_query->have_posts() ) {
711
+ while ( $form_query->have_posts() ) {
712
+ $form_query->the_post();
713
+ /*form id*/
714
+ update_post_meta( get_the_ID(), 'cf7_style_id', '');
715
+ }
716
+ wp_reset_postdata();
717
+ }
718
+ wp_delete_post( $style_id,false);
719
  }
720
+ wp_reset_postdata();
721
  print_r('success');
722
  }
723
  wp_die();
749
  $cf7_style_id = get_post_meta( $form_id, 'cf7_style_id', true );
750
 
751
  if( empty( $cf7_style_id ) ) {
752
+ $form .= "<a href='" . admin_url( 'edit.php?post_type=cf7_style' ) . "' class='frontend-edit-style-link'>" . __( 'Add Style', 'contact-form-7-style' ) . "</a>";
753
  } else {
754
  $cf7_style_data = get_post( $cf7_style_id, OBJECT );
755
+ $template_type = ( has_term( 'custom-style', 'style_category', $cf7_style_data ) ) ? __( 'Edit custom style', 'contact-form-7-style' ) : __( 'Edit predifined template', 'contact-form-7-style' );
756
  $form .= "<a href='" . admin_url( 'post.php?post=' . $cf7_style_id . '&action=edit' ) . "' class='frontend-edit-style-link'>" . $template_type . "</a>";
757
  }
758
  }
css/admin-bar.css CHANGED
@@ -3,6 +3,10 @@
3
  float: right;
4
  }
5
 
 
 
 
 
6
  #wpadminbar .admin-style-icon {
7
  float: right;
8
  padding-top: 7px;
@@ -19,3 +23,20 @@
19
  position: absolute;
20
  top: -6px;
21
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  float: right;
4
  }
5
 
6
+ .remove_template_notice {
7
+ float: right;
8
+ }
9
+
10
  #wpadminbar .admin-style-icon {
11
  float: right;
12
  padding-top: 7px;
23
  position: absolute;
24
  top: -6px;
25
  }
26
+
27
+ .cf7_style_page_cf7style-settings .form-table th,
28
+ .cf7_style_page_cf7style-settings .form-table td {
29
+ padding-top: 5px;
30
+ padding-bottom: 5px;
31
+ }
32
+
33
+ .cf7_style_page_cf7style-settings .form-table th {
34
+ width: auto;
35
+ }
36
+
37
+ .cf7_style_page_cf7style-settings .form-table td label {
38
+ font-style: italic;
39
+ text-decoration: underline;
40
+ padding: 5px 0;
41
+ line-height: 150%;
42
+ }
inc/cssparser.php ADDED
@@ -0,0 +1,373 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class CSSParser {
4
+ protected static $cssCounter = 0;
5
+ protected static $propCounter = 0;
6
+ protected $cssData;
7
+
8
+ function __construct() {
9
+ $this->cssData = array();
10
+ }
11
+
12
+ public function ParseCSS($css) {
13
+ $index = ++self::$cssCounter;
14
+ $this->cssData[$index] = array('all'=>array(),'screen'=>array(),'print'=>array());
15
+ return $this->ParseCode($index, $css);
16
+ }
17
+
18
+ public function ParseCSSAppend($index, $css) {
19
+ if(isset($this->cssData[$index])) {
20
+ return $this->ParseCode($index, $css);
21
+ } else {
22
+ return $this->ParseCSS($css);
23
+ }
24
+ }
25
+
26
+ public function ParseCSSMediaAppend($index, $css, $media) {
27
+ $css = '@'.$media.' {'.PHP_EOL.$css.PHP_EOL.'}'.PHP_EOL;
28
+ if(isset($this->cssData[$index])) {
29
+ return $this->ParseCode($index, $css);
30
+ }
31
+ $index = ++self::$cssCounter;
32
+ $this->cssData[$index] = array('all'=>array(),'screen'=>array(),'print'=>array());
33
+ return $this->ParseCode($index, $css);
34
+ }
35
+
36
+ protected function ParseCode($index, $css) {
37
+ $currentMedia = 'all';
38
+ $mediaList = array();
39
+ $section = false;
40
+ $css = trim($css);
41
+ if(strlen($css) == 0) {
42
+ return $index;
43
+ }
44
+ $css = preg_replace('/\/\*.*\*\//Us', '', $css);
45
+ while(preg_match('/^\s*(\@(media|import|local)([^\{\}]+)(\{)|([^\{\}]+)(\{)|([^\{\}]*)(\}))/Usi', $css, $match)) {
46
+ if(isset($match[8]) && ($match[8] == '}')) {
47
+ if($section !== false) {
48
+ $code = trim($match[7]);
49
+ $idx = 0;
50
+ $inQuote = false;
51
+ $property = false;
52
+ $codeLen = strlen($code);
53
+ $parenthesis = array();
54
+ while($idx < $codeLen) {
55
+ $c = $code{$idx};
56
+ $idx++;
57
+ if($inQuote !== false) {
58
+ if($inQuote === $c) {
59
+ $inQuote = false;
60
+ }
61
+ } elseif(($inQuote === false) && ($c == '(')) {
62
+ array_push($parenthesis, '(');
63
+ } elseif(($inQuote === false) && ($c == ')')) {
64
+ array_pop($parenthesis);
65
+ } elseif(($c == '\'') || ($c == '"')) {
66
+ $inQuote = $c;
67
+ } elseif(($property === false) && ($c == ':')) {
68
+ $property = trim(substr($code, 0, $idx - 1));
69
+ if(preg_match('/^(.*)\[([0-9]*)\]$/Us', $property, $propMatch)) {
70
+ $property = $propMatch[1].'['.static::$propCounter.']';
71
+ static::$propCounter += 1;
72
+ }
73
+ $code = substr($code, $idx);
74
+ $idx = 0;
75
+ } elseif((count($parenthesis) == 0) && ($c == ';')) {
76
+ $value = trim(substr($code, 0, $idx - 1));
77
+ $code = substr($code, $idx);
78
+ $idx = 0;
79
+ $this->AddProperty($index, $currentMedia, $section, $property, $value);
80
+ $property = false;
81
+ }
82
+ }
83
+ if(($idx > 0) && ($property !== false)) {
84
+ $value = trim($code);
85
+ $this->AddProperty($index, $currentMedia, $section, $property, $value);
86
+ }
87
+ $section = false;
88
+ } elseif(count($mediaList) > 0) {
89
+ array_pop($mediaList);
90
+ if(count($mediaList) > 0) {
91
+ $currentMedia = end($mediaList);
92
+ } else {
93
+ $currentMedia = 'all';
94
+ }
95
+ } else {
96
+ // Superfluous }
97
+ }
98
+ } elseif(isset($match[6]) && ($match[6] == '{')) {
99
+ // Section
100
+ $section = trim($match[5]);
101
+ if(!isset($this->cssData[$index][$currentMedia][$section])) {
102
+ $this->cssData[$index][$currentMedia][$section] = array();
103
+ }
104
+ } elseif(isset($match[4]) && ($match[4] == '{')) {
105
+ if($match[2] == 'media') {
106
+ // New media
107
+ $media = trim($match[3]);
108
+ $mediaList[] = $media;
109
+ $currentMedia = $media;
110
+ if(!isset($this->cssData[$index][$currentMedia])) {
111
+ $this->cssData[$index][$currentMedia] = array();
112
+ }
113
+ } elseif($match[2] == 'import') {
114
+ // Can't support import (yet!)
115
+ } elseif($match[2] == 'local') {
116
+ // Can't support local import (yet!)
117
+ }
118
+ } else {
119
+ // Shouldn't get here
120
+ }
121
+ $stripCount = strlen($match[0]);
122
+ $css = trim(substr($css, $stripCount));
123
+ }
124
+ $css = trim($css);
125
+ if(strlen($css) > 0) {
126
+ echo "Potential error in stylesheet: &nbsp;&nbsp;&nbsp;&nbsp;".$css;
127
+ }
128
+ return $index;
129
+ }
130
+
131
+ public function AddProperty($index, $media, $section, $property, $value) {
132
+ if(!isset($this->cssData[$index])) {
133
+ $this->cssData[$index] = array('all'=>array(),'screen'=>array(),'print'=>array());
134
+ }
135
+ $media = trim($media);
136
+ if($media == '') {
137
+ $media = 'all';
138
+ }
139
+ $section = trim($section);
140
+ $property = trim($property);
141
+ if(strlen($property) > 0) {
142
+ $value = trim($value);
143
+ if($media == 'all') {
144
+ $this->cssData[$index][$media][$section][$property] = $value;
145
+ $keys = array_keys($this->cssData[$index]);
146
+ foreach($keys as $key) {
147
+ if(!isset($this->cssData[$index][$key][$section])) {
148
+ $this->cssData[$index][$key][$section] = array();
149
+ }
150
+ $this->cssData[$index][$key][$section][$property] = $value;
151
+ }
152
+ } else {
153
+ if(!isset($this->cssData[$index][$media])) {
154
+ $this->cssData[$index][$media] = $this->cssData[$index]['all'];
155
+ }
156
+ if(!isset($this->cssData[$index][$media][$section])) {
157
+ $this->cssData[$index][$media][$section] = array();
158
+ }
159
+ $this->cssData[$index][$media][$section][$property] = $value;
160
+ }
161
+ }
162
+ }
163
+
164
+ public function GetMediaList($index) {
165
+ if(isset($this->cssData[$index])) {
166
+ return array_keys($this->cssData[$index]);
167
+ }
168
+ return array();
169
+ }
170
+
171
+ public function ExportKeyValues($index, $media, $keys) {
172
+ $result = array();
173
+ if(is_string($keys)) {
174
+ $keys = array($keys);
175
+ }
176
+ if(!is_array($keys)) {
177
+ return $result;
178
+ }
179
+ if(isset($this->cssData[$index]) && isset($this->cssData[$index][$media])) {
180
+ foreach($this->cssData[$index][$media] as $section => $sectionValues) {
181
+ foreach($sectionValues as $property => $value) {
182
+ if(in_array($property, $keys)) {
183
+ $result[] = $value;
184
+ }
185
+ }
186
+ }
187
+ }
188
+ return $result;
189
+ }
190
+
191
+ public function ExportMedia($index, $media, $block = false) {
192
+ $result = '';
193
+ if(isset($this->cssData[$index]) && isset($this->cssData[$index][$media])) {
194
+ foreach($this->cssData[$index][$media] as $section => $sectionValues) {
195
+ $result .= "$section {\n";
196
+ foreach($sectionValues as $property => $value) {
197
+ $property = preg_replace('/(\[[0-9]*\])$/Usi', '', $property);
198
+ if(is_array($block) && isset($block[$property])) {
199
+ if(preg_match('/^'.static::ConvertWildcards($block[$property]).'$/Usi', $value) == 0) {
200
+ $result .= $indent." $property: $value;\n";
201
+ }
202
+ } else {
203
+ $result .= " $property: $value;\n";
204
+ }
205
+ }
206
+ $result .= "}\n\n";
207
+ }
208
+ }
209
+ return $result;
210
+ }
211
+
212
+ public function ExportStyle($index, $block = false) {
213
+ $result = '';
214
+ if(isset($this->cssData[$index])) {
215
+ foreach($this->cssData[$index] as $media => $mediaValues) {
216
+ if($media != 'all') {
217
+ $result .= "@media $media {\n";
218
+ $indent = ' ';
219
+ } else {
220
+ $indent = '';
221
+ }
222
+ foreach($mediaValues as $section => $sectionValues) {
223
+ $result .= $indent."$section {\n";
224
+ foreach($sectionValues as $property => $value) {
225
+ $property = preg_replace('/(\[[0-9]*\])$/Usi', '', $property);
226
+ if(is_array($block) && isset($block[$property])) {
227
+ if(preg_match('/^'.static::ConvertWildcards($block[$property]).'$/Usi', $value) == 0) {
228
+ $result .= $indent." $property: $value;\n";
229
+ }
230
+ } else {
231
+ $result .= $indent." $property: $value;\n";
232
+ }
233
+ }
234
+ $result .= $indent."}\n\n";
235
+ }
236
+ if($media != 'all') {
237
+ $result .= "}\n\n";
238
+ }
239
+ }
240
+ }
241
+ return $result;
242
+ }
243
+
244
+
245
+ public function GetSections($index, $media = 'screen') {
246
+ if(isset($this->cssData[$index])) {
247
+ if(isset($this->cssData[$index][$media])) {
248
+ return array_keys($this->cssData[$index][$media]);
249
+ }
250
+ if(isset($this->cssData[$index]['all'])) {
251
+ return array_keys($this->cssData[$index]['all']);
252
+ }
253
+ }
254
+ return false;
255
+ }
256
+
257
+ public function GetSectionsFiltered($index, $matchKey, $matchValue, $media = 'screen') {
258
+ if(isset($this->cssData[$index])) {
259
+ if(!isset($this->cssData[$index][$media])) {
260
+ $media = 'all';
261
+ if(!isset($this->cssData[$index][$media])) {
262
+ return false;
263
+ }
264
+ }
265
+ if(is_array($this->cssData[$index][$media])) {
266
+ $result = array();
267
+ foreach($this->cssData[$index][$media] as $section => $values) {
268
+ if(isset($values[$matchKey])) {
269
+ if($values[$matchKey] == $matchValue) {
270
+ $result[] = $section;
271
+ }
272
+ }
273
+ }
274
+ return $result;
275
+ }
276
+ }
277
+ return false;
278
+ }
279
+
280
+ public function GetEditorCSS($index) {
281
+ $forbiddenKeys = array();
282
+ $forbiddenKeys[] = '^filter$';
283
+ return $this->GetCSS($index, 'screen', $forbiddenKeys);
284
+ }
285
+
286
+ public function GetCSS($index, $media = 'screen', $forbiddenKeys = array()) {
287
+ if(isset($this->cssData[$index])) {
288
+ if(!isset($this->cssData[$index][$media])) {
289
+ $media = 'all';
290
+ if(!isset($this->cssData[$index][$media])) {
291
+ return false;
292
+ }
293
+ }
294
+ if(is_array($this->cssData[$index][$media])) {
295
+ $result = '';
296
+ foreach($this->cssData[$index][$media] as $section => $values) {
297
+ $result .= $section.' {';
298
+ $result .= "\n";
299
+ if(is_array($values)) {
300
+ foreach($values as $key => $value) {
301
+ $skipThis = false;
302
+ foreach($forbiddenKeys as $fKey) {
303
+ if(preg_match('/'.$fKey.'/Usi', $key)) {
304
+ $skipThis = true;
305
+ break;
306
+ }
307
+ }
308
+ if($skipThis) {
309
+ continue;
310
+ }
311
+ $result .= ' ';
312
+ $key = preg_replace('/(\[[0-9]*\])$/Usi', '', $key);
313
+ $result .= $key.': '.$value.';';
314
+ $result .= "\n";
315
+ }
316
+ }
317
+ $result .= '}';
318
+ $result .= "\n";
319
+ }
320
+ return $result;
321
+ }
322
+ }
323
+ return false;
324
+ }
325
+
326
+ public function GetCSSFiltered($index, $matchKey, $matchValue, $media = 'screen') {
327
+ if(!isset($this->cssData[$index])) {
328
+ if(!isset($this->cssData[$index][$media])) {
329
+ $media = 'all';
330
+ if(!isset($this->cssData[$index][$media])) {
331
+ return false;
332
+ }
333
+ }
334
+ }
335
+ $sections = $this->GetSectionsFiltered($index, $matchKey, $matchValue, $media);
336
+ if($sections !== false) {
337
+ if(is_array($sections)) {
338
+ $result = '';
339
+ foreach($sections as $section) {
340
+ $result .= $section.' {';
341
+ $temp = $this->cssData[$index][$media];
342
+ if(is_array($temp)) {
343
+ foreach($temp as $key => $value) {
344
+ $key = preg_replace('/(\[[0-9]*\])$/Usi', '', $key);
345
+ $result .= $key.': '.$value.';';
346
+ }
347
+ }
348
+ $result .= $section.' }';
349
+ }
350
+ return $result;
351
+ }
352
+ }
353
+ return false;
354
+ }
355
+
356
+ public function GetCSSArray($index, $media = 'screen') {
357
+ if(isset($this->cssData[$index])) {
358
+ if(isset($this->cssData[$index][$media])) {
359
+ return $this->cssData[$index][$media];
360
+ } elseif(isset($this->cssData[$index]['all'])) {
361
+ return $this->cssData[$index][$media];
362
+ }
363
+ }
364
+ return false;
365
+ }
366
+
367
+ public static function ConvertWildcards($text) {
368
+ $text = str_replace('.', '\.', $text);
369
+ $text = str_replace('*', '.*', $text);
370
+ $text = str_replace('?', '.', $text);
371
+ return $text;
372
+ }
373
+ }
inc/editor_page.php CHANGED
@@ -7,16 +7,16 @@ if ( !function_exists( 'cf7style_editor_page_init' ) ) {
7
  function cf7style_editor_page_init() {
8
  add_submenu_page(
9
  'edit.php?post_type=cf7_style',
10
- 'CSS Editor',
11
- 'CSS Editor',
12
  'manage_options',
13
  'cf7style-css-editor',
14
  'cf7style_editor_page_view'
15
  );
16
  add_submenu_page(
17
  'edit.php?post_type=cf7_style',
18
- 'Settings',
19
- 'Settings',
20
  'manage_options',
21
  'cf7style-settings',
22
  'cf7style_settings_view'
@@ -25,9 +25,13 @@ if ( !function_exists( 'cf7style_editor_page_init' ) ) {
25
  }
26
 
27
  if ( !function_exists( 'cf7style_settings_view' ) ) {
28
- function cf7style_settings_view() {
 
 
29
  do_settings_sections( 'cf7style-settings' );
30
- }
 
 
31
  }
32
 
33
  if ( !function_exists( 'cf7style_editor_page_view' ) ) {
@@ -40,77 +44,116 @@ class init_sections_register_fields {
40
  function init_sections_register_fields( ) {
41
  add_filter( 'admin_init' , array( $this , 'register_new_fields' ) );
42
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  function register_new_fields() {
44
  add_settings_section(
45
  'cf7styleeditor',
46
- 'Global CSS',
47
  array( $this, 'description' ),
48
  'cf7style-css-editor'
49
  );
50
  add_settings_section(
51
  'cf7stylesettings',
52
- 'CF7-Style Settings',
53
  array( $this, 'settings_description' ),
54
  'cf7style-settings'
55
  );
56
  $fields = array (
57
  'cf7_style_manual_style' => 'CSS',
58
  );
 
59
  $set_fields = array (
60
- 'cf7_style_allow_tracking' => 'Data collection'
61
- );
62
- foreach ( $set_fields as $field => $value ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  add_settings_field(
64
- $field,
65
- $value,
66
- array($this, 'settings_inputs'),
67
- 'cf7style-settings',
68
- 'cf7stylesettings',
69
- array( $field )
70
  );
71
  register_setting( 'general', $field, 'esc_attr' );
72
- }
73
- foreach ( $fields as $field => $value ) {
74
- add_settings_field(
75
- $field,
76
- $value,
77
- array($this, 'text_inputs'),
78
- 'cf7style-css-editor',
79
- 'cf7styleeditor',
80
- array( $field )
81
- );
82
- register_setting( 'general', $field, 'esc_attr' );
83
- }
84
  }
85
- function settings_inputs( $args ) {
 
 
86
  if(isset( $_POST[ $args[0] ] )){
87
  update_option( $args[0], 1 );
88
  } else {
89
  if(isset($_POST[ 'cf7styletracking' ])){
90
- update_option( $args[0], 0 );
91
  }
92
  }
93
- echo '</tr>';
94
- echo '<tr><td colspan="2"><p>Want to help make CF7 Style even more better? Allow Us to collect non-sensitive diagnostic data.</p><p>We will only collect your website URL, WordPress version, CF7Style plugin version and active status.</p></td></tr>';
95
- echo '<tr><td colspan="2"><form method="POST" action="">';
96
- $option = get_option( $args[0] );
97
- echo '<label>'.__('Allow collecting data:', 'cf7_style').' <input type="checkbox" value="1" '.checked( 1, $option,false).' id="'.$args[0].'[' . $args[0] . ']" name="'.$args[0].'" /></label>';
98
- echo '</td></tr><tr><td colspan="2">';
99
- submit_button( 'Save Settings', 'primary' , 'cf7styletracking');
100
- echo '</form>';
101
  }
102
  function text_inputs( $args ) {
103
  if ( isset( $_POST[ $args[0] ] ) ) {
104
  update_option( $args[0], $_POST[$args[0]] );
105
  }
 
 
 
 
 
 
 
106
  echo '<form method="POST" action="">';
107
- $option = get_option( $args[0] );
108
- echo '<textarea id="'.$args[0].'" name="'.$args[0].'" />' . $option . '</textarea>';
109
  submit_button( 'Save CSS', 'primary' );
110
  echo '</form>';
111
  }
112
  function description() {
113
- echo '<p>On this page You can add a custom CSS mark-up, especially rules which could not be loaded via the style customizer above.</p>';
114
  }
115
  function settings_description() {
116
  }
7
  function cf7style_editor_page_init() {
8
  add_submenu_page(
9
  'edit.php?post_type=cf7_style',
10
+ __( "'CSS Editor", "contact-form-7-style" ),
11
+ __( "CSS Editor", "contact-form-7-style" ),
12
  'manage_options',
13
  'cf7style-css-editor',
14
  'cf7style_editor_page_view'
15
  );
16
  add_submenu_page(
17
  'edit.php?post_type=cf7_style',
18
+ __( "Settings", "contact-form-7-style" ),
19
+ __( "Settings", "contact-form-7-style" ),
20
  'manage_options',
21
  'cf7style-settings',
22
  'cf7style_settings_view'
25
  }
26
 
27
  if ( !function_exists( 'cf7style_settings_view' ) ) {
28
+ function cf7style_settings_view() { ?>
29
+ <form method="POST" action="" class="saputa">
30
+ <?php
31
  do_settings_sections( 'cf7style-settings' );
32
+ submit_button( 'Save Settings', 'primary' , 'cf7styletracking');?>
33
+ </form>
34
+ <?php }
35
  }
36
 
37
  if ( !function_exists( 'cf7style_editor_page_view' ) ) {
44
  function init_sections_register_fields( ) {
45
  add_filter( 'admin_init' , array( $this , 'register_new_fields' ) );
46
  }
47
+ function cf7style_collection_structure( $args ) {
48
+ $html = "";
49
+ $html .= '</tr>';
50
+ $html .= '<tr><td colspan="2"><p>'.__( "Want to help make Contact Form 7 Style even more better? Allow Us to collect non-sensitive diagnostic data.", "contact-form-7-style" ).'</p><p>'.__( "We will only collect your website URL, WordPress version, Contact Form 7 Style plugin version and active status.", "contact-form-7-style" ).'</p></td></tr>';
51
+ $html .= '<tr><td colspan="2">';
52
+ $option = get_option( $args[0] );
53
+ $html .= '<label>'.__('Allow collecting data:', 'contact-form-7-style').' <input type="checkbox" value="1" '.checked( 1, $option,false).' id="'.$args[0].'[' . $args[0] . ']" name="'.$args[0].'" /></label>';
54
+ $html .= '</td></tr><tr><td colspan="2">';
55
+
56
+ return $html;
57
+ }
58
+ function cf7style_templates_structure ( $args) {
59
+ $html = "";
60
+ $html .= '</tr>';
61
+ $html .= '<tr><td colspan="2"><p>'.__( "From here you will be able to import the Contact Form 7 Style predefined templates.", "contact-form-7-style" ).'</p></td></tr>';
62
+ $html .= '<tr><td colspan="2"><p><small>'.__( "This works only if the predefined templates are Deleted Permanently (they don't appear in", "contact-form-7-style" ).' <a href="'.admin_url('edit.php?post_status=trash&post_type=cf7_style').'">'.__( "Trash", "contact-form-7-style" ).'</a> ).</small></p></td></tr>';
63
+ $html .= '<tr><td colspan="2">';
64
+ $option = get_option( $args[0] );
65
+ if( $option == '1'){
66
+ update_option( 'cf7_style_add_categories', 0 );
67
+ }
68
+ if( isset($_POST[ 'cf7styletracking' ]) ){
69
+ update_option( 'cf7_style_no_temps', 'show_box' );
70
+ }
71
+ $html .= '<label>'.__('Install predefined templates:', 'contact-form-7-style').' <input type="checkbox" value="1" '.checked( 1, $option,false).' id="'.$args[0].'[' . $args[0] . ']" name="'.$args[0].'" /></label>';
72
+ $html .= '</td></tr><tr><td colspan="2">';
73
+ return $html;
74
+ }
75
  function register_new_fields() {
76
  add_settings_section(
77
  'cf7styleeditor',
78
+ __('Global CSS', 'contact-form-7-style'),
79
  array( $this, 'description' ),
80
  'cf7style-css-editor'
81
  );
82
  add_settings_section(
83
  'cf7stylesettings',
84
+ __('Contact Form 7 Style Settings', 'contact-form-7-style'),
85
  array( $this, 'settings_description' ),
86
  'cf7style-settings'
87
  );
88
  $fields = array (
89
  'cf7_style_manual_style' => 'CSS',
90
  );
91
+
92
  $set_fields = array (
93
+ 'cf7_style_allow_tracking' => __('Data collection', 'contact-form-7-style'),
94
+ 'cf7_style_deleted' => __('Import predefined Contact Form 7 Style templates', 'contact-form-7-style'),
95
+ ); ?>
96
+ <?php foreach ( $set_fields as $field => $value ) {
97
+ add_settings_field(
98
+ $field,
99
+ $value,
100
+ array($this, 'setting_inputs'),
101
+ 'cf7style-settings',
102
+ 'cf7stylesettings',
103
+ array( $field )
104
+ );
105
+ register_setting( 'general', $field, 'esc_attr' );
106
+ }
107
+
108
+ foreach ( $fields as $field => $value ) {
109
  add_settings_field(
110
+ $field,
111
+ $value,
112
+ array($this, 'text_inputs'),
113
+ 'cf7style-css-editor',
114
+ 'cf7styleeditor',
115
+ array( $field )
116
  );
117
  register_setting( 'general', $field, 'esc_attr' );
118
+ }
 
 
 
 
 
 
 
 
 
 
 
119
  }
120
+
121
+ function setting_inputs( $args ){
122
+
123
  if(isset( $_POST[ $args[0] ] )){
124
  update_option( $args[0], 1 );
125
  } else {
126
  if(isset($_POST[ 'cf7styletracking' ])){
127
+ update_option( $args[0], 0 );
128
  }
129
  }
130
+ switch($args[0]) {
131
+ case 'cf7_style_allow_tracking' :
132
+ echo $this->cf7style_collection_structure( $args );
133
+ break;
134
+ case 'cf7_style_deleted':
135
+ echo $this->cf7style_templates_structure( $args );
136
+ break;
137
+ }
138
  }
139
  function text_inputs( $args ) {
140
  if ( isset( $_POST[ $args[0] ] ) ) {
141
  update_option( $args[0], $_POST[$args[0]] );
142
  }
143
+ $option = stripslashes(get_option( $args[0] ));
144
+
145
+ require_once 'cssparser.php';
146
+ $css = new CSSParser();
147
+ echo "<div class='parser-message'>";
148
+ $cssIndex = $css->ParseCSS($option);
149
+ echo "</div>";
150
  echo '<form method="POST" action="">';
151
+ echo '<textarea id="'.$args[0].'" name="'.$args[0].'" />' . $option. '</textarea>';
 
152
  submit_button( 'Save CSS', 'primary' );
153
  echo '</form>';
154
  }
155
  function description() {
156
+ echo '<p>'.__('On this page You can add a custom CSS mark-up, especially rules which could not be loaded via the style customizer above.', 'contact-form-7-style').'</p>';
157
  }
158
  function settings_description() {
159
  }
inc/slider_meta_box.php CHANGED
@@ -75,7 +75,7 @@ add_action( 'save_post', 'cf7_style_save_meta_box_data' );
75
  */
76
  function cf7style_add_template_panel ( $panels ) {
77
  $panels['Cf7StyleTemplate'] = array(
78
- 'title' => __( 'Template', 'contact-form-7' ),
79
  'callback' => 'cf7_style_display_slider'
80
  );
81
  return $panels;
75
  */
76
  function cf7style_add_template_panel ( $panels ) {
77
  $panels['Cf7StyleTemplate'] = array(
78
+ 'title' => __( 'Contact Form 7 Style Template', 'contact-form-7' ),
79
  'callback' => 'cf7_style_display_slider'
80
  );
81
  return $panels;
inc/system_status.php ADDED
@@ -0,0 +1,279 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * CF7 Style System status
4
+ */
5
+
6
+ function cf7style_system_status() {
7
+
8
+ /**
9
+ * let_to_num function.
10
+ *
11
+ * This function transforms the php.ini notation for numbers (like '2M') to an integer.
12
+ *
13
+ * @param $size
14
+ * @return int
15
+ */
16
+ function cf7style_let_to_num( $size ) {
17
+ $l = substr( $size, -1 );
18
+ $ret = substr( $size, 0, -1 );
19
+ switch ( strtoupper( $l ) ) {
20
+ case 'P':
21
+ $ret *= 1024;
22
+ case 'T':
23
+ $ret *= 1024;
24
+ case 'G':
25
+ $ret *= 1024;
26
+ case 'M':
27
+ $ret *= 1024;
28
+ case 'K':
29
+ $ret *= 1024;
30
+ }
31
+ return $ret;
32
+ }
33
+
34
+
35
+ // Cache variables
36
+ $html = '';
37
+ $table = '';
38
+ $form = '';
39
+ $table_start = '<table class="wp-list-table widefat striped cf7style-status-table">';
40
+ $table_end = '</table><small>&nbsp;</small>';
41
+
42
+ $html .= '<div class="wrap">';
43
+ $html .= '<h2>' . __( "System Status", "contact-form-7-style" ) . '</h2>';
44
+ $html .= '<p>' . __( "The Contact Form 7 Style System Status is a tool for troubleshooting issues with your site.", "contact-form-7-style" ) . '</p>';
45
+ $html .= '<p>' . __( "With the informations gathered from you we can debug and analyze and try to offer you a fix.", "contact-form-7-style" ) . '</p>';
46
+ $html .= '<p>' . __( "The System Status is the best way for Contact Form 7 Style Support to help you!", "contact-form-7-style" ) . '</p>';
47
+
48
+ // Form
49
+ $form .= '<form class="cf7style-status-form">';
50
+ $form .= '<p><input type="text" name="cf7style-name" class="cf7style-name cf7style-input" placeholder="' . __( "Your name", "contact-form-7-style" ) .'" /></p>';
51
+ $form .= '<p><input type="email" name="cf7style-email" class="cf7style-email cf7style-input" placeholder="' . __( "Your email", "contact-form-7-style" ) .'" /></p>';
52
+ $form .= '<p><textarea name="cf7style-message" class="cf7style-message cf7style-input" placeholder="' . __( "Your message", "cf7style-message", "contact-form-7-style" ) . '"></textarea></p>';
53
+ $form .= '<button class="button cf7style-status-info">' . __( "Show the environment report", "contact-form-7-style" ) . '</button>';
54
+
55
+ // Debug - system status send button
56
+ //delete_transient( 'cf7style_system_report' );
57
+
58
+ $report_status = get_transient( 'cf7style_system_report' );
59
+
60
+ if( $report_status && 'sent' == $report_status ) {
61
+ $form .= '<button class="button-primary" disabled="disabled">' . __( "Report sent", "contact-form-7-style" ) . '</button>';
62
+ } else {
63
+ $form .= '<button class="button-primary cf7style-status-submit">' . __( "I think I have a CF7 Style issue. Send Report to CF7 Style Support team.", "contact-form-7-style" ) . '</button>';
64
+ }
65
+
66
+ $form .= '</form>';
67
+
68
+ $html .= $form;
69
+
70
+ // General
71
+ $table .= $table_start;
72
+ $table .= '<thead><tr><th colspan="2"><strong>' . __( "Your WordPress Setup", "contact-form-7-style" ) . '</strong></th></tr></thead>';
73
+
74
+ // Home URL
75
+ $table .= "<tr><td>" . __( 'Home URL:', 'contact-form-7-style' ) . "</td>";
76
+ $table .= "<td>" . home_url() . "</td></tr>";
77
+
78
+ // Site URL
79
+ $table .= "<tr><td>" . __( 'Site URL:', 'contact-form-7-style' ) . "</td>";
80
+ $table .= "<td>" . site_url() . "</td></tr>";
81
+
82
+ // CF7 Style Version
83
+ $table .= "<tr><td>" . __( 'Contact Form 7 Style Version:', 'contact-form-7-style' ) . "</td>";
84
+ $table .= "<td>" . WPCF7S_PLUGIN_VER . "</td></tr>";
85
+
86
+ // WP Version
87
+ $table .= "<tr><td>" . __( 'WP Version:', 'contact-form-7-style' ) . "</td>";
88
+ $table .= "<td>" . get_bloginfo( 'version' ) . "</td></tr>";
89
+
90
+ // WP Multisite
91
+ $table .= "<tr><td>" . __( 'WP Multisite:', 'contact-form-7-style' ) . "</td>";
92
+ $table .= "<td>" . ( ( is_multisite() ) ? "Yes" : "No" ) . "</td></tr>";
93
+
94
+ // WP Memory Limit
95
+ $memory = cf7style_let_to_num( WP_MEMORY_LIMIT );
96
+ $table .= "<tr><td>" . __( ' WP Memory Limit:', 'contact-form-7-style' ) . "</td>";
97
+
98
+ if ( $memory < 100663296 ) {
99
+ $table .= '<td><mark class="error">' . sprintf( __( '%s - Recommended memory at least 96MB. See: <a href="%s" target="_blank">Increasing memory allocated to PHP</a>', 'contact-form-7-style' ), size_format( $memory ), 'http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP' ) . '</mark></td></tr>';
100
+ } else {
101
+ $table .= '<td><mark class="yes">' . size_format( $memory ) . '</mark></td></tr>';
102
+ }
103
+
104
+ // WP Debug Mode
105
+ $table .= "<tr><td>" . __( 'WP Debug Mode:', 'contact-form-7-style' ) . "</td>";
106
+ $table .= "<td>" . ( ( WP_DEBUG ) ? "enabled" : "disabled" ) . "</td></tr>";
107
+
108
+ // Language
109
+ $table .= "<tr><td>" . __( 'Language:', 'contact-form-7-style' ) . "</td>";
110
+ $table .= "<td>" . get_locale() . "</td></tr>";
111
+
112
+ // Email address for feedback
113
+ $table .= "<tr><td>" . __( 'Email address where you want to get feedback', 'contact-form-7-style' ) . "</td>";
114
+ $table .= "<td>" . get_option( 'admin_email' ) . "</td></tr>";
115
+
116
+ $table .= $table_end;
117
+
118
+
119
+ // Your Server Setup
120
+ $table .= $table_start;
121
+ $table .= '<thead><tr><th colspan="2"><strong>' . __( "Your Server Setup", "contact-form-7-style" ) . '</strong></th></tr></thead>';
122
+
123
+ // Server info
124
+ $table .= "<tr><td>" . __( 'Server info', 'contact-form-7-style' ) . "</td>";
125
+ $table .= "<td>" . esc_html( $_SERVER['SERVER_SOFTWARE'] ) . "</td></tr>";
126
+
127
+ // PHP version
128
+ $table .= "<tr><td>" . __( 'PHP Version', 'contact-form-7-style' ) . "</td>";
129
+ if ( function_exists( 'phpversion' ) ) :
130
+
131
+ $php_version = phpversion();
132
+
133
+ if ( version_compare( $php_version, '5.6', '<' ) ) {
134
+ $table .= '<td><mark class="error">' . sprintf( __( '%s - WordPress recommends a minimum PHP version of 5.6. See: %s', 'contact-form-7-style' ), esc_html( $php_version ), '<a href="https://wordpress.org/about/requirements/" target="_blank">' . __( 'WordPress Requirements', 'contact-form-7-style' ) . '</a>' ) . '</mark></td></tr>';
135
+ } else {
136
+ $table .= '<td><mark class="yes">' . esc_html( $php_version ) . '</mark></td></tr>';
137
+ }
138
+ else :
139
+ $table .= '<td>' . __( "Couldn't determine PHP version because phpversion() doesn't exist.", 'contact-form-7-style' ) . '</td></tr>';
140
+ endif;
141
+
142
+ if ( function_exists( 'ini_get' ) ) :
143
+
144
+ // PHP Post Max Size
145
+ $table .= "<tr><td>" . __( 'PHP Post Max Size:', 'contact-form-7-style' ) . "</td>";
146
+ $table .= "<td>" . size_format( cf7style_let_to_num( ini_get( 'post_max_size' ) ) ) . "</td></tr>";
147
+
148
+ endif;
149
+
150
+ // MySQL Version
151
+
152
+ /** @global wpdb $wpdb */
153
+ global $wpdb;
154
+
155
+ $table .= "<tr><td>" . __( 'MySQL Version:', 'contact-form-7-style' ) . "</td>";
156
+ $table .= "<td>" . $wpdb->db_version() . "</td></tr>";
157
+
158
+ // Max Upload Size
159
+ $table .= "<tr><td>" . __( 'Max Upload Size', 'contact-form-7-style' ) . "</td>";
160
+ $table .= "<td>" . size_format( wp_max_upload_size() ) . "</td></tr>";
161
+
162
+ // Default Timezone
163
+ $default_timezone = date_default_timezone_get();
164
+
165
+ $table .= "<tr><td>" . __( 'Default Timezone:', 'contact-form-7-style' ) . "</td>";
166
+ $table .= '<td>' . $default_timezone . '</td></tr>';
167
+
168
+ $table .= $table_end;
169
+
170
+
171
+ // Active Plugins
172
+ $active_plugins_count = count( (array) get_option( 'active_plugins' ) );
173
+
174
+ $table .= $table_start;
175
+ $table .= '<thead><tr><th colspan="2"><strong>' . __( "Active Plugins", "contact-form-7-style" ) . ' (' . $active_plugins_count . ')</strong></th></tr></thead>';
176
+
177
+ $active_plugins = (array) get_option( 'active_plugins', array() );
178
+
179
+ if ( is_multisite() ) {
180
+ $network_activated_plugins = array_keys( get_site_option( 'active_sitewide_plugins', array() ) );
181
+ $active_plugins = array_merge( $active_plugins, $network_activated_plugins );
182
+ }
183
+
184
+ foreach ( $active_plugins as $plugin ) {
185
+
186
+ $plugin_data = @get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
187
+ $dirname = dirname( $plugin );
188
+ $version_string = '';
189
+ $network_string = '';
190
+
191
+ if ( ! empty( $plugin_data['Name'] ) ) {
192
+
193
+ // Link the plugin name to the plugin url if available.
194
+ $plugin_name = esc_html( $plugin_data['Name'] );
195
+
196
+ if ( ! empty( $plugin_data['PluginURI'] ) ) {
197
+ $plugin_name = '<a href="' . esc_url( $plugin_data['PluginURI'] ) . '" title="' . esc_attr__( 'Visit plugin homepage' , 'contact-form-7-style' ) . '" target="_blank">' . $plugin_name . '</a>';
198
+ }
199
+
200
+ $table .= "<tr><td>" . $plugin_name. "</td>";
201
+ $table .= "<td>" . sprintf( _x( 'by %s', 'by author', 'contact-form-7-style' ), $plugin_data['Author'] ) . ' &ndash; ' . __( 'Version', 'contact-form-7-style' ) . ' ' . esc_html( $plugin_data['Version'] ) . $version_string . $network_string . "</td></tr>";
202
+
203
+ }
204
+
205
+ }
206
+
207
+ $table .= $table_end;
208
+
209
+
210
+ // Active Theme
211
+ $active_theme = wp_get_theme();
212
+
213
+ $table .= $table_start;
214
+ $table .= '<thead><tr><th colspan="2"><strong>' . __( "Theme", "contact-form-7-style" ) . '</strong></th></tr></thead>';
215
+
216
+ $table .= "<tr><td>" . __( 'Name:', 'contact-form-7-style' ) . "</td>";
217
+ $table .= "<td>" . $active_theme->Name . "</td></tr>";
218
+
219
+ $table .= "<tr><td>" . __( 'Version:', 'contact-form-7-style' ) . "</td>";
220
+ $table .= "<td>" . $active_theme->Version . "</td></tr>";
221
+
222
+ $table .= "<tr><td>" . __( 'Child Theme:', 'contact-form-7-style' ) . "</td>";
223
+ $table .= "<td>" . ( ( is_child_theme() ) ? 'Yes' : 'No' ) . "</td></tr>";
224
+
225
+ $table .= "<tr><td>" . __( 'Theme URL:', 'contact-form-7-style' ) . "</td>";
226
+ $table .= "<td>" . $active_theme->get( 'ThemeURI' ) . "</td></tr>";
227
+
228
+ $table .= $table_end;
229
+
230
+ $html .= $table;
231
+ $html .= '</div>';
232
+
233
+ echo $html;
234
+ }
235
+
236
+ add_action( 'admin_menu', 'cf7style_register_help_submenu_page' );
237
+
238
+ function cf7style_register_help_submenu_page() {
239
+ add_submenu_page(
240
+ 'edit.php?post_type=cf7_style',
241
+ 'System Status',
242
+ 'System Status',
243
+ 'manage_options',
244
+ 'system-status',
245
+ 'cf7style_system_status'
246
+ );
247
+ }
248
+
249
+
250
+ /**
251
+ * Send status report
252
+ */
253
+
254
+ function cf7_style_send_status_report() {
255
+
256
+ $name = sanitize_text_field( $_POST['name'] );
257
+ $email = sanitize_email( $_POST['email'] );
258
+ $message = sanitize_text_field( $_POST['message'] );
259
+
260
+ $to = 'cf7style@gmail.com';
261
+ $subject = __( 'CF7 Style System Status', 'contact-form-7-style' );
262
+ $body = wp_kses_post( $_POST['report'] );
263
+ $body .= "<table><tr><td>Name: " . $name . "</td></tr>";
264
+ $body .= "<tr><td>Email: " . $email . "</td></tr>";
265
+ $body .= "<tr><td>Message: " . $message . "</td></tr></table>";
266
+ $headers = array( 'Content-Type: text/html; charset=UTF-8' );
267
+
268
+ $wp_mail = wp_mail( $to, $subject, $body, $headers );
269
+
270
+ if( false === $wp_mail ) {
271
+ echo 'error';
272
+ } else {
273
+ set_transient( 'cf7style_system_report', 'sent', DAY_IN_SECONDS );
274
+ echo 'success';
275
+ }
276
+
277
+ wp_die();
278
+ }
279
+ add_action( 'wp_ajax_cf7_style_send_status_report', 'cf7_style_send_status_report' );
misc/tracking.php CHANGED
@@ -45,10 +45,10 @@ if ( !function_exists( 'cf7_style_tracking_enque_script' ) ) {
45
  */
46
  if ( !function_exists( 'cf7_style_print_tooltip' ) ) {
47
  function cf7_style_print_tooltip() {
48
- $pointer_content = '<h3>Thank You for choosing<br/>Contact Form 7 Style!</h3>';
49
- $pointer_content .= '<p>Want to help make CF7 Style even more better? Allow Us to collect non-sensitive diagnostic data.</p>';
50
- $pointer_content .= '<p>We will only collect your website URL, WordPress version, CF7Style plugin version and active status.</p>';
51
- $pointer_content .= '<p><label>Allow collecting data:<input id="cf7_style_allow_tracking" type="checkbox" checked="checked" value="1" name="cf7_style_allow_tracking" /></label> </p>'; ?>
52
  <script type="text/javascript">
53
  //<![CDATA[
54
  jQuery(document).ready( function($) {
@@ -128,14 +128,16 @@ if ( !function_exists( 'cf7style_send_tracking_info' ) ) {
128
  'multisite' => $multi,
129
  'activated' => $activated
130
  );
131
- $cf7curl = curl_init();
132
- $Curl = $url.'?method=withstyle&data='.base64_encode(json_encode($data)).'&format=json';
133
- $curlconfig = array (
134
- CURLOPT_URL => $Curl,
135
- CURLOPT_RETURNTRANSFER => true
136
- );
137
- curl_setopt_array( $cf7curl, $curlconfig );
138
- $output = curl_exec($cf7curl);
139
- curl_close($cf7curl);
 
 
140
  }
141
  }
45
  */
46
  if ( !function_exists( 'cf7_style_print_tooltip' ) ) {
47
  function cf7_style_print_tooltip() {
48
+ $pointer_content = '<h3>'.__( "Thank You for choosing<br/>Contact Form 7 Style!", "contact-form-7-style" ).'</h3>';
49
+ $pointer_content .= '<p>'.__( "Want to help make CF7 Style even more better? Allow Us to collect non-sensitive diagnostic data.", "contact-form-7-style" ).'</p>';
50
+ $pointer_content .= '<p>'.__( "We will only collect your website URL, WordPress version, CF7Style plugin version and active status.", "contact-form-7-style" ).'</p>';
51
+ $pointer_content .= '<p><label>'.__( "Allow collecting data:", "contact-form-7-style" ).'<input id="cf7_style_allow_tracking" type="checkbox" checked="checked" value="1" name="cf7_style_allow_tracking" /></label> </p>'; ?>
52
  <script type="text/javascript">
53
  //<![CDATA[
54
  jQuery(document).ready( function($) {
128
  'multisite' => $multi,
129
  'activated' => $activated
130
  );
131
+ if(function_exists('curl_version')){
132
+ $cf7curl = curl_init();
133
+ $Curl = $url.'?method=withstyle&data='.base64_encode(json_encode($data)).'&format=json';
134
+ $curlconfig = array (
135
+ CURLOPT_URL => $Curl,
136
+ CURLOPT_RETURNTRANSFER => true
137
+ );
138
+ curl_setopt_array( $cf7curl, $curlconfig );
139
+ $output = curl_exec($cf7curl);
140
+ curl_close($cf7curl);
141
+ }
142
  }
143
  }
misc/welcome.php CHANGED
@@ -8,36 +8,38 @@ if ( !function_exists( 'cf7_style_show_welcome_panel' ) ) {
8
  if( $welm == "show_box") {
9
  ?>
10
  <div class="wrap welcome-container">
11
- <table class="wp-list-table widefat fixed cf7style-welcome-panel ">
12
  <tbody>
13
  <tr>
14
  <td>
15
- <h3>Need support?</h3>
16
- <p>Support can be found <a href="https://wordpress.org/support/plugin/contact-form-7-style" target="_blank">here</a> or you can <a href="http://cf7style.com/contact/" target="_blank">contact us</a> for any related question!</p>
17
- <p>Thank you for using Contact Form 7 Style!</p>
 
 
18
  </td>
19
  <td>
20
  <ul>
21
- <li><h3>Get Started</h3></li>
22
- <li><a href="<?php echo admin_url('post-new.php?post_type=cf7_style'); ?>">Creating you first custom template</a></li>
23
- <li><a href="<?php echo admin_url('edit.php?post_type=cf7_style'); ?>">Using predefined templates</a></li>
24
- <li><a href="<?php echo admin_url('edit.php?post_type=cf7_style&page=cf7style-css-editor'); ?>">Adding Extra CSS</a></li>
25
  </ul>
26
  </td>
27
  <td>
28
  <ul>
29
  <li>
30
- <h3>Information</h3>
31
  </li>
32
- <li><a href="http://cf7style.com/#team" target="_blank">Who we are?</a></li>
33
- <li><a href="http://cf7style.com/#why-cf7style" target="_blank">Why use our plugin?</a></li>
34
- <li><a href="http://cf7style.com/faq/" target="_blank">FAQ</a></li>
35
  </ul>
36
  </td>
37
  <td>
38
- <h3>Buy as a coffee</h3>
39
- <p>Supporting and developing this plugin takes us a lot of effort and energy.</p>
40
- <p>You would help us a lot if you make a donation. We thank you in advance. </p>
41
  </td>
42
  <td>
43
  <h3>&nbsp;</h3>
@@ -48,12 +50,10 @@ if ( !function_exists( 'cf7_style_show_welcome_panel' ) ) {
48
  </tr>
49
  <tr>
50
  <td colspan="5">
51
- <a class="close-cf7-panel" href="#">Dismiss</a>
52
  </td>
53
  </tr>
54
  </tbody>
55
-
56
-
57
  </table>
58
  </div>
59
  <?php }
8
  if( $welm == "show_box") {
9
  ?>
10
  <div class="wrap welcome-container">
11
+ <table class="wp-list-table fixed cf7style-welcome-panel ">
12
  <tbody>
13
  <tr>
14
  <td>
15
+ <h3><?php _e( "Need support?", "contact-form-7-style" ); ?></h3>
16
+ <p><?php _e( "Support can be found", "contact-form-7-style" ); ?> <a href="https://wordpress.org/support/plugin/contact-form-7-style" target="_blank"><?php _e( "here", "contact-form-7-style" ); ?></a> <?php _e( "or you can", "contact-form-7-style" ); ?> <a href="http://cf7style.com/contact/" target="_blank"><?php _e( "contact us", "contact-form-7-style" ); ?></a> <?php _e( "for any related question!", "contact-form-7-style" ); ?></p>
17
+ <p><?php _e( "You can use our \"System Status\" to send us a quick report about your environment and with the informations gathered from you we can debug and analyze and try to offer you a fix.", "contact-form-7-style" ); ?> </p>
18
+ <p><a href="<?php echo admin_url('edit.php?post_type=cf7_style&page=system-status'); ?>" class="button-primary"><?php _e( "System status", "contact-form-7-style" ); ?></a></p>
19
+ <p><?php _e( "Thank you for using Contact Form 7 Style!", "contact-form-7-style" ); ?></p>
20
  </td>
21
  <td>
22
  <ul>
23
+ <li><h3><?php _e( "Get Started", "contact-form-7-style" ); ?></h3></li>
24
+ <li><a href="<?php echo admin_url('post-new.php?post_type=cf7_style'); ?>"><?php _e( "Creating you first custom template", "contact-form-7-style" ); ?></a></li>
25
+ <li><a href="<?php echo admin_url('edit.php?post_type=cf7_style'); ?>"><?php _e( "Using predefined templates", "contact-form-7-style" ); ?></a></li>
26
+ <li><a href="<?php echo admin_url('edit.php?post_type=cf7_style&page=cf7style-css-editor'); ?>"><?php _e( "Adding Extra CSS", "contact-form-7-style" ); ?></a></li>
27
  </ul>
28
  </td>
29
  <td>
30
  <ul>
31
  <li>
32
+ <h3><?php _e( "Information", "contact-form-7-style" ); ?></h3>
33
  </li>
34
+ <li><a href="http://cf7style.com/#team" target="_blank"><?php _e( "Who we are?", "contact-form-7-style" ); ?></a></li>
35
+ <li><a href="http://cf7style.com/#why-cf7style" target="_blank"><?php _e( "Why use our plugin?", "contact-form-7-style" ); ?></a></li>
36
+ <li><a href="http://cf7style.com/faq/" target="_blank"><?php _e( "FAQ", "contact-form-7-style" ); ?></a></li>
37
  </ul>
38
  </td>
39
  <td>
40
+ <h3><?php _e( "Buy us a coffee", "contact-form-7-style" ); ?></h3>
41
+ <p><?php _e( "Supporting and developing this plugin takes us a lot of effort and energy.", "contact-form-7-style" ); ?></p>
42
+ <p><?php _e( "You would help us a lot if you make a donation. We thank you in advance.", "contact-form-7-style" ); ?></p>
43
  </td>
44
  <td>
45
  <h3>&nbsp;</h3>
50
  </tr>
51
  <tr>
52
  <td colspan="5">
53
+ <a class="close-cf7-panel" href="#"><?php _e( "Dismiss", "contact-form-7-style" ); ?></a>
54
  </td>
55
  </tr>
56
  </tbody>
 
 
57
  </table>
58
  </div>
59
  <?php }
options.php CHANGED
@@ -3,13 +3,6 @@
3
  * Contact Form 7 Style Options
4
  */
5
 
6
- $domain = 'cf7_style';
7
- $shortname = 'cf7s_custom';
8
-
9
- /**
10
- * Options
11
- */
12
-
13
  require 'plugin-options.php';
14
  $options = json_decode($options_string, true);
15
 
@@ -17,7 +10,7 @@ $options = json_decode($options_string, true);
17
  * Generate property fields
18
  */
19
 
20
- function generate_property_fields( $key, $std, $name, $type, $saved_values, $selector_type, $domain ) {
21
  $temp = '';
22
  /*Had to remove numbers which adds the UNIQUE keys!*/
23
  $title_addon = ($selector_type != "") ? str_replace('_', ' ', $selector_type): "";
@@ -99,7 +92,7 @@ function generate_property_fields( $key, $std, $name, $type, $saved_values, $sel
99
  case "font" : $temp .= '<span class="icon"><i class="fa fa-'.$fonts[$std["style"]].'" aria-hidden="true"></i></span>';break;
100
  }
101
  $temp .= "<select id='". $name . "_" . $std["style"].$selector_type. "' name='cf7stylecustom[". $name . "_" . $std["style"] .$selector_type."]'>";
102
- $temp .= '<option value="">'.__( "Choose value", $domain ).'</option>';
103
  foreach( $std["property"] as $key => $value ) {
104
  $saved_one = ( array_key_exists($name . "_". $std["style"].$selector_type, $saved_values) ) ? $saved_values[ $name . "_". $std["style"].$selector_type] : "";
105
  $temp .= "<option ". selected( $saved_one , $value, false ) . ">". $value ."</option>";
@@ -196,13 +189,13 @@ $elements = array(
196
  */
197
 
198
  wp_nonce_field( 'cf_7_style_style_customizer_inner_custom_box', 'cf_7_style_customizer_custom_box_nonce' );
199
- $saved_values = unserialize( get_post_meta( $post->ID, 'cf7_style_custom_styler', 'a:0:{}' ) );
200
  $saved_values = (empty($saved_values)) ? array() : $saved_values;
201
  $active_panel = get_post_meta( $post->ID, 'cf7_style_active_panel', 'form' );
202
  $active_panel = ( $active_panel=="" ) ? "form" : $active_panel;
203
 
204
  $form_tags = '<div id="form-tag">';
205
- $form_tags .= '<h4>'. __( "Choose element", $domain ).'</h4>';
206
  $form_panel = '';
207
  $form_index = 0;
208
  foreach( $elements as $property => $property_value ) {
@@ -223,8 +216,8 @@ foreach( $elements as $property => $property_value ) {
223
  $form_panel .= "<ul>";
224
  foreach( $options[$sub_property_value]['type'] as $key => $value ) {
225
  if( $key != "comming-soon" ){
226
- $form_panel .= generate_property_fields( $key, $value, $property, $sub_property_slug, $saved_values, '', $domain);
227
- $form_panel .= generate_property_fields( $key, $value, $property, $sub_property_slug, $saved_values, '_hover', $domain );
228
  } else {
229
  $form_panel .= "<li></li>";
230
  }
@@ -256,7 +249,7 @@ foreach( $elements as $property => $property_value ) {
256
  wp_reset_postdata();
257
  $form_choose ="";
258
  if($indexter > 1){
259
- $form_choose = '<div class="choose-preview"><h4>'.__( "Choose form to preview:", $domain ).'</h4>';
260
  $form_choose .= '<select name="form-preview" id="form-preview">';
261
  foreach ($form_el as $key => $cur_form) {
262
  $form_choose .= '<option value="'.$key.'" '.selected($key,0,false).'>'.$cur_form['form_title'].'</option>';
@@ -265,19 +258,19 @@ foreach( $elements as $property => $property_value ) {
265
  }
266
  $form_tags .= '</div>';?>
267
  <div class="panel-options">
268
- <h3><?php echo __( "Customize form", $domain );?></h3>
269
  <?php echo $form_tags; ?>
270
  <div class="element-selector clearfix">
271
- <h4><?php echo __( "Choose element state", $domain ); ?></h4>
272
- <label><input type="radio" name="element-type" checked = "checked" value="normal" /> <?php echo __( "normal state", $domain ); ?></label>
273
- <label><input type="radio" name="element-type" value="hover" /> <?php echo __( ":hover state", $domain ); ?></label>
274
  <div class="hidden"><input type="text" name="cf7styleactivepane" value="<?php echo $active_panel; ?>"></div>
275
  </div>
276
  <?php echo $form_panel; ?>
277
  </div>
278
  <div class='panel-header'>
279
 
280
- <h3><?php echo __( "Preview Area", $domain ); ?></h3>
281
  <?php echo $form_choose; ?>
282
  <div class='preview-form-tag' id="preview">
283
  <?php
@@ -298,6 +291,11 @@ foreach( $elements as $property => $property_value ) {
298
  </div>
299
  </div>
300
  </div>
 
301
  <div class="fixed-save-style">
302
- <input name="save" type="submit" class="button button-primary button-large" id="publish" value="Save Style">
 
 
 
 
303
  </div>
3
  * Contact Form 7 Style Options
4
  */
5
 
 
 
 
 
 
 
 
6
  require 'plugin-options.php';
7
  $options = json_decode($options_string, true);
8
 
10
  * Generate property fields
11
  */
12
 
13
+ function generate_property_fields( $key, $std, $name, $type, $saved_values, $selector_type ) {
14
  $temp = '';
15
  /*Had to remove numbers which adds the UNIQUE keys!*/
16
  $title_addon = ($selector_type != "") ? str_replace('_', ' ', $selector_type): "";
92
  case "font" : $temp .= '<span class="icon"><i class="fa fa-'.$fonts[$std["style"]].'" aria-hidden="true"></i></span>';break;
93
  }
94
  $temp .= "<select id='". $name . "_" . $std["style"].$selector_type. "' name='cf7stylecustom[". $name . "_" . $std["style"] .$selector_type."]'>";
95
+ $temp .= '<option value="">'.__( "Choose value", 'contact-form-7-style' ).'</option>';
96
  foreach( $std["property"] as $key => $value ) {
97
  $saved_one = ( array_key_exists($name . "_". $std["style"].$selector_type, $saved_values) ) ? $saved_values[ $name . "_". $std["style"].$selector_type] : "";
98
  $temp .= "<option ". selected( $saved_one , $value, false ) . ">". $value ."</option>";
189
  */
190
 
191
  wp_nonce_field( 'cf_7_style_style_customizer_inner_custom_box', 'cf_7_style_customizer_custom_box_nonce' );
192
+ $saved_values = maybe_unserialize(get_post_meta( $post->ID, 'cf7_style_custom_styler', true ));
193
  $saved_values = (empty($saved_values)) ? array() : $saved_values;
194
  $active_panel = get_post_meta( $post->ID, 'cf7_style_active_panel', 'form' );
195
  $active_panel = ( $active_panel=="" ) ? "form" : $active_panel;
196
 
197
  $form_tags = '<div id="form-tag">';
198
+ $form_tags .= '<h4>'. __( "Choose element", 'contact-form-7-style' ).'</h4>';
199
  $form_panel = '';
200
  $form_index = 0;
201
  foreach( $elements as $property => $property_value ) {
216
  $form_panel .= "<ul>";
217
  foreach( $options[$sub_property_value]['type'] as $key => $value ) {
218
  if( $key != "comming-soon" ){
219
+ $form_panel .= generate_property_fields( $key, $value, $property, $sub_property_slug, $saved_values, '');
220
+ $form_panel .= generate_property_fields( $key, $value, $property, $sub_property_slug, $saved_values, '_hover');
221
  } else {
222
  $form_panel .= "<li></li>";
223
  }
249
  wp_reset_postdata();
250
  $form_choose ="";
251
  if($indexter > 1){
252
+ $form_choose = '<div class="choose-preview"><h4>'.__( "Choose form to preview:", 'contact-form-7-style' ).'</h4>';
253
  $form_choose .= '<select name="form-preview" id="form-preview">';
254
  foreach ($form_el as $key => $cur_form) {
255
  $form_choose .= '<option value="'.$key.'" '.selected($key,0,false).'>'.$cur_form['form_title'].'</option>';
258
  }
259
  $form_tags .= '</div>';?>
260
  <div class="panel-options">
261
+ <h3><?php echo __( "Customize form", 'contact-form-7-style' );?></h3>
262
  <?php echo $form_tags; ?>
263
  <div class="element-selector clearfix">
264
+ <h4><?php echo __( "Choose element state", 'contact-form-7-style' ); ?></h4>
265
+ <label><input type="radio" name="element-type" checked = "checked" value="normal" /> <?php echo __( "normal state", 'contact-form-7-style' ); ?></label>
266
+ <label><input type="radio" name="element-type" value="hover" /> <?php echo __( ":hover state", 'contact-form-7-style' ); ?></label>
267
  <div class="hidden"><input type="text" name="cf7styleactivepane" value="<?php echo $active_panel; ?>"></div>
268
  </div>
269
  <?php echo $form_panel; ?>
270
  </div>
271
  <div class='panel-header'>
272
 
273
+ <h3><?php echo __( "Preview Area", 'contact-form-7-style' ); ?></h3>
274
  <?php echo $form_choose; ?>
275
  <div class='preview-form-tag' id="preview">
276
  <?php
291
  </div>
292
  </div>
293
  </div>
294
+ <?php $check_screen = get_current_screen(); ?>
295
  <div class="fixed-save-style">
296
+ <?php if( $check_screen->action == "add" && $check_screen->post_type == "cf7_style" ){ ?>
297
+ <input type="submit" name="publish" class="button button-primary button-large" value="Publish Style">
298
+ <?php } else { ?>
299
+ <input name="save" type="submit" class="button button-primary button-large" value="Update Style">
300
+ <?php } ?>
301
  </div>
readme.txt CHANGED
@@ -17,6 +17,8 @@ Supports custom styling, which can be easily managed via admin dashboard. Also h
17
 
18
  > This plugin requires the <a href="http://wordpress.org/extend/plugins/contact-form-7/" rel="nofollow">Contact Form 7 plugin</a><BR>
19
 
 
 
20
  **Custom style options: <BR>**
21
  - color styling, <BR>
22
  - custom fonts ( google fonts included ), <BR>
@@ -60,6 +62,16 @@ You will find 'Contact Style' menu in your WordPress admin panel.
60
 
61
  == Changelog ==
62
 
 
 
 
 
 
 
 
 
 
 
63
  = 3.0.3 =
64
  * [Major Fix](https://wordpress.org/support/topic/existing-styling-deleted?replies=3) JQuery conflict with Siteorigin Page Builder and Visual Composer
65
 
@@ -90,6 +102,22 @@ You will find 'Contact Style' menu in your WordPress admin panel.
90
  * Improvements - Message boxes behaviour
91
  * Improvements - autocomplete styling where possible
92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  = 2.2.5 =
94
  * [Fixed](https://wordpress.org/support/topic/avada-theme-5) Avada Theme Fusion Page Builder incompatibility issue
95
  * [Fixed](https://wordpress.org/support/topic/good-morning-1) Contact form 7 shortcode detection for Flatco - Multipurpose & Responsive WordPress Theme
@@ -158,5 +186,11 @@ You will find 'Contact Style' menu in your WordPress admin panel.
158
  * First plugin version.
159
 
160
  == Upgrade Notice ==
161
- = Contact Form 7 Style Version 3.0.3 =
162
- * [Major Fix](https://wordpress.org/support/topic/existing-styling-deleted?replies=3) JQuery conflict with Siteorigin Page Builder and Visual Composer
 
 
 
 
 
 
17
 
18
  > This plugin requires the <a href="http://wordpress.org/extend/plugins/contact-form-7/" rel="nofollow">Contact Form 7 plugin</a><BR>
19
 
20
+ [youtube https://www.youtube.com/watch?v=dByaDeVlmAc]
21
+
22
  **Custom style options: <BR>**
23
  - color styling, <BR>
24
  - custom fonts ( google fonts included ), <BR>
62
 
63
  == Changelog ==
64
 
65
+ = 3.0.4 =
66
+ * [Major Fix](https://wordpress.org/support/topic/problem-with-css-editor?replies=2) Fixed CSS editor "\" multiplier removed
67
+ * [Major Fix] Collection data functionality to prevent fatal error for various server setups
68
+ * [Major Fix] Prevent existing style data loss based on a new versioning system functionality
69
+ * [Improvement] Publish or Update Style button
70
+ * New feature - System Status page with the possibility to ask for help from the Contact Form 7 Style team by email
71
+ * New feature - Settings page - Install predefined templates or Allow collection data
72
+ * General bugfixing
73
+
74
+
75
  = 3.0.3 =
76
  * [Major Fix](https://wordpress.org/support/topic/existing-styling-deleted?replies=3) JQuery conflict with Siteorigin Page Builder and Visual Composer
77
 
102
  * Improvements - Message boxes behaviour
103
  * Improvements - autocomplete styling where possible
104
 
105
+ = 2.2.8 =
106
+ * Optimize responsive view for predefined templates on mobile devices
107
+ * Added Invitora WordPress Theme compatibility
108
+ * Added support for special characters and fixed bugs
109
+
110
+ = 2.2.7 =
111
+ * Improvements for reliability and speed
112
+ * Enhanced plugin stability and fixed bugs
113
+ * Added Bretheon Premium WordPress Theme compatibility
114
+
115
+ = 2.2.6 =
116
+ * Added Avada Theme compatibility
117
+ * Added Bridge - Creative Multi-Purpose WordPress Theme compatibility
118
+ * Added Flatco - Multipurpose & Responsive WordPress Theme compatibility
119
+ * Improve CSS Editor UI
120
+
121
  = 2.2.5 =
122
  * [Fixed](https://wordpress.org/support/topic/avada-theme-5) Avada Theme Fusion Page Builder incompatibility issue
123
  * [Fixed](https://wordpress.org/support/topic/good-morning-1) Contact form 7 shortcode detection for Flatco - Multipurpose & Responsive WordPress Theme
186
  * First plugin version.
187
 
188
  == Upgrade Notice ==
189
+ = Contact Form 7 Style Version 3.0.4 =
190
+ * [Major Fix]https://wordpress.org/support/topic/problem-with-css-editor?replies=2) Fixed CSS editor "\" multiplier removed
191
+ * [Major Fix] Collection data functionality to prevent fatal error for various server setups
192
+ * [Major Fix] Prevent existing style data loss based on a new versioning system functionality
193
+ * [Improvement] Publish or Update Style button
194
+ * New feature - System Status page with the possibility to ask for help from the Contact Form 7 Style team by email
195
+ * New feature - Settings page - Install predefined templates or Allow collection data
196
+ * General bugfixing