Contact Form 7 Style - Version 3.1.5

Version Description

Release Date: November 6th, 2017

  • Major Fix Fallback for setups where json file can not be accesed by wp_remote_get
Download this release

Release Info

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

Code changes from version 3.1.4 to 3.1.5

admin/predefined_tpls.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+
3
+ $tpl_string = '[{"title":"Monochrome Light","category":"simple pattern style","image":"/admin/images/monochrome-light.png"},{"title":"Transparent Two Columns","category":"simple pattern style","image":"/admin/images/transparent-two-columns.png"},{"title":"Minimal Brown","category":"simple pattern style","image":"/admin/images/minimal-brown.png"},{"title":"Monochrome","category":"simple pattern style","image":"/admin/images/monochrome.png"},{"title":"Twenty Fifteen Pattern","category":"simple pattern style","image":"/admin/images/cf7_simple_twentyfifteen_pattern.jpg"},{"title":"Christmas Classic","category":"christmas style","image":"/admin/images/cf7_xmas_classic.jpg"},{"title":"Christmas Red","category":"christmas style","image":"/admin/images/cf7_xmas_red.jpg"},{"title":"Christmas Simple","category":"christmas style","image":"/admin/images/cf7_xmas_simple.jpg"},{"title":"Valentine\'s Day Classic","category":"valentine\'s day style","image":"/admin/images/cf7_vday_classic.jpg"},{"title":"Valentine\'s Day Roses","category":"valentine\'s day style","image":"/admin/images/cf7_vday_roses.jpg"},{"title":"Valentine\'s Day Birds","category":"valentine\'s day style","image":"/admin/images/cf7_vday_birds.jpg"},{"title":"Valentine\'s Day Blue Birds","category":"valentine\'s day style","image":"/admin/images/cf7_vday_blue_birds.jpg"}]';
admin/settings_setup.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+
3
+ $setting_str = '{"width":{"name":"Width","slug":"width","type":{"numeric":{"title":"Width","style":"width","property":"0","unit":["px","%","em"]}},"desc":"Change the default width of the current element."},"opacity":{"name":"Opacity","slug":"opacity","type":{"numeric":{"title":"Opacity","style":"opacity","property":"1"}},"desc":"Change the default width of the current element."},"height":{"name":"Height","slug":"height","type":{"numeric":{"title":"Height","style":"height","property":"0","unit":["px","%","em"]}},"desc":"Change the default height of the current element."},"background":{"name":"Background","slug":"background","type":{"color-picker":{"title":"Background Color","style":"background-color","property":"#fff"},"input":{"title":"Background Image","style":"background-image","property":"none"},"select1":{"title":"Background Position","style":"background-position","property":["left top","left center","left bottom","center top","center center","center bottom","right top","right center","right bottom"]},"select2":{"title":"Background Size","style":"background-size","property":["inherit","cover","contain"]},"select3":{"title":"Background Repeat","style":"background-repeat","property":["no-repeat","repeat-x","repeat-y","repeat","space","round"]},"select4":{"title":"Background Attachment","style":"background-attachment","property":["inherit","fixed","scroll","local"]}},"desc":"Change the default background properties of the current element."},"border":{"name":"Border","slug":"border","type":{"numeric1":{"title":"Border Width","style":"border-width","property":"0 0 0 0","unit":["px","%","em"]},"select":{"title":"Border Style","style":"border-style","property":["none","solid","dotted","double","groove","ridge","inset","outset"]},"color-picker":{"title":"Border color","style":"border-color","property":"#fff"},"numeric2":{"title":"Border radius","style":"border-radius","property":"0 0 0 0","unit":["px","%","em"]}},"desc":"Add custom border."},"font":{"name":"Font","slug":"font","type":{"numeric1":{"title":"Font size","style":"font-size","property":"0","unit":["px","%","em"]},"select2":{"title":"Font weight","style":"font-weight","property":["inherit","normal","bold","lighter","bolder","300","400","600","700"]},"select1":{"title":"Font style","style":"font-style","property":["normal","italic","oblique"]},"select4":{"title":"Text Align","style":"text-align","property":["left","right","center","justify","start","end"]},"select3":{"title":"Text transform","style":"text-transform","property":["inherit","capitalize","uppercase","lowercase","none"]},"select5":{"title":"Text decoration","style":"text-decoration","property":["none","underline","inherit","initial","unset"]},"numeric2":{"title":"Line Height","style":"line-height","property":"0","unit":["px","%","em"]},"numeric3":{"title":"Text indent","style":"text-indent","property":"0","unit":["px","%","em"]},"color-picker":{"title":"Color","style":"color","property":"#fff"}},"desc":"Add custom font."},"placefont":{"name":"Font","slug":"font","type":{"numeric1":{"title":"Font size","style":"font-size","property":"0","unit":["px","%","em"]},"select2":{"title":"Font weight","style":"font-weight","property":["inherit","normal","bold","lighter","bolder","300","400","600","700"]},"select1":{"title":"Font style","style":"font-style","property":["normal","italic","oblique"]},"numeric2":{"title":"Line Height","style":"line-height","property":"0","unit":["px","%","em"]},"numeric3":{"title":"Text indent","style":"text-indent","property":"0","unit":["px","%","em"]},"color-picker":{"title":"Color","style":"color","property":"#fff"}},"desc":"Add custom font."},"margin":{"name":"Margin","slug":"margin","type":{"numeric":{"title":"Margin","style":"margin","property":"0 0 0 0","unit":["px","%","em"]}},"desc":"Add custom margin."},"padding":{"name":"Padding","slug":"padding","type":{"numeric":{"title":"Padding","style":"padding","property":"0 0 0 0","unit":["px","%","em"]}},"desc":"Add custom padding."},"float":{"name":"Position","slug":"float","type":{"select":{"title":"Position","style":"float","property":["inherit","none","left","right"]}},"desc":"Add custom float."},"display":{"name":"Display","slug":"display","type":{"select":{"title":"Display","style":"display","property":["inherit","none","inline","inline-block","block"]}},"desc":"Add custom display."},"box-sizing":{"name":"Box sizing","slug":"box-sizing","type":{"select":{"title":"Box sizing","style":"box-sizing","property":["inherit","initial","unset","content-box","border-box"]}},"desc":"Add custom box sizing."},"comming-soon":{"name":"Comming Soon","slug":"box-sizing","type":{"comming-soon":{}}}}';
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.1.4
7
  Author: Johnny, dorumarginean, mlehelsz, MirceaR
