Contact Form 7 Style - Version 3.0.2

Version Description

  • Major Fix
  • Collection data settings page
  • New feature - generate cf7 form preview buttons added when creating new custom style
  • Improvements - preview generations on various user interactions
  • Improvements - general bugfixing
Download this release

Release Info

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

Code changes from version 3.0.1 to 3.0.2

admin/css/admin.css CHANGED
@@ -575,3 +575,9 @@ input.cf7style_template {
575
  .description-title {
576
  padding-left: 10px;
577
  }
 
 
 
 
 
 
575
  .description-title {
576
  padding-left: 10px;
577
  }
578
+
579
+ .wp-core-ui .button-primary.generate-preview-button,
580
+ .generate-preview-option,
581
+ .multiple-form-generated-preview {
582
+ display: none;
583
+ }
admin/js/admin.js CHANGED
@@ -80,7 +80,7 @@ function getPreviewElements(previewType) {
80
  newValue = _t.val();
81
  }
82
  }
83
- newElem = (newElem == 'radio') ? 'input[type="radio"]' : (newElem == 'checkbox') ? 'input[type="checkbox"]' : newElem;
84
  $('.preview-form-container ' + newElem).css(splitArray[1], newValue);
85
  }
86
  });
@@ -196,6 +196,7 @@ function showTheOption() {
196
  _t.addClass('button-primary');
197
  $('input[name="cf7styleactivepane"]').val(_t.attr('data-property'));
198
  });
 
199
  $('.element-selector input').on('change', function() {
200
  $('.element-selector input').prop('checked', false);
201
  $(this).prop('checked', true);
@@ -220,6 +221,13 @@ function showTheOption() {
220
  getPreviewElements();
221
  }
222
  });
 
 
 
 
 
 
 
223
  }
224
 
225
  function removePreviewfields(element) {
@@ -278,6 +286,47 @@ function codeMirrorInit() {
278
  }
279
 
280
  jQuery(document).ready(function($) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
281
 
282
  var previewEl = $(".generate-preview"),
283
  cf7StylePostType = $(".post-type-cf7_style "),
@@ -361,7 +410,7 @@ jQuery(document).ready(function($) {
361
  window.location.reload(false);
362
  }, 300);
363
  });
364
- }, 3000);
365
  }
366
  }
367
  });
80
  newValue = _t.val();
81
  }
82
  }
83
+ newElem = (newElem == 'radio') ? 'input[type="radio"]' : (newElem == 'checkbox') ? 'input[type="checkbox"]' : newElem;
84
  $('.preview-form-container ' + newElem).css(splitArray[1], newValue);
85
  }
86
  });
196
  _t.addClass('button-primary');
197
  $('input[name="cf7styleactivepane"]').val(_t.attr('data-property'));
198
  });
199
+
200
  $('.element-selector input').on('change', function() {
201
  $('.element-selector input').prop('checked', false);
202
  $(this).prop('checked', true);
221
  getPreviewElements();
222
  }
223
  });
224
+ $('[name^="cf7stylecustom"]').on("keyup", function() {
225
+ if ($('input[name="element-type"]:checked').val() == "hover") {
226
+ getPreviewElements('hover');
227
+ } else {
228
+ getPreviewElements();
229
+ }
230
+ });
231
  }
232
 
233
  function removePreviewfields(element) {
286
  }
287
 