8
  Author URI: http://cf7style.com
9
  License: GPL2
@@ -20,7 +20,7 @@ if ( !defined( 'ABSPATH' ) ) {
20
  define( 'WPCF7S_PLUGIN', __FILE__ );
21
  define( 'WPCF7S_PLUGIN_DIR', untrailingslashit( dirname( WPCF7S_PLUGIN ) ) );
22
  define( 'WPCF7S_LOCATION',plugin_dir_url( WPCF7S_PLUGIN ) );
23
- define( 'WPCF7S_PLUGIN_VER', '3.1.4' );
24
  define( 'WPCF7S_REQ_PLUGIN', 'contact-form-7/wp-contact-form-7.php' );
25
 
26
  /*
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.1.5
7
  Author: Johnny, dorumarginean, mlehelsz, MirceaR
8
  Author URI: http://cf7style.com
9
  License: GPL2
20
  define( 'WPCF7S_PLUGIN', __FILE__ );
21
  define( 'WPCF7S_PLUGIN_DIR', untrailingslashit( dirname( WPCF7S_PLUGIN ) ) );
22
  define( 'WPCF7S_LOCATION',plugin_dir_url( WPCF7S_PLUGIN ) );
23
+ define( 'WPCF7S_PLUGIN_VER', '3.1.5' );
24
  define( 'WPCF7S_REQ_PLUGIN', 'contact-form-7/wp-contact-form-7.php' );
25
 
26
  /*
inc/init_style.php CHANGED
@@ -11,17 +11,25 @@ if ( !defined( 'ABSPATH' ) ) {
11
  }
12
 
13
  function get_predefined_cf7_style_template_data() {
14
- $request_json = wp_safe_remote_get( WPCF7S_LOCATION.'/admin/predefined-templates.json' );
15
- $templates = json_decode( wp_remote_retrieve_body( $request_json ) , true);
 
 
 
 
 
16
  return $templates;
17
  }// end of get_predefined_cf7_style_template_data
18
 
19
  function cf7_style_set_style_category_on_publish( $ID, $post ) {
20
  $temporizator = 0;
21
- foreach ( get_predefined_cf7_style_template_data() as $predefined_post_titles ) {
22
- if( $post->post_title == $predefined_post_titles[ "title" ] ){
23
- $temporizator++;
24
- }
 
 
 
25
  }
26
  if( 0 == $temporizator ) {
27
  wp_set_object_terms( $ID, 'custom style', 'style_category' );
@@ -129,31 +137,33 @@ function cf7style_load_elements(){
129
  );
130
  //register tax
131
  register_taxonomy( 'style_category', array( 'cf7_style' ), $args );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
 
133
- foreach ( get_predefined_cf7_style_template_data() as $style ) {
134
- cf7_style_create_post( strtolower( str_replace( " ", "-", $style['title'] ) ), $style['title'], $style['image'] );
135
- }
136
- if( get_option( 'cf7_style_add_categories', 0 ) == 0 ){
137
- $cf7_style_args = array(
138
- 'post_type' => 'cf7_style',
139
- 'posts_per_page' => '-1'
140
- );
141
-
142
- $cf7_style_query = new WP_Query( $cf7_style_args );
143
- if ( $cf7_style_query->have_posts() ) {
144
- while ( $cf7_style_query->have_posts() ) {
145
- $cf7_style_query->the_post();
146
- $temp_title = get_the_title();
147
- $temp_ID = get_the_ID();
148
-
149
- foreach ( get_predefined_cf7_style_template_data() as $style ) {
150
- if( $temp_title == wptexturize( $style[ 'title' ] ) ) {
151
- wp_set_object_terms( $temp_ID, $style[ 'category' ], 'style_category' );
152
  }
153
  }
 
 
154
  }
155
- wp_reset_postdata();
156
- update_option( 'cf7_style_add_categories', 1 );
157
  }
158
  }
159
  $cf7_style_update_saved = get_option( 'cf7_style_update_saved' );
11
  }
12
 
13
  function get_predefined_cf7_style_template_data() {
14
+ $request_json = wp_remote_get( WPCF7S_LOCATION.'admin/predefined-templates.json' );
15
+ if ( is_wp_error( $request_json ) ) {
16
+ require WPCF7S_PLUGIN_DIR.'/admin/predefined_tpls.php';
17
+ $templates = json_decode( $tpl_string, true );
18
+ return $templates;
19
+ }
20
+ $templates = json_decode( wp_remote_retrieve_body( $request_json ), true );
21
  return $templates;
22
  }// end of get_predefined_cf7_style_template_data
23
 
24
  function cf7_style_set_style_category_on_publish( $ID, $post ) {
25
  $temporizator = 0;
26
+ $tpl_data = get_predefined_cf7_style_template_data();
27
+ if( $tpl_data ){
28
+ foreach ( $tpl_data as $predefined_post_titles ) {
29
+ if( $post->post_title == $predefined_post_titles[ "title" ] ){
30
+ $temporizator++;
31
+ }
32
+ }
33
  }
34
  if( 0 == $temporizator ) {
35
  wp_set_object_terms( $ID, 'custom style', 'style_category' );
137
  );
138
  //register tax
139
  register_taxonomy( 'style_category', array( 'cf7_style' ), $args );
140
+ $tpl_data = get_predefined_cf7_style_template_data();
141
+ if( $tpl_data ){
142
+ foreach ( $tpl_data as $style ) {
143
+ cf7_style_create_post( strtolower( str_replace( " ", "-", $style['title'] ) ), $style['title'], $style['image'] );
144
+ }
145
+ if( get_option( 'cf7_style_add_categories', 0 ) == 0 ){
146
+ $cf7_style_args = array(
147
+ 'post_type' => 'cf7_style',
148
+ 'posts_per_page' => '-1'
149
+ );
150
+
151
+ $cf7_style_query = new WP_Query( $cf7_style_args );
152
+ if ( $cf7_style_query->have_posts() ) {
153
+ while ( $cf7_style_query->have_posts() ) {
154
+ $cf7_style_query->the_post();
155
+ $temp_title = get_the_title();
156
+ $temp_ID = get_the_ID();
157
 
158
+ foreach ( $tpl_data as $style ) {
159
+ if( $temp_title == wptexturize( $style[ 'title' ] ) ) {
160
+ wp_set_object_terms( $temp_ID, $style[ 'category' ], 'style_category' );
161
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
162
  }
163
  }
164
+ wp_reset_postdata();
165
+ update_option( 'cf7_style_add_categories', 1 );
166
  }
 
 
167
  }
168
  }
169
  $cf7_style_update_saved = get_option( 'cf7_style_update_saved' );
options.php CHANGED
@@ -7,7 +7,7 @@ if ( !defined( 'ABSPATH' ) ) {
7
  exit;
8
  }
9
 
10
- require 'plugin-options.php';
11
 
12
  /**
13
  * Get saved values
7
  exit;
8
  }
9
 
10
+ require_once 'plugin-options.php';
11
 
12
  /**
13
  * Get saved values
plugin-options.php CHANGED
@@ -4,12 +4,14 @@ if ( !defined( 'ABSPATH' ) ) {
4
  exit;
5
  }
6
 
 
7
 
8
- $request_json = wp_safe_remote_get( WPCF7S_LOCATION.'/admin/settings-setup.json' );
9
-
10
-
11
- $options = json_decode( wp_remote_retrieve_body( $request_json ) , true);
12
-
 
13
  /**
14
  * Generate property fields
15
  */
4
  exit;
5
  }
6
 
7
+ $request_json = wp_remote_get( WPCF7S_LOCATION.'admin/settings-setup.json' );
8
 
9
+ if ( is_wp_error( $request_json ) ) {
10
+ require WPCF7S_PLUGIN_DIR.'/admin/settings_setup.php';
11
+ $options = json_decode( $setting_str, true );
12
+ } else {
13
+ $options = json_decode( wp_remote_retrieve_body( $request_json ) , true);
14
+ }
15
  /**
16
  * Generate property fields
17
  */
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://cf7style.com/back-this-project/
4
  Tags: contact form 7, contact form 7 style, contact form 7 templates, contact form 7 styling, CF7, CF7 style, styling contact form, styling contact form 7, multiple form styling, custom form styling, CF7 addon, customize, templates, valentine's day templates, Christmas templates, manual styling, live preview, hover state styling, CF7 form messages styling
5
  Requires at least: 3.0.1
6
  Tested up to: 4.8
7
- Stable tag: 3.1.4
8
  Requires PHP: 5.6.0
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -76,6 +76,12 @@ Please check our FAQ page where you'll find answers to some of your questions on
76
 
77
  == Changelog ==
78
 
 
 
 
 
 
 
79
  = 3.1.4 =
80
 
81
  Release Date: November 4th, 2017