288
  jQuery(document).ready(function($) {
289
+ if ($('.cf7style-no-forms-added').length > 0) {
290
+ $('.generate-preview-button, .generate-preview-option').show();
291
+ } else {
292
+ $('.generate-button-hidden').show();
293
+ }
294
+
295
+ $('.generate-preview-button').on('click', function(e) {
296
+ e.preventDefault();
297
+
298
+ $('.cf7style-no-forms-added').hide();
299
+
300
+ var form_id = $(this).attr('data-attr-id'),
301
+ form_title = $(this).attr('data-attr-title');
302
+ $(this).prop('disabled', true);
303
+ $(this).parents('tr').find('input').prop('checked', true);
304
+
305
+ var paragraph = $("<p />");
306
+ $('.preview-form-tag').prepend(paragraph);
307
+
308
+ $.ajax({
309
+ 'url': ajaxurl,
310
+ 'method': 'POST',
311
+ 'data': {
312
+ 'action': 'cf7_style_generate_preview_dashboard',
313
+ 'form_id': form_id,
314
+ 'form_title': form_title
315
+ },
316
+ 'beforeSend': function() {
317
+ paragraph.text("Loading...");
318
+ $('.multiple-form-generated-preview').hide();
319
+ },
320
+ 'success': function(data) {
321
+ if (data) {
322
+ paragraph.remove();
323
+ $('.preview-form-tag').append(data);
324
+ $('.multiple-form-generated-preview').eq($('.multiple-form-generated-preview').length - 1).show();
325
+ getPreviewElements();
326
+ }
327
+ }
328
+ });
329
+ });
330
 
331
  var previewEl = $(".generate-preview"),
332
  cf7StylePostType = $(".post-type-cf7_style "),
410
  window.location.reload(false);
411
  }, 300);
412
  });
413
+ }, 2000);
414
  }
415
  }
416
  });
admin/js/overall.js CHANGED
@@ -15,13 +15,13 @@ function dismissRemoveMessage() {
15
  $('.template-message-box').fadeOut('slow');
16
  dismissRemoveMessage();
17
  });
18
- $(document).on('click', '.cf7style-pointer a.close', function() {
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
- $('.cf7style-pointer').hide();
25
- return false;
26
  });
27
  });
15
  $('.template-message-box').fadeOut('slow');
16
  dismissRemoveMessage();
17
  });
18
+
19
+ $(document).on('click', '.cf7style-pointer a.close', function(e) {
20
+ e.preventDefault();
21
+ if( $('#cf7_style_allow_tracking').is(':checked') ){
22
  $.post(ajaxurl, "action=cf7_style_allow_tracking&cf7_style_allow_tracking=1", function(res) {});
23
  } else {
24
  $.post(ajaxurl, "action=cf7_style_show_tracking&cf7_style_allow_tracking=0", function(res) {});
25
  }
 
 
26
  });
27
  });