@@ -253,8 +259,6 @@ Release Date: November 3rd, 2017
253
  * First plugin version.
254
 
255
  == Upgrade Notice ==
256
- = Contact Form 7 Style Version 3.1.4 =
257
-
258
- = 3.1.4 =
259
 
260
- * [Major Fix](https://wordpress.org/support/topic/dont-show-background-image/) Background image rendering fixed ( added "url()" )
4
  Tags: contact form 7, contact form 7 style, contact form 7 templates, contact form 7 styling, CF7, CF7 style, styling contact form, styling contact form 7, multiple form styling, custom form styling, CF7 addon, customize, templates, valentine's day templates, Christmas templates, manual styling, live preview, hover state styling, CF7 form messages styling
5
  Requires at least: 3.0.1
6
  Tested up to: 4.8
7
+ Stable tag: 3.1.5
8
  Requires PHP: 5.6.0
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
76
 
77
  == Changelog ==
78
 
79
+ = 3.1.5 =
80
+
81
+ Release Date: November 6th, 2017
82
+
83
+ * [Major Fix](https://wordpress.org/support/topic/error-on-updating-cf7-style/) Fallback for setups where json file can not be accesed by wp_remote_get
84
+
85
  = 3.1.4 =
86
 
87
  Release Date: November 4th, 2017
259
  * First plugin version.
260
 
261
  == Upgrade Notice ==
262
+ = Contact Form 7 Style Version 3.1.5 =
 
 
263
 
264
+ * [Major Fix](https://wordpress.org/support/topic/error-on-updating-cf7-style/) Fallback for setups where json file can not be accesed by wp_remote_get