cf7-style-meta-box.php CHANGED
@@ -189,6 +189,7 @@ class cf7_style_meta_boxes {
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 '</tr>';
193
  echo '</thead>';
194
  echo '<tbody class="cf7style_body_select_all">';
@@ -201,12 +202,20 @@ class cf7_style_meta_boxes {
201
  <label for="<?php echo cf7_style_the_slug(); ?>"><?php the_title(); ?></label>
202
  </td>
203
  <td>
204
- <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'; } ?> />
205
- <?php if ( $currentpostid != $cf7stylehas && !empty( $cf7stylehas ) ) {
206
- 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>';
207
- } ?>
208
  </td>
209
  </tr>
 
 
 
 
 
 
 
 
210
  <?php endwhile; wp_reset_postdata();
211
  echo '</tbody>';
212
  echo '</table>';
@@ -273,13 +282,15 @@ class cf7_style_meta_boxes {
273
  public function render_font_selector( $post ) {
274
  wp_nonce_field( 'cf_7_style_font_inner_custom_box', 'cf_7_style_font_custom_box_nonce' );
275
  //getting all google fonts
276
- $google_list = file_get_contents( 'https://www.googleapis.com/webfonts/v1/webfonts?key=AIzaSyBAympIKDNKmfxhI3udY-U_9vDWSdfHrEo' );
277
- $font_obj = json_decode( $google_list );
 
 
278
  $cf7_style_font = get_post_meta( $post->ID, 'cf7_style_font', true );
279
  $selected = '';
280
  echo '<select name="cf7_style_font_selector">';
281
  echo '<option value="none">None</option>';
282
- foreach ($font_obj->items as $font) {
283
  echo '<option value="' . $font->family . '"' . ( $cf7_style_font == $font->family ? 'selected="selected"' : '' ) . '>' . $font->family . '</option>';
284
  }
285
  echo '</select>'; ?>
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">';
202
  <label for="<?php echo cf7_style_the_slug(); ?>"><?php the_title(); ?></label>
203
  </td>
204
  <td>
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>
218
+ </tr>
219
  <?php endwhile; wp_reset_postdata();
220
  echo '</tbody>';
221
  echo '</table>';
282
  public function render_font_selector( $post ) {
283
  wp_nonce_field( 'cf_7_style_font_inner_custom_box', 'cf_7_style_font_custom_box_nonce' );
284
  //getting all google fonts
285
+ $google_list = wp_remote_get( 'https://www.googleapis.com/webfonts/v1/webfonts?key=AIzaSyBAympIKDNKmfxhI3udY-U_9vDWSdfHrEo' );
286
+ $response = wp_remote_retrieve_body( $google_list );
287
+
288
+ $font_obj = json_decode( $response );
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>'; ?>
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.1
7
  Author: Johnny, dorumarginean, mlehelsz, MirceaR
8
  Author URI: http://cf7style.com
9
  License: GPL2
@@ -17,12 +17,12 @@ define( 'WPCF7S_PLUGIN', __FILE__ );
17
  define( 'WPCF7S_PLUGIN_DIR', untrailingslashit( dirname( WPCF7S_PLUGIN ) ) );
18
 
19
  function set_styleversion(){
20
- return "3.0.1";
21
  }
22
 
23
  function get_predefined_cf7_style_template_data() {
24
- $templates_string = file_get_contents( plugins_url() . '/contact-form-7-style/predefined-templates.json');
25
- $templates = json_decode($templates_string, true);
26
  return $templates;
27
  }// end of get_predefined_cf7_style_template_data
28
  /**
@@ -61,8 +61,8 @@ function form_class_attr( $class, $id ) {
61
  // Get the current CF7 form ID
62
  $cf7 = wpcf7_get_current_contact_form(); // Current contact form 7 object
63
  $form_id = get_form_id( $cf7 );
64
- $template_class = '';
65
- $cf7_style_id = get_post_meta( $form_id, 'cf7_style_id' );
66
  if ( isset( $cf7_style_id[0] ) ) {
67
  $cf7_style_data = get_post( $cf7_style_id[0], OBJECT );
68
  $template_class = ( has_term( 'custom-style', 'style_category', $cf7_style_data ) ) ?
@@ -75,9 +75,9 @@ function form_class_attr( $class, $id ) {
75
  function active_styles() {
76
 
77
  $args = array(
78
- 'post_type' => 'wpcf7_contact_form',
79
- 'post_status' => 'publish',
80
- 'posts_per_page' => -1
81
  );
82
  $active_styles = array();
83
  $forms = new WP_Query( $args );
@@ -85,7 +85,7 @@ function active_styles() {
85
  if( $forms->have_posts() ) :
86
  while( $forms->have_posts() ) : $forms->the_post();
87
  $form_title = get_the_title();
88
- $id = get_the_ID();
89
  $style_id = get_post_meta( $id, 'cf7_style_id', true );
90
  if ( ! empty( $style_id ) || $style_id != 0 ) {
91
  $active_styles[] = $style_id;
@@ -102,21 +102,21 @@ function cf7_style_custom_css_generator(){
102
  return false;
103
  }
104
  $args = array(
105
- 'post_type' => 'wpcf7_contact_form',
106
- 'post_status' => 'publish',
107
- 'posts_per_page' => -1
108
  );
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() ) :
116
  while( $forms->have_posts() ) : $forms->the_post();
117
- $id = get_the_ID();
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";
@@ -128,22 +128,22 @@ 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 = "";
135
- $groundone = "";
136
- $groundone_hover = "";
137
- $tempSave = "0";
138
- $bleah = array();
139
- $bleah_hover = array();
140
- $i = 0;
141
- $i_hover = 0;
142
- $curr_tag_gen = "";
143
- $cur_property_gen = "";
144
- $the_hover = "no";
145
  foreach( $cf7s_custom_settings as $setting_key => $setting ){
146
- $setting_key_part = explode( "_", $setting_key );
147
  $classelem = "body .cf7-style." . ( ( is_numeric( $cf7s_slug ) ) ? "cf7-style-".$cf7s_slug : $cf7s_slug );
148
  $html_element = ( $setting_key_part[0] == "submit" || $setting_key_part[0] == "radio" || $setting_key_part[0] == "checkbox" ) ?
149
  " input[type='". $setting_key_part[0]."']" : ( ( $setting_key_part[0] == "form" ) ? "" : ' '.$setting_key_part[0] );
@@ -184,7 +184,7 @@ function cf7_style_custom_css_generator(){
184
  if(!empty( $setting )){
185
  if ( $groundone != $setting_key_part[1]) {
186
  $groundone = $setting_key_part[1];
187
- $tempSave = $setting;
188
  if( $setting != "px" && $setting != "%" && $setting != "em" ){
189
  $bleah[$i] = $cur_property_gen;
190
  }
@@ -314,12 +314,12 @@ function cf7_style_create_post( $slug, $title, $image) {
314
  // Set the post ID so that we know the post was created successfully
315
  $post_id = wp_insert_post(
316
  array(
317
- 'comment_status' => 'closed',
318
- 'ping_status' => 'closed',
319
- 'post_name' => $slug,
320
- 'post_title' => $title,
321
- 'post_status' => 'publish',
322
- 'post_type' => 'cf7_style'
323
  )
324
  );
325
  //if is_wp_error doesn't trigger, then we add the image
@@ -374,9 +374,10 @@ function cf7_style_set_style_category_on_publish( $ID, $post ) {
374
  }
375
  } // end cf7_style_set_style_category_on_publish
376
  function cf7_style_create_posts(){
377
- update_option( 'cf7_style_no_temps', 'show_box' );
378
  update_option( 'cf7_style_welcome', 'show_box' );
379
  update_option( 'cf7_style_update_saved', 'yes' );
 
380
  }
381
  // Hook into the 'cf7_style_create_posts' action
382
  register_activation_hook( __FILE__, 'cf7_style_create_posts' );
@@ -450,7 +451,7 @@ function cf7style_load_elements(){
450
  //register tax
451
  register_taxonomy( 'style_category', array( 'cf7_style' ), $args );
452
  $cf7_style_templates = get_option( 'cf7_style_no_temps' );
453
- if( $cf7_style_templates == 'show_box'){
454
  //die();
455
  foreach ( get_predefined_cf7_style_template_data() as $style ) {
456
  cf7_style_create_post( strtolower( str_replace( " ", "-", $style['title'] ) ), $style['title'], $style['image'] );
@@ -682,4 +683,20 @@ function cf7_style_frontend_edit_link( $form ) {
682
 
683
  return $form;
684
  }
685
- add_filter( 'wpcf7_form_elements', 'cf7_style_frontend_edit_link' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.2
7
  Author: Johnny, dorumarginean, mlehelsz, MirceaR
8
  Author URI: http://cf7style.com
9
  License: GPL2
17
  define( 'WPCF7S_PLUGIN_DIR', untrailingslashit( dirname( WPCF7S_PLUGIN ) ) );
18
 
19
  function set_styleversion(){
20
+ return "3.0.2";
21
  }
22
 
23
  function get_predefined_cf7_style_template_data() {
24
+ require 'predefined-templates.php';
25
+ $templates = json_decode( $templates_string, true );
26
  return $templates;
27
  }// end of get_predefined_cf7_style_template_data
28
  /**
61
  // Get the current CF7 form ID
62
  $cf7 = wpcf7_get_current_contact_form(); // Current contact form 7 object
63
  $form_id = get_form_id( $cf7 );
64
+ $template_class ='';
65
+ $cf7_style_id = get_post_meta( $form_id, 'cf7_style_id' );
66
  if ( isset( $cf7_style_id[0] ) ) {
67
  $cf7_style_data = get_post( $cf7_style_id[0], OBJECT );
68
  $template_class = ( has_term( 'custom-style', 'style_category', $cf7_style_data ) ) ?
75
  function active_styles() {
76
 
77
  $args = array(
78
+ 'post_type'=>'wpcf7_contact_form',
79
+ 'post_status'=>'publish',
80
+ 'posts_per_page'=> -1
81
  );
82
  $active_styles = array();
83
  $forms = new WP_Query( $args );
85
  if( $forms->have_posts() ) :
86
  while( $forms->have_posts() ) : $forms->the_post();
87
  $form_title = get_the_title();
88
+ $id = get_the_ID();
89
  $style_id = get_post_meta( $id, 'cf7_style_id', true );
90
  if ( ! empty( $style_id ) || $style_id != 0 ) {
91
  $active_styles[] = $style_id;
102
  return false;
103
  }
104
  $args = array(
105
+ 'post_type' => 'wpcf7_contact_form',
106
+ 'post_status' => 'publish',
107
+ 'posts_per_page' => -1
108
  );
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() ) :
116
  while( $forms->have_posts() ) : $forms->the_post();
117
+ $id = get_the_ID();
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";
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 = "";
135
+ $groundone = "";
136
+ $groundone_hover = "";
137
+ $tempSave = "0";
138
+ $bleah = array();
139
+ $bleah_hover = array();
140
+ $i = 0;
141
+ $i_hover = 0;
142
+ $curr_tag_gen = "";
143
+ $cur_property_gen = "";
144
+ $the_hover = "no";
145
  foreach( $cf7s_custom_settings as $setting_key => $setting ){
146
+ $setting_key_part = explode( "_", $setting_key );
147
  $classelem = "body .cf7-style." . ( ( is_numeric( $cf7s_slug ) ) ? "cf7-style-".$cf7s_slug : $cf7s_slug );
148
  $html_element = ( $setting_key_part[0] == "submit" || $setting_key_part[0] == "radio" || $setting_key_part[0] == "checkbox" ) ?
149
  " input[type='". $setting_key_part[0]."']" : ( ( $setting_key_part[0] == "form" ) ? "" : ' '.$setting_key_part[0] );
184
  if(!empty( $setting )){
185
  if ( $groundone != $setting_key_part[1]) {
186
  $groundone = $setting_key_part[1];
187
+ $tempSave = $setting;
188
  if( $setting != "px" && $setting != "%" && $setting != "em" ){
189
  $bleah[$i] = $cur_property_gen;
190
  }
314
  // Set the post ID so that we know the post was created successfully
315
  $post_id = wp_insert_post(
316
  array(
317
+ 'comment_status' => 'closed',
318
+ 'ping_status' => 'closed',
319
+ 'post_name' => $slug,
320
+ 'post_title' => $title,
321
+ 'post_status' => 'publish',
322
+ 'post_type' => 'cf7_style'
323
  )
324
  );
325
  //if is_wp_error doesn't trigger, then we add the image
374
  }
375
  } // end cf7_style_set_style_category_on_publish
376
  function cf7_style_create_posts(){
377
+ update_option( 'cf7_style_no_temps', 'hide_box' );
378
  update_option( 'cf7_style_welcome', 'show_box' );
379
  update_option( 'cf7_style_update_saved', 'yes' );
380
+ update_option( 'cf7_style_allow_tracking', '5' );
381
  }
382
  // Hook into the 'cf7_style_create_posts' action
383
  register_activation_hook( __FILE__, 'cf7_style_create_posts' );
451
  //register tax
452
  register_taxonomy( 'style_category', array( 'cf7_style' ), $args );
453
  $cf7_style_templates = get_option( 'cf7_style_no_temps' );
454
+ if( $cf7_style_templates == 'hide_box'){
455
  //die();
456
  foreach ( get_predefined_cf7_style_template_data() as $style ) {
457
  cf7_style_create_post( strtolower( str_replace( " ", "-", $style['title'] ) ), $style['title'], $style['image'] );
683
 
684
  return $form;
685
  }
686
+ add_filter( 'wpcf7_form_elements', 'cf7_style_frontend_edit_link' );
687
+
688
+
689
+ /**
690
+ * Dashboard generate preview on user interaction
691
+ */
692
+
693
+ function cf7_style_generate_preview_dashboard() {
694
+
695
+ $form_id = sanitize_text_field( $_POST['form_id'] );
696
+ $form_title = sanitize_text_field( $_POST['form_title'] );
697
+ $form = "<div class='multiple-form-generated-preview preview-form-container'><h4>" . $form_title . "</h4>" . do_shortcode( '[contact-form-7 id="'. $form_id .'" title="'. $form_title .'"]' ) . "</div>";
698
+ echo $form;
699
+
700
+ wp_die();
701
+ }
702
+ add_action( 'wp_ajax_cf7_style_generate_preview_dashboard', 'cf7_style_generate_preview_dashboard' );
inc/editor_page.php CHANGED
@@ -13,9 +13,23 @@ if ( !function_exists( 'cf7style_editor_page_init' ) ) {
13
  'cf7style-css-editor',
14
  'cf7style_editor_page_view'
15
  );
16
-
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  }
18
  }
 
19
  if ( !function_exists( 'cf7style_editor_page_view' ) ) {
20
  function cf7style_editor_page_view() {
21
  do_settings_sections( 'cf7style-css-editor' );
@@ -33,9 +47,29 @@ class init_sections_register_fields {
33
  array( $this, 'description' ),
34
  'cf7style-css-editor'
35
  );
 
 
 
 
 
 
36
  $fields = array (
37
- 'cf7_style_manual_style' => 'CSS',
38
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  foreach ( $fields as $field => $value ) {
40
  add_settings_field(
41
  $field,
@@ -48,6 +82,23 @@ class init_sections_register_fields {
48
  register_setting( 'general', $field, 'esc_attr' );
49
  }
50
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  function text_inputs( $args ) {
52
  if ( isset( $_POST[ $args[0] ] ) ) {
53
  update_option( $args[0], $_POST[$args[0]] );
@@ -57,9 +108,10 @@ class init_sections_register_fields {
57
  echo '<textarea id="'.$args[0].'" name="'.$args[0].'" />' . $option . '</textarea>';
58
  submit_button( 'Save CSS', 'primary' );
59
  echo '</form>';
60
-
61
  }
62
  function description() {
63
  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>';
64
  }
 
 
65
  }
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'
23
+ );
24
+ }
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' ) ) {
34
  function cf7style_editor_page_view() {
35
  do_settings_sections( 'cf7style-css-editor' );
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,
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]] );
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
+ }
117
  }
misc/tracking.php CHANGED
@@ -6,7 +6,10 @@ define( 'CF7_STYLE_PLUGIN_PATH', WP_PLUGIN_DIR . '/contact-form-7-style/' );
6
  if ( !function_exists( 'cf7_style_announce_authors_about_deactivation' ) ) {
7
  function cf7_style_announce_authors_about_deactivation () {
8
  $allowedornot = get_option( 'cf7_style_allow_tracking' );
9
- cf7style_send_tracking_info( $allowedornot, '0' );
 
 
 
10
  }
11
  register_deactivation_hook( CF7_STYLE_PLUGIN_PATH . 'cf7-style.php' , 'cf7_style_announce_authors_about_deactivation' );
12
  }
@@ -16,7 +19,9 @@ if ( !function_exists( 'cf7_style_announce_authors_about_deactivation' ) ) {
16
  if ( !function_exists( 'cf7_style_announce_authors_about_activation' ) ) {
17
  function cf7_style_announce_authors_about_activation () {
18
  $allowedornot = get_option( 'cf7_style_allow_tracking' );
19
- cf7style_send_tracking_info( $allowedornot, '1' );
 
 
20
  }
21
  register_activation_hook( CF7_STYLE_PLUGIN_PATH . 'cf7-style.php' , 'cf7_style_announce_authors_about_activation' );
22
  }
@@ -43,11 +48,11 @@ if ( !function_exists( 'cf7_style_print_tooltip' ) ) {
43
  $pointer_content = '<h3>Thank You for choosing<br/>Contact Form 7 Style!</h3>';
44
  $pointer_content .= '<p>Want to help make CF7 Style even more better? Allow Us to collect non-sensitive diagnostic data.</p>';
45
  $pointer_content .= '<p>We will only collect your website URL, WordPress version, CF7Style plugin version and active status.</p>';
46
- $pointer_content .= '<p><label for="cf7_style_allow_tracking">Allow collecting data:</label> <input id="cf7_style_allow_tracking" type="checkbox" checked="checked" value="1" name="cf7_style_allow_tracking" /></p>'; ?>
47
  <script type="text/javascript">
48
  //<![CDATA[
49
  jQuery(document).ready( function($) {
50
- $('.menu-icon-cf7_style').pointer({
51
  pointerClass: 'cf7style-pointer',
52
  content: '<?php echo $pointer_content; ?>',
53
  position: 'left',
6
  if ( !function_exists( 'cf7_style_announce_authors_about_deactivation' ) ) {
7
  function cf7_style_announce_authors_about_deactivation () {
8
  $allowedornot = get_option( 'cf7_style_allow_tracking' );
9
+ if( '1' == $allowedornot){
10
+ cf7style_send_tracking_info( $allowedornot, '1' );
11
+ }
12
+
13
  }
14
  register_deactivation_hook( CF7_STYLE_PLUGIN_PATH . 'cf7-style.php' , 'cf7_style_announce_authors_about_deactivation' );
15
  }
19
  if ( !function_exists( 'cf7_style_announce_authors_about_activation' ) ) {
20
  function cf7_style_announce_authors_about_activation () {
21
  $allowedornot = get_option( 'cf7_style_allow_tracking' );
22
+ if( '1' == $allowedornot){
23
+ cf7style_send_tracking_info( $allowedornot, '1' );
24
+ }
25
  }
26
  register_activation_hook( CF7_STYLE_PLUGIN_PATH . 'cf7-style.php' , 'cf7_style_announce_authors_about_activation' );
27
  }
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($) {
55
+ $('.menu-icon-cf7_style').eq(0).pointer({
56
  pointerClass: 'cf7style-pointer',
57
  content: '<?php echo $pointer_content; ?>',
58
  position: 'left',
options.php CHANGED
@@ -10,7 +10,7 @@ $shortname = 'cf7s_custom';
10
  * Options
11
  */
12
 
13
- $options_string = file_get_contents( plugins_url() . '/contact-form-7-style/options.json');
14
  $options = json_decode($options_string, true);
15
 
16
  /**
@@ -282,7 +282,13 @@ foreach( $elements as $property => $property_value ) {
282
  <div class='preview-form-tag' id="preview">
283
  <?php
284
  $indexter = 0;
285
- foreach ($form_el as $key => $cur_form) {
 
 
 
 
 
 
286
  $extra_class= ($indexter++ != 0) ? 'hidden' : ''; ?>
287
  <div class="preview-form-container <?php echo $extra_class; ?>">
288
  <h4><?php echo $cur_form['form_title']; ?></h4>
10
  * Options
11
  */
12
 
13
+ require 'plugin-options.php';
14
  $options = json_decode($options_string, true);
15
 
16
  /**
282
  <div class='preview-form-tag' id="preview">
283
  <?php
284
  $indexter = 0;
285
+
286
+ // Show default form when on first custom style edit
287
+ if( empty( $form_el ) ) {
288
+ echo "<p class='cf7style-no-forms-added'>" . __( 'Please check one of the forms above to activate the preview mode.', 'cf7style' ) . "</p>";
289
+ }
290
+
291
+ foreach ( $form_el as $key => $cur_form ) {
292
  $extra_class= ($indexter++ != 0) ? 'hidden' : ''; ?>
293
  <div class="preview-form-container <?php echo $extra_class; ?>">
294
  <h4><?php echo $cur_form['form_title']; ?></h4>
options.json → plugin-options.php RENAMED
@@ -1,4 +1,5 @@
1
- {
 
2
  "width": {
3
  "name": "Width",
4
  "slug": "width",
@@ -338,4 +339,4 @@
338
  "comming-soon": {}
339
  }
340
  }
341
- }
1
+ <?php
2
+ $options_string = '{
3
  "width": {
4
  "name": "Width",
5
  "slug": "width",
339
  "comming-soon": {}
340
  }
341
  }
342
+ }';
predefined-templates.json → predefined-templates.php RENAMED
@@ -1,4 +1,5 @@
1
- [
 
2
  {
3
  "title":"Twenty Fifteen Pattern",
4
  "category":"simple pattern style",
@@ -20,23 +21,23 @@
20
  "image":"\/admin\/images\/cf7_xmas_simple.jpg"
21
  },
22
  {
23
- "title":"Valentine's Day Classic",
24
- "category":"valentine's day style",
25
  "image":"\/admin\/images\/cf7_vday_classic.jpg"
26
  },
27
  {
28
- "title":"Valentine's Day Roses",
29
- "category":"valentine's day style",
30
  "image":"\/admin\/images\/cf7_vday_roses.jpg"
31
  },
32
  {
33
- "title":"Valentine's Day Birds",
34
- "category":"valentine's day style",
35
  "image":"\/admin\/images\/cf7_vday_birds.jpg"
36
  },
37
  {
38
- "title":"Valentine's Day Blue Birds",
39
- "category":"valentine's day style",
40
  "image":"\/admin\/images\/cf7_vday_blue_birds.jpg"
41
  }
42
- ]
1
+ <?php
2
+ $templates_string = '[
3
  {
4
  "title":"Twenty Fifteen Pattern",
5
  "category":"simple pattern style",
21
  "image":"\/admin\/images\/cf7_xmas_simple.jpg"
22
  },
23
  {
24
+ "title":"Valentine\'s Day Classic",
25
+ "category":"valentine\'s day style",
26
  "image":"\/admin\/images\/cf7_vday_classic.jpg"
27
  },
28
  {
29
+ "title":"Valentine\'s Day Roses",
30
+ "category":"valentine\'s day style",
31
  "image":"\/admin\/images\/cf7_vday_roses.jpg"
32
  },
33
  {
34
+ "title":"Valentine\'s Day Birds",
35
+ "category":"valentine\'s day style",
36
  "image":"\/admin\/images\/cf7_vday_birds.jpg"
37
  },
38
  {
39
+ "title":"Valentine\'s Day Blue Birds",
40
+ "category":"valentine\'s day style",
41
  "image":"\/admin\/images\/cf7_vday_blue_birds.jpg"
42
  }
43
+ ]';
readme.txt CHANGED
@@ -60,6 +60,13 @@ You will find 'Contact Style' menu in your WordPress admin panel.
60
 
61
  == Changelog ==
62
 
 
 
 
 
 
 
 
63
  = 3.0.1 =
64
  * New feature - width and height styling properties for radio elements
65
  * New feature - width and height styling properties for checkbox elements
@@ -147,7 +154,9 @@ You will find 'Contact Style' menu in your WordPress admin panel.
147
  * First plugin version.
148
 
149
  == Upgrade Notice ==
150
- = Contact Form 7 Style Version 3.0.1 =
151
- * New feature - width and height styling properties for radio elements
152
- * New feature - width and height styling properties for checkbox elements
 
 
153
  * Improvements - general bugfixing
60
 
61
  == Changelog ==
62
 
63
+ = 3.0.2 =
64
+ * [Major Fix](https://wordpress.org/support/topic/does-not-work-639?replies=7)
65
+ * [Collection data settings page](https://wordpress.org/support/topic/how-to-disable-data-collection?replies=2)
66
+ * New feature - generate cf7 form preview buttons added when creating new custom style
67
+ * Improvements - preview generations on various user interactions
68
+ * Improvements - general bugfixing
69
+
70
  = 3.0.1 =
71
  * New feature - width and height styling properties for radio elements
72
  * New feature - width and height styling properties for checkbox elements
154
  * First plugin version.
155
 
156
  == Upgrade Notice ==
157
+ = Contact Form 7 Style Version 3.0.2 =
158
+ * [Major Fix](https://wordpress.org/support/topic/does-not-work-639?replies=7)
159
+ * [Collection data settings page](https://wordpress.org/support/topic/how-to-disable-data-collection?replies=2)
160
+ * New feature - generate cf7 form preview buttons added when creating new custom style
161
+ * Improvements - preview generations on various user interactions
162
  * Improvements - general bugfixing