Calculated Fields Form - Version 1.1.111

Version Description

  • Improves the plugin code.
  • Includes additional forms to the forms library.
Download this release

Release Info

Developer codepeople
Plugin Icon 128x128 Calculated Fields Form
Version 1.1.111
Comparing to
See all releases

Code changes from version 1.1.110 to 1.1.111

Files changed (41) hide show
  1. README.txt +7 -10
  2. captcha/captcha.php +169 -177
  3. changelog.txt +5 -0
  4. config/cpcff_config.cfg.php +178 -179
  5. cp_calculatedfieldsf_free.php +59 -63
  6. feedback/cp-feedback.php +86 -97
  7. inc/cpcff_admin_int.inc.php +741 -719
  8. inc/cpcff_admin_int_list.inc.php +436 -445
  9. inc/cpcff_amp.inc.php +229 -222
  10. inc/cpcff_auxiliary.inc.php +387 -407
  11. inc/cpcff_banner.inc.php +106 -107
  12. inc/cpcff_compatibility.inc.php +100 -110
  13. inc/cpcff_form.inc.php +509 -479
  14. inc/cpcff_install_uninstall.inc.php +323 -337
  15. inc/cpcff_main.inc.php +1074 -1093
  16. inc/cpcff_page_builders.inc.php +187 -210
  17. inc/cpcff_public_int.inc.php +80 -85
  18. inc/cpcff_revisions.inc.php +148 -158
  19. inc/cpcff_session.inc.php +185 -195
  20. inc/cpcff_templates.inc.php +154 -175
  21. inc/cpcff_trial.php +66 -61
  22. js/JSMin.php +334 -343
  23. js/fbuilder-loader-admin.php +72 -89
  24. js/fbuilder-loader-public.php +148 -151
  25. languages/calculated-fields-form-en_US.mo +0 -0
  26. languages/calculated-fields-form-en_US.po +223 -201
  27. pagebuilders/beaverbuilder/cff/cff.inc.php +51 -50
  28. pagebuilders/beaverbuilder/cff/cff/cff.php +21 -20
  29. pagebuilders/beaverbuilder/cff/cff/includes/frontend.php +18 -15
  30. pagebuilders/beaverbuilder/cffvar/cffvar.inc.php +38 -38
  31. pagebuilders/beaverbuilder/cffvar/cffvar/cffvar.php +21 -20
  32. pagebuilders/beaverbuilder/cffvar/cffvar/includes/frontend.php +17 -17
  33. pagebuilders/divi/cff.pb.php +79 -78
  34. pagebuilders/elementor/elementor.pb.php +197 -210
  35. pagebuilders/elementor/elementor_category.pb.php +16 -16
  36. pagebuilders/siteorigin/siteorigin-cpcff-variable/siteorigin-cpcff-variable.php +64 -67
  37. pagebuilders/siteorigin/siteorigin-cpcff-variable/tpl/siteorigin-cff-variable-shortcode.php +20 -15
  38. pagebuilders/siteorigin/siteorigin-cpcff/fields/cff-button.class.php +5 -6
  39. pagebuilders/siteorigin/siteorigin-cpcff/siteorigin-cpcff.php +72 -75
  40. pagebuilders/siteorigin/siteorigin-cpcff/tpl/siteorigin-cff-shortcode.php +16 -13
  41. vendors/forms.js +15 -0
README.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://cff.dwbooster.com
4
  Tags: form,quote form,contact form,form builder,calculator,calculated,quote calculator,forms,form editor,advanced forms,payment calculator,payment,recurring payment,quote,fields,calculated field,price calculator,email,form design,paypal,equation editor,formula,equation,quote calculator,post,posts,plugin,widget,admin,sidebar,images,image,page,shortcode,products form,woocommerce,addons,layout,session,post,cookie,get,webhook,Dropbox,pdf,language
5
  Requires at least: 3.0.5
6
  Tested up to: 6.0
7
- Stable tag: 1.1.110
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -965,6 +965,11 @@ A: Please, follow the steps below:
965
 
966
  == Changelog ==
967
 
 
 
 
 
 
968
  = 1.1.110 =
969
 
970
  * Fixes a minor issue with Upload File and Summary fields settigns.
@@ -1009,12 +1014,4 @@ A: Please, follow the steps below:
1009
 
1010
  = 1.1.102 =
1011
 
1012
- * Fixes an issue with the radio buttons when switching on/off is enabled.
1013
-
1014
- = 1.1.101 =
1015
-
1016
- * Modifies the Textarea control to preserve the changes of line accessing the raw field's value.
1017
- * Fixes an issue in the calculated fields formatted automatically with manually entered values.
1018
- * Removes the extra columns and rows in the generated CSV files from the Messages section (Professional, Developer, and Platinum versions).
1019
- * Implements the new control "HTML Content DS" to display plain HTML content read from an external data source (Developer and Platinum versions).
1020
- * Modifies the "CFF - WooCommerce" add-on to support the "WooCommerce One Page Checkout" plugin (Developer and Platinum versions).
4
  Tags: form,quote form,contact form,form builder,calculator,calculated,quote calculator,forms,form editor,advanced forms,payment calculator,payment,recurring payment,quote,fields,calculated field,price calculator,email,form design,paypal,equation editor,formula,equation,quote calculator,post,posts,plugin,widget,admin,sidebar,images,image,page,shortcode,products form,woocommerce,addons,layout,session,post,cookie,get,webhook,Dropbox,pdf,language
5
  Requires at least: 3.0.5
6
  Tested up to: 6.0
7
+ Stable tag: 1.1.111
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
965
 
966
  == Changelog ==
967
 
968
+ = 1.1.111 =
969
+
970
+ * Improves the plugin code.
971
+ * Includes additional forms to the forms library.
972
+
973
  = 1.1.110 =
974
 
975
  * Fixes a minor issue with Upload File and Summary fields settigns.
1014
 
1015
  = 1.1.102 =
1016
 
1017
+ * Fixes an issue with the radio buttons when switching on/off is enabled.
 
 
 
 
 
 
 
 
captcha/captcha.php CHANGED
@@ -4,196 +4,188 @@ PHP Captcha by Codepeople.net
4
  http://www.codepeople.net
5
  */
6
 
7
- if(!defined('WP_DEBUG') || true != WP_DEBUG)
8
- {
9
- error_reporting(E_ERROR|E_PARSE);
10
  }
11
 
12
- if (!ini_get("zlib.output_compression")) ob_clean();
 
 
13
 
14
- if(!function_exists('cff_captcha_sanitize_key'))
15
- {
16
  function cff_captcha_sanitize_key( $key ) {
17
- $key = strtolower( $key );
18
- $key = preg_replace( '/[^a-z0-9_\-]/', '', $key );
19
- return $key;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  }
22
 
23
- if( !class_exists( 'CP_SESSION' ) && session_id() == '' ) session_start();
24
-
25
- if (!isset($_GET["ps"])) $_GET["ps"] = '';
26
-
27
- if( isset($_GET["hdwtest"]) && $_GET["hdwtest"] == "sessiontest" )
28
- {
29
- if( !isset( $_GET["autocall"] ) || $_GET["autocall"] != 1 )
30
- {
31
- if( class_exists( 'CP_SESSION' ) ) CP_SESSION::set_var("tmpvar", "ok");
32
- else $_SESSION[ "tmpvar" ] = "ok";
33
- }
34
- else
35
- {
36
- if(
37
- ( class_exists( 'CP_SESSION' ) && CP_SESSION::get_var("tmpvar") != "ok") ||
38
- (!class_exists( 'CP_SESSION' ) && empty( $_SESSION[ "tmpvar" ] ) )
39
- )
40
- {
41
- die("Session Error");
42
- }
43
- else
44
- {
45
- die("Sessions works on your server!");
46
- }
47
- }
48
-
49
- $current_url = ( !empty( $_SERVER[ 'REQUEST_URI' ] ) ) ? $_SERVER[ 'REQUEST_URI' ] : $_SERVER['PATH_INFO'];
50
- $current_url .= ( ( strpos( $current_url, "?" ) === false ) ? "?" : "&" )."hdwtest=sessiontest&autocall=1";
51
- header("Location: ".$current_url );
52
- exit;
53
- }
54
-
55
- if(empty($_GET["width"]) || !is_numeric($_GET["width"])) $_GET["width"] = "180";
56
- if(empty($_GET["height"]) || !is_numeric($_GET["height"])) $_GET["height"] = "60";
57
- if(empty($_GET["letter_count"]) || !is_numeric($_GET["letter_count"])) $_GET["letter_count"] = "5";
58
- if(empty($_GET["min_size"]) || !is_numeric($_GET["min_size"])) $_GET["min_size"] = "35";
59
- if(empty($_GET["max_size"]) || !is_numeric($_GET["max_size"])) $_GET["max_size"] = "45";
60
- if(empty($_GET["noise"]) || !is_numeric($_GET["noise"])) $_GET["noise"] = "200";
61
- if(empty($_GET["noiselength"]) || !is_numeric($_GET["noiselength"])) $_GET["noiselength"] = "5";
62
- if(empty($_GET["bcolor"])) $_GET["bcolor"] = "FFFFFF";
63
- if(empty($_GET["border"])) $_GET["border"] = "000000";
64
-
65
- //configuration
66
- $imgX = ( isset($_GET["width"]) && is_numeric( $_GET["width"] ) )? $_GET["width"] : "180" ;
67
- $imgY = ( isset($_GET["height"]) && is_numeric( $_GET["height"] ) )? $_GET["height"] : "60" ;
68
-
69
- $letter_count = ( isset($_GET["letter_count"]) && is_numeric( $_GET["letter_count"] ) )? $_GET["letter_count"] : "5";
70
- $min_size = ( isset($_GET["min_size"]) && is_numeric( $_GET["min_size"] ) )? $_GET["min_size"] : "35";
71
- $max_size = ( isset($_GET["max_size"]) && is_numeric( $_GET["max_size"] ) )? $_GET["max_size"] : "45";
72
- $noise = ( isset($_GET["noise"]) && is_numeric( $_GET["noise"] ) )? $_GET["noise"] : "200";
73
- $noiselength = ( isset($_GET["noiselength"]) && is_numeric( $_GET["noiselength"] ) )? $_GET["noiselength"] : "5";
74
- $bcolor = cpcff_decodeColor($_GET["bcolor"]);
75
- $border = cpcff_decodeColor($_GET["border"]);
76
-
77
- $noisecolor = 0xcdcdcd;
78
- $random_noise_color= true;
79
- $tcolor = cpcff_decodeColor("666666");
80
- $random_text_color= true;
81
-
82
- header("Cache-Control: no-store, no-cache, must-revalidate");
83
- header("Pragma: no-cache");
84
-
85
- function cpcff_decodeColor($hexcolor)
86
- {
87
- $color = hexdec($hexcolor);
88
- $c["b"] = $color % 256;
89
- $color = $color / 256;
90
- $c["g"] = $color % 256;
91
- $color = $color / 256;
92
- $c["r"] = $color % 256;
93
- return $c;
94
- }
95
-
96
- function cpcff_similarColors($c1, $c2)
97
- {
98
- return sqrt( pow($c1["r"]-$c2["r"],2) + pow($c1["g"]-$c2["g"],2) + pow($c1["b"]-$c2["b"],2)) < 125;
99
  }
100
 
101
  function cpcff_make_seed() {
102
- list($usec, $sec) = explode(' ', microtime());
103
- return (float) $sec + ((float) $usec * 100000);
104
  }
105
- mt_srand(cpcff_make_seed());
106
  $randval = mt_rand();
107
 
108
- $str = "";
109
  $length = 0;
110
- for ($i = 0; $i < $letter_count; $i++) {
111
- $str .= chr(mt_rand(97, 122))." ";
112
- }
113
-
114
- if( class_exists( 'CP_SESSION' ) ) CP_SESSION::set_var('rand_code'.cff_captcha_sanitize_key($_GET["ps"]), str_replace(" ", "", $str));
115
- else $_SESSION['rand_code'.cff_captcha_sanitize_key($_GET["ps"]) ] = str_replace(" ", "", $str);
116
-
117
- $image = imagecreatetruecolor($imgX, $imgY);
118
- $backgr_col = imagecolorallocate($image, $bcolor["r"],$bcolor["g"],$bcolor["b"]);
119
- $border_col = imagecolorallocate($image, $border["r"],$border["g"],$border["b"]);
120
-
121
- if ($random_text_color)
122
- {
123
- do
124
- {
125
- $selcolor = mt_rand(0,256*256*256);
126
- } while ( cpcff_similarColors(cpcff_decodeColor($selcolor), $bcolor) );
127
- $tcolor = cpcff_decodeColor($selcolor);
128
- }
129
-
130
- $text_col = imagecolorallocate($image, $tcolor["r"],$tcolor["g"],$tcolor["b"]);
131
-
132
- imagefilledrectangle($image, 0, 0, $imgX, $imgY, $backgr_col);
133
- imagerectangle($image, 0, 0, $imgX-1, $imgY-1, $border_col);
134
- for ($i=0;$i<$noise;$i++)
135
- {
136
- if ($random_noise_color)
137
- $color = mt_rand(0, 256*256*256);
138
- else
139
- $color = $noisecolor;
140
- $x1 = mt_rand(2,$imgX-2);
141
- $y1 = mt_rand(2,$imgY-2);
142
- imageline ( $image, $x1, $y1, mt_rand($x1-$noiselength,$x1+$noiselength), mt_rand($y1-$noiselength,$y1+$noiselength), $color);
143
- }
144
-
145
- $selected_font = "font-1.ttf";
146
- if(isset($_GET["font"]))
147
- {
148
- switch ($_GET["font"])
149
- {
150
- case "font-2.ttf":
151
- $selected_font = "font-2.ttf";
152
- break;
153
- case "font-3.ttf":
154
- $selected_font = "font-3.ttf";
155
- break;
156
- case "font-4.ttf":
157
- $selected_font = "font-4.ttf";
158
- break;
159
- }
160
- }
161
-
162
- $font = dirname( __FILE__ ) . "/" . $selected_font; // font
163
 
164
  // Removed @2x, the patch fixes an issue caused by other plugin that includes the @2x in the name of font files.
165
- $font = str_replace( array("\\", "@2x"), array("/", ""), $font );
166
-
167
- $font_size = rand($min_size, $max_size);
168
-
169
- $angle = rand(-15, 15);
170
-
171
- if (function_exists("imagettfbbox") && function_exists("imagettftext"))
172
- {
173
- $box = imagettfbbox($font_size, $angle, $font, $str);
174
- $x = (int)($imgX - $box[4]) / 2;
175
- $y = (int)($imgY - $box[5]) / 2;
176
- imagettftext($image, $font_size, $angle, $x, $y, $text_col, $font, $str);
177
- }
178
- else if (function_exists("imageFtBBox") && function_exists("imageFTText"))
179
- {
180
- $box = imageFtBBox($font_size, $angle, $font, $str);
181
- $x = (int)($imgX - $box[4]) / 2;
182
- $y = (int)($imgY - $box[5]) / 2;
183
- imageFTText ($image, $font_size, $angle, $x, $y, $text_col, $font, $str);
184
- }
185
- else
186
- {
187
- $angle = 0;
188
- $font = 6;
189
- $wf = ImageFontWidth(6) * strlen($str);
190
- $hf = ImageFontHeight(6);
191
- $x = (int)($imgX - $wf) / 2;
192
- $y = (int)($imgY - $hf) / 2;
193
- imagestring ( $image, $font, $x, $y, $str, $text_col);
194
- }
195
-
196
- header("Content-type: image/png");
197
- imagepng($image);
198
- imagedestroy ($image);
199
- exit;
4
  http://www.codepeople.net
5
  */
6
 
7
+ if ( ! defined( 'WP_DEBUG' ) || true != WP_DEBUG ) {
8
+ error_reporting( E_ERROR | E_PARSE );
 
9
  }
10
 
11
+ if ( ! ini_get( 'zlib.output_compression' ) ) {
12
+ ob_clean();
13
+ }
14
 
15
+ if ( ! function_exists( 'cff_captcha_sanitize_key' ) ) {
 
16
  function cff_captcha_sanitize_key( $key ) {
17
+ $key = strtolower( $key );
18
+ $key = preg_replace( '/[^a-z0-9_\-]/', '', $key );
19
+ return $key;
20
+ }
21
+ }
22
+
23
+ if ( ! function_exists( 'sanitize_text_field' ) ) {
24
+ function sanitize_text_field( $v ) {
25
+ return strip_tags( $v );
26
+ }
27
+ }
28
+
29
+ if ( ! function_exists( 'wp_unslash' ) ) {
30
+ function wp_unslash( $v ) {
31
+ return stripcslashes( $v );
32
+ }
33
+ }
34
+
35
+ if ( ! class_exists( 'CP_SESSION' ) && session_id() == '' ) {
36
+ session_start();
37
+ }
38
+
39
+ $_ps = isset( $_GET['ps'] ) ? cff_captcha_sanitize_key( sanitize_text_field( wp_unslash( $_GET['ps'] ) ) ) : '';
40
+
41
+ if ( isset( $_GET['hdwtest'] ) && 'sessiontest' == $_GET['hdwtest'] ) {
42
+ if ( ! isset( $_GET['autocall'] ) || 1 != $_GET['autocall'] ) {
43
+ if ( class_exists( 'CP_SESSION' ) ) {
44
+ CP_SESSION::set_var( 'tmpvar', 'ok' );
45
+ } else {
46
+ $_SESSION['tmpvar'] = 'ok';
47
+ }
48
+ } else {
49
+ if (
50
+ ( class_exists( 'CP_SESSION' ) && CP_SESSION::get_var( 'tmpvar' ) != 'ok' ) ||
51
+ ( ! class_exists( 'CP_SESSION' ) && empty( $_SESSION['tmpvar'] ) )
52
+ ) {
53
+ die( 'Session Error' );
54
+ } else {
55
+ die( 'Sessions works on your server!' );
56
+ }
57
  }
58
+
59
+ $current_url = ( ! empty( $_SERVER['REQUEST_URI'] ) ) ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : ( ! empty( $_SERVER['PATH_INFO'] ) ? sanitize_text_field( wp_unslash( $_SERVER['PATH_INFO'] ) ) : '' );
60
+ $current_url .= ( ( strpos( $current_url, '?' ) === false ) ? '?' : '&' ) . 'hdwtest=sessiontest&autocall=1';
61
+ header( 'Location: ' . $current_url );
62
+ exit;
63
+ }
64
+
65
+ // configuration
66
+ $imgX = ( ! empty( $_GET['width'] ) && is_numeric( $_GET['width'] ) ) ? intval( $_GET['width'] ) : 180;
67
+ $imgY = ( ! empty( $_GET['height'] ) && is_numeric( $_GET['height'] ) ) ? intval( $_GET['height'] ) : 60;
68
+
69
+ $letter_count = ( ! empty( $_GET['letter_count'] ) && is_numeric( $_GET['letter_count'] ) ) ? intval( $_GET['letter_count'] ) : 5;
70
+ $min_size = ( ! empty( $_GET['min_size'] ) && is_numeric( $_GET['min_size'] ) ) ? floatval( $_GET['min_size'] ) : 35;
71
+ $max_size = ( ! empty( $_GET['max_size'] ) && is_numeric( $_GET['max_size'] ) ) ? floatval( $_GET['max_size'] ) : 45;
72
+ $noise = ( ! empty( $_GET['noise'] ) && is_numeric( $_GET['noise'] ) ) ? intval( $_GET['noise'] ) : 200;
73
+ $noiselength = ( ! empty( $_GET['noiselength'] ) && is_numeric( $_GET['noiselength'] ) ) ? intval( $_GET['noiselength'] ) : 5;
74
+ $bcolor = cpcff_decodeColor( ! empty( $_GET['bcolor'] ) ? sanitize_text_field( wp_unslash( $_GET['bcolor'] ) ) : 'FFFFFF' );
75
+ $border = cpcff_decodeColor( ! empty( $_GET['border'] ) ? sanitize_text_field( wp_unslash( $_GET['border'] ) ) : '000000' );
76
+
77
+ $noisecolor = 0xcdcdcd;
78
+ $random_noise_color = true;
79
+ $tcolor = cpcff_decodeColor( '666666' );
80
+ $random_text_color = true;
81
+
82
+ header( 'Cache-Control: no-store, no-cache, must-revalidate' );
83
+ header( 'Pragma: no-cache' );
84
+
85
+ function cpcff_decodeColor( $hexcolor ) {
86
+ $color = hexdec( $hexcolor );
87
+ $c['b'] = $color % 256;
88
+ $color = $color / 256;
89
+ $c['g'] = $color % 256;
90
+ $color = $color / 256;
91
+ $c['r'] = $color % 256;
92
+ return $c;
93
  }
94
 
95
+ function cpcff_similarColors( $c1, $c2 ) {
96
+ return sqrt( pow( $c1['r'] - $c2['r'], 2 ) + pow( $c1['g'] - $c2['g'], 2 ) + pow( $c1['b'] - $c2['b'], 2 ) ) < 125;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  }
98
 
99
  function cpcff_make_seed() {
100
+ list($usec, $sec) = explode( ' ', microtime() );
101
+ return (float) $sec + ( (float) $usec * 100000 );
102
  }
103
+ mt_srand( cpcff_make_seed() );
104
  $randval = mt_rand();
105
 
106
+ $str = '';
107
  $length = 0;
108
+ for ( $i = 0; $i < $letter_count; $i++ ) {
109
+ $str .= chr( mt_rand( 97, 122 ) ) . ' ';
110
+ }
111
+
112
+ if ( class_exists( 'CP_SESSION' ) ) {
113
+ CP_SESSION::set_var( 'rand_code' . $_ps, str_replace( ' ', '', $str ) );
114
+ } else {
115
+ $_SESSION[ 'rand_code' . $_ps ] = str_replace( ' ', '', $str );
116
+ }
117
+
118
+ $image = imagecreatetruecolor( $imgX, $imgY );
119
+ $backgr_col = imagecolorallocate( $image, $bcolor['r'], $bcolor['g'], $bcolor['b'] );
120
+ $border_col = imagecolorallocate( $image, $border['r'], $border['g'], $border['b'] );
121
+
122
+ if ( $random_text_color ) {
123
+ do {
124
+ $selcolor = mt_rand( 0, 256 * 256 * 256 );
125
+ } while ( cpcff_similarColors( cpcff_decodeColor( $selcolor ), $bcolor ) );
126
+ $tcolor = cpcff_decodeColor( $selcolor );
127
+ }
128
+
129
+ $text_col = imagecolorallocate( $image, $tcolor['r'], $tcolor['g'], $tcolor['b'] );
130
+
131
+ imagefilledrectangle( $image, 0, 0, $imgX, $imgY, $backgr_col );
132
+ imagerectangle( $image, 0, 0, $imgX - 1, $imgY - 1, $border_col );
133
+ for ( $i = 0;$i < $noise;$i++ ) {
134
+ if ( $random_noise_color ) {
135
+ $color = mt_rand( 0, 256 * 256 * 256 );
136
+ } else {
137
+ $color = $noisecolor;
138
+ }
139
+ $x1 = mt_rand( 2, $imgX - 2 );
140
+ $y1 = mt_rand( 2, $imgY - 2 );
141
+ imageline( $image, $x1, $y1, mt_rand( $x1 - $noiselength, $x1 + $noiselength ), mt_rand( $y1 - $noiselength, $y1 + $noiselength ), $color );
142
+ }
143
+
144
+ $selected_font = 'font-1.ttf';
145
+ if ( isset( $_GET['font'] ) ) {
146
+ switch ( $_GET['font'] ) {
147
+ case 'font-2.ttf':
148
+ $selected_font = 'font-2.ttf';
149
+ break;
150
+ case 'font-3.ttf':
151
+ $selected_font = 'font-3.ttf';
152
+ break;
153
+ case 'font-4.ttf':
154
+ $selected_font = 'font-4.ttf';
155
+ break;
156
+ }
157
+ }
158
+
159
+ $font = dirname( __FILE__ ) . '/' . $selected_font; // font
 
160
 
161
  // Removed @2x, the patch fixes an issue caused by other plugin that includes the @2x in the name of font files.
162
+ $font = str_replace( array( '\\', '@2x' ), array( '/', '' ), $font );
163
+
164
+ $font_size = rand( $min_size, $max_size );
165
+
166
+ $angle = rand( -15, 15 );
167
+
168
+ if ( function_exists( 'imagettfbbox' ) && function_exists( 'imagettftext' ) ) {
169
+ $box = imagettfbbox( $font_size, $angle, $font, $str );
170
+ $x = (int) ( $imgX - $box[4] ) / 2;
171
+ $y = (int) ( $imgY - $box[5] ) / 2;
172
+ imagettftext( $image, $font_size, $angle, $x, $y, $text_col, $font, $str );
173
+ } elseif ( function_exists( 'imageFtBBox' ) && function_exists( 'imageFTText' ) ) {
174
+ $box = imageFtBBox( $font_size, $angle, $font, $str );
175
+ $x = (int) ( $imgX - $box[4] ) / 2;
176
+ $y = (int) ( $imgY - $box[5] ) / 2;
177
+ imageFTText( $image, $font_size, $angle, $x, $y, $text_col, $font, $str );
178
+ } else {
179
+ $angle = 0;
180
+ $font = 6;
181
+ $wf = ImageFontWidth( 6 ) * strlen( $str );
182
+ $hf = ImageFontHeight( 6 );
183
+ $x = (int) ( $imgX - $wf ) / 2;
184
+ $y = (int) ( $imgY - $hf ) / 2;
185
+ imagestring( $image, $font, $x, $y, $str, $text_col );
186
+ }
187
+
188
+ header( 'Content-type: image/png' );
189
+ imagepng( $image );
190
+ imagedestroy( $image );
191
+ exit;
 
 
 
 
 
changelog.txt CHANGED
@@ -1,5 +1,10 @@
1
  == Changelog ==
2
 
 
 
 
 
 
3
  = 1.1.110 =
4
 
5
  * Fixes a minor issue with Upload File and Summary fields settigns.
1
  == Changelog ==
2
 
3
+ = 1.1.111 =
4
+
5
+ * Improves the plugin code.
6
+ * Includes additional forms to the forms library.
7
+
8
  = 1.1.110 =
9
 
10
  * Fixes a minor issue with Upload File and Summary fields settigns.
config/cpcff_config.cfg.php CHANGED
@@ -1,179 +1,178 @@
1
- <?php
2
- /**
3
- * Defines the plugin's constants and global variables
4
- */
5
-
6
- // Calculated Fields Form constants and global variables
7
- define('CP_CFF_PHPVERSION', phpversion());
8
- define('CP_SCHEME', ( is_ssl() ) ? 'https://' : 'http://' );
9
- $GLOBALS['CP_CALCULATEDFIELDSF_DEFAULT_DEFER_SCRIPTS_LOADING'] = (get_option('CP_CFF_LOAD_SCRIPTS',"1") == "1" ? true : false);
10
- define('CP_CALCULATEDFIELDSF_USE_CACHE', 1 );
11
- define('CP_CALCULATEDFIELDSF_DISABLE_REVISIONS', 0 );
12
- define('CP_CALCULATEDFIELDSF_DEFAULT_vs_use_validation', 'true');
13
- define('CP_CALCULATEDFIELDSF_OPTIMIZATION_PLUGIN', 1);
14
-
15
- // Forms access:
16
- define('CP_CALCULATEDFIELDSF_AMP', 1 );
17
- define('CP_CALCULATEDFIELDSF_DIRECT_FORM_ACCESS', 1 );
18
-
19
- // Thank you page cache control
20
- define('CP_CALCULATEDFIELDSF_TYPC', 1 );
21
-
22
- // Admin pages
23
- define('CP_CALCULATED_FIELDS_SETTINGS_PAGE', 'cp_calculated_fields_form');
24
- define('CP_CALCULATED_FIELDS_SETTINGS_PAGE2', 'cp_calculated_fields_form_sub2');
25
- define('CP_CALCULATED_FIELDS_SETTINGS_PAGE3', 'cp_calculated_fields_form_sub3');
26
-
27
- define('CP_CALCULATEDFIELDSF_DEFAULT_template', get_option('CP_CALCULATEDFIELDSF_DEFAULT_template','cp_cff_13'));
28
- define('CP_CALCULATEDFIELDSF_DEFAULT_display_submit_button', get_option('CP_CALCULATEDFIELDSF_DEFAULT_display_submit_button',''));
29
-
30
- // Default forms
31
- define('CP_CALCULATEDFIELDSF_DEFAULT_form_structure', '[[{"name":"fieldname2","index":0,"title":"Number","predefined":"5","ftype":"fnumber","userhelp":"","csslayout":"","required":false,"size":"medium","min":"","max":"","dformat":"digits","formats":["digits","number"]},{"name":"separator1","index":1,"title":"The field below will show the double of the number above.","userhelp":"","ftype":"fSectionBreak","csslayout":""},{"name":"fieldname1","index":2,"title":"Calculated Value","eq":"fieldname2*2","ftype":"fCalculated","userhelp":"","csslayout":"","predefined":"","required":false,"size":"medium","readonly":true}],[{"title":"Calculated Form","description":"Starting form. Basic calculated fields sample. ","formlayout":"top_aligned", "formtemplate": "'.esc_js(CP_CALCULATEDFIELDSF_DEFAULT_template).'"}]]');
32
- define('CP_CALCULATEDFIELDSF_DEFAULT_form_structure1', '[[{"name":"fieldname5","index":0,"title":"Simple Sum of two numbers","userhelp":"","ftype":"fSectionBreak","csslayout":""},{"name":"fieldname2","index":1,"title":"First Number","userhelp":"","dformat":"number","min":"","max":"","predefined":"3","ftype":"fnumber","csslayout":"","required":false,"size":"small","formats":["digits","number"]},{"name":"fieldname6","index":2,"title":"Second Number","predefined":"2","ftype":"fnumber","userhelp":"","csslayout":"","required":false,"size":"small","min":"","max":"","dformat":"digits","formats":["digits","number"]},{"name":"fieldname4","index":3,"readonly":true,"title":"Sum","predefined":"","userhelp":"Note: Sum of First Number + Second Number","eq":"fieldname2+fieldname6","ftype":"fCalculated","csslayout":"","required":false,"size":"medium"},{"name":"fieldname7","index":4,"title":"Sum of selected fields","userhelp":"","ftype":"fSectionBreak","csslayout":""},{"choices":["Item A: $10","Item B: $20","Item C: $40"],"choiceSelected":[true,true,false],"name":"fieldname8","index":5,"title":"Select/un-select some items","ftype":"fcheck","userhelp":"","csslayout":"","layout":"one_column","required":false},{"name":"fieldname9","index":6,"title":"Sum of selected items","eq":"fieldname8","ftype":"fCalculated","userhelp":"","csslayout":"","predefined":"","required":false,"size":"medium","readonly":false}],[{"title":"Simple Operations","description":"Below you can test two simple and frequent operations.","formlayout":"top_aligned", "formtemplate": "'.esc_js(CP_CALCULATEDFIELDSF_DEFAULT_template).'"}]]');
33
- define('CP_CALCULATEDFIELDSF_DEFAULT_form_structure2', '[[{"name":"fieldname1","index":0,"title":"Check-in","ftype":"fdate","userhelp":"","csslayout":"","predefined":"","size":"medium","required":false,"dformat":"mm/dd/yyyy","showDropdown":false,"dropdownRange":"-10:+10","formats":["mm/dd/yyyy","dd/mm/yyyy"]},{"name":"fieldname2","index":1,"title":"Check-out","ftype":"fdate","userhelp":"","csslayout":"","predefined":"","size":"medium","required":false,"dformat":"mm/dd/yyyy","showDropdown":false,"dropdownRange":"-10:+10","formats":["mm/dd/yyyy","dd/mm/yyyy"]},{"choices":["Parking - $10","Breakfast - $20","Premium Internet Access - $3"],"choiceSelected":[false,false,false],"name":"fieldname3","index":2,"title":"Optional Services","ftype":"fcheck","userhelp":"","csslayout":"","layout":"one_column","required":false,"choicesVal":["10","20","3"]},{"name":"fieldname4","index":3,"title":"","userhelp":"Note: The cost of the optional services are per each night.","ftype":"fSectionBreak","csslayout":""},{"name":"fieldname5","index":4,"title":"Total Cost","eq":"abs(fieldname2-fieldname1) * (fieldname3+50)","userhelp":"The formula is: (checkout - checkin) * (optionals + base rate)<br />Without the optional services the formula would be: (checkout-checkin) * base rate","ftype":"fCalculated","csslayout":"","predefined":"","required":false,"size":"medium","readonly":false}],[{"title":"Calculation with Dates","description":"The form below gives a quote for a stay in a hotel based in the check-in date, check-out date and some optional services. The base rate used is $50 per night.","formlayout":"top_aligned", "formtemplate": "'.esc_js(CP_CALCULATEDFIELDSF_DEFAULT_template).'"}]]');
34
- define('CP_CALCULATEDFIELDSF_DEFAULT_form_structure3', '[[{"name":"fieldname2","index":0,"title":"Height","userhelp":"In centimeters","dformat":"number","min":"30","max":"250","predefined":"180","ftype":"fnumber","csslayout":"","required":false,"size":"small","formats":["digits","number"]},{"choices":["Male","Female"],"name":"fieldname3","index":1,"choiceSelected":"Male","title":"Sex","ftype":"fdropdown","userhelp":"","csslayout":"","size":"medium","required":false},{"name":"fieldname5","index":2,"title":"Ideal Weight","userhelp":"Formula used:<br />Men: (height - 100)*0.90<br />Woman: (height - 100)*0.85","ftype":"fSectionBreak","csslayout":""},{"name":"fieldname4","index":3,"readonly":true,"title":"Ideal Weight","predefined":"","userhelp":"Note: Based in the above data and formula","eq":"(fieldname2-100)*(fieldname3==\'Male\'?0.90:0.85)","ftype":"fCalculated","csslayout":"","required":false,"size":"medium"}],[{"title":"Ideal Weight Calculator","description":"This sample uses a simple formula but with a conditional rule (if male or female). The conditional expression is built using the JavaScript ternary operator. It\'s basically as follows: <em>condition ? value_if_true : value_if_false</em>.","formlayout":"top_aligned", "formtemplate": "'.esc_js(CP_CALCULATEDFIELDSF_DEFAULT_template).'"}]]');
35
- define('CP_CALCULATEDFIELDSF_DEFAULT_form_structure4', '[[{"name":"fieldname1","index":0,"title":"Enter the first day of last menstrual period","ftype":"fdate","userhelp":"","csslayout":"","predefined":"01/01/2013","size":"medium","required":false,"dformat":"mm/dd/yyyy","showDropdown":false,"dropdownRange":"-10:+10","formats":["mm/dd/yyyy","dd/mm/yyyy"]},{"name":"fieldname4","index":1,"title":"","userhelp":"Note: The dates below are approximate calculations. The real date may be slightly different.","ftype":"fSectionBreak","csslayout":""},{"name":"fieldname5","index":2,"title":"Conception Date","eq":"cdate(fieldname1+14)","userhelp":"","ftype":"fCalculated","csslayout":"","predefined":"","required":false,"size":"medium","readonly":false},{"name":"fieldname6","index":3,"title":"Due Date","eq":"cdate(fieldname1+40*7)","ftype":"fCalculated","userhelp":"","csslayout":"","predefined":"","required":false,"size":"medium","readonly":false}],[{"title":"Pregnancy Calculator","description":"The form below calculates the conception date and due date based in the first day of last menstrual period. The calculated values are converted to date again after the calculation.","formlayout":"top_aligned", "formtemplate": "'.esc_js(CP_CALCULATEDFIELDSF_DEFAULT_template).'"}]]');
36
- define('CP_CALCULATEDFIELDSF_DEFAULT_form_structure5', '[[{"name":"fieldname2","index":0,"title":"Loan Amount","userhelp":"","dformat":"number","min":"","max":"","predefined":"20000","ftype":"fnumber","csslayout":"","required":false,"size":"small","formats":["digits","number"]},{"name":"fieldname6","index":1,"title":"Residual Value","userhelp":"","predefined":"10000","ftype":"fnumber","csslayout":"","required":false,"size":"small","min":"","max":"","dformat":"number","formats":["digits","number"]},{"name":"fieldname7","index":2,"predefined":"7.5","title":"Interest Rate %","ftype":"fnumber","userhelp":"","csslayout":"","required":false,"size":"small","min":"","max":"","dformat":"number","formats":["digits","number"]},{"name":"fieldname8","index":3,"title":"Number of Months","dformat":"number","predefined":"36","ftype":"fnumber","userhelp":"","csslayout":"","required":false,"size":"small","min":"","max":"","formats":["digits","number"]},{"name":"fieldname5","index":4,"title":"","userhelp":"Results based in the data entered above:","ftype":"fSectionBreak","csslayout":""},{"name":"fieldname4","index":5,"readonly":true,"title":"Monthly Payment","predefined":"","userhelp":"","eq":"prec((fieldname2*fieldname7/1200*pow(1+fieldname7/1200,fieldname8)-fieldname6*fieldname7/1200)/(pow(1+fieldname7/1200,fieldname8)-1),2)","ftype":"fCalculated","csslayout":"","required":false,"size":"medium","dformat":"number"},{"name":"fieldname9","index":6,"title":"Total Payment","readonly":true,"eq":"prec(fieldname4*fieldname8,2)","ftype":"fCalculated","userhelp":"","csslayout":"","predefined":"","required":false,"size":"medium"},{"name":"fieldname10","index":7,"title":"Interest Amount","eq":"prec(fieldname6+fieldname9-fieldname2,2)","ftype":"fCalculated","userhelp":"","csslayout":"","predefined":"","required":false,"size":"medium","readonly":false}],[{"title":"Lease Calculator","description":"This sample uses a more complex formula for a lease calculator. It includes the \"power\" (pow) and \"precision\" (prec) functions.","formlayout":"top_aligned", "formtemplate": "'.esc_js(CP_CALCULATEDFIELDSF_DEFAULT_template).'"}]]');
37
-
38
- // Email constants
39
- define('CP_CALCULATEDFIELDSF_DEFAULT_fp_subject', 'Contact from the blog...');
40
- define('CP_CALCULATEDFIELDSF_DEFAULT_fp_inc_additional_info', 'true');
41
- define('CP_CALCULATEDFIELDSF_DEFAULT_fp_return_page', CPCFF_AUXILIARY::site_url().'/' );
42
- define('CP_CALCULATEDFIELDSF_DEFAULT_fp_message', "The following contact message has been sent:\n\n<%INFO%>\n\n");
43
-
44
- define('CP_CALCULATEDFIELDSF_DEFAULT_cu_enable_copy_to_user', 'true');
45
- define('CP_CALCULATEDFIELDSF_DEFAULT_cu_user_email_field', '');
46
- define('CP_CALCULATEDFIELDSF_DEFAULT_cu_subject', 'Confirmation: Message received...');
47
- define('CP_CALCULATEDFIELDSF_DEFAULT_cu_message', "Thank you for your message. We will reply you as soon as possible.\n\nThis is a copy of the data sent:\n\n<%INFO%>\n\nBest Regards.");
48
- define('CP_CALCULATEDFIELDSF_DEFAULT_email_format','text');
49
-
50
- // Captcha constants
51
- define('CP_CALCULATEDFIELDSF_DEFAULT_cv_enable_captcha', get_option('CP_CALCULATEDFIELDSF_DEFAULT_cv_enable_captcha','true'));
52
- define('CP_CALCULATEDFIELDSF_DEFAULT_cv_width', '180');
53
- define('CP_CALCULATEDFIELDSF_DEFAULT_cv_height', '60');
54
- define('CP_CALCULATEDFIELDSF_DEFAULT_cv_chars', '5');
55
- define('CP_CALCULATEDFIELDSF_DEFAULT_cv_font', 'font-1.ttf');
56
- define('CP_CALCULATEDFIELDSF_DEFAULT_cv_min_font_size', '25');
57
- define('CP_CALCULATEDFIELDSF_DEFAULT_cv_max_font_size', '35');
58
- define('CP_CALCULATEDFIELDSF_DEFAULT_cv_noise', '200');
59
- define('CP_CALCULATEDFIELDSF_DEFAULT_cv_noise_length', '4');
60
- define('CP_CALCULATEDFIELDSF_DEFAULT_cv_background', 'ffffff');
61
- define('CP_CALCULATEDFIELDSF_DEFAULT_cv_border', '000000');
62
- define('CP_CALCULATEDFIELDSF_DEFAULT_cv_text_enter_valid_captcha', 'Please enter a valid captcha code.');
63
-
64
- // Payments contstants
65
- define('CP_CALCULATEDFIELDSF_DEFAULT_CURRENCY_SYMBOL','$');
66
- define('CP_CALCULATEDFIELDSF_GBP_CURRENCY_SYMBOL',chr(163));
67
- define('CP_CALCULATEDFIELDSF_EUR_CURRENCY_SYMBOL_A','EUR ');
68
- define('CP_CALCULATEDFIELDSF_EUR_CURRENCY_SYMBOL_B',chr(128));
69
-
70
- // PayPal constants
71
- define('CP_CALCULATEDFIELDSF_DEFAULT_ENABLE_PAYPAL', 1);
72
- define('CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_MODE', 'production');
73
- define('CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_RECURRENT', '0');
74
- define('CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_IDENTIFY_PRICES', '0');
75
- define('CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_ZERO_PAYMENT', '0');
76
- define('CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_EMAIL','put_your@email_here.com');
77
- define('CP_CALCULATEDFIELDSF_DEFAULT_PRODUCT_NAME','Reservation');
78
- define('CP_CALCULATEDFIELDSF_DEFAULT_COST','25');
79
- define('CP_CALCULATEDFIELDSF_DEFAULT_CURRENCY','USD');
80
- define('CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_LANGUAGE','EN');
81
-
82
- // Database table names
83
- global $wpdb;
84
- define('CP_CALCULATEDFIELDSF_FORMS_TABLE', 'cp_calculated_fields_form_settings');
85
- define('CP_CALCULATEDFIELDSF_FORMS_REVISIONS_TABLE', 'cp_calculated_fields_form_revision');
86
- define('CP_CALCULATEDFIELDSF_DISCOUNT_CODES_TABLE_NAME_NO_PREFIX', "cp_calculated_fields_form_discount_codes");
87
- define('CP_CALCULATEDFIELDSF_DISCOUNT_CODES_TABLE_NAME', @$wpdb->prefix ."cp_calculated_fields_form_discount_codes");
88
- define('CP_CALCULATEDFIELDSF_POSTS_TABLE_NAME_NO_PREFIX', "cp_calculated_fields_form_posts");
89
- define('CP_CALCULATEDFIELDSF_POSTS_TABLE_NAME', @$wpdb->prefix ."cp_calculated_fields_form_posts");
90
-
91
- // Default texts constants and global variables
92
- define('CP_CALCULATEDFIELDSF_DEFAULT_vs_text_is_required', 'This field is required.');
93
- define('CP_CALCULATEDFIELDSF_DEFAULT_vs_text_is_email', 'Please enter a valid email address.');
94
- define('CP_CALCULATEDFIELDSF_DEFAULT_vs_text_datemmddyyyy', 'Please enter a valid date with this format(mm/dd/yyyy)');
95
- define('CP_CALCULATEDFIELDSF_DEFAULT_vs_text_dateddmmyyyy', 'Please enter a valid date with this format(dd/mm/yyyy)');
96
- define('CP_CALCULATEDFIELDSF_DEFAULT_vs_text_number', 'Please enter a valid number.');
97
- define('CP_CALCULATEDFIELDSF_DEFAULT_vs_text_digits', 'Please enter only digits.');
98
- define('CP_CALCULATEDFIELDSF_DEFAULT_vs_text_max', 'Please enter a value less than or equal to {0}.');
99
- define('CP_CALCULATEDFIELDSF_DEFAULT_vs_text_min', 'Please enter a value greater than or equal to {0}.');
100
-
101
- global $cpcff_default_texts_array;
102
- $cpcff_default_texts_array = array(
103
- 'page_of_text' => array(
104
- 'label' => 'Page X of Y (text)',
105
- 'text' => 'Page {0} of {0}'
106
- ),
107
- 'audio_tutorial_text' => array(
108
- 'label' => 'Audio tutorial (text)',
109
- 'text' => 'Help'
110
- ),
111
- 'errors' => array(
112
- 'currency' => array(
113
- 'label' => '"Invalid Currency" text',
114
- 'text' => 'Please enter a valid currency value.'
115
- ),
116
- 'maxlength' => array(
117
- 'label' => '"Max length/characters" text',
118
- 'text' => 'Please enter no more than {0} characters.'
119
- ),
120
- 'minlength' => array(
121
- 'label' => '"Min length/characters" text',
122
- 'text' => 'Please enter at least {0} characters.'
123
- ),
124
- 'equalTo' => array(
125
- 'label' => '"Equal to" text',
126
- 'text' => 'Please enter the same value again.'
127
- ),
128
- 'accept' => array(
129
- 'label' => '"Accept these file extensions" text',
130
- 'text' => 'Please enter a value with a valid extension.'
131
- ),
132
- 'upload_size' => array(
133
- 'label' => '"Maximum upload size in kB" text',
134
- 'text' => 'The file you\'ve chosen is too big, maximum is {0} kB.'
135
- ),
136
- 'phone' => array(
137
- 'label' => '"Phone number" text',
138
- 'text' => 'Invalid phone number.'
139
- )
140
- )
141
- );
142
-
143
- add_action('init', 'cpcff_init_constants', 1);
144
- if(!function_exists('cpcff_init_constants'))
145
- {
146
- function cpcff_init_constants()
147
- {
148
- $current_user_id = get_current_user_id();
149
- $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
150
- preg_match("/[^\.\/]+(\.[^\.\/]+)?$/", $host, $matches);
151
- $domain = (!empty($matches)) ? $matches[0] : '';
152
-
153
- if(!empty($current_user_id))
154
- {
155
- // User emails
156
- if(!defined('CP_CALCULATEDFIELDSF_DEFAULT_fp_from_email'))
157
- {
158
- $user_email = get_the_author_meta('user_email', $current_user_id);
159
- if(empty($user_email) || ($pos = strpos($user_email, $domain)) === false)
160
- define('CP_CALCULATEDFIELDSF_DEFAULT_fp_from_email', 'admin@'.$domain );
161
- else define('CP_CALCULATEDFIELDSF_DEFAULT_fp_from_email', $user_email );
162
- }
163
-
164
- if(!defined('CP_CALCULATEDFIELDSF_DEFAULT_fp_destination_emails'))
165
- {
166
- if(!isset($user_email)) $user_email = get_the_author_meta('user_email', $current_user_id);
167
- define('CP_CALCULATEDFIELDSF_DEFAULT_fp_destination_emails', (!empty($user_email)) ? $user_email : CP_CALCULATEDFIELDSF_DEFAULT_fp_from_email);
168
- }
169
- }
170
- else
171
- {
172
- if(!defined('CP_CALCULATEDFIELDSF_DEFAULT_fp_from_email'))
173
- define('CP_CALCULATEDFIELDSF_DEFAULT_fp_from_email', 'admin@'.$domain );
174
-
175
- if(!defined('CP_CALCULATEDFIELDSF_DEFAULT_fp_destination_emails'))
176
- define('CP_CALCULATEDFIELDSF_DEFAULT_fp_destination_emails', CP_CALCULATEDFIELDSF_DEFAULT_fp_from_email);
177
- }
178
- } // End cpcff_init_constants
179
- }
1
+ <?php
2
+ /**
3
+ * Defines the plugin's constants and global variables
4
+ */
5
+
6
+ // Calculated Fields Form constants and global variables
7
+ define( 'CP_CFF_PHPVERSION', phpversion() );
8
+ define( 'CP_SCHEME', ( is_ssl() ) ? 'https://' : 'http://' );
9
+ $GLOBALS['CP_CALCULATEDFIELDSF_DEFAULT_DEFER_SCRIPTS_LOADING'] = ( get_option( 'CP_CFF_LOAD_SCRIPTS', '1' ) == '1' ? true : false );
10
+ define( 'CP_CALCULATEDFIELDSF_USE_CACHE', 1 );
11
+ define( 'CP_CALCULATEDFIELDSF_DISABLE_REVISIONS', 0 );
12
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_vs_use_validation', 'true' );
13
+ define( 'CP_CALCULATEDFIELDSF_OPTIMIZATION_PLUGIN', 1 );
14
+
15
+ // Forms access:
16
+ define( 'CP_CALCULATEDFIELDSF_AMP', 1 );
17
+ define( 'CP_CALCULATEDFIELDSF_DIRECT_FORM_ACCESS', 1 );
18
+
19
+ // Thank you page cache control
20
+ define( 'CP_CALCULATEDFIELDSF_TYPC', 1 );
21
+
22
+ // Admin pages
23
+ define( 'CP_CALCULATED_FIELDS_SETTINGS_PAGE', 'cp_calculated_fields_form' );
24
+ define( 'CP_CALCULATED_FIELDS_SETTINGS_PAGE2', 'cp_calculated_fields_form_sub2' );
25
+ define( 'CP_CALCULATED_FIELDS_SETTINGS_PAGE3', 'cp_calculated_fields_form_sub3' );
26
+
27
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_template', get_option( 'CP_CALCULATEDFIELDSF_DEFAULT_template', 'cp_cff_13' ) );
28
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_display_submit_button', get_option( 'CP_CALCULATEDFIELDSF_DEFAULT_display_submit_button', '' ) );
29
+
30
+ // Default forms
31
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_form_structure', '[[{"name":"fieldname2","index":0,"title":"Number","predefined":"5","ftype":"fnumber","userhelp":"","csslayout":"","required":false,"size":"medium","min":"","max":"","dformat":"digits","formats":["digits","number"]},{"name":"separator1","index":1,"title":"The field below will show the double of the number above.","userhelp":"","ftype":"fSectionBreak","csslayout":""},{"name":"fieldname1","index":2,"title":"Calculated Value","eq":"fieldname2*2","ftype":"fCalculated","userhelp":"","csslayout":"","predefined":"","required":false,"size":"medium","readonly":true}],[{"title":"Calculated Form","description":"Starting form. Basic calculated fields sample. ","formlayout":"top_aligned", "formtemplate": "' . esc_js( CP_CALCULATEDFIELDSF_DEFAULT_template ) . '"}]]' );
32
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_form_structure1', '[[{"name":"fieldname5","index":0,"title":"Simple Sum of two numbers","userhelp":"","ftype":"fSectionBreak","csslayout":""},{"name":"fieldname2","index":1,"title":"First Number","userhelp":"","dformat":"number","min":"","max":"","predefined":"3","ftype":"fnumber","csslayout":"","required":false,"size":"small","formats":["digits","number"]},{"name":"fieldname6","index":2,"title":"Second Number","predefined":"2","ftype":"fnumber","userhelp":"","csslayout":"","required":false,"size":"small","min":"","max":"","dformat":"digits","formats":["digits","number"]},{"name":"fieldname4","index":3,"readonly":true,"title":"Sum","predefined":"","userhelp":"Note: Sum of First Number + Second Number","eq":"fieldname2+fieldname6","ftype":"fCalculated","csslayout":"","required":false,"size":"medium"},{"name":"fieldname7","index":4,"title":"Sum of selected fields","userhelp":"","ftype":"fSectionBreak","csslayout":""},{"choices":["Item A: $10","Item B: $20","Item C: $40"],"choiceSelected":[true,true,false],"name":"fieldname8","index":5,"title":"Select/un-select some items","ftype":"fcheck","userhelp":"","csslayout":"","layout":"one_column","required":false},{"name":"fieldname9","index":6,"title":"Sum of selected items","eq":"fieldname8","ftype":"fCalculated","userhelp":"","csslayout":"","predefined":"","required":false,"size":"medium","readonly":false}],[{"title":"Simple Operations","description":"Below you can test two simple and frequent operations.","formlayout":"top_aligned", "formtemplate": "' . esc_js( CP_CALCULATEDFIELDSF_DEFAULT_template ) . '"}]]' );
33
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_form_structure2', '[[{"name":"fieldname1","index":0,"title":"Check-in","ftype":"fdate","userhelp":"","csslayout":"","predefined":"","size":"medium","required":false,"dformat":"mm/dd/yyyy","showDropdown":false,"dropdownRange":"-10:+10","formats":["mm/dd/yyyy","dd/mm/yyyy"]},{"name":"fieldname2","index":1,"title":"Check-out","ftype":"fdate","userhelp":"","csslayout":"","predefined":"","size":"medium","required":false,"dformat":"mm/dd/yyyy","showDropdown":false,"dropdownRange":"-10:+10","formats":["mm/dd/yyyy","dd/mm/yyyy"]},{"choices":["Parking - $10","Breakfast - $20","Premium Internet Access - $3"],"choiceSelected":[false,false,false],"name":"fieldname3","index":2,"title":"Optional Services","ftype":"fcheck","userhelp":"","csslayout":"","layout":"one_column","required":false,"choicesVal":["10","20","3"]},{"name":"fieldname4","index":3,"title":"","userhelp":"Note: The cost of the optional services are per each night.","ftype":"fSectionBreak","csslayout":""},{"name":"fieldname5","index":4,"title":"Total Cost","eq":"abs(fieldname2-fieldname1) * (fieldname3+50)","userhelp":"The formula is: (checkout - checkin) * (optionals + base rate)<br />Without the optional services the formula would be: (checkout-checkin) * base rate","ftype":"fCalculated","csslayout":"","predefined":"","required":false,"size":"medium","readonly":false}],[{"title":"Calculation with Dates","description":"The form below gives a quote for a stay in a hotel based in the check-in date, check-out date and some optional services. The base rate used is $50 per night.","formlayout":"top_aligned", "formtemplate": "' . esc_js( CP_CALCULATEDFIELDSF_DEFAULT_template ) . '"}]]' );
34
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_form_structure3', '[[{"name":"fieldname2","index":0,"title":"Height","userhelp":"In centimeters","dformat":"number","min":"30","max":"250","predefined":"180","ftype":"fnumber","csslayout":"","required":false,"size":"small","formats":["digits","number"]},{"choices":["Male","Female"],"name":"fieldname3","index":1,"choiceSelected":"Male","title":"Sex","ftype":"fdropdown","userhelp":"","csslayout":"","size":"medium","required":false},{"name":"fieldname5","index":2,"title":"Ideal Weight","userhelp":"Formula used:<br />Men: (height - 100)*0.90<br />Woman: (height - 100)*0.85","ftype":"fSectionBreak","csslayout":""},{"name":"fieldname4","index":3,"readonly":true,"title":"Ideal Weight","predefined":"","userhelp":"Note: Based in the above data and formula","eq":"(fieldname2-100)*(fieldname3==\'Male\'?0.90:0.85)","ftype":"fCalculated","csslayout":"","required":false,"size":"medium"}],[{"title":"Ideal Weight Calculator","description":"This sample uses a simple formula but with a conditional rule (if male or female). The conditional expression is built using the JavaScript ternary operator. It\'s basically as follows: <em>condition ? value_if_true : value_if_false</em>.","formlayout":"top_aligned", "formtemplate": "' . esc_js( CP_CALCULATEDFIELDSF_DEFAULT_template ) . '"}]]' );
35
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_form_structure4', '[[{"name":"fieldname1","index":0,"title":"Enter the first day of last menstrual period","ftype":"fdate","userhelp":"","csslayout":"","predefined":"01/01/2013","size":"medium","required":false,"dformat":"mm/dd/yyyy","showDropdown":false,"dropdownRange":"-10:+10","formats":["mm/dd/yyyy","dd/mm/yyyy"]},{"name":"fieldname4","index":1,"title":"","userhelp":"Note: The dates below are approximate calculations. The real date may be slightly different.","ftype":"fSectionBreak","csslayout":""},{"name":"fieldname5","index":2,"title":"Conception Date","eq":"cdate(fieldname1+14)","userhelp":"","ftype":"fCalculated","csslayout":"","predefined":"","required":false,"size":"medium","readonly":false},{"name":"fieldname6","index":3,"title":"Due Date","eq":"cdate(fieldname1+40*7)","ftype":"fCalculated","userhelp":"","csslayout":"","predefined":"","required":false,"size":"medium","readonly":false}],[{"title":"Pregnancy Calculator","description":"The form below calculates the conception date and due date based in the first day of last menstrual period. The calculated values are converted to date again after the calculation.","formlayout":"top_aligned", "formtemplate": "' . esc_js( CP_CALCULATEDFIELDSF_DEFAULT_template ) . '"}]]' );
36
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_form_structure5', '[[{"name":"fieldname2","index":0,"title":"Loan Amount","userhelp":"","dformat":"number","min":"","max":"","predefined":"20000","ftype":"fnumber","csslayout":"","required":false,"size":"small","formats":["digits","number"]},{"name":"fieldname6","index":1,"title":"Residual Value","userhelp":"","predefined":"10000","ftype":"fnumber","csslayout":"","required":false,"size":"small","min":"","max":"","dformat":"number","formats":["digits","number"]},{"name":"fieldname7","index":2,"predefined":"7.5","title":"Interest Rate %","ftype":"fnumber","userhelp":"","csslayout":"","required":false,"size":"small","min":"","max":"","dformat":"number","formats":["digits","number"]},{"name":"fieldname8","index":3,"title":"Number of Months","dformat":"number","predefined":"36","ftype":"fnumber","userhelp":"","csslayout":"","required":false,"size":"small","min":"","max":"","formats":["digits","number"]},{"name":"fieldname5","index":4,"title":"","userhelp":"Results based in the data entered above:","ftype":"fSectionBreak","csslayout":""},{"name":"fieldname4","index":5,"readonly":true,"title":"Monthly Payment","predefined":"","userhelp":"","eq":"prec((fieldname2*fieldname7/1200*pow(1+fieldname7/1200,fieldname8)-fieldname6*fieldname7/1200)/(pow(1+fieldname7/1200,fieldname8)-1),2)","ftype":"fCalculated","csslayout":"","required":false,"size":"medium","dformat":"number"},{"name":"fieldname9","index":6,"title":"Total Payment","readonly":true,"eq":"prec(fieldname4*fieldname8,2)","ftype":"fCalculated","userhelp":"","csslayout":"","predefined":"","required":false,"size":"medium"},{"name":"fieldname10","index":7,"title":"Interest Amount","eq":"prec(fieldname6+fieldname9-fieldname2,2)","ftype":"fCalculated","userhelp":"","csslayout":"","predefined":"","required":false,"size":"medium","readonly":false}],[{"title":"Lease Calculator","description":"This sample uses a more complex formula for a lease calculator. It includes the \"power\" (pow) and \"precision\" (prec) functions.","formlayout":"top_aligned", "formtemplate": "' . esc_js( CP_CALCULATEDFIELDSF_DEFAULT_template ) . '"}]]' );
37
+
38
+ // Email constants
39
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_fp_subject', 'Contact from the blog...' );
40
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_fp_inc_additional_info', 'true' );
41
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_fp_return_page', CPCFF_AUXILIARY::site_url() . '/' );
42
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_fp_message', "The following contact message has been sent:\n\n<%INFO%>\n\n" );
43
+
44
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_cu_enable_copy_to_user', 'true' );
45
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_cu_user_email_field', '' );
46
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_cu_subject', 'Confirmation: Message received...' );
47
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_cu_message', "Thank you for your message. We will reply you as soon as possible.\n\nThis is a copy of the data sent:\n\n<%INFO%>\n\nBest Regards." );
48
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_email_format', 'text' );
49
+
50
+ // Captcha constants
51
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_cv_enable_captcha', get_option( 'CP_CALCULATEDFIELDSF_DEFAULT_cv_enable_captcha', 'true' ) );
52
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_cv_width', '180' );
53
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_cv_height', '60' );
54
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_cv_chars', '5' );
55
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_cv_font', 'font-1.ttf' );
56
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_cv_min_font_size', '25' );
57
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_cv_max_font_size', '35' );
58
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_cv_noise', '200' );
59
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_cv_noise_length', '4' );
60
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_cv_background', 'ffffff' );
61
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_cv_border', '000000' );
62
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_cv_text_enter_valid_captcha', 'Please enter a valid captcha code.' );
63
+
64
+ // Payments contstants
65
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_CURRENCY_SYMBOL', '$' );
66
+ define( 'CP_CALCULATEDFIELDSF_GBP_CURRENCY_SYMBOL', chr( 163 ) );
67
+ define( 'CP_CALCULATEDFIELDSF_EUR_CURRENCY_SYMBOL_A', 'EUR ' );
68
+ define( 'CP_CALCULATEDFIELDSF_EUR_CURRENCY_SYMBOL_B', chr( 128 ) );
69
+
70
+ // PayPal constants
71
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_ENABLE_PAYPAL', 1 );
72
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_MODE', 'production' );
73
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_RECURRENT', '0' );
74
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_IDENTIFY_PRICES', '0' );
75
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_ZERO_PAYMENT', '0' );
76
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_EMAIL', 'put_your@email_here.com' );
77
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_PRODUCT_NAME', 'Reservation' );
78
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_COST', '25' );
79
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_CURRENCY', 'USD' );
80
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_LANGUAGE', 'EN' );
81
+
82
+ // Database table names
83
+ global $wpdb;
84
+ define( 'CP_CALCULATEDFIELDSF_FORMS_TABLE', 'cp_calculated_fields_form_settings' );
85
+ define( 'CP_CALCULATEDFIELDSF_FORMS_REVISIONS_TABLE', 'cp_calculated_fields_form_revision' );
86
+ define( 'CP_CALCULATEDFIELDSF_DISCOUNT_CODES_TABLE_NAME_NO_PREFIX', 'cp_calculated_fields_form_discount_codes' );
87
+ define( 'CP_CALCULATEDFIELDSF_DISCOUNT_CODES_TABLE_NAME', @$wpdb->prefix . 'cp_calculated_fields_form_discount_codes' );
88
+ define( 'CP_CALCULATEDFIELDSF_POSTS_TABLE_NAME_NO_PREFIX', 'cp_calculated_fields_form_posts' );
89
+ define( 'CP_CALCULATEDFIELDSF_POSTS_TABLE_NAME', @$wpdb->prefix . 'cp_calculated_fields_form_posts' );
90
+
91
+ // Default texts constants and global variables
92
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_vs_text_is_required', 'This field is required.' );
93
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_vs_text_is_email', 'Please enter a valid email address.' );
94
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_vs_text_datemmddyyyy', 'Please enter a valid date with this format(mm/dd/yyyy)' );
95
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_vs_text_dateddmmyyyy', 'Please enter a valid date with this format(dd/mm/yyyy)' );
96
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_vs_text_number', 'Please enter a valid number.' );
97
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_vs_text_digits', 'Please enter only digits.' );
98
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_vs_text_max', 'Please enter a value less than or equal to {0}.' );
99
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_vs_text_min', 'Please enter a value greater than or equal to {0}.' );
100
+
101
+ global $cpcff_default_texts_array;
102
+ $cpcff_default_texts_array = array(
103
+ 'page_of_text' => array(
104
+ 'label' => 'Page X of Y (text)',
105
+ 'text' => 'Page {0} of {0}',
106
+ ),
107
+ 'audio_tutorial_text' => array(
108
+ 'label' => 'Audio tutorial (text)',
109
+ 'text' => 'Help',
110
+ ),
111
+ 'errors' => array(
112
+ 'currency' => array(
113
+ 'label' => '"Invalid Currency" text',
114
+ 'text' => 'Please enter a valid currency value.',
115
+ ),
116
+ 'maxlength' => array(
117
+ 'label' => '"Max length/characters" text',
118
+ 'text' => 'Please enter no more than {0} characters.',
119
+ ),
120
+ 'minlength' => array(
121
+ 'label' => '"Min length/characters" text',
122
+ 'text' => 'Please enter at least {0} characters.',
123
+ ),
124
+ 'equalTo' => array(
125
+ 'label' => '"Equal to" text',
126
+ 'text' => 'Please enter the same value again.',
127
+ ),
128
+ 'accept' => array(
129
+ 'label' => '"Accept these file extensions" text',
130
+ 'text' => 'Please enter a value with a valid extension.',
131
+ ),
132
+ 'upload_size' => array(
133
+ 'label' => '"Maximum upload size in kB" text',
134
+ 'text' => 'The file you\'ve chosen is too big, maximum is {0} kB.',
135
+ ),
136
+ 'phone' => array(
137
+ 'label' => '"Phone number" text',
138
+ 'text' => 'Invalid phone number.',
139
+ ),
140
+ ),
141
+ );
142
+
143
+ add_action( 'init', 'cpcff_init_constants', 1 );
144
+ if ( ! function_exists( 'cpcff_init_constants' ) ) {
145
+ function cpcff_init_constants() {
146
+ $current_user_id = get_current_user_id();
147
+ $host = isset( $_SERVER['HTTP_HOST'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) ) : '';
148
+ preg_match( '/[^\.\/]+(\.[^\.\/]+)?$/', $host, $matches );
149
+ $domain = ( ! empty( $matches ) ) ? $matches[0] : '';
150
+
151
+ if ( ! empty( $current_user_id ) ) {
152
+ // User emails
153
+ if ( ! defined( 'CP_CALCULATEDFIELDSF_DEFAULT_fp_from_email' ) ) {
154
+ $user_email = get_the_author_meta( 'user_email', $current_user_id );
155
+ if ( empty( $user_email ) || ( $pos = strpos( $user_email, $domain ) ) === false ) {
156
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_fp_from_email', 'admin@' . $domain );
157
+ } else {
158
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_fp_from_email', $user_email );
159
+ }
160
+ }
161
+
162
+ if ( ! defined( 'CP_CALCULATEDFIELDSF_DEFAULT_fp_destination_emails' ) ) {
163
+ if ( ! isset( $user_email ) ) {
164
+ $user_email = get_the_author_meta( 'user_email', $current_user_id );
165
+ }
166
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_fp_destination_emails', ( ! empty( $user_email ) ) ? $user_email : CP_CALCULATEDFIELDSF_DEFAULT_fp_from_email );
167
+ }
168
+ } else {
169
+ if ( ! defined( 'CP_CALCULATEDFIELDSF_DEFAULT_fp_from_email' ) ) {
170
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_fp_from_email', 'admin@' . $domain );
171
+ }
172
+
173
+ if ( ! defined( 'CP_CALCULATEDFIELDSF_DEFAULT_fp_destination_emails' ) ) {
174
+ define( 'CP_CALCULATEDFIELDSF_DEFAULT_fp_destination_emails', CP_CALCULATEDFIELDSF_DEFAULT_fp_from_email );
175
+ }
176
+ }
177
+ } // End cpcff_init_constants
178
+ }
 
cp_calculatedfieldsf_free.php CHANGED
@@ -3,27 +3,26 @@
3
  Plugin Name: Calculated Fields Form
4
  Plugin URI: https://cff.dwbooster.com
5
  Description: Create forms with field values calculated based in other form field values.
6
- Version: 1.1.110
7
  Text Domain: calculated-fields-form
8
  Author: CodePeople
9
  Author URI: https://cff.dwbooster.com
10
  License: GPL
11
  */
12
 
13
- if(!defined('WP_DEBUG') || true != WP_DEBUG)
14
- {
15
- error_reporting(E_ERROR|E_PARSE);
16
  }
17
 
18
  // Defining main constants
19
- define('CP_CALCULATEDFIELDSF_VERSION', '1.1.110' );
20
- define('CP_CALCULATEDFIELDSF_MAIN_FILE_PATH', __FILE__ );
21
- define('CP_CALCULATEDFIELDSF_BASE_PATH', dirname( CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ) );
22
- define('CP_CALCULATEDFIELDSF_BASE_NAME', plugin_basename( CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ) );
23
 
24
  // Feedback system
25
  require_once 'feedback/cp-feedback.php';
26
- new CP_FEEDBACK('calculated-fields-form', __FILE__, 'https://cff.dwbooster.com/contact-us');
27
 
28
  require_once 'inc/cpcff_auxiliary.inc.php';
29
  require_once 'config/cpcff_config.cfg.php';
@@ -40,21 +39,19 @@ add_action( 'init', 'cp_calculated_fields_form_check_posted_data', 11 );
40
  add_action( 'init', 'cp_calculated_fields_form_direct_form_access', 1 );
41
 
42
  // functions
43
- //------------------------------------------
44
- function cp_calculated_fields_form_direct_form_access()
45
- {
46
- if(
47
- get_option('CP_CALCULATEDFIELDSF_DIRECT_FORM_ACCESS', CP_CALCULATEDFIELDSF_DIRECT_FORM_ACCESS) &&
48
- !empty($_GET['cff-form']) &&
49
- @intval($_GET['cff-form'])
50
- )
51
- {
52
  $cpcff_main = CPCFF_MAIN::instance();
53
  $cpcff_main->form_preview(
54
  array(
55
- 'shortcode_atts' => array('id' => @intval($_GET['cff-form'])),
56
- 'page_title' => 'CFF',
57
- 'page' => true
58
  )
59
  );
60
  }
@@ -62,75 +59,74 @@ function cp_calculated_fields_form_direct_form_access()
62
 
63
  function cp_calculated_fields_form_check_posted_data() {
64
 
65
- global $wpdb;
66
 
67
  $cpcff_main = CPCFF_MAIN::instance();
68
 
69
- if ( isset($_SERVER['REQUEST_METHOD']) && 'POST' == $_SERVER['REQUEST_METHOD'] && isset( $_POST['cp_calculatedfieldsf_post_options'] ) && is_admin() )
70
- {
71
- cp_calculatedfieldsf_save_options();
72
- if(
73
- isset($_POST['preview']) &&
74
- isset($_POST['cp_calculatedfieldsf_id'])
75
- )
76
- {
 
77
  $cpcff_main->form_preview(
78
  array(
79
- 'shortcode_atts' => array('id' => @intval($_POST['cp_calculatedfieldsf_id'])),
80
- 'page_title' => __('Form Preview', 'calculated-fields-form'),
81
- 'wp_die' => 1
82
  )
83
  );
84
  }
85
  return;
86
- }
87
  }
88
 
89
- function cp_calculatedfieldsf_save_options()
90
- {
91
  check_admin_referer( 'cff-form-settings', '_cpcff_nonce' );
92
- global $wpdb;
93
- if (!defined('CP_CALCULATEDFIELDSF_ID'))
94
- define ('CP_CALCULATEDFIELDSF_ID',$_POST["cp_calculatedfieldsf_id"]);
 
95
 
96
  $error_occur = false;
97
- if( isset( $_POST[ 'form_structure' ] ) )
98
- {
 
 
99
  // Remove bom characters
100
- $_POST[ 'form_structure' ] = CPCFF_AUXILIARY::clean_bom($_POST[ 'form_structure' ]);
101
 
102
- $form_structure_obj = CPCFF_AUXILIARY::json_decode( $_POST[ 'form_structure' ] );
103
- if( !empty( $form_structure_obj ) )
104
- {
105
- $form_structure_obj = CPCFF_FORM::sanitize_structure($form_structure_obj);
106
 
107
  global $cpcff_default_texts_array;
108
  $cpcff_text_array = '';
109
 
110
- $_POST = CPCFF_AUXILIARY::stripcslashes_recursive($_POST);
111
- $_POST['form_structure'] = json_encode($form_structure_obj);
112
- if( isset( $_POST[ 'cpcff_text_array' ] ) ) $_POST['vs_all_texts'] = $_POST[ 'cpcff_text_array' ];
 
 
113
 
114
  $cpcff_main = CPCFF_MAIN::instance();
115
- if( $cpcff_main->get_form($_POST["cp_calculatedfieldsf_id"])->save_settings($_POST) === false )
116
- {
117
  global $cff_structure_error;
118
- $cff_structure_error = __('<div class="error-text">The data cannot be stored in database because has occurred an error with the database structure. Please, go to the plugins section and Deactivate/Activate the plugin to be sure the structure of database has been checked, and corrected if needed. If the issue persist, please <a href="https://cff.dwbooster.com/contact-us">contact us</a></div>', 'calculated-fields-form' );
119
  }
120
- }
121
- else
122
- {
123
  $error_occur = true;
124
  }
125
- }
126
- else
127
- {
128
  $error_occur = true;
129
- }
130
 
131
- if( $error_occur )
132
- {
133
  global $cff_structure_error;
134
- $cff_structure_error = __('<div class="error-text">The data cannot be stored in database because has occurred an error with the form structure. Please, try to save the data again. If have been copied and pasted data from external text editors, the data can contain invalid characters. If the issue persist, please <a href="https://cff.dwbooster.com/contact-us">contact us</a></div>', 'calculated-fields-form' );
135
  }
136
- }
3
  Plugin Name: Calculated Fields Form
4
  Plugin URI: https://cff.dwbooster.com
5
  Description: Create forms with field values calculated based in other form field values.
6
+ Version: 1.1.111
7
  Text Domain: calculated-fields-form
8
  Author: CodePeople
9
  Author URI: https://cff.dwbooster.com
10
  License: GPL
11
  */
12
 
13
+ if ( ! defined( 'WP_DEBUG' ) || true != WP_DEBUG ) {
14
+ error_reporting( E_ERROR | E_PARSE );
 
15
  }
16
 
17
  // Defining main constants
18
+ define( 'CP_CALCULATEDFIELDSF_VERSION', '1.1.111' );
19
+ define( 'CP_CALCULATEDFIELDSF_MAIN_FILE_PATH', __FILE__ );
20
+ define( 'CP_CALCULATEDFIELDSF_BASE_PATH', dirname( CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ) );
21
+ define( 'CP_CALCULATEDFIELDSF_BASE_NAME', plugin_basename( CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ) );
22
 
23
  // Feedback system
24
  require_once 'feedback/cp-feedback.php';
25
+ new CP_FEEDBACK( 'calculated-fields-form', __FILE__, 'https://cff.dwbooster.com/contact-us' );
26
 
27
  require_once 'inc/cpcff_auxiliary.inc.php';
28
  require_once 'config/cpcff_config.cfg.php';
39
  add_action( 'init', 'cp_calculated_fields_form_direct_form_access', 1 );
40
 
41
  // functions
42
+ // ------------------------------------------
43
+ function cp_calculated_fields_form_direct_form_access() {
44
+ if (
45
+ get_option( 'CP_CALCULATEDFIELDSF_DIRECT_FORM_ACCESS', CP_CALCULATEDFIELDSF_DIRECT_FORM_ACCESS ) &&
46
+ ! empty( $_GET['cff-form'] ) &&
47
+ @intval( $_GET['cff-form'] )
48
+ ) {
 
 
49
  $cpcff_main = CPCFF_MAIN::instance();
50
  $cpcff_main->form_preview(
51
  array(
52
+ 'shortcode_atts' => array( 'id' => @intval( $_GET['cff-form'] ) ),
53
+ 'page_title' => 'CFF',
54
+ 'page' => true,
55
  )
56
  );
57
  }
59
 
60
  function cp_calculated_fields_form_check_posted_data() {
61
 
62
+ global $wpdb;
63
 
64
  $cpcff_main = CPCFF_MAIN::instance();
65
 
66
+ if ( isset( $_SERVER['REQUEST_METHOD'] ) && 'POST' == $_SERVER['REQUEST_METHOD'] && isset( $_POST['cp_calculatedfieldsf_post_options'] ) && is_admin() && isset( $_POST['_cpcff_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_cpcff_nonce'] ) ), 'cff-form-settings' ) ) {
67
+
68
+ cp_calculatedfieldsf_save_options();
69
+
70
+ if (
71
+ isset( $_POST['preview'] ) &&
72
+ isset( $_POST['cp_calculatedfieldsf_id'] ) &&
73
+ is_numeric( $_POST['cp_calculatedfieldsf_id'] )
74
+ ) {
75
  $cpcff_main->form_preview(
76
  array(
77
+ 'shortcode_atts' => array( 'id' => intval( $_POST['cp_calculatedfieldsf_id'] ) ),
78
+ 'page_title' => __( 'Form Preview', 'calculated-fields-form' ),
79
+ 'wp_die' => 1,
80
  )
81
  );
82
  }
83
  return;
84
+ }
85
  }
86
 
87
+ function cp_calculatedfieldsf_save_options() {
 
88
  check_admin_referer( 'cff-form-settings', '_cpcff_nonce' );
89
+ global $wpdb;
90
+ if ( ! defined( 'CP_CALCULATEDFIELDSF_ID' ) && isset( $_POST['cp_calculatedfieldsf_id'] ) ) {
91
+ define( 'CP_CALCULATEDFIELDSF_ID', sanitize_text_field( wp_unslash( $_POST['cp_calculatedfieldsf_id'] ) ) );
92
+ }
93
 
94
  $error_occur = false;
95
+ if ( isset( $_POST['form_structure'] ) ) {
96
+
97
+ $_cff_POST = $_POST;
98
+
99
  // Remove bom characters
100
+ $_cff_POST['form_structure'] = CPCFF_AUXILIARY::clean_bom( $_cff_POST['form_structure'] ); // phpcs:ignore WordPress.Security.EscapeOutput
101
 
102
+ $form_structure_obj = CPCFF_AUXILIARY::json_decode( $_cff_POST['form_structure'] );
103
+ if ( ! empty( $form_structure_obj ) ) {
104
+ $form_structure_obj = CPCFF_FORM::sanitize_structure( $form_structure_obj );
 
105
 
106
  global $cpcff_default_texts_array;
107
  $cpcff_text_array = '';
108
 
109
+ $_cff_POST = CPCFF_AUXILIARY::stripcslashes_recursive( $_cff_POST );
110
+ $_POST['form_structure'] = json_encode( $form_structure_obj );
111
+ if ( isset( $_POST['cpcff_text_array'] ) ) {
112
+ $_cff_POST['vs_all_texts'] = $_cff_POST['cpcff_text_array'];
113
+ }
114
 
115
  $cpcff_main = CPCFF_MAIN::instance();
116
+ $_cff_calculatedfieldsf_id = isset( $_cff_POST['cp_calculatedfieldsf_id'] ) && is_numeric( $_cff_POST['cp_calculatedfieldsf_id'] ) ? intval( $_cff_POST['cp_calculatedfieldsf_id'] ) : 0;
117
+ if ( $cpcff_main->get_form( $_cff_calculatedfieldsf_id )->save_settings( $_cff_POST ) === false ) {
118
  global $cff_structure_error;
119
+ $cff_structure_error = __( '<div class="error-text">The data cannot be stored in database because has occurred an error with the database structure. Please, go to the plugins section and Deactivate/Activate the plugin to be sure the structure of database has been checked, and corrected if needed. If the issue persist, please <a href="https://cff.dwbooster.com/contact-us">contact us</a></div>', 'calculated-fields-form' );
120
  }
121
+ } else {
 
 
122
  $error_occur = true;
123
  }
124
+ } else {
 
 
125
  $error_occur = true;
126
+ }
127
 
128
+ if ( $error_occur ) {
 
129
  global $cff_structure_error;
130
+ $cff_structure_error = __( '<div class="error-text">The data cannot be stored in database because has occurred an error with the form structure. Please, try to save the data again. If have been copied and pasted data from external text editors, the data can contain invalid characters. If the issue persist, please <a href="https://cff.dwbooster.com/contact-us">contact us</a></div>', 'calculated-fields-form' );
131
  }
132
+ }
feedback/cp-feedback.php CHANGED
@@ -1,97 +1,86 @@
1
- <?php
2
- if(!class_exists('CP_FEEDBACK'))
3
- {
4
- class CP_FEEDBACK
5
- {
6
- private $feedback_url = 'https://wordpress.dwbooster.com/licensesystem/debug-data.php';
7
- private $plugin_slug;
8
- private $plugin_file;
9
- private $support_link;
10
- private $full_support_link;
11
-
12
- public function __construct($plugin_slug, $plugin_file, $support_link)
13
- {
14
- $this->plugin_slug = $plugin_slug;
15
- $this->plugin_file = $plugin_file;
16
- $this->support_link = $support_link;
17
- $this->full_support_link = $support_link.((strpos($support_link, '?') === false) ? '?' : '&' ).'priority-support=yes';
18
-
19
- // To know when the plugin was installed
20
- if (!get_option('installed_'.$this->plugin_slug, false))
21
- {
22
- update_option('installed_'.$this->plugin_slug, time() );
23
- }
24
- // Actions and filters
25
- add_action( 'admin_enqueue_scripts', array($this, 'enqueue_scripts'), 1);
26
- add_action( 'wp_ajax_cp_feedback', array($this,'feedback_action'));
27
- } // End __construct
28
-
29
- public function enqueue_scripts($hook)
30
- {
31
- if( 'plugins.php' == $hook )
32
- {
33
- wp_enqueue_style('wp-jquery-ui-dialog');
34
- wp_enqueue_script('jquery');
35
- wp_enqueue_script('jquery-ui-dialog');
36
-
37
- add_action( 'admin_footer', array($this, 'feedback_interface') );
38
- }
39
- } // End insert_admin_scripts
40
-
41
- public function feedback_interface()
42
- {
43
- // Varibles to use into the feedback interface
44
- $plugin_slug = $this->plugin_slug;
45
- $support_link = $this->support_link;
46
- $full_support_link = $this->full_support_link;
47
-
48
- include_once dirname($this->plugin_file).'/feedback/feedback.html';
49
- } // End feedback_interface
50
-
51
- // This function is used only if explicitly accepted (opt-in) by the user
52
- public function feedback_action()
53
- {
54
- if(isset($_POST['feedback_plugin']) && $_POST['feedback_plugin'] == $this->plugin_slug)
55
- {
56
- $plugin_data = get_plugin_data( $this->plugin_file );
57
- $plugin_version = $plugin_data['Version'];
58
- $time = time() - get_option('installed_'.$this->plugin_slug, 0);
59
-
60
- $data = array(
61
- 'plugin' => $plugin_data['Name'],
62
- 'pluginv' => $plugin_version,
63
- 'wordpress' => get_bloginfo('version'),
64
- 'itime' => $time,
65
- 'phpversion' => phpversion()
66
- );
67
-
68
- foreach($_POST as $parameter => $value)
69
- {
70
- $data[$parameter] = $value;
71
- }
72
-
73
- if(!isset($_POST["cp_feedback_anonymous"])) // send this data only if explicitly accepted
74
- {
75
- $current_user = wp_get_current_user();
76
- $data['email'] = $current_user->user_email;
77
- $data['website'] = $_SERVER['HTTP_HOST'];
78
- $data['url'] = get_site_url();
79
- }
80
-
81
- // Send data
82
- $response = wp_remote_post(
83
- $this->feedback_url,
84
- array(
85
- 'body' => $data,
86
- 'sslverify' => false
87
- )
88
- );
89
-
90
- wp_die(); // this is required to terminate immediately and return a proper response
91
- }
92
-
93
-
94
- } // End feedback_action
95
-
96
- } // End class
97
- }
1
+ <?php
2
+ if ( ! class_exists( 'CP_FEEDBACK' ) ) {
3
+ class CP_FEEDBACK {
4
+
5
+ private $feedback_url = 'https://wordpress.dwbooster.com/licensesystem/debug-data.php';
6
+ private $plugin_slug;
7
+ private $plugin_file;
8
+ private $support_link;
9
+ private $full_support_link;
10
+
11
+ public function __construct( $plugin_slug, $plugin_file, $support_link ) {
12
+ $this->plugin_slug = $plugin_slug;
13
+ $this->plugin_file = $plugin_file;
14
+ $this->support_link = $support_link;
15
+ $this->full_support_link = $support_link . ( ( strpos( $support_link, '?' ) === false ) ? '?' : '&' ) . 'priority-support=yes';
16
+
17
+ // To know when the plugin was installed
18
+ if ( ! get_option( 'installed_' . $this->plugin_slug, false ) ) {
19
+ update_option( 'installed_' . $this->plugin_slug, time() );
20
+ }
21
+ // Actions and filters
22
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 );
23
+ add_action( 'wp_ajax_cp_feedback', array( $this, 'feedback_action' ) );
24
+ } // End __construct
25
+
26
+ public function enqueue_scripts( $hook ) {
27
+ if ( 'plugins.php' == $hook ) {
28
+ wp_enqueue_style( 'wp-jquery-ui-dialog' );
29
+ wp_enqueue_script( 'jquery' );
30
+ wp_enqueue_script( 'jquery-ui-dialog' );
31
+
32
+ add_action( 'admin_footer', array( $this, 'feedback_interface' ) );
33
+ }
34
+ } // End insert_admin_scripts
35
+
36
+ public function feedback_interface() {
37
+ // Varibles to use into the feedback interface
38
+ $plugin_slug = $this->plugin_slug;
39
+ $support_link = $this->support_link;
40
+ $full_support_link = $this->full_support_link;
41
+
42
+ include_once dirname( $this->plugin_file ) . '/feedback/feedback.html';
43
+ } // End feedback_interface
44
+
45
+ // This function is used only if explicitly accepted (opt-in) by the user
46
+ public function feedback_action() {
47
+ if ( isset( $_POST['feedback_plugin'] ) && $_POST['feedback_plugin'] == $this->plugin_slug ) { // phpcs:ignore WordPress.Security.NonceVerification
48
+ $plugin_data = get_plugin_data( $this->plugin_file );
49
+ $plugin_version = $plugin_data['Version'];
50
+ $time = time() - get_option( 'installed_' . $this->plugin_slug, 0 );
51
+
52
+ $data = array(
53
+ 'plugin' => $plugin_data['Name'],
54
+ 'pluginv' => $plugin_version,
55
+ 'wordpress' => get_bloginfo( 'version' ),
56
+ 'itime' => $time,
57
+ 'phpversion' => phpversion(),
58
+ );
59
+
60
+ foreach ( $_POST as $parameter => $value ) { // phpcs:ignore WordPress.Security.NonceVerification
61
+ $data[ $parameter ] = sanitize_text_field( wp_unslash( $value ) );
62
+ }
63
+
64
+ if ( ! isset( $_POST['cp_feedback_anonymous'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
65
+ $current_user = wp_get_current_user();
66
+ $data['email'] = $current_user->user_email;
67
+ $data['website'] = isset( $_SERVER['HTTP_HOST'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) ) : '';
68
+ $data['url'] = get_site_url();
69
+ }
70
+
71
+ // Send data
72
+ $response = wp_remote_post(
73
+ $this->feedback_url,
74
+ array(
75
+ 'body' => $data,
76
+ 'sslverify' => false,
77
+ )
78
+ );
79
+
80
+ wp_die(); // this is required to terminate immediately and return a proper response
81
+ }
82
+
83
+ } // End feedback_action
84
+
85
+ } // End class
86
+ }
 
 
 
 
 
 
 
 
 
 
 
inc/cpcff_admin_int.inc.php CHANGED
@@ -1,725 +1,747 @@
1
- <?php
2
-
3
- if ( !is_admin() )
4
- {
5
- print 'Direct access not allowed.';
6
- exit;
7
- }
8
-
9
- // Required scripts
10
- require_once CP_CALCULATEDFIELDSF_BASE_PATH.'/inc/cpcff_templates.inc.php';
11
-
12
- check_admin_referer( 'cff-form-settings', '_cpcff_nonce' );
13
-
14
- // Load resources
15
- wp_enqueue_media();
16
- if(function_exists('wp_enqueue_code_editor')) wp_enqueue_code_editor( array( 'type' => 'text/html' ) );
17
- wp_enqueue_style('cff-chosen-css', plugins_url('/vendors/chosen/chosen.min.css', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH));
18
- wp_enqueue_script('cff-chosen-js', plugins_url('/vendors/chosen/chosen.jquery.min.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH),array("jquery"));
19
-
20
- if (!defined('CP_CALCULATEDFIELDSF_ID'))
21
- define ('CP_CALCULATEDFIELDSF_ID',intval($_GET["cal"]));
22
-
23
- $cpcff_main = CPCFF_MAIN::instance();
24
- $form_obj = $cpcff_main->get_form(intval($_GET["cal"]));
25
-
26
- if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset( $_POST['cpcff_revision_to_apply'] ) )
27
- {
28
- $revision_id = @intval($_POST['cpcff_revision_to_apply']);
29
- if($revision_id)
30
- {
31
- $form_obj->apply_revision($revision_id);
32
- }
33
- }
34
-
35
- if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset( $_POST['cp_calculatedfieldsf_post_options'] ) )
36
- echo "<div id='setting-error-settings_updated' class='updated settings-error'> <p><strong>".__( 'Settings saved', 'calculated-fields-form' )."</strong></p></div>";
37
-
38
- global $cpcff_default_texts_array;
39
- $cpcff_texts_array = $form_obj->get_option( 'vs_all_texts', $cpcff_default_texts_array );
40
- $cpcff_texts_array = CPCFF_AUXILIARY::array_replace_recursive(
41
- $cpcff_default_texts_array,
42
- ( is_string( $cpcff_texts_array ) && is_array( unserialize( $cpcff_texts_array ) ) )
43
- ? unserialize( $cpcff_texts_array )
44
- : ( ( is_array( $cpcff_texts_array ) ) ? $cpcff_texts_array : array() )
45
- );
46
-
47
- ?>
48
- <div class="wrap">
49
- <h1 class="cff-form-name"><?php
50
- print __( 'Calculated Fields Form', 'calculated-fields-form' ).' <span class="cff-form-name-shortcode">(<b>'.__('Form', 'calculated-fields-form').' '.CP_CALCULATEDFIELDSF_ID.' - '.$form_obj->get_option( 'form_name', '').'</b>) Shortcode: [CP_CALCULATED_FIELDS id="'.CP_CALCULATEDFIELDSF_ID.'"]</span>';
51
-
52
- if(get_option('CP_CALCULATEDFIELDSF_DIRECT_FORM_ACCESS', CP_CALCULATEDFIELDSF_DIRECT_FORM_ACCESS))
53
- {
54
- $url = CPCFF_AUXILIARY::site_url();
55
- $url .= (strpos($url, '?') === false) ? '?' : '&';
56
- $url .= 'cff-form='.CP_CALCULATEDFIELDSF_ID;
57
- print '<br><span style="font-size:14px;font-style:italic;">'.__('Direct form URL', 'calculated-fields-form').': <a href="'.esc_attr($url).'" target="_blank">'.$url.'</a></span>';
58
- }
59
- ?></h1>
60
- <input type="button" name="backbtn" value="<?php esc_attr_e( 'Back to items list...', 'calculated-fields-form' ); ?>" onclick="document.location='admin.php?page=cp_calculated_fields_form';" class="button-secondary" />
61
- <br /><br />
62
- <?php $_cpcff_nonce = wp_create_nonce( 'cff-form-settings' );?>
63
- <form method="post" action="" id="cpformconf" name="cpformconf" class="cff_form_builder">
64
- <input type="hidden" name="_cpcff_nonce" value="<?php echo $_cpcff_nonce; ?>" />
65
- <input name="cp_calculatedfieldsf_post_options" type="hidden" value="1" />
66
- <input name="cp_calculatedfieldsf_id" type="hidden" value="<?php echo CP_CALCULATEDFIELDSF_ID; ?>" />
67
-
68
- <div id="normal-sortables" class="meta-box-sortables">
69
-
70
- <h2><?php _e( 'Form Settings', 'calculated-fields-form' ); ?>:</h2>
71
- <!-- Form category -->
72
- <div class="postbox" >
73
- <div class="inside">
74
- <b><?php _e('Form Category', 'calculated-fields-form'); ?></b>
75
- <input type="text" name="calculated-fields-form-category" class="width75" value="<?php print esc_attr($form_obj->get_option('category', '')); ?>" list="calculated-fields-form-categories" />
76
- <datalist id="calculated-fields-form-categories">
77
- <?php
78
- print $cpcff_main->get_categories('DATALIST');
79
- ?>
80
- </datalist>
81
- </div>
82
- </div>
83
- <hr />
84
- <div><?php _e( '* Different form styles available on the tab Form Settings &gt;&gt; Form Template', 'calculated-fields-form' ); ?></div>
85
- <div id="metabox_form_structure" class="postbox" >
86
- <div class="hndle">
87
- <h3 style="padding:5px;display:inline-block;"><span><?php _e( 'Form Builder', 'calculated-fields-form' ); ?></span></h3>
88
- <div class="cff-revisions-container">
89
- <?php
90
- if(get_option('CP_CALCULATEDFIELDSF_DISABLE_REVISIONS', CP_CALCULATEDFIELDSF_DISABLE_REVISIONS) == 0):
91
- _e('Revisions','calculated-fields-form');
92
- ?>
93
- <select name="cff_revision_list">
94
-
95
- <?php
96
- print '<option value="0">'.esc_html(__('Select a revision', 'calculated-fields-form')).'</option>';
97
- $revisions_obj = $form_obj->get_revisions();
98
- $revisions = $revisions_obj->revisions_list();
99
- foreach($revisions as $revision_id => $revision_data)
100
- {
101
- print '<option value="'.esc_attr($revision_id).'">'.esc_html($revision_data['time']).'</option>';
102
- }
103
- ?>
104
- </select>
105
- <input type="button" name="cff_apply_revision" value="<?php print esc_attr('Load Revision', 'calculated-fields-form'); ?>" class="button" style="float:none;" />
106
- <?php
107
- endif;
108
- ?>
109
- <input type="button" name="previewbtn" id="previewbtn2" class="button-primary" value="<?php esc_attr_e( 'Preview', 'calculated-fields-form' ); ?>" onclick="fbuilderjQuery.fbuilder.preview( this );" title="<?php esc_attr_e("Saves the form's structure only, and opens a preview windows", 'calculated-fields-form');?>" />
110
- <input type="button" name="cff_fields_list" class="button-secondary" value="&#9776;" title="<?php esc_attr_e( 'Fields List', 'calculated-fields-form'); ?>" onclick="fbuilderjQuery.fbuilder.printFields();" />
111
  </div>
112
- </div>
113
- <div class="inside">
114
- <div class="form-builder-error-messages"><?php
115
- global $cff_structure_error;
116
- if( !empty( $cff_structure_error ) )
117
- {
118
- echo $cff_structure_error;
119
- }
120
- ?></div>
121
- <p style="border:1px solid #F0AD4E;background:#FBE6CA;padding:10px;"><span style="font-weight:bold;"><?php _e('If the form is not loading in the public website, go to the settings page of the plugin through the menu option: "Settings/Calculated Fields Form", select the "Classic" option for the attribute: "Script load method", and press the "Update" button.','calculated-fields-form'); ?></span><br /><?php _e( 'If you need also the form to be sent to the server side for processing (for example to deliver emails) then the <a href="https://cff.dwbooster.com/download" target="_blank">Commercial versions</a> of the plugin are required.', 'calculated-fields-form' ); ?></p>
122
- <input type="hidden" name="form_structure" id="form_structure" value="<?php print esc_attr(preg_replace('/&quot;/i', '&amp;quot;', json_encode($form_obj->get_option( 'form_structure', CP_CALCULATEDFIELDSF_DEFAULT_form_structure )))); ?>" />
123
- <input type="hidden" name="templates" id="templates" value="<?php print esc_attr( json_encode( CPCFF_TEMPLATES::load_templates() ) ); ?>" />
124
- <link href="<?php print esc_attr(plugins_url('/vendors/jquery-ui/jquery-ui.min.css', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH)); ?>" type="text/css" rel="stylesheet" property="stylesheet" />
125
- <pre style="display:none;">
126
- <script type="text/javascript">
127
- var cff_metabox_nonce = '<?php print esc_js( wp_create_nonce( 'cff-metabox-status' ) ); ?>';
128
- try
129
- {
130
- function calculatedFieldsFormReady()
131
- {
132
- /* Revisions code */
133
- $calculatedfieldsfQuery('[name="cff_apply_revision"]').click(
134
- function(){
135
- var revision = $calculatedfieldsfQuery('[name="cff_revision_list"]').val();
136
- if(revision*1)
137
- {
138
- result = window.confirm('<?php print esc_js(__('The action will load the revision selected, the data are not stored will be lose. Do you want continue?', 'calculated-fields-form'));?>');
139
- if(result)
140
- {
141
- $calculatedfieldsfQuery('<form method="post" action="" id="cpformconf" name="cpformconf" class="cff_form_builder"><input type="hidden" name="_cpcff_nonce" value="<?php echo $_cpcff_nonce; ?>" /><input name="cp_calculatedfieldsf_id" type="hidden" value="<?php echo CP_CALCULATEDFIELDSF_ID; ?>" /><input type="hidden" name="cpcff_revision_to_apply" value="'+revision+'"></form>').appendTo('body').submit();
142
- }
143
- }
144
- }
145
- );
146
-
147
- // Form builder code
148
-
149
- var f;
150
- function run_fbuilder($)
151
- {
152
- f = $("#fbuilder").fbuilder();
153
- window['cff_form'] = f;
154
- f.fBuild.loadData( "form_structure", "templates" );
155
- };
156
-
157
- if(!('fbuilder' in $calculatedfieldsfQuery.fn))
158
- {
159
- $calculatedfieldsfQuery.getScript(
160
- location.protocol + '//' + location.host + location.pathname+'?page=cp_calculated_fields_form&cp_cff_resources=admin',
161
- function(){run_fbuilder(fbuilderjQuery);}
162
- );
163
- }
164
- else
165
- {
166
- run_fbuilder($calculatedfieldsfQuery);
167
- }
168
-
169
- $calculatedfieldsfQuery(".itemForm").click(function() {
170
- f.fBuild.addItem($calculatedfieldsfQuery(this).attr("id"));
171
- })
172
- .draggable({
173
- connectToSortable: '#fbuilder #fieldlist',
174
- delay: 100,
175
- helper: function() {
176
- var $ = $calculatedfieldsfQuery,
177
- e = $(this),
178
- width = e.outerWidth(),
179
- text = e.text(),
180
- type = e.attr('id'),
181
- el = $('<div class="cff-button-drag '+type+'">');
182
-
183
- return el.html( text ).css( 'width', width ).attr('data-control',type);
184
- },
185
- revert: 'invalid',
186
- cancel: false,
187
- scroll: false,
188
- opacity: 1,
189
- containment: 'document',
190
- stop: function(){$calculatedfieldsfQuery('.ctrlsColumn .itemForm').removeClass('button-primary');}
191
- });
192
-
193
- jQuery(".metabox_disabled_section .inside")
194
- .click( function(){
195
- if(confirm("<?php _e( 'These features aren\'t available in this version. Do you want to open the plugin\'s page to check other versions?', 'calculated-fields-form' ); ?>"))
196
- document.location = 'https://cff.dwbooster.com/';
197
- })
198
- .find('*')
199
- .prop('disabled', true);
200
- };
201
- }
202
- catch( err ){}
203
- try{$calculatedfieldsfQuery = jQuery.noConflict();} catch ( err ) {}
204
- if (typeof $calculatedfieldsfQuery == 'undefined')
205
- {
206
- if(window.addEventListener){
207
- window.addEventListener('load', function(){
208
- try{$calculatedfieldsfQuery = jQuery.noConflict();} catch ( err ) {return;}
209
- calculatedFieldsFormReady();
210
- });
211
- }else{
212
- window.attachEvent('onload', function(){
213
- try{$calculatedfieldsfQuery = jQuery.noConflict();} catch ( err ) {return;}
214
- calculatedFieldsFormReady();
215
- });
216
- }
217
- }
218
- else
219
- {
220
- $calculatedfieldsfQuery(document).ready( calculatedFieldsFormReady );
221
- }
222
- </script>
223
- </pre>
224
- <div style="background:#fafafa;" class="form-builder">
225
-
226
- <div class="column ctrlsColumn">
227
- <div id="tabs">
228
- <span class="ui-icon ui-icon-triangle-1-e expand-shrink"></span>
229
- <ul>
230
- <li><a href="#tabs-1"><?php _e( 'Add a Field', 'calculated-fields-form' ); ?></a></li>
231
- <li><a href="#tabs-2"><?php _e( 'Field Settings', 'calculated-fields-form' ); ?></a></li>
232
- <li><a href="#tabs-3"><?php _e( 'Form Settings', 'calculated-fields-form' ); ?></a></li>
233
- </ul>
234
- <div id="tabs-1"></div>
235
- <div id="tabs-2"></div>
236
- <div id="tabs-3"></div>
237
- </div>
238
- </div>
239
- <div class="columnr dashboardColumn padding10" id="fbuilder">
240
- <div id="formheader"></div>
241
- <div id="fieldlist"></div>
242
- </div>
243
- <div class="clearer"></div>
244
-
245
- </div>
246
-
247
- </div>
248
- </div>
249
-
250
- <p class="submit">
251
- <input type="submit" name="save" id="save2" class="button-primary" value="<?php esc_attr_e( 'Save Changes', 'calculated-fields-form' ); ?>" title="Saves the form's structure and settings and creates a revision" />
252
- <input type="button" name="previewbtn" id="previewbtn" class="button-primary" value="<?php esc_attr_e( 'Preview', 'calculated-fields-form' ); ?>" onclick="fbuilderjQuery.fbuilder.preview( this );" title="Saves the form's structure only, and opens a preview windows" />
253
- <?php
254
- if(get_option('CP_CALCULATEDFIELDSF_DISABLE_REVISIONS', CP_CALCULATEDFIELDSF_DISABLE_REVISIONS) == 0):
255
- ?>
256
- | <input type="checkbox" name="cff-revisions-in-preview" <?php if(get_option('CP_CALCULATEDFIELDSF_REVISIONS_IN_PREVIEW', true)) print 'CHECKED'; ?> />
257
- <?php
258
- _e('Generate revisions in the form preview as well', 'calculated-fields-form');
259
- endif;
260
- ?>
261
- </p>
262
- <div style="margin-bottom:20px;">
263
- <a href="#metabox_define_texts"><?php _e('Texts definition', 'calculated-fields-form'); ?></a>&nbsp;|&nbsp;
264
- <a href="#metabox_define_validation_texts"><?php _e('Error texts', 'calculated-fields-form'); ?></a>&nbsp;|&nbsp;
265
- <a href="#metabox_payment_settings"><?php _e('General payment settings', 'calculated-fields-form'); ?></a>&nbsp;|&nbsp;
266
- <a href="#metabox_paypal_integration"><?php _e('PayPal integration', 'calculated-fields-form'); ?></a>&nbsp;|&nbsp;
267
- <a href="#metabox_notification_email"><?php _e('Notification email', 'calculated-fields-form'); ?></a>&nbsp;|&nbsp;
268
- <a href="#metabox_email_copy_to_user"><?php _e('Email copy to user', 'calculated-fields-form'); ?></a>&nbsp;|&nbsp;
269
- <a href="#metabox_captcha_settings"><?php _e('Captcha settings', 'calculated-fields-form'); ?></a>
270
- </div>
271
- <div id="metabox_define_texts" class="postbox cff-metabox <?php print esc_attr($cpcff_main->metabox_status( 'metabox_define_texts' ) ); ?>" >
272
- <h3 class='hndle' style="padding:5px;"><span><?php _e( 'Define Texts', 'calculated-fields-form' ); ?></span></h3>
273
- <div class="inside">
274
- <table class="form-table">
275
- <tr valign="top">
276
- <th scope="row"><?php _e( 'Previous button label (text)', 'calculated-fields-form' ); ?>:</th>
277
- <td><input type="text" name="vs_text_previousbtn" class="width75" value="<?php $label = esc_attr($form_obj->get_option('vs_text_previousbtn', 'Previous')); echo ($label==''?'Previous':$label); ?>" /></td>
278
- </tr>
279
- <tr valign="top">
280
- <th scope="row"><?php _e( 'Next button label (text)', 'calculated-fields-form' ); ?>:</th>
281
- <td><input type="text" name="vs_text_nextbtn" class="width75" value="<?php $label = esc_attr($form_obj->get_option('vs_text_nextbtn', 'Next')); echo ($label==''?'Next':$label); ?>" /></td>
282
- </tr>
283
- <tr valign="top">
284
- <td colspan="2">
285
- <?php _e( '- The styles can be applied into any of the CSS files of your theme or into the CSS file <em>"calculated-fields-form\css\stylepublic.css"</em>.', 'calculated-fields-form' ); ?><br />
286
- <?php _e( '- For general CSS styles modifications to the form and samples <a href="https://cff.dwbooster.com/faq#q82" target="_blank">check this FAQ</a>.', 'calculated-fields-form' ); ?>
287
- </tr>
288
- <?php
289
- // Display all other text fields
290
- foreach( $cpcff_texts_array as $cpcff_text_index => $cpcff_text_attr )
291
- {
292
- if( $cpcff_text_index !== 'errors' && isset($cpcff_text_attr[ 'label' ]) )
293
- {
294
- print '
295
- <tr valign="top">
296
- <th scope="row">'.$cpcff_text_attr[ 'label' ].':</th>
297
- <td><input type="text" name="cpcff_text_array['.$cpcff_text_index.'][text]" class="width75" value="'. esc_attr( $cpcff_text_attr[ 'text' ] ).'" /></td>
298
- </tr>
299
- ';
300
- }
301
- }
302
- ?>
303
- </table>
304
- <div class="cff-goto-top"><a href="#cpformconf"><?php _e('Up to form structure', 'calculated-fields-form'); ?></a></div>
305
- </div>
306
- </div>
307
-
308
- <div id="metabox_define_validation_texts" class="postbox cff-metabox <?php print esc_attr($cpcff_main->metabox_status( 'metabox_define_validation_texts' ) ); ?>" >
309
- <h3 class='hndle' style="padding:5px;"><span><?php _e( 'Validation Settings', 'calculated-fields-form' ); ?></span></h3>
310
- <div class="inside">
311
- <table class="form-table">
312
- <tr valign="top">
313
- <th scope="row"><?php _e( '"is required" text', 'calculated-fields-form' ); ?>:</th>
314
- <td><input type="text" name="vs_text_is_required" class="width75" value="<?php echo esc_attr($form_obj->get_option('vs_text_is_required', CP_CALCULATEDFIELDSF_DEFAULT_vs_text_is_required)); ?>" /></td>
315
- </tr>
316
- <tr valign="top">
317
- <th scope="row"><?php _e( '"is email" text', 'calculated-fields-form' ); ?>:</th>
318
- <td><input type="text" name="vs_text_is_email" class="width75" value="<?php echo esc_attr($form_obj->get_option('vs_text_is_email', CP_CALCULATEDFIELDSF_DEFAULT_vs_text_is_email)); ?>" /></td>
319
- </tr>
320
- <tr valign="top">
321
- <th scope="row"><?php _e( '"is valid captcha" text', 'calculated-fields-form' ); ?>:</th>
322
- <td><input type="text" name="cv_text_enter_valid_captcha" class="width75" value="<?php echo esc_attr($form_obj->get_option('cv_text_enter_valid_captcha', CP_CALCULATEDFIELDSF_DEFAULT_cv_text_enter_valid_captcha)); ?>" /></td>
323
- </tr>
324
-
325
- <tr valign="top">
326
- <th scope="row"><?php _e( '"is valid date (mm/dd/yyyy)" text', 'calculated-fields-form' ); ?>:</th>
327
- <td><input type="text" name="vs_text_datemmddyyyy" class="width75" value="<?php echo esc_attr($form_obj->get_option('vs_text_datemmddyyyy', CP_CALCULATEDFIELDSF_DEFAULT_vs_text_datemmddyyyy)); ?>" /></td>
328
- </tr>
329
- <tr valign="top">
330
- <th scope="row"><?php _e( '"is valid date (dd/mm/yyyy)" text', 'calculated-fields-form' ); ?>:</th>
331
- <td><input type="text" name="vs_text_dateddmmyyyy" class="width75" value="<?php echo esc_attr($form_obj->get_option('vs_text_dateddmmyyyy', CP_CALCULATEDFIELDSF_DEFAULT_vs_text_dateddmmyyyy)); ?>" /></td>
332
- </tr>
333
- <tr valign="top">
334
- <th scope="row"><?php _e( '"is number" text', 'calculated-fields-form' ); ?>:</th>
335
- <td><input type="text" name="vs_text_number" class="width75" value="<?php echo esc_attr($form_obj->get_option('vs_text_number', CP_CALCULATEDFIELDSF_DEFAULT_vs_text_number)); ?>" /></td>
336
- </tr>
337
- <tr valign="top">
338
- <th scope="row"><?php _e( '"only digits" text', 'calculated-fields-form' ); ?>:</th>
339
- <td><input type="text" name="vs_text_digits" class="width75" value="<?php echo esc_attr($form_obj->get_option('vs_text_digits', CP_CALCULATEDFIELDSF_DEFAULT_vs_text_digits)); ?>" /></td>
340
- </tr>
341
- <tr valign="top">
342
- <th scope="row"><?php _e( '"under maximum" text', 'calculated-fields-form' ); ?>:</th>
343
- <td><input type="text" name="vs_text_max" class="width75" value="<?php echo esc_attr($form_obj->get_option('vs_text_max', CP_CALCULATEDFIELDSF_DEFAULT_vs_text_max)); ?>" /></td>
344
- </tr>
345
- <tr valign="top">
346
- <th scope="row"><?php _e( '"over minimum" text', 'calculated-fields-form' ); ?>:</th>
347
- <td><input type="text" name="vs_text_min" class="width75" value="<?php echo esc_attr($form_obj->get_option('vs_text_min', CP_CALCULATEDFIELDSF_DEFAULT_vs_text_min)); ?>" /></td>
348
- </tr>
349
- <?php
350
- // Display all other text fields
351
- if( !empty( $cpcff_texts_array[ 'errors' ] ) )
352
  {
353
- foreach( $cpcff_texts_array[ 'errors' ] as $cpcff_text_index => $cpcff_text_attr )
354
- {
355
- if(isset($cpcff_text_attr[ 'label' ]))
356
- {
357
- print '
358
- <tr valign="top">
359
- <th scope="row">'.$cpcff_text_attr[ 'label' ].':</th>
360
- <td><input type="text" name="cpcff_text_array[errors]['.$cpcff_text_index.'][text]" class="width75" value="'. esc_attr( $cpcff_text_attr[ 'text' ] ).'" /></td>
361
- </tr>
362
- ';
363
- }
364
- }
365
  }
366
- ?>
367
- </table>
368
- <div class="cff-goto-top"><a href="#cpformconf"><?php _e('Up to form structure', 'calculated-fields-form'); ?></a></div>
369
- </div>
370
- </div>
371
-
372
- <div id="metabox_basic_settings" class="postbox" >
373
- <h3 class='hndle' style="padding:5px;"><span><?php _e( 'Note', 'calculated-fields-form' ); ?></span></h3>
374
- <div class="inside">
375
- <?php _e( 'To display the form in a post/page, enter your shortcode in the post/page content:', 'calculated-fields-form' ); ?>
376
- <?php print '<b>[CP_CALCULATED_FIELDS id="'.CP_CALCULATEDFIELDSF_ID.'"]</b>'; ?><br />
377
- <?php _e( 'The CFF plugin implements widgets and blocks to allow inserting the form visually with the most popular page builders such as Gutenberg Editor, Classic Editor, Elementor, Site Origin, Visual Composer, Beaver Builder, Divi, and for the other page builders insert the shortcode directly.', 'calculated-fields-form' ); ?>
378
- <br /><br />
379
- </div>
380
- </div>
381
-
382
- <p class="submit">
383
- <input type="submit" name="save" id="save1" class="button-primary" value="<?php esc_attr_e( 'Save Changes', 'calculated-fields-form' ); ?>" title="Saves the form's structure and settings and creates a revision" />
384
- </p>
385
-
386
- [<a href="https://cff.dwbooster.com/customization" target="_blank"><?php _e( 'Request Custom Modifications', 'calculated-fields-form' ); ?></a>] | [<a href="https://wordpress.org/support/plugin/calculated-fields-form#new-post" target="_blank"><?php _e( 'Help', 'calculated-fields-form' ); ?></a>]
387
-
388
- <br /><br /><br />
389
- <style>@media screen and (min-width:710px){.cff-plugin-promote{width: calc( 100% - 180px );}} @media screen and (max-width:710px){.cff-plugin-logo-promote{display:none;}}</style>
390
- <div id="cff-upgrade-frame" style="border:1px solid #F0AD4E;background:#FBE6CA;padding:10px;color:#3c434a;">
391
- <a href="https://cff.dwbooster.com/download" target="_blank" style="text-decoration:none;float:left;" class="cff-plugin-logo-promote"><img src="https://ps.w.org/calculated-fields-form/assets/icon-256x256.jpg" style="width:160px;border:2px solid white;margin-right:10px;margin-bottom:10px;"></a>
392
- <div style="float:left;" class="cff-plugin-promote">
393
- <div style="font-weight:500;font-size:20px;line-height:28px;"><?php _e( 'The following features are available in the commercial version of the <a href="https://cff.dwbooster.com/download" target="_blank" style="text-decoration:none;">"Calculated Fields Form"</a>', 'calculated-fields-form' ); ?></div>
394
- <div style="text-transform: uppercase; font-weight:700; font-size:24px;margin-top:15px;margin-bottom:15px;line-height:28px;"><a href="https://cff.dwbooster.com/download" target="_blank" style="text-decoration:none;color:#3c434a;text-shadow:1px 1px 2px white;"><?php _e( 'Pay only ONCE, use it FOREVER', 'calculated-fields-form' ); ?></a></div>
395
- <div style="font-size:18px; font-weight:400;line-height:28px;">No additional charges, <span style="background:white;display:inline-block;padding:0 5px;"><a href="https://cff.dwbooster.com/terms" target="_blank" style="text-decoration:none;">lifetime updates</a></span>, one copy for all your websites.</div>
396
- <div style="font-size:16px; font-weight:400; font-style: italic;">And you get notification emails, payment gateways integration, data and forms exportation, advanced operations and more...</div>
397
- <?php
398
- print get_option('cff-t-t', '<div style="text-align:right; font-size:16px; font-weight:600;margin-top:15px;">To test some of the commercial features of the "Calculated Fields Form" plugin, you can <a class="button-primary" href="admin.php?page=cp_calculated_fields_form&cal='.CP_CALCULATEDFIELDSF_ID.'&_cpcff_nonce='.$_cpcff_nonce.'&cff-install-trial=1#cff-upgrade-frame">install the trial version</a></div>');
399
- ?>
400
- </div>
401
- <div style="clear:both;"></div>
402
- </div>
403
- <h2><?php _e( 'Form Processing and Payment Settings', 'calculated-fields-form' ); ?>:</h2>
404
- <hr />
405
-
406
- <div id="metabox_payment_settings" class="postbox metabox_disabled_section cff-metabox <?php print esc_attr($cpcff_main->metabox_status( 'metabox_payment_settings' ) ); ?>" style="position:relative;">
407
- <h3 class='hndle' style="padding:5px;"><span><?php _e( 'Payment Settings', 'calculated-fields-form' ); ?></span></h3>
408
- <div class="inside">
409
-
410
- <table class="form-table">
411
- <tr valign="top">
412
- <th scope="row"><?php _e( 'Request cost', 'calculated-fields-form' ); ?></th>
413
- <td><select name="request_cost" id="request_cost" class="width75"></select></td>
414
- </tr>
415
-
416
- <tr valign="top">
417
- <th scope="row"><?php _e( 'Currency', 'calculated-fields-form' ); ?></th>
418
- <td><input type="text" name="currency" value="<?php echo esc_attr($form_obj->get_option('currency',CP_CALCULATEDFIELDSF_DEFAULT_CURRENCY)); ?>" /><br>
419
- <b>USD</b> (<?php esc_html_e('United States dollar', 'calculated-fields-form'); ?>), <b>EUR</b> (Euro), <b>GBP</b> (<?php esc_html_e('Pound sterling', 'calculated-fields-form'); ?>), ... (<a href="https://developer.paypal.com/docs/api/reference/currency-codes/" target="_blank"><?php esc_html_e('PayPal Currency Codes', 'calculated-fields-form');?></a>)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
420
  </td>
421
- </tr>
422
-
423
- <tr valign="top">
424
- <th scope="row"><?php _e( 'Base amount', 'calculated-fields-form' ); ?>:</th>
425
- <td><input type="text" name="paypal_base_amount" value="<?php echo esc_attr($form_obj->get_option( 'paypal_base_amount', '0.01' ) ); ?>" /><br><i style="font-size:11px;"><?php _e( 'Minimum amount to charge. If the final price is lesser than this number, the base amount will be applied.', 'calculated-fields-form' ); ?></i>
426
- </td>
427
- </tr>
428
-
429
- <tr valign="top">
430
- <th scope="row"><?php _e( 'Paypal product name', 'calculated-fields-form' ); ?></th>
431
- <td><input type="text" name="paypal_product_name" class="width75" value="<?php echo esc_attr($form_obj->get_option('paypal_product_name',CP_CALCULATEDFIELDSF_DEFAULT_PRODUCT_NAME)); ?>" /></td>
432
- </tr>
433
-
434
- <tr valign="top">
435
- <th scope="row"><?php _e( 'Discount Codes', 'calculated-fields-form' ); ?></th>
436
- <td>
437
- <div id="dex_nocodes_availmsg"><?php _e( 'This feature isn\'t available in this version.', 'calculated-fields-form' ); ?></div>
438
-
439
- <br />
440
- <strong><?php _e( 'Add new discount code', 'calculated-fields-form' ); ?>:</strong>
441
- <br />
442
- <nobr><?php _e( 'Code', 'calculated-fields-form' ); ?>: <input type="text" name="dex_dc_code" id="dex_dc_code" value="" /></nobr> &nbsp; &nbsp; &nbsp;
443
- <nobr><?php _e( 'Discount', 'calculated-fields-form' ); ?>: <input type="text" size="3" name="dex_dc_discount" id="dex_dc_discount" value="25" /><select name="dex_dc_discounttype" id="dex_dc_discounttype">
444
- <option value="0"><?php _e( 'Percent', 'calculated-fields-form' ); ?></option>
445
- <option value="1"><?php _e( 'Fixed Value', 'calculated-fields-form' ); ?></option>
446
- </select></nobr>
447
- &nbsp; &nbsp;
448
- <nobr><?php _e( 'Valid until', 'calculated-fields-form' ); ?>: <input type="text" size="10" name="dex_dc_expires" id="dex_dc_expires" value="" /></nobr>&nbsp; &nbsp; &nbsp;
449
- <input type="button" name="dex_dc_subccode" id="dex_dc_subccode" value="<?php esc_attr_e( 'Add', 'calculated-fields-form' ); ?>" onclick="alert('This feature ins\'t available in this version');" class="button-secondary" />
450
- <br />
451
- <em style="font-size:11px;"><?php _e( 'Note: Expiration date based in server time. Server time now is', 'calculated-fields-form' ); ?> <?php echo date("Y-m-d H:i"); ?></em>
452
- </td>
453
- </tr>
454
- </table>
455
- <div class="cff-goto-top"><a href="#cpformconf"><?php _e('Up to form structure', 'calculated-fields-form'); ?></a></div>
456
- </div>
457
- </div>
458
-
459
- <div id="metabox_paypal_integration" class="postbox metabox_disabled_section cff-metabox <?php print esc_attr($cpcff_main->metabox_status( 'metabox_paypal_integration' ) ); ?>">
460
- <h3 class='hndle' style="padding:5px;"><span><?php _e( 'Paypal Payment Configuration', 'calculated-fields-form' ); ?></span></h3>
461
- <div class="inside">
462
-
463
- <table class="form-table">
464
- <tr valign="top">
465
- <th scope="row"><?php _e( 'Enable Paypal Payments?', 'calculated-fields-form' ); ?></th>
466
- <td><select name="enable_paypal">
467
- <option value="0"><?php _e( 'No', 'calculated-fields-form' ); ?></option>
468
- </select>
469
- <br /><i style="font-size:11px;"><?php _e( 'Note: If "Optional" is selected, a radiobutton will appear in the form to select if the payment will be made with PayPal or not.', 'calculated-fields-form' ); ?></i>
470
- <div id="cff_paypal_options_label" style="margin-top:10px;background:#EEF5FB;border: 1px dotted #888888;padding:10px;width:260px;">
471
- <?php _e( 'Label for the "<strong>Pay with PayPal</strong>" option', 'calculated-fields-form' ); ?>:<br />
472
- <input type="text" size="40" style="width:250px;" />
473
- </div></td>
474
- </tr>
475
-
476
- <tr valign="top">
477
- <th scope="row"><?php _e( 'Paypal Mode', 'calculated-fields-form' ); ?></th>
478
- <td><select name="paypal_mode" class="width75">
479
- <option value="production" <?php if ($form_obj->get_option('paypal_mode',CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_MODE) != 'sandbox') echo 'selected'; ?>><?php _e( 'Production - real payments processed', 'calculated-fields-form' ); ?></option>
480
- <option value="sandbox" <?php if ($form_obj->get_option('paypal_mode',CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_MODE) == 'sandbox') echo 'selected'; ?>><?php _e( 'SandBox - PayPal testing sandbox area', 'calculated-fields-form' ); ?></option>
481
- </select>
482
- </td>
483
- </tr>
484
-
485
- <tr valign="top">
486
- <th scope="row"><?php _e( 'Paypal email', 'calculated-fields-form' ); ?></th>
487
- <td><input type="text" name="paypal_email" class="width75" value="<?php echo esc_attr($form_obj->get_option('paypal_email',CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_EMAIL)); ?>" /></td>
488
- </tr>
489
-
490
- <tr valign="top">
491
- <th scope="row"><?php _e( 'A $0 amount to pay means', 'calculated-fields-form' ); ?>:</th>
492
- <td><select name="paypal_zero_payment" class="width75">
493
- <option value="0" <?php if ($form_obj->get_option('paypal_zero_payment',CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_ZERO_PAYMENT) != '1') echo 'selected'; ?>><?php _e( 'Let the user enter any amount at PayPal (ex: for a donation)', 'calculated-fields-form' ); ?></option>
494
- <option value="1" <?php if ($form_obj->get_option('paypal_zero_payment',CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_ZERO_PAYMENT) == '1') echo 'selected'; ?>><?php _e( 'Don\'t require any payment. Form is submitted skiping the PayPal page.', 'calculated-fields-form' ); ?></option>
495
- </select>
496
- </td>
497
- </tr>
498
-
499
- <tr valign="top">
500
- <th scope="row"><?php _e( 'Paypal language', 'calculated-fields-form' ); ?></th>
501
- <td><input type="text" name="paypal_language" value="<?php echo esc_attr($form_obj->get_option('paypal_language',CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_LANGUAGE)); ?>" /></td>
502
- </tr>
503
-
504
- <tr valign="top">
505
- <th scope="row"><?php _e( 'Payment frequency', 'calculated-fields-form' ); ?></th>
506
- <td><select name="paypal_recurrent" class="width75">
507
- <option value="0" <?php if ($form_obj->get_option('paypal_recurrent',CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_RECURRENT) == '0' ||
508
- $form_obj->get_option('paypal_recurrent',CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_RECURRENT) == ''
509
- ) echo 'selected'; ?>><?php _e( 'One time payment (default option, user is billed only once)', 'calculated-fields-form' ); ?></option>
510
- <option value="1" <?php if ($form_obj->get_option('paypal_recurrent',CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_RECURRENT) == '1') echo 'selected'; ?>><?php _e( 'Bill the user every 1 month', 'calculated-fields-form' ); ?></option>
511
- <option value="3" <?php if ($form_obj->get_option('paypal_recurrent',CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_RECURRENT) == '3') echo 'selected'; ?>><?php _e( 'Bill the user every 3 months', 'calculated-fields-form' ); ?></option>
512
- <option value="6" <?php if ($form_obj->get_option('paypal_recurrent',CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_RECURRENT) == '6') echo 'selected'; ?>><?php _e( 'Bill the user every 6 months', 'calculated-fields-form' ); ?></option>
513
- <option value="12" <?php if ($form_obj->get_option('paypal_recurrent',CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_RECURRENT) == '12') echo 'selected'; ?>><?php _e( 'Bill the user every 12 months', 'calculated-fields-form' ); ?></option>
514
- </select>
515
- </td>
516
- </tr>
517
- <tr valign="top">
518
- <th scope="row"><?php _e( 'Paypal prompt buyers for shipping address', 'calculated-fields-form' ); ?></th>
519
- <td>
520
- <?php $paypal_address = $form_obj->get_option('paypal_address', 1); ?>
521
- <select name="paypal_address" class="width75">
522
- <option value="1" <?php if($paypal_address == 1) print 'SELECTED'; ?>><?php _e('Do not prompt for an address', 'calculated-fields-form'); ?></option>
523
- <option value="0" <?php if($paypal_address == 0) print 'SELECTED'; ?>><?php _e('Prompt for an address, but do not require one', 'calculated-fields-form'); ?></option>
524
- <option value="2" <?php if($paypal_address == 2) print 'SELECTED'; ?>><?php _e('Prompt for an address and require one', 'calculated-fields-form'); ?></option>
525
  </select>
526
  </td>
527
- </tr>
528
- </table>
529
- <div class="cff-goto-top"><a href="#cpformconf"><?php _e('Up to form structure', 'calculated-fields-form'); ?></a></div>
530
- </div>
531
- </div>
532
-
533
- <div id="metabox_notification_email" class="postbox metabox_disabled_section cff-metabox <?php print esc_attr($cpcff_main->metabox_status( 'metabox_notification_email' ) ); ?>" >
534
- <h3 class='hndle' style="padding:5px;"><span><?php _e( 'Form Processing / Email Settings', 'calculated-fields-form' ); ?></span></h3>
535
- <div class="inside">
536
- <table class="form-table">
537
- <tr valign="top">
538
- <th scope="row"><?php _e( '"From" email', 'calculated-fields-form' ); ?></th>
539
- <td><input type="text" name="fp_from_email" class="width75" value="<?php echo esc_attr($form_obj->get_option('fp_from_email', CP_CALCULATEDFIELDSF_DEFAULT_fp_from_email)); ?>" /><br><b><em style="font-size:11px;">Ex: admin@<?php echo str_replace('www.','',$_SERVER["HTTP_HOST"]); ?></em></b><br><em style="font-size:11px;"><?php _e( 'This email is required if the "From fixed email address" option is selected, or it is enabled the email copy to the user.', 'calculated-fields-form' ); ?></em></td>
540
- </tr>
541
- <tr valign="top">
542
- <th scope="row"><?php _e( 'Destination emails (comma separated)', 'calculated-fields-form' ); ?></th>
543
- <td><input type="text" name="fp_destination_emails" class="width75" value="<?php echo esc_attr($form_obj->get_option('fp_destination_emails', CP_CALCULATEDFIELDSF_DEFAULT_fp_destination_emails)); ?>" /></td>
544
- </tr>
545
- <tr valign="top">
546
- <th scope="row"><?php _e( 'Email subject', 'calculated-fields-form' ); ?></th>
547
- <td><input type="text" name="fp_subject" class="width75" value="<?php echo esc_attr($form_obj->get_option('fp_subject', CP_CALCULATEDFIELDSF_DEFAULT_fp_subject)); ?>" /></td>
548
- </tr>
549
- <tr valign="top">
550
- <th scope="row"><?php _e( 'Include additional information?', 'calculated-fields-form' ); ?></th>
551
- <td>
552
- <?php $option = $form_obj->get_option('fp_inc_additional_info', CP_CALCULATEDFIELDSF_DEFAULT_fp_inc_additional_info); ?>
553
- <select name="fp_inc_additional_info">
554
- <option value="true"<?php if ($option == 'true') echo ' selected'; ?>><?php _e( 'Yes', 'calculated-fields-form' ); ?></option>
555
- <option value="false"<?php if ($option == 'false') echo ' selected'; ?>><?php _e( 'No', 'calculated-fields-form' ); ?></option>
556
- </select>&nbsp;<em style="font-size:11px;"><?php _e('If the "No" option is selected the plugin won\'t capture the IP address of users.','calculated-fields-form'); ?></em>
557
- </td>
558
- </tr>
559
- <tr valign="top">
560
- <th scope="row"><?php _e( 'Thank you page (after sending the message)', 'calculated-fields-form' ); ?></th>
561
- <td><input type="text" name="fp_return_page" class="width75" value="<?php echo esc_attr($form_obj->get_option('fp_return_page', CP_CALCULATEDFIELDSF_DEFAULT_fp_return_page)); ?>" /></td>
562
- </tr>
563
- <tr valign="top">
564
- <th scope="row"><?php _e( 'Email format?', 'calculated-fields-form' ); ?></th>
565
- <td>
566
- <?php $option = $form_obj->get_option('fp_emailformat', CP_CALCULATEDFIELDSF_DEFAULT_email_format); ?>
567
- <select name="fp_emailformat" class="width75">
568
- <option value="text"<?php if ($option != 'html') echo ' selected'; ?>><?php _e( 'Plain Text (default)', 'calculated-fields-form' ); ?></option>
569
- <option value="html"<?php if ($option == 'html') echo ' selected'; ?>><?php _e( 'HTML (use html in the textarea below)', 'calculated-fields-form' ); ?></option>
570
- </select>
571
- </td>
572
- </tr>
573
- <tr valign="top">
574
- <th scope="row"><?php _e( 'Message', 'calculated-fields-form' ); ?></th>
575
- <td><textarea type="text" name="fp_message" rows="6" class="width75"><?php echo $form_obj->get_option('fp_message', CP_CALCULATEDFIELDSF_DEFAULT_fp_message); ?></textarea></td>
576
- </tr>
577
- </table>
578
- <div class="cff-goto-top"><a href="#cpformconf"><?php _e('Up to form structure', 'calculated-fields-form'); ?></a></div>
579
- </div>
580
- </div>
581
-
582
-
583
- <div id="metabox_email_copy_to_user" class="postbox metabox_disabled_section cff-metabox <?php print esc_attr($cpcff_main->metabox_status( 'metabox_email_copy_to_user' ) ); ?>" >
584
- <h3 class='hndle' style="padding:5px;"><span><?php _e( 'Email Copy to User', 'calculated-fields-form' ); ?></span></h3>
585
- <div class="inside">
586
- <table class="form-table">
587
- <tr valign="top">
588
- <th scope="row"><?php _e( 'Send confirmation/thank you message to user?', 'calculated-fields-form' ); ?></th>
589
- <td>
590
- <?php $option = $form_obj->get_option('cu_enable_copy_to_user', CP_CALCULATEDFIELDSF_DEFAULT_cu_enable_copy_to_user); ?>
591
- <select name="cu_enable_copy_to_user">
592
- <option value="true"<?php if ($option == 'true') echo ' selected'; ?>><?php _e( 'Yes', 'calculated-fields-form' ); ?></option>
593
- <option value="false"<?php if ($option == 'false') echo ' selected'; ?>><?php _e( 'No', 'calculated-fields-form' ); ?></option>
594
- </select>
595
- </td>
596
- </tr>
597
- <tr valign="top">
598
- <th scope="row"><?php _e( 'Email field on the form', 'calculated-fields-form' ); ?></th>
599
- <td><select id="cu_user_email_field" name="cu_user_email_field" def="<?php echo esc_attr($form_obj->get_option('cu_user_email_field', CP_CALCULATEDFIELDSF_DEFAULT_cu_user_email_field)); ?>" class="width75"></select></td>
600
- </tr>
601
- <tr valign="top">
602
- <th scope="row"><?php _e( 'Email subject', 'calculated-fields-form' ); ?></th>
603
- <td><input type="text" name="cu_subject" class="width75" value="<?php echo esc_attr($form_obj->get_option('cu_subject', CP_CALCULATEDFIELDSF_DEFAULT_cu_subject)); ?>" /></td>
604
- </tr>
605
- <tr valign="top">
606
- <th scope="row"><?php _e( 'Email format?', 'calculated-fields-form' ); ?></th>
607
- <td>
608
- <?php $option = $form_obj->get_option('cu_emailformat', CP_CALCULATEDFIELDSF_DEFAULT_email_format); ?>
609
- <select name="cu_emailformat" class="width75">
610
- <option value="text"<?php if ($option != 'html') echo ' selected'; ?>><?php _e( 'Plain Text (default)', 'calculated-fields-form' ); ?></option>
611
- <option value="html"<?php if ($option == 'html') echo ' selected'; ?>><?php _e( 'HTML (use html in the textarea below)', 'calculated-fields-form' ); ?></option>
612
- </select>
613
- </td>
614
- </tr>
615
- <tr valign="top">
616
- <th scope="row"><?php _e( 'Message', 'calculated-fields-form' ); ?></th>
617
- <td><textarea type="text" name="cu_message" rows="6" class="width75"><?php echo $form_obj->get_option('cu_message', CP_CALCULATEDFIELDSF_DEFAULT_cu_message); ?></textarea></td>
618
- </tr>
619
- </table>
620
- <div class="cff-goto-top"><a href="#cpformconf"><?php _e('Up to form structure', 'calculated-fields-form'); ?></a></div>
621
- </div>
622
- </div>
623
-
624
- <div id="metabox_captcha_settings" class="postbox metabox_disabled_section cff-metabox <?php print esc_attr($cpcff_main->metabox_status( 'metabox_captcha_settings' ) ); ?>" >
625
- <h3 class='hndle' style="padding:5px;"><span><?php _e( 'Captcha Verification', 'calculated-fields-form' ); ?></span></h3>
626
- <div class="inside">
627
- <table class="form-table">
628
- <tr valign="top">
629
- <th scope="row"><?php _e( 'Use Captcha Verification?', 'calculated-fields-form' ); ?></th>
630
- <td colspan="5">
631
- <?php $option = $form_obj->get_option('cv_enable_captcha', CP_CALCULATEDFIELDSF_DEFAULT_cv_enable_captcha); ?>
632
- <select name="cv_enable_captcha">
633
- <option value="true"<?php if ($option == 'true') echo ' selected'; ?>><?php _e( 'Yes', 'calculated-fields-form' ); ?></option>
634
- <option value="false"<?php if ($option == 'false') echo ' selected'; ?>><?php _e( 'No', 'calculated-fields-form' ); ?></option>
635
- </select>
636
- </td>
637
- </tr>
638
-
639
- <tr valign="top">
640
- <th scope="row"><?php _e( 'Width', 'calculated-fields-form' ); ?>:</th>
641
- <td><input type="text" readonly=readonly name="cv_width" size="10" value="<?php echo esc_attr($form_obj->get_option('cv_width', CP_CALCULATEDFIELDSF_DEFAULT_cv_width)); ?>" onblur="generateCaptcha();" /></td>
642
- <th scope="row"><?php _e( 'Height', 'calculated-fields-form' ); ?>:</th>
643
- <td><input type="text" readonly=readonly name="cv_height" size="10" value="<?php echo esc_attr($form_obj->get_option('cv_height', CP_CALCULATEDFIELDSF_DEFAULT_cv_height)); ?>" onblur="generateCaptcha();" /></td>
644
- <th scope="row"><?php _e( 'Chars', 'calculated-fields-form' ); ?>:</th>
645
- <td><input type="text" readonly=readonly name="cv_chars" size="10" value="<?php echo esc_attr($form_obj->get_option('cv_chars', CP_CALCULATEDFIELDSF_DEFAULT_cv_chars)); ?>" onblur="generateCaptcha();" /></td>
646
- </tr>
647
-
648
- <tr valign="top">
649
- <th scope="row"><?php _e( 'Min font size', 'calculated-fields-form' ); ?>:</th>
650
- <td><input type="text" readonly=readonly name="cv_min_font_size" size="10" value="<?php echo esc_attr($form_obj->get_option('cv_min_font_size', CP_CALCULATEDFIELDSF_DEFAULT_cv_min_font_size)); ?>" onblur="generateCaptcha();" /></td>
651
- <th scope="row"><?php _e( 'Max font size', 'calculated-fields-form' ); ?>:</th>
652
- <td><input type="text" readonly=readonly name="cv_max_font_size" size="10" value="<?php echo esc_attr($form_obj->get_option('cv_max_font_size', CP_CALCULATEDFIELDSF_DEFAULT_cv_max_font_size)); ?>" onblur="generateCaptcha();" /></td>
653
- <td colspan="2" rowspan="">
654
- <?php _e( 'Preview', 'calculated-fields-form' ); ?>:<br />
655
- <br />
656
- <img src="<?php echo plugins_url('/captcha/captcha.php', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH); ?>" id="captchaimg" alt="<?php esc_attr_e( 'security code', 'calculated-fields-form' ); ?>" border="0" class="skip-lazy" />
657
- </td>
658
- </tr>
659
-
660
-
661
- <tr valign="top">
662
- <th scope="row"><?php _e( 'Noise', 'calculated-fields-form' ); ?>:</th>
663
- <td><input type="text" readonly=readonly name="cv_noise" size="10" value="<?php echo esc_attr($form_obj->get_option('cv_noise', CP_CALCULATEDFIELDSF_DEFAULT_cv_noise)); ?>" onblur="generateCaptcha();" /></td>
664
- <th scope="row"><?php _e( 'Noise Length', 'calculated-fields-form' ); ?>:</th>
665
- <td><input type="text" readonly=readonly name="cv_noise_length" size="10" value="<?php echo esc_attr($form_obj->get_option('cv_noise_length', CP_CALCULATEDFIELDSF_DEFAULT_cv_noise_length)); ?>" onblur="generateCaptcha();" /></td>
666
- </tr>
667
-
668
- <tr valign="top">
669
- <th scope="row"><?php _e( 'Background', 'calculated-fields-form' ); ?>:</th>
670
- <td><input type="text" readonly=readonly name="cv_background" size="10" value="<?php echo esc_attr($form_obj->get_option('cv_background', CP_CALCULATEDFIELDSF_DEFAULT_cv_background)); ?>" onblur="generateCaptcha();" /></td>
671
- <th scope="row">Border:</th>
672
- <td><input type="text" readonly=readonly name="cv_border" size="10" value="<?php echo esc_attr($form_obj->get_option('cv_border', CP_CALCULATEDFIELDSF_DEFAULT_cv_border)); ?>" onblur="generateCaptcha();" /></td>
673
- </tr>
674
-
675
- <tr valign="top">
676
- <th scope="row"><?php _e( 'Font', 'calculated-fields-form' ); ?>:</th>
677
- <td>
678
- <select name="cv_font" onchange="generateCaptcha();" >
679
- <option value="font-1.ttf"<?php if ("font-1.ttf" == $form_obj->get_option('cv_font', CP_CALCULATEDFIELDSF_DEFAULT_cv_font)) echo " selected"; ?>>Font 1</option>
680
- <option value="font-2.ttf"<?php if ("font-2.ttf" == $form_obj->get_option('cv_font', CP_CALCULATEDFIELDSF_DEFAULT_cv_font)) echo " selected"; ?>>Font 2</option>
681
- <option value="font-3.ttf"<?php if ("font-3.ttf" == $form_obj->get_option('cv_font', CP_CALCULATEDFIELDSF_DEFAULT_cv_font)) echo " selected"; ?>>Font 3</option>
682
- <option value="font-4.ttf"<?php if ("font-4.ttf" == $form_obj->get_option('cv_font', CP_CALCULATEDFIELDSF_DEFAULT_cv_font)) echo " selected"; ?>>Font 4</option>
683
- </select>
684
- </td>
685
- </tr>
686
- </table>
687
- <div class="cff-goto-top"><a href="#cpformconf"><?php _e('Up to form structure', 'calculated-fields-form'); ?></a></div>
688
- </div>
689
- </div>
690
- <a id="metabox_addons_section"></a>
691
- <?php
692
- do_action('cpcff_form_settings', CP_CALCULATEDFIELDSF_ID);
693
- ?>
694
- </div>
695
-
696
-
697
- <p class="submit">
698
- <input type="submit" name="save" id="save" class="button-primary" value="<?php esc_attr_e( 'Save Changes', 'calculated-fields-form' ); ?>" title="Saves the form's structure and settings" />
699
- </p>
700
-
701
- [<a href="https://cff.dwbooster.com/customization" target="_blank"><?php _e( 'Request Custom Modifications', 'calculated-fields-form' ); ?></a>] | [<a href="https://wordpress.org/support/plugin/calculated-fields-form#new-post" target="_blank"><?php _e( 'Help', 'calculated-fields-form' ); ?></a>]
702
- </form>
703
- </div>
704
- <script type="text/javascript">
705
- function generateCaptcha()
706
- {
707
- var d=new Date(),
708
- f = document.cpformconf,
709
- qs = "?width="+f.cv_width.value;
710
-
711
- qs += "&height="+f.cv_height.value;
712
- qs += "&letter_count="+f.cv_chars.value;
713
- qs += "&min_size="+f.cv_min_font_size.value;
714
- qs += "&max_size="+f.cv_max_font_size.value;
715
- qs += "&noise="+f.cv_noise.value;
716
- qs += "&noiselength="+f.cv_noise_length.value;
717
- qs += "&bcolor="+f.cv_background.value;
718
- qs += "&border="+f.cv_border.value;
719
- qs += "&font="+f.cv_font.options[f.cv_font.selectedIndex].value;
720
- qs += "&rand="+d;
721
-
722
- document.getElementById("captchaimg").src= "<?php echo plugins_url('/captcha/captcha.php', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH); ?>"+qs;
723
- }
724
- generateCaptcha();
725
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! is_admin() ) {
4
+ print 'Direct access not allowed.';
5
+ exit;
6
+ }
7
+
8
+ // Required scripts
9
+ require_once CP_CALCULATEDFIELDSF_BASE_PATH . '/inc/cpcff_templates.inc.php';
10
+
11
+ check_admin_referer( 'cff-form-settings', '_cpcff_nonce' );
12
+
13
+ // Load resources
14
+ wp_enqueue_media();
15
+ if ( function_exists( 'wp_enqueue_code_editor' ) ) {
16
+ wp_enqueue_code_editor( array( 'type' => 'text/html' ) );
17
+ }
18
+ wp_enqueue_style( 'cff-chosen-css', plugins_url( '/vendors/chosen/chosen.min.css', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ), array(), CP_CALCULATEDFIELDSF_VERSION );
19
+ wp_enqueue_script( 'cff-chosen-js', plugins_url( '/vendors/chosen/chosen.jquery.min.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ), array( 'jquery' ), CP_CALCULATEDFIELDSF_VERSION );
20
+
21
+ if ( ! defined( 'CP_CALCULATEDFIELDSF_ID' ) ) {
22
+ define( 'CP_CALCULATEDFIELDSF_ID', isset( $_GET['cal'] ) && is_numeric( $_GET['cal'] ) ? intval( $_GET['cal'] ) : 0 );
23
+ }
24
+
25
+ $cpcff_main = CPCFF_MAIN::instance();
26
+ $form_obj = $cpcff_main->get_form( intval( $_GET['cal'] ) );
27
+
28
+ if ( isset( $_SERVER['REQUEST_METHOD'] ) && 'POST' == $_SERVER['REQUEST_METHOD'] && isset( $_POST['cpcff_revision_to_apply'] ) && is_numeric( $_POST['cpcff_revision_to_apply'] ) ) {
29
+ $revision_id = intval( $_POST['cpcff_revision_to_apply'] );
30
+ if ( $revision_id ) {
31
+ $form_obj->apply_revision( $revision_id );
32
+ }
33
+ }
34
+
35
+ if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset( $_POST['cp_calculatedfieldsf_post_options'] ) ) {
36
+ echo "<div id='setting-error-settings_updated' class='updated settings-error'> <p><strong>" . esc_html__( 'Settings saved', 'calculated-fields-form' ) . '</strong></p></div>';
37
+ }
38
+
39
+ global $cpcff_default_texts_array;
40
+ $cpcff_texts_array = $form_obj->get_option( 'vs_all_texts', $cpcff_default_texts_array );
41
+ $cpcff_texts_array = CPCFF_AUXILIARY::array_replace_recursive(
42
+ $cpcff_default_texts_array,
43
+ ( is_string( $cpcff_texts_array ) && is_array( unserialize( $cpcff_texts_array ) ) )
44
+ ? unserialize( $cpcff_texts_array )
45
+ : ( ( is_array( $cpcff_texts_array ) ) ? $cpcff_texts_array : array() )
46
+ );
47
+
48
+ ?>
49
+ <div class="wrap">
50
+ <h1 class="cff-form-name"><?php
51
+ print esc_html__( 'Calculated Fields Form', 'calculated-fields-form' ) . ' <span class="cff-form-name-shortcode">(<b>' . esc_html__( 'Form', 'calculated-fields-form' ) . ' ' . esc_html( CP_CALCULATEDFIELDSF_ID ) . ' - ' . esc_html( $form_obj->get_option( 'form_name', '' ) ) . '</b>) Shortcode: [CP_CALCULATED_FIELDS id="' . esc_attr( CP_CALCULATEDFIELDSF_ID ) . '"]</span>';
52
+
53
+ if ( get_option( 'CP_CALCULATEDFIELDSF_DIRECT_FORM_ACCESS', CP_CALCULATEDFIELDSF_DIRECT_FORM_ACCESS ) ) {
54
+ $url = CPCFF_AUXILIARY::site_url();
55
+ $url .= ( strpos( $url, '?' ) === false ) ? '?' : '&';
56
+ $url .= 'cff-form=' . CP_CALCULATEDFIELDSF_ID;
57
+ print '<br><span style="font-size:14px;font-style:italic;">' . esc_html__( 'Direct form URL', 'calculated-fields-form' ) . ': <a href="' . esc_attr( $url ) . '" target="_blank">' . esc_html( $url ) . '</a></span>';
58
+ }
59
+ ?></h1>
60
+ <input type="button" name="backbtn" value="<?php esc_attr_e( 'Back to items list...', 'calculated-fields-form' ); ?>" onclick="document.location='admin.php?page=cp_calculated_fields_form';" class="button-secondary" />
61
+ <br /><br />
62
+ <?php $_cpcff_nonce = wp_create_nonce( 'cff-form-settings' ); ?>
63
+ <form method="post" action="" id="cpformconf" name="cpformconf" class="cff_form_builder">
64
+ <input type="hidden" name="_cpcff_nonce" value="<?php echo esc_attr( $_cpcff_nonce ); ?>" />
65
+ <input name="cp_calculatedfieldsf_post_options" type="hidden" value="1" />
66
+ <input name="cp_calculatedfieldsf_id" type="hidden" value="<?php echo esc_attr( CP_CALCULATEDFIELDSF_ID ); ?>" />
67
+
68
+ <div id="normal-sortables" class="meta-box-sortables">
69
+
70
+ <h2><?php esc_html_e( 'Form Settings', 'calculated-fields-form' ); ?>:</h2>
71
+ <!-- Form category -->
72
+ <div class="postbox" >
73
+ <div class="inside">
74
+ <b><?php esc_html_e( 'Form Category', 'calculated-fields-form' ); ?></b>
75
+ <input type="text" name="calculated-fields-form-category" class="width75" value="<?php print esc_attr( $form_obj->get_option( 'category', '' ) ); ?>" list="calculated-fields-form-categories" />
76
+ <datalist id="calculated-fields-form-categories">
77
+ <?php
78
+ print $cpcff_main->get_categories( 'DATALIST' ); // phpcs:ignore WordPress.Security.EscapeOutput
79
+ ?>
80
+ </datalist>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  </div>
82
+ </div>
83
+ <hr />
84
+ <div><?php esc_html_e( '* Different form styles available on the tab Form Settings &gt;&gt; Form Template', 'calculated-fields-form' ); ?></div>
85
+ <div id="metabox_form_structure" class="postbox" >
86
+ <div class="hndle">
87
+ <h3 style="padding:5px;display:inline-block;"><span><?php esc_html_e( 'Form Builder', 'calculated-fields-form' ); ?></span></h3>
88
+ <div class="cff-revisions-container">
89
+ <?php
90
+ if ( get_option( 'CP_CALCULATEDFIELDSF_DISABLE_REVISIONS', CP_CALCULATEDFIELDSF_DISABLE_REVISIONS ) == 0 ) :
91
+ esc_html_e( 'Revisions', 'calculated-fields-form' );
92
+ ?>
93
+ <select name="cff_revision_list">
94
+
95
+ <?php
96
+ print '<option value="0">' . esc_html__( 'Select a revision', 'calculated-fields-form' ) . '</option>';
97
+ $revisions_obj = $form_obj->get_revisions();
98
+ $revisions = $revisions_obj->revisions_list();
99
+ foreach ( $revisions as $revision_id => $revision_data ) {
100
+ print '<option value="' . esc_attr( $revision_id ) . '">' . esc_html( $revision_data['time'] ) . '</option>';
101
+ }
102
+ ?>
103
+ </select>
104
+ <input type="button" name="cff_apply_revision" value="<?php print esc_attr( 'Load Revision', 'calculated-fields-form' ); ?>" class="button" style="float:none;" />
105
+ <?php
106
+ endif;
107
+ ?>
108
+ <input type="button" name="previewbtn" id="previewbtn2" class="button-primary" value="<?php esc_attr_e( 'Preview', 'calculated-fields-form' ); ?>" onclick="fbuilderjQuery.fbuilder.preview( this );" title="<?php esc_attr_e( "Saves the form's structure only, and opens a preview windows", 'calculated-fields-form' ); ?>" />
109
+ <input type="button" name="cff_fields_list" class="button-secondary" value="&#9776;" title="<?php esc_attr_e( 'Fields List', 'calculated-fields-form' ); ?>" onclick="fbuilderjQuery.fbuilder.printFields();" />
110
+ </div>
111
+ </div>
112
+ <div class="inside">
113
+ <div class="form-builder-error-messages"><?php
114
+ global $cff_structure_error;
115
+ if ( ! empty( $cff_structure_error ) ) {
116
+ echo $cff_structure_error; // phpcs:ignore WordPress.Security.EscapeOutput
117
+ }
118
+ ?></div>
119
+ <p style="border:1px solid #F0AD4E;background:#FBE6CA;padding:10px;"><span style="font-weight:bold;"><?php esc_html_e( 'If the form is not loading in the public website, go to the settings page of the plugin through the menu option: "Settings/Calculated Fields Form", select the "Classic" option for the attribute: "Script load method", and press the "Update" button.', 'calculated-fields-form' ); ?></span><br /><?php _e( 'If you need also the form to be sent to the server side for processing (for example to deliver emails) then the <a href="https://cff.dwbooster.com/download" target="_blank">Commercial versions</a> of the plugin are required.', 'calculated-fields-form' ); // phpcs:ignore WordPress.Security.EscapeOutput ?></p>
120
+ <input type="hidden" name="form_structure" id="form_structure" value="<?php print esc_attr( preg_replace( '/&quot;/i', '&amp;quot;', json_encode( $form_obj->get_option( 'form_structure', CP_CALCULATEDFIELDSF_DEFAULT_form_structure ) ) ) ); ?>" />
121
+ <input type="hidden" name="templates" id="templates" value="<?php print esc_attr( json_encode( CPCFF_TEMPLATES::load_templates() ) ); ?>" />
122
+ <link href="<?php print esc_attr( plugins_url( '/vendors/jquery-ui/jquery-ui.min.css', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ) ); // phpcs:ignore WordPress.WP.EnqueuedResources ?>" type="text/css" rel="stylesheet" property="stylesheet" />
123
+ <pre style="display:none;">
124
+ <script type="text/javascript">
125
+ var cff_metabox_nonce = '<?php print esc_js( wp_create_nonce( 'cff-metabox-status' ) ); ?>';
126
+ try
127
+ {
128
+ function calculatedFieldsFormReady()
129
+ {
130
+ /* Revisions code */
131
+ $calculatedfieldsfQuery('[name="cff_apply_revision"]').click(
132
+ function(){
133
+ var revision = $calculatedfieldsfQuery('[name="cff_revision_list"]').val();
134
+ if(revision*1)
135
+ {
136
+ result = window.confirm('<?php print esc_js( __( 'The action will load the revision selected, the data are not stored will be lose. Do you want continue?', 'calculated-fields-form' ) ); ?>');
137
+ if(result)
138
+ {
139
+ $calculatedfieldsfQuery('<form method="post" action="" id="cpformconf" name="cpformconf" class="cff_form_builder"><input type="hidden" name="_cpcff_nonce" value="<?php echo esc_attr( $_cpcff_nonce ); ?>" /><input name="cp_calculatedfieldsf_id" type="hidden" value="<?php echo esc_attr( CP_CALCULATEDFIELDSF_ID ); ?>" /><input type="hidden" name="cpcff_revision_to_apply" value="'+esc_attr( revision )+'"></form>').appendTo('body').submit();
140
+ }
141
+ }
142
+ }
143
+ );
144
+
145
+ // Form builder code
146
+
147
+ var f;
148
+ function run_fbuilder($)
149
+ {
150
+ f = $("#fbuilder").fbuilder();
151
+ window['cff_form'] = f;
152
+ f.fBuild.loadData( "form_structure", "templates" );
153
+ };
154
+
155
+ if(!('fbuilder' in $calculatedfieldsfQuery.fn))
156
+ {
157
+ $calculatedfieldsfQuery.getScript(
158
+ location.protocol + '//' + location.host + location.pathname+'?page=cp_calculated_fields_form&cp_cff_resources=admin',
159
+ function(){run_fbuilder(fbuilderjQuery);}
160
+ );
161
+ }
162
+ else
163
+ {
164
+ run_fbuilder($calculatedfieldsfQuery);
165
+ }
166
+
167
+ $calculatedfieldsfQuery(".itemForm").click(function() {
168
+ f.fBuild.addItem($calculatedfieldsfQuery(this).attr("id"));
169
+ })
170
+ .draggable({
171
+ connectToSortable: '#fbuilder #fieldlist',
172
+ delay: 100,
173
+ helper: function() {
174
+ var $ = $calculatedfieldsfQuery,
175
+ e = $(this),
176
+ width = e.outerWidth(),
177
+ text = e.text(),
178
+ type = e.attr('id'),
179
+ el = $('<div class="cff-button-drag '+type+'">');
180
+
181
+ return el.html( text ).css( 'width', width ).attr('data-control',type);
182
+ },
183
+ revert: 'invalid',
184
+ cancel: false,
185
+ scroll: false,
186
+ opacity: 1,
187
+ containment: 'document',
188
+ stop: function(){$calculatedfieldsfQuery('.ctrlsColumn .itemForm').removeClass('button-primary');}
189
+ });
190
+
191
+ jQuery(".metabox_disabled_section .inside")
192
+ .click( function(){
193
+ if(confirm("<?php esc_html_e( 'These features aren\'t available in this version. Do you want to open the plugin\'s page to check other versions?', 'calculated-fields-form' ); ?>"))
194
+ document.location = 'https://cff.dwbooster.com/';
195
+ })
196
+ .find('*')
197
+ .prop('disabled', true);
198
+ };
199
+ }
200
+ catch( err ){}
201
+ try{$calculatedfieldsfQuery = jQuery.noConflict();} catch ( err ) {}
202
+ if (typeof $calculatedfieldsfQuery == 'undefined')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
  {
204
+ if(window.addEventListener){
205
+ window.addEventListener('load', function(){
206
+ try{$calculatedfieldsfQuery = jQuery.noConflict();} catch ( err ) {return;}
207
+ calculatedFieldsFormReady();
208
+ });
209
+ }else{
210
+ window.attachEvent('onload', function(){
211
+ try{$calculatedfieldsfQuery = jQuery.noConflict();} catch ( err ) {return;}
212
+ calculatedFieldsFormReady();
213
+ });
214
+ }
 
215
  }
216
+ else
217
+ {
218
+ $calculatedfieldsfQuery(document).ready( calculatedFieldsFormReady );
219
+ }
220
+ </script>
221
+ </pre>
222
+ <div style="background:#fafafa;" class="form-builder">
223
+
224
+ <div class="column ctrlsColumn">
225
+ <div id="tabs">
226
+ <span class="ui-icon ui-icon-triangle-1-e expand-shrink"></span>
227
+ <ul>
228
+ <li><a href="#tabs-1"><?php esc_html_e( 'Add a Field', 'calculated-fields-form' ); ?></a></li>
229
+ <li><a href="#tabs-2"><?php esc_html_e( 'Field Settings', 'calculated-fields-form' ); ?></a></li>
230
+ <li><a href="#tabs-3"><?php esc_html_e( 'Form Settings', 'calculated-fields-form' ); ?></a></li>
231
+ </ul>
232
+ <div id="tabs-1"></div>
233
+ <div id="tabs-2"></div>
234
+ <div id="tabs-3"></div>
235
+ </div>
236
+ </div>
237
+ <div class="columnr dashboardColumn padding10" id="fbuilder">
238
+ <div id="formheader"></div>
239
+ <div id="fieldlist"></div>
240
+ </div>
241
+ <div class="clearer"></div>
242
+
243
+ </div>
244
+
245
+ </div>
246
+ </div>
247
+
248
+ <p class="submit">
249
+ <input type="submit" name="save" id="save2" class="button-primary" value="<?php esc_attr_e( 'Save Changes', 'calculated-fields-form' ); ?>" title="Saves the form's structure and settings and creates a revision" />
250
+ <input type="button" name="previewbtn" id="previewbtn" class="button-primary" value="<?php esc_attr_e( 'Preview', 'calculated-fields-form' ); ?>" onclick="fbuilderjQuery.fbuilder.preview( this );" title="Saves the form's structure only, and opens a preview windows" />
251
+ <?php
252
+ if ( get_option( 'CP_CALCULATEDFIELDSF_DISABLE_REVISIONS', CP_CALCULATEDFIELDSF_DISABLE_REVISIONS ) == 0 ) :
253
+ ?>
254
+ | <input type="checkbox" name="cff-revisions-in-preview" <?php if ( get_option( 'CP_CALCULATEDFIELDSF_REVISIONS_IN_PREVIEW', true ) ) {
255
+ print 'CHECKED';} ?> />
256
+ <?php
257
+ esc_html_e( 'Generate revisions in the form preview as well', 'calculated-fields-form' );
258
+ endif;
259
+ ?>
260
+ </p>
261
+ <div style="margin-bottom:20px;">
262
+ <a href="#metabox_define_texts"><?php esc_html_e( 'Texts definition', 'calculated-fields-form' ); ?></a>&nbsp;|&nbsp;
263
+ <a href="#metabox_define_validation_texts"><?php esc_html_e( 'Error texts', 'calculated-fields-form' ); ?></a>&nbsp;|&nbsp;
264
+ <a href="#metabox_payment_settings"><?php esc_html_e( 'General payment settings', 'calculated-fields-form' ); ?></a>&nbsp;|&nbsp;
265
+ <a href="#metabox_paypal_integration"><?php esc_html_e( 'PayPal integration', 'calculated-fields-form' ); ?></a>&nbsp;|&nbsp;
266
+ <a href="#metabox_notification_email"><?php esc_html_e( 'Notification email', 'calculated-fields-form' ); ?></a>&nbsp;|&nbsp;
267
+ <a href="#metabox_email_copy_to_user"><?php esc_html_e( 'Email copy to user', 'calculated-fields-form' ); ?></a>&nbsp;|&nbsp;
268
+ <a href="#metabox_captcha_settings"><?php esc_html_e( 'Captcha settings', 'calculated-fields-form' ); ?></a>
269
+ </div>
270
+ <div id="metabox_define_texts" class="postbox cff-metabox <?php print esc_attr( $cpcff_main->metabox_status( 'metabox_define_texts' ) ); ?>" >
271
+ <h3 class='hndle' style="padding:5px;"><span><?php esc_html_e( 'Define Texts', 'calculated-fields-form' ); ?></span></h3>
272
+ <div class="inside">
273
+ <table class="form-table">
274
+ <tr valign="top">
275
+ <th scope="row"><?php esc_html_e( 'Previous button label (text)', 'calculated-fields-form' ); ?>:</th>
276
+ <td><input type="text" name="vs_text_previousbtn" class="width75" value="<?php $label = $form_obj->get_option( 'vs_text_previousbtn', 'Previous' );
277
+ echo esc_attr( '' == $label ? 'Previous' : $label ); ?>" /></td>
278
+ </tr>
279
+ <tr valign="top">
280
+ <th scope="row"><?php esc_html_e( 'Next button label (text)', 'calculated-fields-form' ); ?>:</th>
281
+ <td><input type="text" name="vs_text_nextbtn" class="width75" value="<?php $label = $form_obj->get_option( 'vs_text_nextbtn', 'Next' );
282
+ echo esc_attr( '' == $label ? 'Next' : $label ); ?>" /></td>
283
+ </tr>
284
+ <tr valign="top">
285
+ <td colspan="2">
286
+ <?php _e( '- The styles can be applied into any of the CSS files of your theme or into the CSS file <em>"calculated-fields-form\css\stylepublic.css"</em>.', 'calculated-fields-form' ); // phpcs:ignore WordPress.Security.EscapeOutput ?><br />
287
+ <?php _e( '- For general CSS styles modifications to the form and samples <a href="https://cff.dwbooster.com/faq#q82" target="_blank">check this FAQ</a>.', 'calculated-fields-form' ); // phpcs:ignore WordPress.Security.EscapeOutput ?>
288
+ </tr>
289
+ <?php
290
+ // Display all other text fields
291
+ foreach ( $cpcff_texts_array as $cpcff_text_index => $cpcff_text_attr ) {
292
+ if ( 'errors' !== $cpcff_text_index && isset( $cpcff_text_attr['label'] ) ) {
293
+ print '
294
+ <tr valign="top">
295
+ <th scope="row">' . esc_html( $cpcff_text_attr['label'] ) . ':</th>
296
+ <td><input type="text" name="cpcff_text_array[' . esc_attr( $cpcff_text_index ) . '][text]" class="width75" value="' . esc_attr( $cpcff_text_attr['text'] ) . '" /></td>
297
+ </tr>
298
+ ';
299
+ }
300
+ }
301
+ ?>
302
+ </table>
303
+ <div class="cff-goto-top"><a href="#cpformconf"><?php esc_html_e( 'Up to form structure', 'calculated-fields-form' ); ?></a></div>
304
+ </div>
305
+ </div>
306
+
307
+ <div id="metabox_define_validation_texts" class="postbox cff-metabox <?php print esc_attr( $cpcff_main->metabox_status( 'metabox_define_validation_texts' ) ); ?>" >
308
+ <h3 class='hndle' style="padding:5px;"><span><?php esc_html_e( 'Validation Settings', 'calculated-fields-form' ); ?></span></h3>
309
+ <div class="inside">
310
+ <table class="form-table">
311
+ <tr valign="top">
312
+ <th scope="row"><?php esc_html_e( '"is required" text', 'calculated-fields-form' ); ?>:</th>
313
+ <td><input type="text" name="vs_text_is_required" class="width75" value="<?php echo esc_attr( $form_obj->get_option( 'vs_text_is_required', CP_CALCULATEDFIELDSF_DEFAULT_vs_text_is_required ) ); ?>" /></td>
314
+ </tr>
315
+ <tr valign="top">
316
+ <th scope="row"><?php esc_html_e( '"is email" text', 'calculated-fields-form' ); ?>:</th>
317
+ <td><input type="text" name="vs_text_is_email" class="width75" value="<?php echo esc_attr( $form_obj->get_option( 'vs_text_is_email', CP_CALCULATEDFIELDSF_DEFAULT_vs_text_is_email ) ); ?>" /></td>
318
+ </tr>
319
+ <tr valign="top">
320
+ <th scope="row"><?php esc_html_e( '"is valid captcha" text', 'calculated-fields-form' ); ?>:</th>
321
+ <td><input type="text" name="cv_text_enter_valid_captcha" class="width75" value="<?php echo esc_attr( $form_obj->get_option( 'cv_text_enter_valid_captcha', CP_CALCULATEDFIELDSF_DEFAULT_cv_text_enter_valid_captcha ) ); ?>" /></td>
322
+ </tr>
323
+
324
+ <tr valign="top">
325
+ <th scope="row"><?php esc_html_e( '"is valid date (mm/dd/yyyy)" text', 'calculated-fields-form' ); ?>:</th>
326
+ <td><input type="text" name="vs_text_datemmddyyyy" class="width75" value="<?php echo esc_attr( $form_obj->get_option( 'vs_text_datemmddyyyy', CP_CALCULATEDFIELDSF_DEFAULT_vs_text_datemmddyyyy ) ); ?>" /></td>
327
+ </tr>
328
+ <tr valign="top">
329
+ <th scope="row"><?php esc_html_e( '"is valid date (dd/mm/yyyy)" text', 'calculated-fields-form' ); ?>:</th>
330
+ <td><input type="text" name="vs_text_dateddmmyyyy" class="width75" value="<?php echo esc_attr( $form_obj->get_option( 'vs_text_dateddmmyyyy', CP_CALCULATEDFIELDSF_DEFAULT_vs_text_dateddmmyyyy ) ); ?>" /></td>
331
+ </tr>
332
+ <tr valign="top">
333
+ <th scope="row"><?php esc_html_e( '"is number" text', 'calculated-fields-form' ); ?>:</th>
334
+ <td><input type="text" name="vs_text_number" class="width75" value="<?php echo esc_attr( $form_obj->get_option( 'vs_text_number', CP_CALCULATEDFIELDSF_DEFAULT_vs_text_number ) ); ?>" /></td>
335
+ </tr>
336
+ <tr valign="top">
337
+ <th scope="row"><?php esc_html_e( '"only digits" text', 'calculated-fields-form' ); ?>:</th>
338
+ <td><input type="text" name="vs_text_digits" class="width75" value="<?php echo esc_attr( $form_obj->get_option( 'vs_text_digits', CP_CALCULATEDFIELDSF_DEFAULT_vs_text_digits ) ); ?>" /></td>
339
+ </tr>
340
+ <tr valign="top">
341
+ <th scope="row"><?php esc_html_e( '"under maximum" text', 'calculated-fields-form' ); ?>:</th>
342
+ <td><input type="text" name="vs_text_max" class="width75" value="<?php echo esc_attr( $form_obj->get_option( 'vs_text_max', CP_CALCULATEDFIELDSF_DEFAULT_vs_text_max ) ); ?>" /></td>
343
+ </tr>
344
+ <tr valign="top">
345
+ <th scope="row"><?php esc_html_e( '"over minimum" text', 'calculated-fields-form' ); ?>:</th>
346
+ <td><input type="text" name="vs_text_min" class="width75" value="<?php echo esc_attr( $form_obj->get_option( 'vs_text_min', CP_CALCULATEDFIELDSF_DEFAULT_vs_text_min ) ); ?>" /></td>
347
+ </tr>
348
+ <?php
349
+ // Display all other text fields
350
+ if ( ! empty( $cpcff_texts_array['errors'] ) ) {
351
+ foreach ( $cpcff_texts_array['errors'] as $cpcff_text_index => $cpcff_text_attr ) {
352
+ if ( isset( $cpcff_text_attr['label'] ) ) {
353
+ print '
354
+ <tr valign="top">
355
+ <th scope="row">' . esc_html( $cpcff_text_attr['label'] ) . ':</th>
356
+ <td><input type="text" name="cpcff_text_array[errors][' . esc_attr( $cpcff_text_index ) . '][text]" class="width75" value="' . esc_attr( $cpcff_text_attr['text'] ) . '" /></td>
357
+ </tr>
358
+ ';
359
+ }
360
+ }
361
+ }
362
+ ?>
363
+ </table>
364
+ <div class="cff-goto-top"><a href="#cpformconf"><?php esc_html_e( 'Up to form structure', 'calculated-fields-form' ); ?></a></div>
365
+ </div>
366
+ </div>
367
+
368
+ <div id="metabox_basic_settings" class="postbox" >
369
+ <h3 class='hndle' style="padding:5px;"><span><?php esc_html_e( 'Note', 'calculated-fields-form' ); ?></span></h3>
370
+ <div class="inside">
371
+ <?php esc_html_e( 'To display the form in a post/page, enter your shortcode in the post/page content:', 'calculated-fields-form' ); ?>
372
+ <?php print '<b>[CP_CALCULATED_FIELDS id="' . esc_attr( CP_CALCULATEDFIELDSF_ID ) . '"]</b>'; ?><br />
373
+ <?php esc_html_e( 'The CFF plugin implements widgets and blocks to allow inserting the form visually with the most popular page builders such as Gutenberg Editor, Classic Editor, Elementor, Site Origin, Visual Composer, Beaver Builder, Divi, and for the other page builders insert the shortcode directly.', 'calculated-fields-form' ); ?>
374
+ <br /><br />
375
+ </div>
376
+ </div>
377
+
378
+ <p class="submit">
379
+ <input type="submit" name="save" id="save1" class="button-primary" value="<?php esc_attr_e( 'Save Changes', 'calculated-fields-form' ); ?>" title="Saves the form's structure and settings and creates a revision" />
380
+ </p>
381
+
382
+ [<a href="https://cff.dwbooster.com/customization" target="_blank"><?php esc_html_e( 'Request Custom Modifications', 'calculated-fields-form' ); ?></a>] | [<a href="https://wordpress.org/support/plugin/calculated-fields-form#new-post" target="_blank"><?php esc_html_e( 'Help', 'calculated-fields-form' ); ?></a>]
383
+
384
+ <br /><br /><br />
385
+ <style>@media screen and (min-width:710px){.cff-plugin-promote{width: calc( 100% - 180px );}} @media screen and (max-width:710px){.cff-plugin-logo-promote{display:none;}}</style>
386
+ <div id="cff-upgrade-frame" style="border:1px solid #F0AD4E;background:#FBE6CA;padding:10px;color:#3c434a;">
387
+ <a href="https://cff.dwbooster.com/download" target="_blank" style="text-decoration:none;float:left;" class="cff-plugin-logo-promote"><img src="https://ps.w.org/calculated-fields-form/assets/icon-256x256.jpg" style="width:160px;border:2px solid white;margin-right:10px;margin-bottom:10px;"></a>
388
+ <div style="float:left;" class="cff-plugin-promote">
389
+ <div style="font-weight:500;font-size:20px;line-height:28px;"><?php _e( 'The following features are available in the commercial version of the <a href="https://cff.dwbooster.com/download" target="_blank" style="text-decoration:none;">"Calculated Fields Form"</a>', 'calculated-fields-form' ); // phpcs:ignore WordPress.Security.EscapeOutput ?></div>
390
+ <div style="text-transform: uppercase; font-weight:700; font-size:24px;margin-top:15px;margin-bottom:15px;line-height:28px;"><a href="https://cff.dwbooster.com/download" target="_blank" style="text-decoration:none;color:#3c434a;text-shadow:1px 1px 2px white;"><?php esc_html_e( 'Pay only ONCE, use it FOREVER', 'calculated-fields-form' ); ?></a></div>
391
+ <div style="font-size:18px; font-weight:400;line-height:28px;">No additional charges, <span style="background:white;display:inline-block;padding:0 5px;"><a href="https://cff.dwbooster.com/terms" target="_blank" style="text-decoration:none;">lifetime updates</a></span>, one copy for all your websites.</div>
392
+ <div style="font-size:16px; font-weight:400; font-style: italic;">And you get notification emails, payment gateways integration, data and forms exportation, advanced operations and more...</div>
393
+ <?php
394
+ print get_option( 'cff-t-t', '<div style="text-align:right; font-size:16px; font-weight:600;margin-top:15px;">To test some of the commercial features of the "Calculated Fields Form" plugin, you can <a class="button-primary" href="admin.php?page=cp_calculated_fields_form&cal=' . CP_CALCULATEDFIELDSF_ID . '&_cpcff_nonce=' . $_cpcff_nonce . '&cff-install-trial=1#cff-upgrade-frame">install the trial version</a></div>' ); // phpcs:ignore WordPress.Security.EscapeOutput
395
+ ?>
396
+ </div>
397
+ <div style="clear:both;"></div>
398
+ </div>
399
+ <h2><?php esc_html_e( 'Form Processing and Payment Settings', 'calculated-fields-form' ); ?>:</h2>
400
+ <hr />
401
+
402
+ <div id="metabox_payment_settings" class="postbox metabox_disabled_section cff-metabox <?php print esc_attr( $cpcff_main->metabox_status( 'metabox_payment_settings' ) ); ?>" style="position:relative;">
403
+ <h3 class='hndle' style="padding:5px;"><span><?php esc_html_e( 'Payment Settings', 'calculated-fields-form' ); ?></span></h3>
404
+ <div class="inside">
405
+
406
+ <table class="form-table">
407
+ <tr valign="top">
408
+ <th scope="row"><?php esc_html_e( 'Request cost', 'calculated-fields-form' ); ?></th>
409
+ <td><select name="request_cost" id="request_cost" class="width75"></select></td>
410
+ </tr>
411
+
412
+ <tr valign="top">
413
+ <th scope="row"><?php esc_html_e( 'Currency', 'calculated-fields-form' ); ?></th>
414
+ <td><input type="text" name="currency" value="<?php echo esc_attr( $form_obj->get_option( 'currency', CP_CALCULATEDFIELDSF_DEFAULT_CURRENCY ) ); ?>" /><br>
415
+ <b>USD</b> (<?php esc_html_e( 'United States dollar', 'calculated-fields-form' ); ?>), <b>EUR</b> (Euro), <b>GBP</b> (<?php esc_html_e( 'Pound sterling', 'calculated-fields-form' ); ?>), ... (<a href="https://developer.paypal.com/docs/api/reference/currency-codes/" target="_blank"><?php esc_html_e( 'PayPal Currency Codes', 'calculated-fields-form' ); ?></a>)
416
+ </td>
417
+ </tr>
418
+
419
+ <tr valign="top">
420
+ <th scope="row"><?php esc_html_e( 'Base amount', 'calculated-fields-form' ); ?>:</th>
421
+ <td><input type="text" name="paypal_base_amount" value="<?php echo esc_attr( $form_obj->get_option( 'paypal_base_amount', '0.01' ) ); ?>" /><br><i style="font-size:11px;"><?php esc_html_e( 'Minimum amount to charge. If the final price is lesser than this number, the base amount will be applied.', 'calculated-fields-form' ); ?></i>
422
+ </td>
423
+ </tr>
424
+
425
+ <tr valign="top">
426
+ <th scope="row"><?php esc_html_e( 'Paypal product name', 'calculated-fields-form' ); ?></th>
427
+ <td><input type="text" name="paypal_product_name" class="width75" value="<?php echo esc_attr( $form_obj->get_option( 'paypal_product_name', CP_CALCULATEDFIELDSF_DEFAULT_PRODUCT_NAME ) ); ?>" /></td>
428
+ </tr>
429
+
430
+ <tr valign="top">
431
+ <th scope="row"><?php esc_html_e( 'Discount Codes', 'calculated-fields-form' ); ?></th>
432
+ <td>
433
+ <div id="dex_nocodes_availmsg"><?php esc_html_e( 'This feature isn\'t available in this version.', 'calculated-fields-form' ); ?></div>
434
+
435
+ <br />
436
+ <strong><?php esc_html_e( 'Add new discount code', 'calculated-fields-form' ); ?>:</strong>
437
+ <br />
438
+ <nobr><?php esc_html_e( 'Code', 'calculated-fields-form' ); ?>: <input type="text" name="dex_dc_code" id="dex_dc_code" value="" /></nobr> &nbsp; &nbsp; &nbsp;
439
+ <nobr><?php esc_html_e( 'Discount', 'calculated-fields-form' ); ?>: <input type="text" size="3" name="dex_dc_discount" id="dex_dc_discount" value="25" /><select name="dex_dc_discounttype" id="dex_dc_discounttype">
440
+ <option value="0"><?php esc_html_e( 'Percent', 'calculated-fields-form' ); ?></option>
441
+ <option value="1"><?php esc_html_e( 'Fixed Value', 'calculated-fields-form' ); ?></option>
442
+ </select></nobr>
443
+ &nbsp; &nbsp;
444
+ <nobr><?php esc_html_e( 'Valid until', 'calculated-fields-form' ); ?>: <input type="text" size="10" name="dex_dc_expires" id="dex_dc_expires" value="" /></nobr>&nbsp; &nbsp; &nbsp;
445
+ <input type="button" name="dex_dc_subccode" id="dex_dc_subccode" value="<?php esc_attr_e( 'Add', 'calculated-fields-form' ); ?>" onclick="alert('This feature ins\'t available in this version');" class="button-secondary" />
446
+ <br />
447
+ <em style="font-size:11px;"><?php esc_html_e( 'Note: Expiration date based in server time. Server time now is', 'calculated-fields-form' ); ?> <?php echo esc_html( gmdate( 'Y-m-d H:i' ) ); ?></em>
448
  </td>
449
+ </tr>
450
+ </table>
451
+ <div class="cff-goto-top"><a href="#cpformconf"><?php esc_html_e( 'Up to form structure', 'calculated-fields-form' ); ?></a></div>
452
+ </div>
453
+ </div>
454
+
455
+ <div id="metabox_paypal_integration" class="postbox metabox_disabled_section cff-metabox <?php print esc_attr( $cpcff_main->metabox_status( 'metabox_paypal_integration' ) ); ?>">
456
+ <h3 class='hndle' style="padding:5px;"><span><?php esc_html_e( 'Paypal Payment Configuration', 'calculated-fields-form' ); ?></span></h3>
457
+ <div class="inside">
458
+
459
+ <table class="form-table">
460
+ <tr valign="top">
461
+ <th scope="row"><?php esc_html_e( 'Enable Paypal Payments?', 'calculated-fields-form' ); ?></th>
462
+ <td><select name="enable_paypal">
463
+ <option value="0"><?php esc_html_e( 'No', 'calculated-fields-form' ); ?></option>
464
+ </select>
465
+ <br /><i style="font-size:11px;"><?php esc_html_e( 'Note: If "Optional" is selected, a radiobutton will appear in the form to select if the payment will be made with PayPal or not.', 'calculated-fields-form' ); ?></i>
466
+ <div id="cff_paypal_options_label" style="margin-top:10px;background:#EEF5FB;border: 1px dotted #888888;padding:10px;width:260px;">
467
+ <?php _e( 'Label for the "<strong>Pay with PayPal</strong>" option', 'calculated-fields-form' ); // phpcs:ignore WordPress.Security.EscapeOutput ?>:<br />
468
+ <input type="text" size="40" style="width:250px;" />
469
+ </div></td>
470
+ </tr>
471
+
472
+ <tr valign="top">
473
+ <th scope="row"><?php esc_html_e( 'Paypal Mode', 'calculated-fields-form' ); ?></th>
474
+ <td><select name="paypal_mode" class="width75">
475
+ <option value="production" <?php if ( 'sandbox' != $form_obj->get_option( 'paypal_mode', CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_MODE ) ) {
476
+ echo 'selected';} ?>><?php esc_html_e( 'Production - real payments processed', 'calculated-fields-form' ); ?></option>
477
+ <option value="sandbox" <?php if ( 'sandbox' == $form_obj->get_option( 'paypal_mode', CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_MODE ) ) {
478
+ echo 'selected';} ?>><?php esc_html_e( 'SandBox - PayPal testing sandbox area', 'calculated-fields-form' ); ?></option>
479
+ </select>
480
+ </td>
481
+ </tr>
482
+
483
+ <tr valign="top">
484
+ <th scope="row"><?php esc_html_e( 'Paypal email', 'calculated-fields-form' ); ?></th>
485
+ <td><input type="text" name="paypal_email" class="width75" value="<?php echo esc_attr( $form_obj->get_option( 'paypal_email', CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_EMAIL ) ); ?>" /></td>
486
+ </tr>
487
+
488
+ <tr valign="top">
489
+ <th scope="row"><?php esc_html_e( 'A $0 amount to pay means', 'calculated-fields-form' ); ?>:</th>
490
+ <td><select name="paypal_zero_payment" class="width75">
491
+ <option value="0" <?php if ( '1' != $form_obj->get_option( 'paypal_zero_payment', CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_ZERO_PAYMENT ) ) {
492
+ echo 'selected';} ?>><?php esc_html_e( 'Let the user enter any amount at PayPal (ex: for a donation)', 'calculated-fields-form' ); ?></option>
493
+ <option value="1" <?php if ( $form_obj->get_option( 'paypal_zero_payment', '1' == CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_ZERO_PAYMENT ) ) {
494
+ echo 'selected';} ?>><?php esc_html_e( 'Don\'t require any payment. Form is submitted skiping the PayPal page.', 'calculated-fields-form' ); ?></option>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
495
  </select>
496
  </td>
497
+ </tr>
498
+
499
+ <tr valign="top">
500
+ <th scope="row"><?php esc_html_e( 'Paypal language', 'calculated-fields-form' ); ?></th>
501
+ <td><input type="text" name="paypal_language" value="<?php echo esc_attr( $form_obj->get_option( 'paypal_language', CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_LANGUAGE ) ); ?>" /></td>
502
+ </tr>
503
+
504
+ <tr valign="top">
505
+ <th scope="row"><?php esc_html_e( 'Payment frequency', 'calculated-fields-form' ); ?></th>
506
+ <td><select name="paypal_recurrent" class="width75">
507
+ <option value="0" <?php if ( '0' == $form_obj->get_option( 'paypal_recurrent', CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_RECURRENT ) ||
508
+ '' == $form_obj->get_option( 'paypal_recurrent', CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_RECURRENT )
509
+ ) {
510
+ echo 'selected';} ?>><?php esc_html_e( 'One time payment (default option, user is billed only once)', 'calculated-fields-form' ); ?></option>
511
+ <option value="1" <?php if ( '1' == $form_obj->get_option( 'paypal_recurrent', CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_RECURRENT ) ) {
512
+ echo 'selected';} ?>><?php esc_html_e( 'Bill the user every 1 month', 'calculated-fields-form' ); ?></option>
513
+ <option value="3" <?php if ( '3' == $form_obj->get_option( 'paypal_recurrent', CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_RECURRENT ) ) {
514
+ echo 'selected';} ?>><?php esc_html_e( 'Bill the user every 3 months', 'calculated-fields-form' ); ?></option>
515
+ <option value="6" <?php if ( '6' == $form_obj->get_option( 'paypal_recurrent', CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_RECURRENT ) ) {
516
+ echo 'selected';} ?>><?php esc_html_e( 'Bill the user every 6 months', 'calculated-fields-form' ); ?></option>
517
+ <option value="12" <?php if ( '12' == $form_obj->get_option( 'paypal_recurrent', CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_RECURRENT ) ) {
518
+ echo 'selected';} ?>><?php esc_html_e( 'Bill the user every 12 months', 'calculated-fields-form' ); ?></option>
519
+ </select>
520
+ </td>
521
+ </tr>
522
+ <tr valign="top">
523
+ <th scope="row"><?php esc_html_e( 'Paypal prompt buyers for shipping address', 'calculated-fields-form' ); ?></th>
524
+ <td>
525
+ <?php $paypal_address = $form_obj->get_option( 'paypal_address', 1 ); ?>
526
+ <select name="paypal_address" class="width75">
527
+ <option value="1" <?php if ( 1 == $paypal_address ) {
528
+ print 'SELECTED';} ?>><?php esc_html_e( 'Do not prompt for an address', 'calculated-fields-form' ); ?></option>
529
+ <option value="0" <?php if ( 0 == $paypal_address ) {
530
+ print 'SELECTED';} ?>><?php esc_html_e( 'Prompt for an address, but do not require one', 'calculated-fields-form' ); ?></option>
531
+ <option value="2" <?php if ( 2 == $paypal_address ) {
532
+ print 'SELECTED';} ?>><?php esc_html_e( 'Prompt for an address and require one', 'calculated-fields-form' ); ?></option>
533
+ </select>
534
+ </td>
535
+ </tr>
536
+ </table>
537
+ <div class="cff-goto-top"><a href="#cpformconf"><?php esc_html_e( 'Up to form structure', 'calculated-fields-form' ); ?></a></div>
538
+ </div>
539
+ </div>
540
+
541
+ <div id="metabox_notification_email" class="postbox metabox_disabled_section cff-metabox <?php print esc_attr( $cpcff_main->metabox_status( 'metabox_notification_email' ) ); ?>" >
542
+ <h3 class='hndle' style="padding:5px;"><span><?php esc_html_e( 'Form Processing / Email Settings', 'calculated-fields-form' ); ?></span></h3>
543
+ <div class="inside">
544
+ <table class="form-table">
545
+ <tr valign="top">
546
+ <th scope="row"><?php esc_html_e( '"From" email', 'calculated-fields-form' ); ?></th>
547
+ <td><input type="text" name="fp_from_email" class="width75" value="<?php echo esc_attr( $form_obj->get_option( 'fp_from_email', CP_CALCULATEDFIELDSF_DEFAULT_fp_from_email ) ); ?>" /><br><b><em style="font-size:11px;">Ex: admin@<?php echo esc_html( isset( $_SERVER['HTTP_HOST'] ) ? str_replace( 'www.', '', sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) ) ) : '' ); ?></em></b><br><em style="font-size:11px;"><?php esc_html_e( 'This email is required if the "From fixed email address" option is selected, or it is enabled the email copy to the user.', 'calculated-fields-form' ); ?></em></td>
548
+ </tr>
549
+ <tr valign="top">
550
+ <th scope="row"><?php esc_html_e( 'Destination emails (comma separated)', 'calculated-fields-form' ); ?></th>
551
+ <td><input type="text" name="fp_destination_emails" class="width75" value="<?php echo esc_attr( $form_obj->get_option( 'fp_destination_emails', CP_CALCULATEDFIELDSF_DEFAULT_fp_destination_emails ) ); ?>" /></td>
552
+ </tr>
553
+ <tr valign="top">
554
+ <th scope="row"><?php esc_html_e( 'Email subject', 'calculated-fields-form' ); ?></th>
555
+ <td><input type="text" name="fp_subject" class="width75" value="<?php echo esc_attr( $form_obj->get_option( 'fp_subject', CP_CALCULATEDFIELDSF_DEFAULT_fp_subject ) ); ?>" /></td>
556
+ </tr>
557
+ <tr valign="top">
558
+ <th scope="row"><?php esc_html_e( 'Include additional information?', 'calculated-fields-form' ); ?></th>
559
+ <td>
560
+ <?php $option = $form_obj->get_option( 'fp_inc_additional_info', CP_CALCULATEDFIELDSF_DEFAULT_fp_inc_additional_info ); ?>
561
+ <select name="fp_inc_additional_info">
562
+ <option value="true"<?php if ( 'true' == $option ) {
563
+ echo ' selected';} ?>><?php esc_html_e( 'Yes', 'calculated-fields-form' ); ?></option>
564
+ <option value="false"<?php if ( 'false' == $option ) {
565
+ echo ' selected';} ?>><?php esc_html_e( 'No', 'calculated-fields-form' ); ?></option>
566
+ </select>&nbsp;<em style="font-size:11px;"><?php esc_html_e( 'If the "No" option is selected the plugin won\'t capture the IP address of users.', 'calculated-fields-form' ); ?></em>
567
+ </td>
568
+ </tr>
569
+ <tr valign="top">
570
+ <th scope="row"><?php esc_html_e( 'Thank you page (after sending the message)', 'calculated-fields-form' ); ?></th>
571
+ <td><input type="text" name="fp_return_page" class="width75" value="<?php echo esc_attr( $form_obj->get_option( 'fp_return_page', CP_CALCULATEDFIELDSF_DEFAULT_fp_return_page ) ); ?>" /></td>
572
+ </tr>
573
+ <tr valign="top">
574
+ <th scope="row"><?php esc_html_e( 'Email format?', 'calculated-fields-form' ); ?></th>
575
+ <td>
576
+ <?php $option = $form_obj->get_option( 'fp_emailformat', CP_CALCULATEDFIELDSF_DEFAULT_email_format ); ?>
577
+ <select name="fp_emailformat" class="width75">
578
+ <option value="text"<?php if ( 'html' != $option ) {
579
+ echo ' selected';} ?>><?php esc_html_e( 'Plain Text (default)', 'calculated-fields-form' ); ?></option>
580
+ <option value="html"<?php if ( 'html' == $option ) {
581
+ echo ' selected';} ?>><?php esc_html_e( 'HTML (use html in the textarea below)', 'calculated-fields-form' ); ?></option>
582
+ </select>
583
+ </td>
584
+ </tr>
585
+ <tr valign="top">
586
+ <th scope="row"><?php esc_html_e( 'Message', 'calculated-fields-form' ); ?></th>
587
+ <td><textarea type="text" name="fp_message" rows="6" class="width75"><?php echo esc_textarea( $form_obj->get_option( 'fp_message', CP_CALCULATEDFIELDSF_DEFAULT_fp_message ) ); ?></textarea></td>
588
+ </tr>
589
+ </table>
590
+ <div class="cff-goto-top"><a href="#cpformconf"><?php esc_html_e( 'Up to form structure', 'calculated-fields-form' ); ?></a></div>
591
+ </div>
592
+ </div>
593
+
594
+
595
+ <div id="metabox_email_copy_to_user" class="postbox metabox_disabled_section cff-metabox <?php print esc_attr( $cpcff_main->metabox_status( 'metabox_email_copy_to_user' ) ); ?>" >
596
+ <h3 class='hndle' style="padding:5px;"><span><?php esc_html_e( 'Email Copy to User', 'calculated-fields-form' ); ?></span></h3>
597
+ <div class="inside">
598
+ <table class="form-table">
599
+ <tr valign="top">
600
+ <th scope="row"><?php esc_html_e( 'Send confirmation/thank you message to user?', 'calculated-fields-form' ); ?></th>
601
+ <td>
602
+ <?php $option = $form_obj->get_option( 'cu_enable_copy_to_user', CP_CALCULATEDFIELDSF_DEFAULT_cu_enable_copy_to_user ); ?>
603
+ <select name="cu_enable_copy_to_user">
604
+ <option value="true"<?php if ( 'true' == $option ) {
605
+ echo ' selected';} ?>><?php esc_html_e( 'Yes', 'calculated-fields-form' ); ?></option>
606
+ <option value="false"<?php if ( 'false' == $option ) {
607
+ echo ' selected';} ?>><?php esc_html_e( 'No', 'calculated-fields-form' ); ?></option>
608
+ </select>
609
+ </td>
610
+ </tr>
611
+ <tr valign="top">
612
+ <th scope="row"><?php esc_html_e( 'Email field on the form', 'calculated-fields-form' ); ?></th>
613
+ <td><select id="cu_user_email_field" name="cu_user_email_field" def="<?php echo esc_attr( $form_obj->get_option( 'cu_user_email_field', CP_CALCULATEDFIELDSF_DEFAULT_cu_user_email_field ) ); ?>" class="width75"></select></td>
614
+ </tr>
615
+ <tr valign="top">
616
+ <th scope="row"><?php esc_html_e( 'Email subject', 'calculated-fields-form' ); ?></th>
617
+ <td><input type="text" name="cu_subject" class="width75" value="<?php echo esc_attr( $form_obj->get_option( 'cu_subject', CP_CALCULATEDFIELDSF_DEFAULT_cu_subject ) ); ?>" /></td>
618
+ </tr>
619
+ <tr valign="top">
620
+ <th scope="row"><?php esc_html_e( 'Email format?', 'calculated-fields-form' ); ?></th>
621
+ <td>
622
+ <?php $option = $form_obj->get_option( 'cu_emailformat', CP_CALCULATEDFIELDSF_DEFAULT_email_format ); ?>
623
+ <select name="cu_emailformat" class="width75">
624
+ <option value="text"<?php if ( 'html' != $option ) {
625
+ echo ' selected';} ?>><?php esc_html_e( 'Plain Text (default)', 'calculated-fields-form' ); ?></option>
626
+ <option value="html"<?php if ( 'html' == $option ) {
627
+ echo ' selected';} ?>><?php esc_html_e( 'HTML (use html in the textarea below)', 'calculated-fields-form' ); ?></option>
628
+ </select>
629
+ </td>
630
+ </tr>
631
+ <tr valign="top">
632
+ <th scope="row"><?php esc_html_e( 'Message', 'calculated-fields-form' ); ?></th>
633
+ <td><textarea type="text" name="cu_message" rows="6" class="width75"><?php echo esc_textarea( $form_obj->get_option( 'cu_message', CP_CALCULATEDFIELDSF_DEFAULT_cu_message ) ); ?></textarea></td>
634
+ </tr>
635
+ </table>
636
+ <div class="cff-goto-top"><a href="#cpformconf"><?php esc_html_e( 'Up to form structure', 'calculated-fields-form' ); ?></a></div>
637
+ </div>
638
+ </div>
639
+
640
+ <div id="metabox_captcha_settings" class="postbox metabox_disabled_section cff-metabox <?php print esc_attr( $cpcff_main->metabox_status( 'metabox_captcha_settings' ) ); ?>" >
641
+ <h3 class='hndle' style="padding:5px;"><span><?php esc_html_e( 'Captcha Verification', 'calculated-fields-form' ); ?></span></h3>
642
+ <div class="inside">
643
+ <table class="form-table">
644
+ <tr valign="top">
645
+ <th scope="row"><?php esc_html_e( 'Use Captcha Verification?', 'calculated-fields-form' ); ?></th>
646
+ <td colspan="5">
647
+ <?php $option = $form_obj->get_option( 'cv_enable_captcha', CP_CALCULATEDFIELDSF_DEFAULT_cv_enable_captcha ); ?>
648
+ <select name="cv_enable_captcha">
649
+ <option value="true"<?php if ( 'true' == $option ) {
650
+ echo ' selected';} ?>><?php esc_html_e( 'Yes', 'calculated-fields-form' ); ?></option>
651
+ <option value="false"<?php if ( 'false' == $option ) {
652
+ echo ' selected';} ?>><?php esc_html_e( 'No', 'calculated-fields-form' ); ?></option>
653
+ </select>
654
+ </td>
655
+ </tr>
656
+
657
+ <tr valign="top">
658
+ <th scope="row"><?php esc_html_e( 'Width', 'calculated-fields-form' ); ?>:</th>
659
+ <td><input type="text" readonly=readonly name="cv_width" size="10" value="<?php echo esc_attr( $form_obj->get_option( 'cv_width', CP_CALCULATEDFIELDSF_DEFAULT_cv_width ) ); ?>" onblur="generateCaptcha();" /></td>
660
+ <th scope="row"><?php esc_html_e( 'Height', 'calculated-fields-form' ); ?>:</th>
661
+ <td><input type="text" readonly=readonly name="cv_height" size="10" value="<?php echo esc_attr( $form_obj->get_option( 'cv_height', CP_CALCULATEDFIELDSF_DEFAULT_cv_height ) ); ?>" onblur="generateCaptcha();" /></td>
662
+ <th scope="row"><?php esc_html_e( 'Chars', 'calculated-fields-form' ); ?>:</th>
663
+ <td><input type="text" readonly=readonly name="cv_chars" size="10" value="<?php echo esc_attr( $form_obj->get_option( 'cv_chars', CP_CALCULATEDFIELDSF_DEFAULT_cv_chars ) ); ?>" onblur="generateCaptcha();" /></td>
664
+ </tr>
665
+
666
+ <tr valign="top">
667
+ <th scope="row"><?php esc_html_e( 'Min font size', 'calculated-fields-form' ); ?>:</th>
668
+ <td><input type="text" readonly=readonly name="cv_min_font_size" size="10" value="<?php echo esc_attr( $form_obj->get_option( 'cv_min_font_size', CP_CALCULATEDFIELDSF_DEFAULT_cv_min_font_size ) ); ?>" onblur="generateCaptcha();" /></td>
669
+ <th scope="row"><?php esc_html_e( 'Max font size', 'calculated-fields-form' ); ?>:</th>
670
+ <td><input type="text" readonly=readonly name="cv_max_font_size" size="10" value="<?php echo esc_attr( $form_obj->get_option( 'cv_max_font_size', CP_CALCULATEDFIELDSF_DEFAULT_cv_max_font_size ) ); ?>" onblur="generateCaptcha();" /></td>
671
+ <td colspan="2" rowspan="">
672
+ <?php esc_html_e( 'Preview', 'calculated-fields-form' ); ?>:<br />
673
+ <br />
674
+ <img src="<?php echo esc_url( plugins_url( '/captcha/captcha.php', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ) ); ?>" id="captchaimg" alt="<?php esc_attr_e( 'security code', 'calculated-fields-form' ); ?>" border="0" class="skip-lazy" />
675
+ </td>
676
+ </tr>
677
+
678
+
679
+ <tr valign="top">
680
+ <th scope="row"><?php esc_html_e( 'Noise', 'calculated-fields-form' ); ?>:</th>
681
+ <td><input type="text" readonly=readonly name="cv_noise" size="10" value="<?php echo esc_attr( $form_obj->get_option( 'cv_noise', CP_CALCULATEDFIELDSF_DEFAULT_cv_noise ) ); ?>" onblur="generateCaptcha();" /></td>
682
+ <th scope="row"><?php esc_html_e( 'Noise Length', 'calculated-fields-form' ); ?>:</th>
683
+ <td><input type="text" readonly=readonly name="cv_noise_length" size="10" value="<?php echo esc_attr( $form_obj->get_option( 'cv_noise_length', CP_CALCULATEDFIELDSF_DEFAULT_cv_noise_length ) ); ?>" onblur="generateCaptcha();" /></td>
684
+ </tr>
685
+
686
+ <tr valign="top">
687
+ <th scope="row"><?php esc_html_e( 'Background', 'calculated-fields-form' ); ?>:</th>
688
+ <td><input type="text" readonly=readonly name="cv_background" size="10" value="<?php echo esc_attr( $form_obj->get_option( 'cv_background', CP_CALCULATEDFIELDSF_DEFAULT_cv_background ) ); ?>" onblur="generateCaptcha();" /></td>
689
+ <th scope="row">Border:</th>
690
+ <td><input type="text" readonly=readonly name="cv_border" size="10" value="<?php echo esc_attr( $form_obj->get_option( 'cv_border', CP_CALCULATEDFIELDSF_DEFAULT_cv_border ) ); ?>" onblur="generateCaptcha();" /></td>
691
+ </tr>
692
+
693
+ <tr valign="top">
694
+ <th scope="row"><?php esc_html_e( 'Font', 'calculated-fields-form' ); ?>:</th>
695
+ <td>
696
+ <select name="cv_font" onchange="generateCaptcha();" >
697
+ <option value="font-1.ttf"<?php if ( 'font-1.ttf' == $form_obj->get_option( 'cv_font', CP_CALCULATEDFIELDSF_DEFAULT_cv_font ) ) {
698
+ echo ' selected';} ?>>Font 1</option>
699
+ <option value="font-2.ttf"<?php if ( 'font-2.ttf' == $form_obj->get_option( 'cv_font', CP_CALCULATEDFIELDSF_DEFAULT_cv_font ) ) {
700
+ echo ' selected';} ?>>Font 2</option>
701
+ <option value="font-3.ttf"<?php if ( 'font-3.ttf' == $form_obj->get_option( 'cv_font', CP_CALCULATEDFIELDSF_DEFAULT_cv_font ) ) {
702
+ echo ' selected';} ?>>Font 3</option>
703
+ <option value="font-4.ttf"<?php if ( 'font-4.ttf' == $form_obj->get_option( 'cv_font', CP_CALCULATEDFIELDSF_DEFAULT_cv_font ) ) {
704
+ echo ' selected';} ?>>Font 4</option>
705
+ </select>
706
+ </td>
707
+ </tr>
708
+ </table>
709
+ <div class="cff-goto-top"><a href="#cpformconf"><?php esc_html_e( 'Up to form structure', 'calculated-fields-form' ); ?></a></div>
710
+ </div>
711
+ </div>
712
+ <a id="metabox_addons_section"></a>
713
+ <?php
714
+ do_action( 'cpcff_form_settings', CP_CALCULATEDFIELDSF_ID );
715
+ ?>
716
+ </div>
717
+
718
+
719
+ <p class="submit">
720
+ <input type="submit" name="save" id="save" class="button-primary" value="<?php esc_attr_e( 'Save Changes', 'calculated-fields-form' ); ?>" title="Saves the form's structure and settings" />
721
+ </p>
722
+
723
+ [<a href="https://cff.dwbooster.com/customization" target="_blank"><?php esc_html_e( 'Request Custom Modifications', 'calculated-fields-form' ); ?></a>] | [<a href="https://wordpress.org/support/plugin/calculated-fields-form#new-post" target="_blank"><?php esc_html_e( 'Help', 'calculated-fields-form' ); ?></a>]
724
+ </form>
725
+ </div>
726
+ <script type="text/javascript">
727
+ function generateCaptcha()
728
+ {
729
+ var d=new Date(),
730
+ f = document.cpformconf,
731
+ qs = "?width="+f.cv_width.value;
732
+
733
+ qs += "&height="+f.cv_height.value;
734
+ qs += "&letter_count="+f.cv_chars.value;
735
+ qs += "&min_size="+f.cv_min_font_size.value;
736
+ qs += "&max_size="+f.cv_max_font_size.value;
737
+ qs += "&noise="+f.cv_noise.value;
738
+ qs += "&noiselength="+f.cv_noise_length.value;
739
+ qs += "&bcolor="+f.cv_background.value;
740
+ qs += "&border="+f.cv_border.value;
741
+ qs += "&font="+f.cv_font.options[f.cv_font.selectedIndex].value;
742
+ qs += "&rand="+d;
743
+
744
+ document.getElementById("captchaimg").src= "<?php echo esc_url( plugins_url( '/captcha/captcha.php', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ) ); ?>"+qs;
745
+ }
746
+ generateCaptcha();
747
+ </script>
inc/cpcff_admin_int_list.inc.php CHANGED
@@ -1,449 +1,440 @@
1
- <?php
2
- if ( !is_admin() )
3
- {
4
- print 'Direct access not allowed.';
5
- exit;
6
- }
7
-
8
- $_GET['u'] = (isset($_GET['u'])) ? intval(@$_GET['u']) : 0;
9
- $_GET['c'] = (isset($_GET['c'])) ? intval(@$_GET['c']) : 0;
10
- $_GET['d'] = (isset($_GET['d'])) ? intval(@$_GET['d']) : 0;
11
-
12
- global $wpdb;
13
- $cpcff_main = CPCFF_MAIN::instance();
14
-
15
- $message = "";
16
-
17
- if(isset($_GET['orderby']))
18
- {
19
- update_option('CP_CALCULATEDFIELDSF_FORMS_LIST_ORDERBY', $_GET['orderby'] == 'form_name' ? 'form_name' : 'id');
20
- }
21
-
22
- $cp_default_template = CP_CALCULATEDFIELDSF_DEFAULT_template;
23
-
24
- if( isset($_REQUEST['cp_default_template']) )
25
- {
26
- check_admin_referer( 'cff-default-settings', '_cpcff_nonce' );
27
-
28
- $cp_default_template = sanitize_text_field($_REQUEST['cp_default_template']);
29
-
30
- // Update default settings
31
- update_option('CP_CALCULATEDFIELDSF_DEFAULT_template', $cp_default_template);
32
-
33
- if(isset($_REQUEST['cp_default_existing_forms']))
34
- {
35
- $myrows = $wpdb->get_results( "SELECT id,form_structure,enable_submit,cv_enable_captcha FROM ".$wpdb->prefix.CP_CALCULATEDFIELDSF_FORMS_TABLE);
36
- foreach ($myrows as $item)
37
- {
38
- $form_structure = preg_replace('/"formtemplate"\s*\:\s*"[^"]*"/', '"formtemplate":"'.esc_js($cp_default_template).'"', $item->form_structure);
39
-
40
- $wpdb->update(
41
- $wpdb->prefix.CP_CALCULATEDFIELDSF_FORMS_TABLE,
42
- array(
43
- 'form_structure' => $form_structure
44
- ),
45
- array(
46
- 'id' => $item->id
47
- ),
48
- array('%s'),
49
- array('%d')
50
- );
51
- }
52
- }
53
- $message = __( "Default settings updated", 'calculated-fields-form' );;
54
- }
55
-
56
- if (isset($_GET['a']) && $_GET['a'] == '1')
57
- {
58
- check_admin_referer( 'cff-add-form', '_cpcff_nonce' );
59
- $new_form = $cpcff_main->create_form(
60
- isset($_GET["name"]) ? sanitize_text_field(stripcslashes($_GET["name"])) : '',
61
- isset($_GET["category"]) ? sanitize_text_field(stripcslashes($_GET["category"])) : '',
62
- isset($_GET['ftpl']) ? sanitize_text_field(wp_unslash($_GET['ftpl'])) : 0
63
- );
64
- // Update the default category
65
- $cff_current_form_category = get_option('calculated-fields-form-category', '');
66
- if(!empty($cff_current_form_category))
67
- update_option('calculated-fields-form-category', sanitize_text_field(stripcslashes($_GET["category"])));
68
-
69
- $message = __( "Item added", 'calculated-fields-form' );
70
- if($new_form)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  {
72
- print "<script>document.location = 'admin.php?page=cp_calculated_fields_form&cal=".$new_form->get_id()."&r=".rand()."&_cpcff_nonce=".wp_create_nonce( 'cff-form-settings' )."';</script>";
73
  }
74
- }
75
- else if (!empty($_GET['u']))
76
- {
77
- check_admin_referer( 'cff-update-form', '_cpcff_nonce' );
78
- $cpcff_main->get_form($_GET['u'])->update_name((isset($_GET["name"])) ? sanitize_text_field(stripcslashes($_GET["name"])) : '');
79
- $message = __( "Item updated", 'calculated-fields-form' );
80
- }
81
- else if (!empty($_GET['d']))
82
- {
83
- check_admin_referer( 'cff-delete-form', '_cpcff_nonce' );
84
- $cpcff_main->delete_form($_GET['d']);
85
- $message = __( "Item deleted", 'calculated-fields-form' );
86
- } else if (!empty($_GET['c']))
87
- {
88
- check_admin_referer( 'cff-clone-form', '_cpcff_nonce' );
89
- if($cpcff_main->clone_form(@intval($_GET['c'])) !== false) $message = __( "Item duplicated/cloned", 'calculated-fields-form' );
90
- else $message = __( "Duplicate/Clone Error, the form cannot be cloned", 'calculated-fields-form' );
91
- } else if (isset($_GET['ac']) && $_GET['ac'] == 'st')
92
- {
93
- check_admin_referer( 'cff-update-general-settings', '_cpcff_nonce' );
94
- update_option( 'CP_CFF_LOAD_SCRIPTS', (isset($_GET["scr"]) && $_GET["scr"]=="1"? "0":"1") );
95
- update_option( 'CP_CALCULATEDFIELDSF_DISABLE_REVISIONS',(isset($_GET["dr"]) && $_GET["dr"]=="1" ? 1 : 0) );
96
- update_option( 'CP_CALCULATEDFIELDSF_USE_CACHE', (isset($_GET["jsc"]) && $_GET["jsc"]=="1" ? 1 : 0) );
97
- update_option( 'CP_CALCULATEDFIELDSF_OPTIMIZATION_PLUGIN',(isset($_GET["optm"]) && $_GET["optm"]=="1" ? 1 : 0) );
98
- update_option( 'CP_CALCULATEDFIELDSF_EXCLUDE_CRAWLERS', (isset($_GET["ecr"]) && $_GET["ecr"]=="1" ? 1 : 0) );
99
- update_option( 'CP_CALCULATEDFIELDSF_DIRECT_FORM_ACCESS',(isset($_GET["df"]) && $_GET["df"]=="1" ? 1 : 0) );
100
- update_option( 'CP_CALCULATEDFIELDSF_AMP', (isset($_GET["amp"]) && $_GET["amp"]=="1" ? 1 : 0) );
101
-
102
- $public_js_path = CP_CALCULATEDFIELDSF_BASE_PATH.'/js/cache/all.js';
103
- try{
104
- if( get_option( 'CP_CALCULATEDFIELDSF_USE_CACHE', CP_CALCULATEDFIELDSF_USE_CACHE ) == false )
105
- {
106
- if( file_exists( $public_js_path ) )
107
- {
108
- unlink( $public_js_path );
109
- }
110
- }
111
- else
112
  {
113
- if(!file_exists($public_js_path))
114
- {
115
- wp_remote_get(CPCFF_AUXILIARY::wp_url().((strpos(CPCFF_AUXILIARY::wp_url(),'?') === false) ? '/?' : '&').'cp_cff_resources=public&min=1', array('sslverify' => false));
116
- }
117
  }
118
- }catch( Exception $err ){}
119
-
120
- if (!empty($_GET["chs"]))
121
- {
122
- $target_charset = $_GET["chs"];
123
- if( !in_array($target_charset, array('utf8_general_ci', 'utf8mb4_general_ci', 'latin1_swedish_ci')) ) $target_charset = 'utf8_general_ci';
124
-
125
- $tables = array( $wpdb->prefix.CP_CALCULATEDFIELDSF_FORMS_TABLE, $wpdb->prefix.CP_CALCULATEDFIELDSF_POSTS_TABLE_NAME_NO_PREFIX );
126
- foreach ($tables as $tab)
127
- {
128
- $myrows = $wpdb->get_results( "DESCRIBE {$tab}" );
129
- foreach ($myrows as $item)
130
- {
131
- $name = $item->Field;
132
- $type = $item->Type;
133
- if (preg_match("/^varchar\((\d+)\)$/i", $type, $mat) || !strcasecmp($type, "CHAR") || !strcasecmp($type, "TEXT") || !strcasecmp($type, "MEDIUMTEXT"))
134
- {
135
- $wpdb->query("ALTER TABLE {$tab} CHANGE {$name} {$name} {$type} COLLATE {$target_charset}");
136
- }
137
- }
138
- }
139
- }
140
- $message = __( "Troubleshoot settings updated", 'calculated-fields-form' );
141
- }
142
-
143
- $orderby = get_option('CP_CALCULATEDFIELDSF_FORMS_LIST_ORDERBY', 'id'); // For sortin the forms list
144
- if ($message) echo "<div id='setting-error-settings_updated' class='".( stripos($message, 'error') !== false ? "error" : "updated")." settings-error'><p><strong>".$message."</strong></p></div>";
145
-
146
- ?>
147
- <div class="wrap">
148
- <?php
149
- if(get_option('cff-t-f', 0)):
150
- ?>
151
- <div style="border:1px solid #F0AD4E;background:#FBE6CA;padding:10px;margin:10px 0;font-size:1.3em;">
152
- <?php print get_option('cff-t-t', '');?>
153
- </div>
154
- <?php
155
- delete_option('cff-t-f');
156
- endif;
157
- ?>
158
- <h1><?php _e( 'Calculated Fields Form', 'calculated-fields-form' ); ?></h1>
159
-
160
- <script type="text/javascript">
161
- var cff_metabox_nonce = '<?php print esc_js( wp_create_nonce( 'cff-metabox-status' ) ); ?>';
162
- function cp_addItem()
163
- {
164
- var e = jQuery("#cp_itemname"),
165
- form_tag = e.closest('form')[0],
166
- calname = e.val().replace(/^\s*/, '').replace(/^\s*/, '').replace(/\s*$/, ''),
167
- category = document.getElementById("calculated-fields-form-category").value;
168
-
169
- e.val(calname);
170
-
171
- if('reportValidity' in form_tag && !form_tag.reportValidity()) return;
172
-
173
- document.location = 'admin.php?page=cp_calculated_fields_form&a=1&r='+Math.random()+'&name='+encodeURIComponent(calname)+'&category='+encodeURIComponent(category)+'&_cpcff_nonce=<?php echo wp_create_nonce( 'cff-add-form' ); ?>';
174
- }
175
-
176
- function cp_addItem_keyup( e )
177
- {
178
- e.which = e.which || e.keyCode;
179
- if(e.which == 13) cp_addItem();
180
- }
181
-
182
- function cp_updateItem(id)
183
- {
184
- var calname = document.getElementById("calname_"+id).value;
185
- document.location = 'admin.php?page=cp_calculated_fields_form&u='+id+'&r='+Math.random()+'&name='+encodeURIComponent(calname)+'&_cpcff_nonce=<?php echo wp_create_nonce( 'cff-update-form' ); ?>';
186
- }
187
-
188
- function cp_cloneItem(id)
189
- {
190
- document.location = 'admin.php?page=cp_calculated_fields_form&c='+id+'&r='+Math.random()+'&_cpcff_nonce=<?php echo wp_create_nonce( 'cff-clone-form' ); ?>';
191
- }
192
-
193
- function cp_manageSettings(id)
194
- {
195
- document.location = 'admin.php?page=cp_calculated_fields_form&cal='+id+'&r='+Math.random()+'&_cpcff_nonce=<?php echo wp_create_nonce( 'cff-form-settings' ); ?>';
196
- }
197
-
198
- function cp_viewMessages(id)
199
- {
200
- alert('Not available in this version. Check other versions at: '+"\n\n"+'https://cff.dwbooster.com/download');
201
- }
202
-
203
- function cp_BookingsList(id)
204
- {
205
- document.location = 'admin.php?page=cp_calculated_fields_form&cal='+id+'&list=1&r='+Math.random();
206
- }
207
-
208
- function cp_deleteItem(id)
209
- {
210
- if (confirm('<?php _e( 'Are you sure you want to delete this item?', 'calculated-fields-form' ); ?>'))
211
- {
212
- document.location = 'admin.php?page=cp_calculated_fields_form&d='+id+'&r='+Math.random()+'&_cpcff_nonce=<?php echo wp_create_nonce( 'cff-delete-form' ); ?>';
213
- }
214
- }
215
-
216
- function cp_updateConfig()
217
- {
218
- if (confirm('<?php _e( 'Are you sure you want to update these settings?', 'calculated-fields-form' ); ?>'))
219
- {
220
- var scr = document.getElementById("ccscriptload").value,
221
- chs = document.getElementById("cccharsets").value,
222
- dr = (document.getElementById("ccdisablerevisions").checked) ? 1 : 0,
223
- jsc = (document.getElementById("ccjscache").checked) ? 1 : 0,
224
- optm = (document.getElementById("ccoptimizationplugin").checked) ? 1 : 0,
225
- df = (document.getElementById("ccdirectform").checked) ? 1 : 0,
226
- amp = (document.getElementById("ccampform").checked) ? 1 : 0,
227
- ecr = (document.getElementById("ccexcludecrawler").checked) ? 1 : 0;
228
-
229
- document.location = 'admin.php?page=cp_calculated_fields_form&ecr='+ecr+'&ac=st&scr='+scr+'&chs='+chs+'&dr='+dr+'&jsc='+jsc+'&optm='+optm+'&df='+df+'&amp='+amp+'&r='+Math.random()+'&_cpcff_nonce=<?php echo wp_create_nonce( 'cff-update-general-settings' ); ?>';
230
- }
231
- }
232
-
233
- function cp_select_template()
234
- {
235
- jQuery('.cp_template_info').hide();
236
- jQuery('.cp_template_'+jQuery('#cp_default_template').val()).show();
237
- }
238
-
239
- function cp_update_default_settings(e)
240
- {
241
- if(jQuery('[name="cp_default_existing_forms"]').prop('checked'))
242
- {
243
- if (confirm('<?php _e( 'Are you sure you want to modify existing forms?\\nWe recommend modifying the forms one by one.', 'calculated-fields-form' ); ?>'))
244
- {
245
- e.form.submit();
246
- }
247
- }
248
- else e.form.submit();
249
- }
250
- </script>
251
- <h2 class="nav-tab-wrapper">
252
- <a href="admin.php?page=cp_calculated_fields_form&cff-tab=forms" class="nav-tab <?php if(empty($_GET['cff-tab']) || $_GET['cff-tab'] == 'forms' ) print 'nav-tab-active'; ?>"><?php _e('Forms and Settings', 'calculated-fields-form'); ?></a>
253
- <a href="admin.php?page=cp_calculated_fields_form&cff-tab=marketplace" class="nav-tab <?php if(!empty($_GET['cff-tab']) && $_GET['cff-tab'] == 'marketplace' ) print 'nav-tab-active'; ?>"><?php _e('Marketplace', 'calculated-fields-form'); ?></a>
254
- </h2>
255
- <div style="margin-top:20px;display:<?php print (empty($_GET['cff-tab']) || $_GET['cff-tab'] == 'forms' ) ? 'block' : 'none'; ?>;"><!-- Forms & Settings Section -->
256
- <div id="normal-sortables" class="meta-box-sortables">
257
-
258
- <!-- Form Categories -->
259
- <div id="metabox_categories_list" class="postbox" >
260
- <div class="inside" style="overflow-x:auto;">
261
- <form action="admin.php?page=cp_calculated_fields_form" method="post">
262
- <?php
263
- if(isset($_POST['calculated-fields-form-category']))
264
- {
265
- check_admin_referer( 'cff-change-category', '_cpcff_nonce' );
266
- update_option('calculated-fields-form-category', stripcslashes(sanitize_text_field($_POST['calculated-fields-form-category'])));
267
- }
268
- $cff_current_form_category = get_option('calculated-fields-form-category', '');
269
- ?>
270
- <input type="hidden" name="_cpcff_nonce" value="<?php echo wp_create_nonce( 'cff-change-category' ); ?>" />
271
- <b><?php _e('Form Categories', 'calculated-fields-form'); ?></b>
272
- <select name="calculated-fields-form-category" class="width50" onchange="this.form.submit();">
273
- <option value=""><?php print esc_html(__('All forms', 'calculated-fields-form')); ?></option>
274
- <?php
275
- print $cpcff_main->get_categories('SELECT', $cff_current_form_category);
276
- ?>
277
- </select>
278
- </form>
279
- </div>
280
- </div>
281
-
282
- <!-- Forms List -->
283
- <div id="metabox_form_list" class="postbox" >
284
- <h3 class='hndle' style="padding:5px;"><span><?php
285
- _e( 'Form List / Items List', 'calculated-fields-form' );
286
-
287
- if($cff_current_form_category != '')
288
- {
289
- print '&nbsp;'.__('in', 'calculated-fields-form').'&nbsp;<u>'.$cff_current_form_category.'</u>&nbsp;'.__('category', 'calculated-fields-form');
290
- }
291
- ?></span></h3>
292
- <div class="inside" style="overflow-x:auto;">
293
- <table cellspacing="10" class="cff-custom-table cff-forms-list">
294
- <thead>
295
- <tr>
296
- <th align="left"><a href="?page=cp_calculated_fields_form&orderby=id" <?php if($orderby == 'id') print 'class="cff-active-column"'; ?>><?php _e( 'ID', 'calculated-fields-form' ); ?></a></th>
297
- <th align="left"><a href="?page=cp_calculated_fields_form&orderby=form_name" <?php if($orderby == 'form_name') print 'class="cff-active-column"'; ?>><?php _e( 'Form Name', 'calculated-fields-form' ); ?></a></th>
298
- <th align="center"><?php _e( 'Options', 'calculated-fields-form' ); ?></th>
299
- <th align="left"><?php _e( 'Category/Shortcode', 'calculated-fields-form' ); ?></th>
300
- </tr>
301
- </thead>
302
- <tbody>
303
- <?php
304
- $myrows = $wpdb->get_results( "SELECT * FROM ".$wpdb->prefix.CP_CALCULATEDFIELDSF_FORMS_TABLE.($cff_current_form_category != '' ? $wpdb->prepare(' WHERE category=%s ', $cff_current_form_category) : '')." ORDER BY ".$orderby." ASC" );
305
- foreach ($myrows as $item)
306
- {
307
- ?>
308
- <tr>
309
- <td nowrap><?php echo $item->id; ?></td>
310
- <td nowrap><input type="text" name="calname_<?php echo $item->id; ?>" id="calname_<?php echo $item->id; ?>" value="<?php echo esc_attr($item->form_name); ?>" /></td>
311
- <td nowrap>
312
- <input type="button" name="calupdate_<?php echo $item->id; ?>" value="<?php esc_attr_e( 'Update', 'calculated-fields-form' ); ?>" onclick="cp_updateItem(<?php echo $item->id; ?>);" class="button-secondary" />
313
- <input type="button" name="calmanage_<?php echo $item->id; ?>" value="<?php esc_attr_e( 'Settings', 'calculated-fields-form' ); ?>" onclick="cp_manageSettings(<?php echo $item->id; ?>);" class="button-primary" />
314
- <input type="button" name="calmanage_<?php echo $item->id; ?>" value="<?php esc_attr_e( 'Messages', 'calculated-fields-form' ); ?>" onclick="cp_viewMessages(<?php echo $item->id; ?>);" class="button-secondary" />
315
- <input type="button" name="calclone_<?php echo $item->id; ?>" value="<?php esc_attr_e( 'Clone', 'calculated-fields-form' ); ?>" onclick="cp_cloneItem(<?php echo $item->id; ?>);" class="button-secondary" />
316
- <input type="button" name="caldelete_<?php echo $item->id; ?>" value="<?php esc_attr_e( 'Delete', 'calculated-fields-form' ); ?>" onclick="cp_deleteItem(<?php echo $item->id; ?>);" class="button-secondary" />
317
- </td>
318
- <td><?php if(!empty($item->category)) print __('Category: ', 'calculated-fields-form').'<b>'.esc_html($item->category).'</b><br>'; ?><div style="white-space:nowrap;">[CP_CALCULATED_FIELDS id="<?php echo $item->id; ?>"]</div></td>
319
- </tr>
320
- <?php
321
- }
322
- ?>
323
- </tbody>
324
- </table>
325
- </div>
326
- </div>
327
-
328
- <div id="metabox_new_form_area" class="postbox" >
329
- <h3 class='hndle' style="padding:5px;"><span><?php _e( 'New Form', 'calculated-fields-form' ); ?></span></h3>
330
- <div class="inside">
331
- <form name="additem">
332
- <?php _e( 'Item Name', 'calculated-fields-form' ); ?>(*):<br />
333
- <div>
334
- <input type="text" name="cp_itemname" id="cp_itemname" value="" onkeyup="cp_addItem_keyup( event );" style="margin-top:5px;" required />
335
- <input type="text" name="calculated-fields-form-category" id="calculated-fields-form-category" value="<?php print esc_attr($cff_current_form_category); ?>" style="margin-top:5px;" placeholder="<?php esc_attr_e('Category', 'calculated-fields-form'); ?>" list="calculated-fields-form-categories" />
336
- <datalist id="calculated-fields-form-categories">
337
- <?php
338
- print $cpcff_main->get_categories('DATALIST');
339
- ?>
340
- </datalist>
341
- <input type="button" onclick="cp_addItem();" name="gobtn" value="<?php esc_attr_e( 'Create Form', 'calculated-fields-form' ); ?>" class="button-secondary" style="margin-top:5px;" />
342
- <input type="button" onclick="cff_openLibraryDialog();" name="gobtn" value="<?php esc_attr_e( 'From Template', 'calculated-fields-form' ); ?>" class="button-secondary" style="margin-top:5px;" />
343
- </div>
344
- </form>
345
- </div>
346
- </div>
347
- <i id="default-settings-section"></i>
348
- <div id="metabox_default_settings" class="postbox cff-metabox <?php print esc_attr($cpcff_main->metabox_status( 'metabox_default_settings' ) ); ?>" >
349
- <h3 class='hndle' style="padding:5px;"><span><?php _e( 'Default Settings', 'calculated-fields-form' ); ?></span></h3>
350
- <div class="inside">
351
- <p><?php _e('Applies the default settings to new forms.', 'calculated-fields-form'); ?></p>
352
- <form name="defaultsettings" action="admin.php?page=cp_calculated_fields_form" method="post">
353
- <?php _e( 'Default Template', 'calculated-fields-form' ); ?>:<br />
354
- <?php
355
- require_once CP_CALCULATEDFIELDSF_BASE_PATH.'/inc/cpcff_templates.inc.php';
356
- $templates_list = CPCFF_TEMPLATES::load_templates();
357
- $template_options = '<option value="">Use default template</option>';
358
- $template_information = '';
359
- foreach($templates_list as $template_item)
360
- {
361
- $template_options .= '<option value="'.esc_attr($template_item['prefix']).'" '.($template_item['prefix'] == $cp_default_template ? 'SELECTED' : '').'>'.esc_html($template_item['title']).'</option>';
362
- $template_information .= '<div class="width50 cp_template_info cp_template_'.esc_attr($template_item['prefix']).'" style="text-align:center;padding:10px 0; display:'.($template_item['prefix'] == $cp_default_template ? 'block' : 'none').'; margin:10px 0; border: 1px dashed #CCC;">'.(!empty($template_item['thumbnail']) ? '<img src="'.esc_attr($template_item['thumbnail']).'"><br>' : '').(!empty($template_item['description']) ? esc_html($template_item['description']) : '').'</div>';
363
- }
364
- ?>
365
- <select name="cp_default_template" id="cp_default_template"class="width50" onchange="cp_select_template();"><?php print $template_options; ?></select><br />
366
- <?php print $template_information; ?>
367
- <br /><br />
368
- <div style="border:1px solid #DADADA; padding:10px;" class="width50">
369
- <input type="checkbox" aria-label="<?php esc_attr_e('Apply To Existing Forms', 'calculated-fields-form'); ?>" name="cp_default_existing_forms" /> <?php _e( 'Apply To Existing Forms', 'calculated-fields-form' ); ?> (<i><?php _e('It will modify the settings of existing forms', 'calculated-fields-form'); ?></i>)
370
- </div>
371
- <br />
372
- <input type="button" name="cp_save_default_settings" value="<?php esc_attr_e( 'Update', 'calculated-fields-form' ); ?>" class="button-secondary" onclick="cp_update_default_settings(this);" />
373
- <input type="hidden" name="_cpcff_nonce" value="<?php echo wp_create_nonce( 'cff-default-settings' ); ?>" />
374
- </form>
375
- </div>
376
- </div>
377
- <div style="border:1px solid #F0AD4E;background:#FBE6CA;padding:10px;margin:10px 0;font-size:1.3em;">
378
- <div><?php _e('For additional resources visit the plugin\'s', 'calculated-fields-form')?> <a href="https://cff-bundles.dwbooster.com" target="_blank" style="font-weight:bold;"><?php _e('Marketplace', 'calculated-fields-form'); ?></a></div>
379
- <div class="cff-bundles-plugin"></div>
380
- </div>
381
- <div id="metabox_troubleshoot_area" class="postbox cff-metabox <?php print esc_attr($cpcff_main->metabox_status( 'metabox_troubleshoot_area' ) ); ?>" >
382
- <h3 class='hndle' style="padding:5px;"><span><?php _e( 'Troubleshoot Area & General Settings', 'calculated-fields-form' ); ?></span></h3>
383
- <div class="inside">
384
- <form name="updatesettings">
385
- <div style="border:1px solid #DADADA; padding:10px;">
386
- <p><?php _e( '<strong>Important!</strong>: Use this area <strong>only</strong> if you are experiencing conflicts with third party plugins, with the theme scripts or with the character encoding.', 'calculated-fields-form' ); ?></p>
387
- <?php _e( 'Script load method', 'calculated-fields-form' ); ?>:<br />
388
- <select id="ccscriptload" name="ccscriptload" class="width50">
389
- <option value="0" <?php if (get_option('CP_CFF_LOAD_SCRIPTS',"0") == "1") echo 'selected'; ?>><?php _e( 'Classic (Recommended)', 'calculated-fields-form' ); ?></option>
390
- <option value="1" <?php if (get_option('CP_CFF_LOAD_SCRIPTS',"0") != "1") echo 'selected'; ?>><?php _e( 'Direct', 'calculated-fields-form' ); ?></option>
391
- </select><br />
392
- <em><?php _e( '* Change the script load method if the form doesn\'t appear in the public website.', 'calculated-fields-form' ); ?></em>
393
- <br /><br />
394
- <?php _e( 'Character encoding', 'calculated-fields-form' ); ?>:<br />
395
- <select id="cccharsets" name="cccharsets" class="width50">
396
- <option value=""><?php _e( 'Keep current charset (Recommended)', 'calculated-fields-form' ); ?></option>
397
- <option value="utf8_general_ci">UTF-8 (<?php _e( 'try this first', 'calculated-fields-form' ); ?>)</option>
398
- <option value="utf8mb4_general_ci">UTF-8mb4 (<?php _e( 'Only from MySQL 5.5', 'calculated-fields-form' ); ?>)</option>
399
- <option value="latin1_swedish_ci">latin1_swedish_ci</option>
400
- </select><br />
401
- <em><?php _e( '* Update the charset if you are getting problems displaying special/non-latin characters. After updated you need to edit the special characters again.', 'calculated-fields-form' ); ?></em>
402
- <br /><br />
403
- <?php
404
- $compatibility_warnings = $cpcff_main->compatibility_warnings();
405
- if(!empty($compatibility_warnings))
406
- {
407
- print '<div style="margin:10px 0; border:1px dashed #FF0000; padding:10px; color:red;">'.$compatibility_warnings;
408
- }
409
- _e( "There is active an optimization plugin in WordPress", 'calculated-fields-form' ); ?>:<br />
410
- <input type="checkbox" id="ccoptimizationplugin" name="ccoptimizationplugin" value="1" <?php echo ( get_option( 'CP_CALCULATEDFIELDSF_OPTIMIZATION_PLUGIN', CP_CALCULATEDFIELDSF_OPTIMIZATION_PLUGIN ) ) ? 'CHECKED' : ''; ?> /><em><?php _e('* Tick the checkbox if there is an optimization plugin active on the website, and the forms are not visible.', 'calculated-fields-form'); ?></em>
411
- <?php
412
- if(!empty($compatibility_warnings))
413
- {
414
- print '</div>';
415
- }
416
- ?>
417
- </div>
418
- <br />
419
- <input type="checkbox" name="ccdisablerevisions" id="ccdisablerevisions" <?php echo ( get_option( 'CP_CALCULATEDFIELDSF_DISABLE_REVISIONS', CP_CALCULATEDFIELDSF_DISABLE_REVISIONS ) ) ? 'CHECKED' : ''; ?> /> <?php _e( 'Disable Form Revisions', 'calculated-fields-form' ); ?>
420
- <br /><br />
421
- <input type="checkbox" name="ccjscache" id="ccjscache" <?php echo ( get_option( 'CP_CALCULATEDFIELDSF_USE_CACHE', CP_CALCULATEDFIELDSF_USE_CACHE ) ) ? 'CHECKED' : ''; ?> /> <?php _e( 'Activate Javascript Cache', 'calculated-fields-form' ); ?>
422
- <br /><br />
423
- <input type="checkbox" name="ccdirectform" id="ccdirectform" <?php echo ( get_option( 'CP_CALCULATEDFIELDSF_DIRECT_FORM_ACCESS', CP_CALCULATEDFIELDSF_DIRECT_FORM_ACCESS ) ) ? 'CHECKED' : ''; ?> /> <?php _e( 'Allows to access the forms directly', 'calculated-fields-form' ); ?>
424
- <br /><br />
425
- <input type="checkbox" name="ccampform" id="ccampform" <?php echo ( get_option( 'CP_CALCULATEDFIELDSF_AMP', CP_CALCULATEDFIELDSF_AMP ) ) ? 'CHECKED' : ''; ?> /> <?php _e( 'Allows to access the forms from amp pages', 'calculated-fields-form' ); ?>
426
- <br /><br />
427
- <input type="checkbox" name="ccexcludecrawler" id="ccexcludecrawler" <?php echo ( get_option( 'CP_CALCULATEDFIELDSF_EXCLUDE_CRAWLERS', false ) ) ? 'CHECKED' : ''; ?> /> <?php _e( 'Do not load the forms with crawlers', 'calculated-fields-form' ); ?>
428
- <br /><i><?php _e( '* The forms are not loaded when website is being indexed by searchers.', 'calculated-fields-form' ); ?></i>
429
- <br /><br />
430
- <input type="button" onclick="cp_updateConfig();" name="gobtn" value="<?php esc_attr_e( 'UPDATE', 'calculated-fields-form' ); ?>" class="button-secondary" />
431
- <br />
432
- </form>
433
- </div>
434
- </div>
435
- </div>
436
- </div><!-- End Forms & Settings Section -->
437
- <div style="margin-top:20px;display:<?php print (!empty($_GET['cff-tab']) && $_GET['cff-tab'] == 'marketplace' ) ? 'block' : 'none'; ?>;"><!-- Marketplace Section -->
438
- <div id="metabox_basic_settings" class="postbox" >
439
- <h3 class='hndle' style="padding:5px;"><span><?php _e( 'Calculated Fields Form Marketplace', 'calculated-fields-form' ); ?></span></h3>
440
- <div class="inside">
441
- <div class="cff-marketplace"></div>
442
- </div>
443
- </div>
444
- </div><!-- End Marketplace Section -->
445
- [<a href="https://cff.dwbooster.com/customization" target="_blank"><?php _e( 'Request Custom Modifications', 'calculated-fields-form' ); ?></a>] | [<a href="https://cff.dwbooster.com/download" target="_blank"><?php _e( 'Upgrade', 'calculated-fields-form' ); ?></a>] | [<a href="https://wordpress.org/support/plugin/calculated-fields-form#new-post" target="_blank"><?php _e( 'Help', 'calculated-fields-form' ); ?></a>]
446
- </div>
447
- <script>cff_current_version='free';</script>
448
- <script src="https://cff-bundles.dwbooster.com/plugins/plugins.js?v=<?php print CP_CALCULATEDFIELDSF_VERSION.'_'.date('Y-m-d'); ?>"></script>
449
- <script src="<?php print esc_attr( plugins_url('/vendors/forms.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH).'?v='.CP_CALCULATEDFIELDSF_VERSION.'_'.date('Y-m-d') ); ?>"></script>
1
+ <?php
2
+ if ( ! is_admin() ) {
3
+ print 'Direct access not allowed.';
4
+ exit;
5
+ }
6
+
7
+ $_GET['u'] = ( isset( $_GET['u'] ) ) ? intval( @$_GET['u'] ) : 0;
8
+ $_GET['c'] = ( isset( $_GET['c'] ) ) ? intval( @$_GET['c'] ) : 0;
9
+ $_GET['d'] = ( isset( $_GET['d'] ) ) ? intval( @$_GET['d'] ) : 0;
10
+
11
+ global $wpdb;
12
+ $cpcff_main = CPCFF_MAIN::instance();
13
+
14
+ $message = '';
15
+
16
+ if ( isset( $_GET['orderby'] ) ) {
17
+ update_option( 'CP_CALCULATEDFIELDSF_FORMS_LIST_ORDERBY', 'form_name' == $_GET['orderby'] ? 'form_name' : 'id' );
18
+ }
19
+
20
+ $cp_default_template = CP_CALCULATEDFIELDSF_DEFAULT_template;
21
+
22
+ if ( isset( $_REQUEST['cp_default_template'] ) ) {
23
+ check_admin_referer( 'cff-default-settings', '_cpcff_nonce' );
24
+
25
+ $cp_default_template = sanitize_text_field( wp_unslash( $_REQUEST['cp_default_template'] ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
26
+
27
+ // Update default settings
28
+ update_option( 'CP_CALCULATEDFIELDSF_DEFAULT_template', $cp_default_template );
29
+
30
+ if ( isset( $_REQUEST['cp_default_existing_forms'] ) ) {
31
+ $myrows = $wpdb->get_results( 'SELECT id,form_structure,enable_submit,cv_enable_captcha FROM ' . $wpdb->prefix . CP_CALCULATEDFIELDSF_FORMS_TABLE ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
32
+ foreach ( $myrows as $item ) {
33
+ $form_structure = preg_replace( '/"formtemplate"\s*\:\s*"[^"]*"/', '"formtemplate":"' . esc_js( $cp_default_template ) . '"', $item->form_structure );
34
+
35
+ $wpdb->update(
36
+ $wpdb->prefix . CP_CALCULATEDFIELDSF_FORMS_TABLE,
37
+ array(
38
+ 'form_structure' => $form_structure,
39
+ ),
40
+ array(
41
+ 'id' => $item->id,
42
+ ),
43
+ array( '%s' ),
44
+ array( '%d' )
45
+ );
46
+ }
47
+ }
48
+ $message = __( 'Default settings updated', 'calculated-fields-form' );
49
+
50
+ }
51
+
52
+ if ( isset( $_GET['a'] ) && '1' == $_GET['a'] ) {
53
+ check_admin_referer( 'cff-add-form', '_cpcff_nonce' );
54
+ $new_form = $cpcff_main->create_form(
55
+ isset( $_GET['name'] ) ? sanitize_text_field( wp_unslash( $_GET['name'] ) ) : '',
56
+ isset( $_GET['category'] ) ? sanitize_text_field( wp_unslash( $_GET['category'] ) ) : '',
57
+ isset( $_GET['ftpl'] ) ? sanitize_text_field( wp_unslash( $_GET['ftpl'] ) ) : 0
58
+ );
59
+ // Update the default category
60
+ $cff_current_form_category = get_option( 'calculated-fields-form-category', '' );
61
+ if ( ! empty( $cff_current_form_category ) ) {
62
+ update_option( 'calculated-fields-form-category', sanitize_text_field( wp_unslash( $_GET['category'] ) ) );
63
+ }
64
+
65
+ $message = __( 'Item added', 'calculated-fields-form' );
66
+ if ( $new_form ) {
67
+ print "<script>document.location = 'admin.php?page=cp_calculated_fields_form&cal=" . esc_js( $new_form->get_id() ) . '&r=' . esc_js( rand() ) . '&_cpcff_nonce=' . esc_js( wp_create_nonce( 'cff-form-settings' ) ) . "';</script>";
68
+ }
69
+ } elseif ( ! empty( $_GET['u'] ) ) {
70
+ check_admin_referer( 'cff-update-form', '_cpcff_nonce' );
71
+ $cpcff_main->get_form( sanitize_text_field( wp_unslash( $_GET['u'] ) ) )->update_name( ( isset( $_GET['name'] ) ) ? sanitize_text_field( wp_unslash( $_GET['name'] ) ) : '' );
72
+ $message = __( 'Item updated', 'calculated-fields-form' );
73
+ } elseif ( ! empty( $_GET['d'] ) ) {
74
+ check_admin_referer( 'cff-delete-form', '_cpcff_nonce' );
75
+ $cpcff_main->delete_form( sanitize_text_field( wp_unslash( $_GET['d'] ) ) );
76
+ $message = __( 'Item deleted', 'calculated-fields-form' );
77
+ } elseif ( ! empty( $_GET['c'] ) ) {
78
+ check_admin_referer( 'cff-clone-form', '_cpcff_nonce' );
79
+ if ( is_numeric( $_GET['c'] ) && $cpcff_main->clone_form( intval( $_GET['c'] ) ) !== false ) {
80
+ $message = __( 'Item duplicated/cloned', 'calculated-fields-form' );
81
+ } else {
82
+ $message = __( 'Duplicate/Clone Error, the form cannot be cloned', 'calculated-fields-form' );
83
+ }
84
+ } elseif ( isset( $_GET['ac'] ) && 'st' == $_GET['ac'] ) {
85
+ check_admin_referer( 'cff-update-general-settings', '_cpcff_nonce' );
86
+ update_option( 'CP_CFF_LOAD_SCRIPTS', ( isset( $_GET['scr'] ) && '1' == $_GET['scr'] ? '0' : '1' ) );
87
+ update_option( 'CP_CALCULATEDFIELDSF_DISABLE_REVISIONS', ( isset( $_GET['dr'] ) && '1' == $_GET['dr'] ? 1 : 0 ) );
88
+ update_option( 'CP_CALCULATEDFIELDSF_USE_CACHE', ( isset( $_GET['jsc'] ) && '1' == $_GET['jsc'] ? 1 : 0 ) );
89
+ update_option( 'CP_CALCULATEDFIELDSF_OPTIMIZATION_PLUGIN', ( isset( $_GET['optm'] ) && '1' == $_GET['optm'] ? 1 : 0 ) );
90
+ update_option( 'CP_CALCULATEDFIELDSF_EXCLUDE_CRAWLERS', ( isset( $_GET['ecr'] ) && '1' == $_GET['ecr'] ? 1 : 0 ) );
91
+ update_option( 'CP_CALCULATEDFIELDSF_DIRECT_FORM_ACCESS', ( isset( $_GET['df'] ) && '1' == $_GET['df'] ? 1 : 0 ) );
92
+ update_option( 'CP_CALCULATEDFIELDSF_AMP', ( isset( $_GET['amp'] ) && '1' == $_GET['amp'] ? 1 : 0 ) );
93
+
94
+ $public_js_path = CP_CALCULATEDFIELDSF_BASE_PATH . '/js/cache/all.js';
95
+ try {
96
+ if ( get_option( 'CP_CALCULATEDFIELDSF_USE_CACHE', CP_CALCULATEDFIELDSF_USE_CACHE ) == false ) {
97
+ if ( file_exists( $public_js_path ) ) {
98
+ unlink( $public_js_path );
99
+ }
100
+ } else {
101
+ if ( ! file_exists( $public_js_path ) ) {
102
+ wp_remote_get( CPCFF_AUXILIARY::wp_url() . ( ( strpos( CPCFF_AUXILIARY::wp_url(), '?' ) === false ) ? '/?' : '&' ) . 'cp_cff_resources=public&min=1', array( 'sslverify' => false ) );
103
+ }
104
+ }
105
+ } catch ( Exception $err ) {
106
+ error_log( $err->getMessage() );
107
+ }
108
+
109
+ if ( ! empty( $_GET['chs'] ) ) {
110
+ $target_charset = sanitize_text_field( wp_unslash( $_GET['chs'] ) );
111
+ if ( ! in_array( $target_charset, array( 'utf8_general_ci', 'utf8mb4_general_ci', 'latin1_swedish_ci' ) ) ) {
112
+ $target_charset = 'utf8_general_ci';
113
+ }
114
+
115
+ $tables = array( $wpdb->prefix . CP_CALCULATEDFIELDSF_FORMS_TABLE, $wpdb->prefix . CP_CALCULATEDFIELDSF_POSTS_TABLE_NAME_NO_PREFIX );
116
+ foreach ( $tables as $tab ) { // phpcs:ignore WordPress.WP.GlobalVariablesOverride
117
+ $myrows = $wpdb->get_results( "DESCRIBE {$tab}" ); // phpcs:ignore WordPress.DB.PreparedSQL
118
+ foreach ( $myrows as $item ) {
119
+ $name = $item->Field;
120
+ $type = $item->Type; // phpcs:ignore WordPress.WP.GlobalVariablesOverride
121
+ if ( preg_match( '/^varchar\((\d+)\)$/i', $type, $mat ) || ! strcasecmp( $type, 'CHAR' ) || ! strcasecmp( $type, 'TEXT' ) || ! strcasecmp( $type, 'MEDIUMTEXT' ) ) {
122
+ $wpdb->query( "ALTER TABLE {$tab} CHANGE {$name} {$name} {$type} COLLATE {$target_charset}" ); // phpcs:ignore WordPress.DB.PreparedSQL
123
+ }
124
+ }
125
+ }
126
+ }
127
+ $message = __( 'Troubleshoot settings updated', 'calculated-fields-form' );
128
+ }
129
+
130
+ // For sortin the forms list
131
+ $orderby = get_option( 'CP_CALCULATEDFIELDSF_FORMS_LIST_ORDERBY', 'id' ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride
132
+ if ( $message ) {
133
+ echo "<div id='setting-error-settings_updated' class='" . ( stripos( $message, 'error' ) !== false ? 'error' : 'updated' ) . " settings-error'><p><strong>" . esc_html( $message ) . '</strong></p></div>';
134
+ }
135
+
136
+ ?>
137
+ <div class="wrap">
138
+ <?php
139
+ if ( get_option( 'cff-t-f', 0 ) ) :
140
+ ?>
141
+ <div style="border:1px solid #F0AD4E;background:#FBE6CA;padding:10px;margin:10px 0;font-size:1.3em;">
142
+ <?php print get_option( 'cff-t-t', '' ); // phpcs:ignore WordPress.Security.EscapeOutput ?>
143
+ </div>
144
+ <?php
145
+ delete_option( 'cff-t-f' );
146
+ endif;
147
+ ?>
148
+ <h1><?php esc_html_e( 'Calculated Fields Form', 'calculated-fields-form' ); ?></h1>
149
+
150
+ <script type="text/javascript">
151
+ var cff_metabox_nonce = '<?php print esc_js( wp_create_nonce( 'cff-metabox-status' ) ); ?>';
152
+ function cp_addItem()
153
+ {
154
+ var e = jQuery("#cp_itemname"),
155
+ form_tag = e.closest('form')[0],
156
+ calname = e.val().replace(/^\s*/, '').replace(/^\s*/, '').replace(/\s*$/, ''),
157
+ category = document.getElementById("calculated-fields-form-category").value;
158
+
159
+ e.val(calname);
160
+
161
+ if('reportValidity' in form_tag && !form_tag.reportValidity()) return;
162
+
163
+ document.location = 'admin.php?page=cp_calculated_fields_form&a=1&r='+Math.random()+'&name='+encodeURIComponent(calname)+'&category='+encodeURIComponent(category)+'&_cpcff_nonce=<?php echo esc_js( wp_create_nonce( 'cff-add-form' ) ); ?>';
164
+ }
165
+
166
+ function cp_addItem_keyup( e )
167
+ {
168
+ e.which = e.which || e.keyCode;
169
+ if(e.which == 13) cp_addItem();
170
+ }
171
+
172
+ function cp_updateItem(id)
173
+ {
174
+ var calname = document.getElementById("calname_"+id).value;
175
+ document.location = 'admin.php?page=cp_calculated_fields_form&u='+id+'&r='+Math.random()+'&name='+encodeURIComponent(calname)+'&_cpcff_nonce=<?php echo esc_js( wp_create_nonce( 'cff-update-form' ) ); ?>';
176
+ }
177
+
178
+ function cp_cloneItem(id)
179
+ {
180
+ document.location = 'admin.php?page=cp_calculated_fields_form&c='+id+'&r='+Math.random()+'&_cpcff_nonce=<?php echo esc_js( wp_create_nonce( 'cff-clone-form' ) ); ?>';
181
+ }
182
+
183
+ function cp_manageSettings(id)
184
+ {
185
+ document.location = 'admin.php?page=cp_calculated_fields_form&cal='+id+'&r='+Math.random()+'&_cpcff_nonce=<?php echo esc_js( wp_create_nonce( 'cff-form-settings' ) ); ?>';
186
+ }
187
+
188
+ function cp_viewMessages(id)
189
+ {
190
+ alert('Not available in this version. Check other versions at: '+"\n\n"+'https://cff.dwbooster.com/download');
191
+ }
192
+
193
+ function cp_BookingsList(id)
194
+ {
195
+ document.location = 'admin.php?page=cp_calculated_fields_form&cal='+id+'&list=1&r='+Math.random();
196
+ }
197
+
198
+ function cp_deleteItem(id)
199
+ {
200
+ if (confirm('<?php esc_html_e( 'Are you sure you want to delete this item?', 'calculated-fields-form' ); ?>'))
201
  {
202
+ document.location = 'admin.php?page=cp_calculated_fields_form&d='+id+'&r='+Math.random()+'&_cpcff_nonce=<?php echo esc_js( wp_create_nonce( 'cff-delete-form' ) ); ?>';
203
  }
204
+ }
205
+
206
+ function cp_updateConfig()
207
+ {
208
+ if (confirm('<?php esc_html_e( 'Are you sure you want to update these settings?', 'calculated-fields-form' ); ?>'))
209
+ {
210
+ var scr = document.getElementById("ccscriptload").value,
211
+ chs = document.getElementById("cccharsets").value,
212
+ dr = (document.getElementById("ccdisablerevisions").checked) ? 1 : 0,
213
+ jsc = (document.getElementById("ccjscache").checked) ? 1 : 0,
214
+ optm = (document.getElementById("ccoptimizationplugin").checked) ? 1 : 0,
215
+ df = (document.getElementById("ccdirectform").checked) ? 1 : 0,
216
+ amp = (document.getElementById("ccampform").checked) ? 1 : 0,
217
+ ecr = (document.getElementById("ccexcludecrawler").checked) ? 1 : 0;
218
+
219
+ document.location = 'admin.php?page=cp_calculated_fields_form&ecr='+ecr+'&ac=st&scr='+scr+'&chs='+chs+'&dr='+dr+'&jsc='+jsc+'&optm='+optm+'&df='+df+'&amp='+amp+'&r='+Math.random()+'&_cpcff_nonce=<?php echo esc_js( wp_create_nonce( 'cff-update-general-settings' ) ); ?>';
220
+ }
221
+ }
222
+
223
+ function cp_select_template()
224
+ {
225
+ jQuery('.cp_template_info').hide();
226
+ jQuery('.cp_template_'+jQuery('#cp_default_template').val()).show();
227
+ }
228
+
229
+ function cp_update_default_settings(e)
230
+ {
231
+ if(jQuery('[name="cp_default_existing_forms"]').prop('checked'))
232
+ {
233
+ if (confirm('<?php esc_html_e( 'Are you sure you want to modify existing forms?\\nWe recommend modifying the forms one by one.', 'calculated-fields-form' ); ?>'))
 
 
 
 
 
 
 
 
234
  {
235
+ e.form.submit();
 
 
 
236
  }
237
+ }
238
+ else e.form.submit();
239
+ }
240
+ </script>
241
+ <h2 class="nav-tab-wrapper">
242
+ <a href="admin.php?page=cp_calculated_fields_form&cff-tab=forms" class="nav-tab <?php if ( empty( $_GET['cff-tab'] ) || 'forms' == $_GET['cff-tab'] ) {
243
+ print 'nav-tab-active';} ?>"><?php esc_html_e( 'Forms and Settings', 'calculated-fields-form' ); ?></a>
244
+ <a href="admin.php?page=cp_calculated_fields_form&cff-tab=marketplace" class="nav-tab <?php if ( ! empty( $_GET['cff-tab'] ) && 'marketplace' == $_GET['cff-tab'] ) {
245
+ print 'nav-tab-active';} ?>"><?php esc_html_e( 'Marketplace', 'calculated-fields-form' ); ?></a>
246
+ </h2>
247
+ <div style="margin-top:20px;display:<?php print ( empty( $_GET['cff-tab'] ) || 'forms' == $_GET['cff-tab'] ) ? 'block' : 'none'; ?>;"><!-- Forms & Settings Section -->
248
+ <div id="normal-sortables" class="meta-box-sortables">
249
+
250
+ <!-- Form Categories -->
251
+ <div id="metabox_categories_list" class="postbox" >
252
+ <div class="inside" style="overflow-x:auto;">
253
+ <form action="admin.php?page=cp_calculated_fields_form" method="post">
254
+ <?php
255
+ if ( isset( $_POST['calculated-fields-form-category'] ) ) {
256
+ check_admin_referer( 'cff-change-category', '_cpcff_nonce' );
257
+ update_option( 'calculated-fields-form-category', sanitize_text_field( wp_unslash( $_POST['calculated-fields-form-category'] ) ) );
258
+ }
259
+ $cff_current_form_category = get_option( 'calculated-fields-form-category', '' );
260
+ ?>
261
+ <input type="hidden" name="_cpcff_nonce" value="<?php echo esc_attr( wp_create_nonce( 'cff-change-category' ) ); ?>" />
262
+ <b><?php esc_html_e( 'Form Categories', 'calculated-fields-form' ); ?></b>
263
+ <select name="calculated-fields-form-category" class="width50" onchange="this.form.submit();">
264
+ <option value=""><?php esc_html_e( 'All forms', 'calculated-fields-form' ); ?></option>
265
+ <?php
266
+ print $cpcff_main->get_categories( 'SELECT', $cff_current_form_category ); // phpcs:ignore WordPress.Security.EscapeOutput
267
+ ?>
268
+ </select>
269
+ </form>
270
+ </div>
271
+ </div>
272
+
273
+ <!-- Forms List -->
274
+ <div id="metabox_form_list" class="postbox" >
275
+ <h3 class='hndle' style="padding:5px;"><span><?php
276
+ esc_html_e( 'Form List / Items List', 'calculated-fields-form' );
277
+
278
+ if ( '' != $cff_current_form_category ) {
279
+ print '&nbsp;' . esc_html__( 'in', 'calculated-fields-form' ) . '&nbsp;<u>' . esc_html( $cff_current_form_category ) . '</u>&nbsp;' . esc_html__( 'category', 'calculated-fields-form' );
280
+ }
281
+ ?></span></h3>
282
+ <div class="inside" style="overflow-x:auto;">
283
+ <table cellspacing="10" class="cff-custom-table cff-forms-list">
284
+ <thead>
285
+ <tr>
286
+ <th align="left"><a href="?page=cp_calculated_fields_form&orderby=id" <?php if ( 'id' == $orderby ) {
287
+ print 'class="cff-active-column"';} ?>><?php esc_html_e( 'ID', 'calculated-fields-form' ); ?></a></th>
288
+ <th align="left"><a href="?page=cp_calculated_fields_form&orderby=form_name" <?php if ( 'form_name' == $orderby ) {
289
+ print 'class="cff-active-column"';} ?>><?php esc_html_e( 'Form Name', 'calculated-fields-form' ); ?></a></th>
290
+ <th align="center"><?php esc_html_e( 'Options', 'calculated-fields-form' ); ?></th>
291
+ <th align="left"><?php esc_html_e( 'Category/Shortcode', 'calculated-fields-form' ); ?></th>
292
+ </tr>
293
+ </thead>
294
+ <tbody>
295
+ <?php
296
+ $myrows = $wpdb->get_results( 'SELECT * FROM ' . $wpdb->prefix . CP_CALCULATEDFIELDSF_FORMS_TABLE . ( '' != $cff_current_form_category ? $wpdb->prepare( ' WHERE category=%s ', $cff_current_form_category ) : '' ) . ' ORDER BY ' . $orderby . ' ASC' ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
297
+ foreach ( $myrows as $item ) {
298
+ ?>
299
+ <tr>
300
+ <td nowrap><?php echo esc_html( $item->id ); ?></td>
301
+ <td nowrap><input type="text" name="calname_<?php echo esc_attr( $item->id ); ?>" id="calname_<?php echo esc_attr( $item->id ); ?>" value="<?php echo esc_attr( $item->form_name ); ?>" /></td>
302
+ <td nowrap>
303
+ <input type="button" name="calupdate_<?php echo esc_attr( $item->id ); ?>" value="<?php esc_attr_e( 'Update', 'calculated-fields-form' ); ?>" onclick="cp_updateItem(<?php echo esc_attr( $item->id ); ?>);" class="button-secondary" />
304
+ <input type="button" name="calmanage_<?php echo esc_attr( $item->id ); ?>" value="<?php esc_attr_e( 'Settings', 'calculated-fields-form' ); ?>" onclick="cp_manageSettings(<?php echo esc_attr( $item->id ); ?>);" class="button-primary" />
305
+ <input type="button" name="calmanage_<?php echo esc_attr( $item->id ); ?>" value="<?php esc_attr_e( 'Messages', 'calculated-fields-form' ); ?>" onclick="cp_viewMessages(<?php echo esc_attr( $item->id ); ?>);" class="button-secondary" />
306
+ <input type="button" name="calclone_<?php echo esc_attr( $item->id ); ?>" value="<?php esc_attr_e( 'Clone', 'calculated-fields-form' ); ?>" onclick="cp_cloneItem(<?php echo esc_attr( $item->id ); ?>);" class="button-secondary" />
307
+ <input type="button" name="caldelete_<?php echo esc_attr( $item->id ); ?>" value="<?php esc_attr_e( 'Delete', 'calculated-fields-form' ); ?>" onclick="cp_deleteItem(<?php echo esc_attr( $item->id ); ?>);" class="button-secondary" />
308
+ </td>
309
+ <td><?php if ( ! empty( $item->category ) ) {
310
+ print esc_html__( 'Category: ', 'calculated-fields-form' ) . '<b>' . esc_html( $item->category ) . '</b><br>';} ?><div style="white-space:nowrap;">[CP_CALCULATED_FIELDS id="<?php echo esc_attr( $item->id ); ?>"]</div></td>
311
+ </tr>
312
+ <?php
313
+ }
314
+ ?>
315
+ </tbody>
316
+ </table>
317
+ </div>
318
+ </div>
319
+
320
+ <div id="metabox_new_form_area" class="postbox" >
321
+ <h3 class='hndle' style="padding:5px;"><span><?php esc_html_e( 'New Form', 'calculated-fields-form' ); ?></span></h3>
322
+ <div class="inside">
323
+ <form name="additem">
324
+ <?php esc_html_e( 'Item Name', 'calculated-fields-form' ); ?>(*):<br />
325
+ <div>
326
+ <input type="text" name="cp_itemname" id="cp_itemname" value="" onkeyup="cp_addItem_keyup( event );" style="margin-top:5px;" required />
327
+ <input type="text" name="calculated-fields-form-category" id="calculated-fields-form-category" value="<?php print esc_attr( $cff_current_form_category ); ?>" style="margin-top:5px;" placeholder="<?php esc_attr_e( 'Category', 'calculated-fields-form' ); ?>" list="calculated-fields-form-categories" />
328
+ <datalist id="calculated-fields-form-categories">
329
+ <?php
330
+ print $cpcff_main->get_categories( 'DATALIST' ); // phpcs:ignore WordPress.Security.EscapeOutput
331
+ ?>
332
+ </datalist>
333
+ <input type="button" onclick="cp_addItem();" name="gobtn" value="<?php esc_attr_e( 'Create Form', 'calculated-fields-form' ); ?>" class="button-secondary" style="margin-top:5px;" />
334
+ <input type="button" onclick="cff_openLibraryDialog();" name="gobtn" value="<?php esc_attr_e( 'From Template', 'calculated-fields-form' ); ?>" class="button-secondary" style="margin-top:5px;" />
335
+ </div>
336
+ </form>
337
+ </div>
338
+ </div>
339
+ <i id="default-settings-section"></i>
340
+ <div id="metabox_default_settings" class="postbox cff-metabox <?php print esc_attr( $cpcff_main->metabox_status( 'metabox_default_settings' ) ); ?>" >
341
+ <h3 class='hndle' style="padding:5px;"><span><?php esc_html_e( 'Default Settings', 'calculated-fields-form' ); ?></span></h3>
342
+ <div class="inside">
343
+ <p><?php esc_html_e( 'Applies the default settings to new forms.', 'calculated-fields-form' ); ?></p>
344
+ <form name="defaultsettings" action="admin.php?page=cp_calculated_fields_form" method="post">
345
+ <?php esc_html_e( 'Default Template', 'calculated-fields-form' ); ?>:<br />
346
+ <?php
347
+ require_once CP_CALCULATEDFIELDSF_BASE_PATH . '/inc/cpcff_templates.inc.php';
348
+ $templates_list = CPCFF_TEMPLATES::load_templates();
349
+ $template_options = '<option value="">Use default template</option>';
350
+ $template_information = '';
351
+ foreach ( $templates_list as $template_item ) {
352
+ $template_options .= '<option value="' . esc_attr( $template_item['prefix'] ) . '" ' . ( $template_item['prefix'] == $cp_default_template ? 'SELECTED' : '' ) . '>' . esc_html( $template_item['title'] ) . '</option>';
353
+ $template_information .= '<div class="width50 cp_template_info cp_template_' . esc_attr( $template_item['prefix'] ) . '" style="text-align:center;padding:10px 0; display:' . ( $template_item['prefix'] == $cp_default_template ? 'block' : 'none' ) . '; margin:10px 0; border: 1px dashed #CCC;">' . ( ! empty( $template_item['thumbnail'] ) ? '<img src="' . esc_attr( $template_item['thumbnail'] ) . '"><br>' : '' ) . ( ! empty( $template_item['description'] ) ? esc_html( $template_item['description'] ) : '' ) . '</div>';
354
+ }
355
+ ?>
356
+ <select name="cp_default_template" id="cp_default_template"class="width50" onchange="cp_select_template();"><?php print $template_options; // phpcs:ignore WordPress.Security.EscapeOutput ?></select><br />
357
+ <?php print $template_information; // phpcs:ignore WordPress.Security.EscapeOutput ?>
358
+ <br /><br />
359
+ <div style="border:1px solid #DADADA; padding:10px;" class="width50">
360
+ <input type="checkbox" aria-label="<?php esc_attr_e( 'Apply To Existing Forms', 'calculated-fields-form' ); ?>" name="cp_default_existing_forms" /> <?php esc_html_e( 'Apply To Existing Forms', 'calculated-fields-form' ); ?> (<i><?php esc_html_e( 'It will modify the settings of existing forms', 'calculated-fields-form' ); ?></i>)
361
+ </div>
362
+ <br />
363
+ <input type="button" name="cp_save_default_settings" value="<?php esc_attr_e( 'Update', 'calculated-fields-form' ); ?>" class="button-secondary" onclick="cp_update_default_settings(this);" />
364
+ <input type="hidden" name="_cpcff_nonce" value="<?php echo esc_attr( wp_create_nonce( 'cff-default-settings' ) ); ?>" />
365
+ </form>
366
+ </div>
367
+ </div>
368
+ <div style="border:1px solid #F0AD4E;background:#FBE6CA;padding:10px;margin:10px 0;font-size:1.3em;">
369
+ <div><?php esc_html_e( 'For additional resources visit the plugin\'s', 'calculated-fields-form' ); ?> <a href="https://cff-bundles.dwbooster.com" target="_blank" style="font-weight:bold;"><?php esc_html_e( 'Marketplace', 'calculated-fields-form' ); ?></a></div>
370
+ <div class="cff-bundles-plugin"></div>
371
+ </div>
372
+ <div id="metabox_troubleshoot_area" class="postbox cff-metabox <?php print esc_attr( $cpcff_main->metabox_status( 'metabox_troubleshoot_area' ) ); ?>" >
373
+ <h3 class='hndle' style="padding:5px;"><span><?php esc_html_e( 'Troubleshoot Area & General Settings', 'calculated-fields-form' ); ?></span></h3>
374
+ <div class="inside">
375
+ <form name="updatesettings">
376
+ <div style="border:1px solid #DADADA; padding:10px;">
377
+ <p><?php _e( '<strong>Important!</strong>: Use this area <strong>only</strong> if you are experiencing conflicts with third party plugins, with the theme scripts or with the character encoding.', 'calculated-fields-form' ); // phpcs:ignore WordPress.Security.EscapeOutput ?></p>
378
+ <?php esc_html_e( 'Script load method', 'calculated-fields-form' ); ?>:<br />
379
+ <select id="ccscriptload" name="ccscriptload" class="width50">
380
+ <option value="0" <?php if ( get_option( 'CP_CFF_LOAD_SCRIPTS', '0' ) == '1' ) {
381
+ echo 'selected';} ?>><?php esc_html_e( 'Classic (Recommended)', 'calculated-fields-form' ); ?></option>
382
+ <option value="1" <?php if ( get_option( 'CP_CFF_LOAD_SCRIPTS', '0' ) != '1' ) {
383
+ echo 'selected';} ?>><?php esc_html_e( 'Direct', 'calculated-fields-form' ); ?></option>
384
+ </select><br />
385
+ <em><?php esc_html_e( '* Change the script load method if the form doesn\'t appear in the public website.', 'calculated-fields-form' ); ?></em>
386
+ <br /><br />
387
+ <?php esc_html_e( 'Character encoding', 'calculated-fields-form' ); ?>:<br />
388
+ <select id="cccharsets" name="cccharsets" class="width50">
389
+ <option value=""><?php esc_html_e( 'Keep current charset (Recommended)', 'calculated-fields-form' ); ?></option>
390
+ <option value="utf8_general_ci">UTF-8 (<?php esc_html_e( 'try this first', 'calculated-fields-form' ); ?>)</option>
391
+ <option value="utf8mb4_general_ci">UTF-8mb4 (<?php esc_html_e( 'Only from MySQL 5.5', 'calculated-fields-form' ); ?>)</option>
392
+ <option value="latin1_swedish_ci">latin1_swedish_ci</option>
393
+ </select><br />
394
+ <em><?php esc_html_e( '* Update the charset if you are getting problems displaying special/non-latin characters. After updated you need to edit the special characters again.', 'calculated-fields-form' ); ?></em>
395
+ <br /><br />
396
+ <?php
397
+ $compatibility_warnings = $cpcff_main->compatibility_warnings();
398
+ if ( ! empty( $compatibility_warnings ) ) {
399
+ print '<div style="margin:10px 0; border:1px dashed #FF0000; padding:10px; color:red;">' . $compatibility_warnings; // phpcs:ignore WordPress.Security.EscapeOutput
400
+ }
401
+ esc_html_e( 'There is active an optimization plugin in WordPress', 'calculated-fields-form' ); ?>:<br />
402
+ <input type="checkbox" id="ccoptimizationplugin" name="ccoptimizationplugin" value="1" <?php echo ( get_option( 'CP_CALCULATEDFIELDSF_OPTIMIZATION_PLUGIN', CP_CALCULATEDFIELDSF_OPTIMIZATION_PLUGIN ) ) ? 'CHECKED' : ''; ?> /><em><?php esc_html_e( '* Tick the checkbox if there is an optimization plugin active on the website, and the forms are not visible.', 'calculated-fields-form' ); ?></em>
403
+ <?php
404
+ if ( ! empty( $compatibility_warnings ) ) {
405
+ print '</div>';
406
+ }
407
+ ?>
408
+ </div>
409
+ <br />
410
+ <input type="checkbox" name="ccdisablerevisions" id="ccdisablerevisions" <?php echo ( get_option( 'CP_CALCULATEDFIELDSF_DISABLE_REVISIONS', CP_CALCULATEDFIELDSF_DISABLE_REVISIONS ) ) ? 'CHECKED' : ''; ?> /> <?php esc_html_e( 'Disable Form Revisions', 'calculated-fields-form' ); ?>
411
+ <br /><br />
412
+ <input type="checkbox" name="ccjscache" id="ccjscache" <?php echo ( get_option( 'CP_CALCULATEDFIELDSF_USE_CACHE', CP_CALCULATEDFIELDSF_USE_CACHE ) ) ? 'CHECKED' : ''; ?> /> <?php esc_html_e( 'Activate Javascript Cache', 'calculated-fields-form' ); ?>
413
+ <br /><br />
414
+ <input type="checkbox" name="ccdirectform" id="ccdirectform" <?php echo ( get_option( 'CP_CALCULATEDFIELDSF_DIRECT_FORM_ACCESS', CP_CALCULATEDFIELDSF_DIRECT_FORM_ACCESS ) ) ? 'CHECKED' : ''; ?> /> <?php esc_html_e( 'Allows to access the forms directly', 'calculated-fields-form' ); ?>
415
+ <br /><br />
416
+ <input type="checkbox" name="ccampform" id="ccampform" <?php echo ( get_option( 'CP_CALCULATEDFIELDSF_AMP', CP_CALCULATEDFIELDSF_AMP ) ) ? 'CHECKED' : ''; ?> /> <?php esc_html_e( 'Allows to access the forms from amp pages', 'calculated-fields-form' ); ?>
417
+ <br /><br />
418
+ <input type="checkbox" name="ccexcludecrawler" id="ccexcludecrawler" <?php echo ( get_option( 'CP_CALCULATEDFIELDSF_EXCLUDE_CRAWLERS', false ) ) ? 'CHECKED' : ''; ?> /> <?php esc_html_e( 'Do not load the forms with crawlers', 'calculated-fields-form' ); ?>
419
+ <br /><i><?php esc_html_e( '* The forms are not loaded when website is being indexed by searchers.', 'calculated-fields-form' ); ?></i>
420
+ <br /><br />
421
+ <input type="button" onclick="cp_updateConfig();" name="gobtn" value="<?php esc_attr_e( 'UPDATE', 'calculated-fields-form' ); ?>" class="button-secondary" />
422
+ <br />
423
+ </form>
424
+ </div>
425
+ </div>
426
+ </div>
427
+ </div><!-- End Forms & Settings Section -->
428
+ <div style="margin-top:20px;display:<?php print ( ! empty( $_GET['cff-tab'] ) && 'marketplace' == $_GET['cff-tab'] ) ? 'block' : 'none'; ?>;"><!-- Marketplace Section -->
429
+ <div id="metabox_basic_settings" class="postbox" >
430
+ <h3 class='hndle' style="padding:5px;"><span><?php esc_html_e( 'Calculated Fields Form Marketplace', 'calculated-fields-form' ); ?></span></h3>
431
+ <div class="inside">
432
+ <div class="cff-marketplace"></div>
433
+ </div>
434
+ </div>
435
+ </div><!-- End Marketplace Section -->
436
+ [<a href="https://cff.dwbooster.com/customization" target="_blank"><?php esc_html_e( 'Request Custom Modifications', 'calculated-fields-form' ); ?></a>] | [<a href="https://cff.dwbooster.com/download" target="_blank"><?php esc_html_e( 'Upgrade', 'calculated-fields-form' ); ?></a>] | [<a href="https://wordpress.org/support/plugin/calculated-fields-form#new-post" target="_blank"><?php esc_html_e( 'Help', 'calculated-fields-form' ); ?></a>]
437
+ </div>
438
+ <script>cff_current_version='free';</script>
439
+ <script src="https://cff-bundles.dwbooster.com/plugins/plugins.js?v=<?php print esc_attr( CP_CALCULATEDFIELDSF_VERSION . '_' . gmdate( 'Y-m-d' ) ); // phpcs:ignore WordPress.WP.EnqueuedResources ?>"></script>
440
+ <script src="<?php print esc_attr( plugins_url( '/vendors/forms.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ) . '?v=' . CP_CALCULATEDFIELDSF_VERSION . '_' . gmdate( 'Y-m-d' ) ); // phpcs:ignore WordPress.WP.EnqueuedResources ?>"></script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/cpcff_amp.inc.php CHANGED
@@ -1,222 +1,229 @@
1
- <?php
2
- /**
3
- * Actions required to include the forms in the AMP pages: CPCFF_AMP class
4
- *
5
- * @package CFF.
6
- * @since 1.0.230
7
- */
8
-
9
- if(!class_exists('CPCFF_AMP'))
10
- {
11
- /**
12
- * Class that defines the operations to display the foms in AMP pages.
13
- *
14
- * @since 1.0.170
15
- */
16
- class CPCFF_AMP
17
- {
18
- /**
19
- * Main plugin object
20
- */
21
- private $_main_obj;
22
-
23
- public function __construct($main_obj)
24
- {
25
- $this->_main_obj = $main_obj;
26
- add_action( 'init', array($this, 'amp_init') ); // for amp pages.
27
- } // End __construct
28
-
29
- /**
30
- * Loads the form's preview in AMP pages.
31
- *
32
- * @return void.
33
- */
34
- public function amp_init()
35
- {
36
- if(
37
- !empty($_GET['cff-amp-form']) &&
38
- get_option('CP_CALCULATEDFIELDSF_AMP', CP_CALCULATEDFIELDSF_AMP)
39
- )
40
- {
41
- $atts = $this->_params_to_attrs();
42
- $page_title = (!empty($atts['page_title'])) ? $atts['page_title'] : '';
43
- print '<!DOCTYPE html><html '.
44
- ((function_exists( 'is_rtl' ) && is_rtl()) ? 'dir="rtl"' : '').
45
- '>'.
46
- '<head>'.
47
- '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'.
48
- '<meta name="viewport" content="width=device-width">'.
49
- '<title>'.esc_html($page_title).'</title>';
50
-
51
- // Patch for editor preview
52
- if(empty($_GET['cff-editor-preview']))
53
- {
54
- print '<style>'.
55
- 'body{background:#FFF;overflow:hidden;margin:0;}'.
56
- 'html, body {height:100%;position:relative;min-height:100%;display:block;}'.
57
- '#fbuilder{'.$this->_get_styles().'box-sizing:border-box!important;}'.
58
- '</style>';
59
- }
60
-
61
- global $wp_styles, $wp_scripts;
62
- if(!empty($wp_scripts)) $wp_scripts->reset();
63
- $message = $this->_main_obj->public_form($atts);
64
- // Patch for editor preview
65
- if(empty($_GET['cff-editor-preview']))
66
- {
67
- $message = preg_replace('/<form\s+/i', '<form target="_parent" ', $message, 1);
68
- $message = preg_replace('/<\/form>/i', '</form><pre style="display:none !important;"><script>try{
69
- document.addEventListener("DOMContentLoaded",
70
- function(){fbuilderjQuery(document).one("showHideDepEvent", function(){window.parent.postMessage({sentinel: "amp",type:"embed-size",height: document.body.scrollHeight+25}, "*");});});}catch(err){console.log(err);}</script></pre>',
71
- $message, 1
72
- );
73
- }
74
- ob_start();
75
- if(!empty($wp_styles)) $wp_styles->do_items();
76
- if(!empty($wp_scripts)) $wp_scripts->do_items();
77
- if(class_exists('Error'))
78
- {
79
- try{ wp_footer(); } catch(Error $err) {}
80
- }
81
- $message .= ob_get_contents();
82
- ob_end_clean();
83
-
84
- // Patch for editor preview
85
- if(!empty($_GET['cff-editor-preview']))
86
- {
87
- $message .= '<script type="text/javascript">
88
- window.addEventListener("load",
89
- function() {
90
- var frameEl = window.frameElement;
91
- if(frameEl && typeof fbuilderjQuery != "undefined")
92
- frameEl.height = fbuilderjQuery("form").outerHeight(true) + 25;
93
- }, false);
94
- </script>';
95
- }
96
- print '</head>'.
97
- '<body>'.
98
- $message.
99
- '</body>'.
100
- '</html>';
101
- remove_all_actions('shutdown');
102
- exit;
103
- }
104
- } // End amp_init
105
-
106
- /**
107
- * Checks if the page is AMP or not
108
- *
109
- * Checks first for the existence of functions: "is_amp_endpoint" or "ampforwp_is_amp_endpoint",
110
- * and if they don't exists, checks the URL.
111
- *
112
- * @return bool.
113
- */
114
- public function is_amp()
115
- {
116
- if(!get_option('CP_CALCULATEDFIELDSF_AMP', CP_CALCULATEDFIELDSF_AMP)) return false;
117
- if(!empty($_REQUEST['isamp'])) return true;
118
- if(empty($_GET['non-amp']))
119
- {
120
- if( function_exists('ampforwp_is_amp_endpoint') ) return ampforwp_is_amp_endpoint();
121
- elseif( function_exists('is_amp_endpoint') ) return is_amp_endpoint();
122
- }
123
- return false;
124
- } // End is_amp
125
-
126
- /**
127
- * Returns an iframe tag for loading the a webpage with the form only, specially useful for AMP pages.
128
- *
129
- * @return string, the iframe tag's structure for loading a page with the form.
130
- */
131
- public function get_iframe( $atts )
132
- {
133
- $url = CPCFF_AUXILIARY::site_url();
134
- $url = preg_replace('/^http\:/i', 'https:', $url);
135
- $url .= (strpos($url, '?') === false) ? '?' : '&';
136
- $url .= 'cff-amp-form='.((!empty($atts['id']))?$atts['id'] : '');
137
- $height = '';
138
- $width = '';
139
- foreach($atts as $attr_name => $attr_value)
140
- {
141
- if('amp_iframe_height' == $attr_name) $height = $attr_value;
142
- elseif('amp_iframe_width' == $attr_name) $width = $attr_value;
143
- elseif('id' != $attr_name) $url .= '&cff-form-attr-'.$attr_name.'='.$attr_value;
144
- }
145
-
146
- if(empty($height)) $height = 320;
147
- else $url .= '&cff-form-height='.$height;
148
- if(empty($width)) $width = 500;
149
-
150
- $url .= '&non-amp=1';
151
-
152
- add_action('amp_post_template_css', array($this, 'amp_css') );
153
- add_filter( 'amp_post_template_data', array($this, 'amp_iframe') );
154
-
155
- return '<amp-iframe id="cff-form-iframe" src="'.esc_attr( esc_url($url)).'" layout="responsive" resizable sandbox="allow-popups allow-forms allow-top-navigation allow-modals allow-scripts" width="'.esc_attr($width).'" height="'.esc_attr($height).'"><amp-img src="data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB4bWxuczpkYz0iaHR0cDovL3B1cmwub3JnL2RjL2VsZW1lbnRzLzEuMS8iIHhtbG5zOmNjPSJodHRwOi8vY3JlYXRpdmVjb21tb25zLm9yZy9ucyMiIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyIgeG1sbnM6c3ZnPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiBpZD0ic3ZnOCIgdmVyc2lvbj0iMS4xIiB2aWV3Qm94PSIwIDAgMTMuMjI5MTY3IDEzLjIyOTE2NyIgaGVpZ2h0PSI1MCIgd2lkdGg9IjUwIj48ZGVmcyBpZD0iZGVmczIiIC8+PG1ldGFkYXRhIGlkPSJtZXRhZGF0YTUiPjxyZGY6UkRGPjxjYzpXb3JrIHJkZjphYm91dD0iIj48ZGM6Zm9ybWF0PmltYWdlL3N2Zyt4bWw8L2RjOmZvcm1hdD48ZGM6dHlwZSByZGY6cmVzb3VyY2U9Imh0dHA6Ly9wdXJsLm9yZy9kYy9kY21pdHlwZS9TdGlsbEltYWdlIiAvPjxkYzp0aXRsZT48L2RjOnRpdGxlPjwvY2M6V29yaz48L3JkZjpSREY+PC9tZXRhZGF0YT48ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgwLC0yODMuNzcwODMpIiBpZD0ibGF5ZXIxIiAvPjwvc3ZnPg==" placeholder layout="responsive" width="50" height="50" /><div overflow tabindex=0 role=button style="bottom:0;border-bottom:2px dotted #ccc; width:100%;"><div aria-label="'.esc_attr__('Click to expand', 'calculated-fields-form').'" style="margin-bottom:10px;margin-left:50%;transform:translate(-50%);padding:10px 20px;background:#666;color:white;border-radius:5px;display:inline-block;">'.esc_html(__('Click to expand', 'calculated-fields-form')).'</div></div></amp-iframe>';
156
- }
157
-
158
- /**
159
- * Includes the CSS rules for the amp version of form
160
- *
161
- * @param object, template.
162
- */
163
- public function amp_css($template)
164
- {
165
- print '#cff-form-iframe{margin:0;}';
166
- } // End amp_css
167
-
168
- /**
169
- * Checks if the amp-iframe.js was included, and includes it if not.
170
- *
171
- * @param $data, associative array.
172
- * @return $data, associative array.
173
- */
174
- public function amp_iframe($data)
175
- {
176
- if ( empty( $data['amp_component_scripts']['amp-iframe'] ) )
177
- {
178
- $data['amp_component_scripts']['amp-iframe'] = 'https://cdn.ampproject.org/v0/amp-iframe-0.1.js';
179
- }
180
- return $data;
181
- } // End amp_iframe
182
-
183
- /**
184
- * Converts the URL parameters related with the form in the redirection process required for load the forms into the amp-frames
185
- *
186
- * The parameter cff-amp-form is converted in the id attribute,
187
- * and the parameteres with the name: cff-form-attr-<param>, are converted in the attributes <param>
188
- *
189
- * @return array $attrs.
190
- */
191
- private function _params_to_attrs()
192
- {
193
- $attrs = array();
194
- if(!empty($_GET))
195
- {
196
- foreach($_GET as $param => $value)
197
- {
198
- if( $param == 'cff-amp-form')
199
- $attrs['id'] = @intval($value);
200
- elseif(preg_match('/^cff\-form\-attr\-/i', $param))
201
- {
202
- $param = preg_replace('/^cff\-form\-attr\-/i', '', $param);
203
- $param = sanitize_text_field($param);
204
- $attrs[$param] = sanitize_text_field($value);
205
- }
206
- }
207
- }
208
- return $attrs;
209
- } // End _params_to_attrs
210
-
211
- /**
212
- * Reads the form height from the URL parameter cff-form-height, returns 500 by default.
213
- *
214
- * @return int.
215
- */
216
- private function _get_styles()
217
- {
218
- return (!empty($_GET['cff-form-height']) && ($height=@intval($_GET['cff-form-height'])) !== 0 ) ?
219
- 'overflow-x:hidden;overflow-y:auto;height:'.$height.'px;padding:5px 32px 5px 5px;' : '';
220
- }
221
- }
222
- }
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Actions required to include the forms in the AMP pages: CPCFF_AMP class
4
+ *
5
+ * @package CFF.
6
+ * @since 1.0.230
7
+ */
8
+
9
+ if ( ! class_exists( 'CPCFF_AMP' ) ) {
10
+ /**
11
+ * Class that defines the operations to display the foms in AMP pages.
12
+ *
13
+ * @since 1.0.170
14
+ */
15
+ class CPCFF_AMP {
16
+
17
+ /**
18
+ * Main plugin object
19
+ */
20
+ private $_main_obj;
21
+
22
+ public function __construct( $main_obj ) {
23
+ $this->_main_obj = $main_obj;
24
+ add_action( 'init', array( $this, 'amp_init' ) ); // for amp pages.
25
+ } // End __construct
26
+
27
+ /**
28
+ * Loads the form's preview in AMP pages.
29
+ *
30
+ * @return void.
31
+ */
32
+ public function amp_init() {
33
+ if (
34
+ ! empty( $_GET['cff-amp-form'] ) &&
35
+ get_option( 'CP_CALCULATEDFIELDSF_AMP', CP_CALCULATEDFIELDSF_AMP )
36
+ ) {
37
+ $atts = $this->_params_to_attrs();
38
+ $page_title = ( ! empty( $atts['page_title'] ) ) ? $atts['page_title'] : '';
39
+ print '<!DOCTYPE html><html ' .
40
+ ( ( function_exists( 'is_rtl' ) && is_rtl() ) ? 'dir="rtl"' : '' ) .
41
+ '>' .
42
+ '<head>' .
43
+ '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />' .
44
+ '<meta name="viewport" content="width=device-width">' .
45
+ '<title>' . esc_html( $page_title ) . '</title>';
46
+
47
+ // Patch for editor preview
48
+ if ( empty( $_GET['cff-editor-preview'] ) ) {
49
+ print '<style>' .
50
+ 'body{background:#FFF;overflow:hidden;margin:0;}' .
51
+ 'html, body {height:100%;position:relative;min-height:100%;display:block;}' .
52
+ '#fbuilder{' . $this->_get_styles() . 'box-sizing:border-box!important;}' . // phpcs:ignore WordPress.Security.EscapeOutput
53
+ '</style>';
54
+ }
55
+
56
+ global $wp_styles, $wp_scripts;
57
+ if ( ! empty( $wp_scripts ) ) {
58
+ $wp_scripts->reset();
59
+ }
60
+ $message = $this->_main_obj->public_form( $atts );
61
+ // Patch for editor preview
62
+ if ( empty( $_GET['cff-editor-preview'] ) ) {
63
+ $message = preg_replace( '/<form\s+/i', '<form target="_parent" ', $message, 1 );
64
+ $message = preg_replace(
65
+ '/<\/form>/i',
66
+ '</form><pre style="display:none !important;"><script>try{
67
+ document.addEventListener("DOMContentLoaded",
68
+ function(){fbuilderjQuery(document).one("showHideDepEvent", function(){window.parent.postMessage({sentinel: "amp",type:"embed-size",height: document.body.scrollHeight+25}, "*");});});}catch(err){console.log(err);}</script></pre>',
69
+ $message,
70
+ 1
71
+ );
72
+ }
73
+ ob_start();
74
+ if ( ! empty( $wp_styles ) ) {
75
+ $wp_styles->do_items();
76
+ }
77
+ if ( ! empty( $wp_scripts ) ) {
78
+ $wp_scripts->do_items();
79
+ }
80
+ if ( class_exists( 'Error' ) ) {
81
+ try {
82
+ wp_footer(); } catch ( Error $err ) {
83
+ error_log( $err->getMessage() );
84
+ }
85
+ }
86
+ $message .= ob_get_contents();
87
+ ob_end_clean();
88
+
89
+ // Patch for editor preview
90
+ if ( ! empty( $_GET['cff-editor-preview'] ) ) {
91
+ $message .= '<script type="text/javascript">
92
+ window.addEventListener("load",
93
+ function() {
94
+ var frameEl = window.frameElement;
95
+ if(frameEl && typeof fbuilderjQuery != "undefined")
96
+ frameEl.height = fbuilderjQuery("form").outerHeight(true) + 25;
97
+ }, false);
98
+ </script>';
99
+ }
100
+ print '</head>' .
101
+ '<body>' .
102
+ $message . // phpcs:ignore WordPress.Security.EscapeOutput
103
+ '</body>' .
104
+ '</html>';
105
+ remove_all_actions( 'shutdown' );
106
+ exit;
107
+ }
108
+ } // End amp_init
109
+
110
+ /**
111
+ * Checks if the page is AMP or not
112
+ *
113
+ * Checks first for the existence of functions: "is_amp_endpoint" or "ampforwp_is_amp_endpoint",
114
+ * and if they don't exists, checks the URL.
115
+ *
116
+ * @return bool.
117
+ */
118
+ public function is_amp() {
119
+ if ( ! get_option( 'CP_CALCULATEDFIELDSF_AMP', CP_CALCULATEDFIELDSF_AMP ) ) {
120
+ return false;
121
+ }
122
+ if ( ! empty( $_REQUEST['isamp'] ) ) {
123
+ return true;
124
+ }
125
+ if ( empty( $_GET['non-amp'] ) ) {
126
+ if ( function_exists( 'ampforwp_is_amp_endpoint' ) ) {
127
+ return ampforwp_is_amp_endpoint();
128
+ } elseif ( function_exists( 'is_amp_endpoint' ) ) {
129
+ return is_amp_endpoint();
130
+ }
131
+ }
132
+ return false;
133
+ } // End is_amp
134
+
135
+ /**
136
+ * Returns an iframe tag for loading the a webpage with the form only, specially useful for AMP pages.
137
+ *
138
+ * @return string, the iframe tag's structure for loading a page with the form.
139
+ */
140
+ public function get_iframe( $atts ) {
141
+ $url = CPCFF_AUXILIARY::site_url();
142
+ $url = preg_replace( '/^http\:/i', 'https:', $url );
143
+ $url .= ( strpos( $url, '?' ) === false ) ? '?' : '&';
144
+ $url .= 'cff-amp-form=' . ( ( ! empty( $atts['id'] ) ) ? $atts['id'] : '' );
145
+ $height = '';
146
+ $width = '';
147
+ foreach ( $atts as $attr_name => $attr_value ) {
148
+ if ( 'amp_iframe_height' == $attr_name ) {
149
+ $height = $attr_value;
150
+ } elseif ( 'amp_iframe_width' == $attr_name ) {
151
+ $width = $attr_value;
152
+ } elseif ( 'id' != $attr_name ) {
153
+ $url .= '&cff-form-attr-' . $attr_name . '=' . $attr_value;
154
+ }
155
+ }
156
+
157
+ if ( empty( $height ) ) {
158
+ $height = 320;
159
+ } else {
160
+ $url .= '&cff-form-height=' . $height;
161
+ }
162
+ if ( empty( $width ) ) {
163
+ $width = 500;
164
+ }
165
+
166
+ $url .= '&non-amp=1';
167
+
168
+ add_action( 'amp_post_template_css', array( $this, 'amp_css' ) );
169
+ add_filter( 'amp_post_template_data', array( $this, 'amp_iframe' ) );
170
+
171
+ return '<amp-iframe id="cff-form-iframe" src="' . esc_attr( esc_url( $url ) ) . '" layout="responsive" resizable sandbox="allow-popups allow-forms allow-top-navigation allow-modals allow-scripts" width="' . esc_attr( $width ) . '" height="' . esc_attr( $height ) . '"><amp-img src="data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB4bWxuczpkYz0iaHR0cDovL3B1cmwub3JnL2RjL2VsZW1lbnRzLzEuMS8iIHhtbG5zOmNjPSJodHRwOi8vY3JlYXRpdmVjb21tb25zLm9yZy9ucyMiIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyIgeG1sbnM6c3ZnPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiBpZD0ic3ZnOCIgdmVyc2lvbj0iMS4xIiB2aWV3Qm94PSIwIDAgMTMuMjI5MTY3IDEzLjIyOTE2NyIgaGVpZ2h0PSI1MCIgd2lkdGg9IjUwIj48ZGVmcyBpZD0iZGVmczIiIC8+PG1ldGFkYXRhIGlkPSJtZXRhZGF0YTUiPjxyZGY6UkRGPjxjYzpXb3JrIHJkZjphYm91dD0iIj48ZGM6Zm9ybWF0PmltYWdlL3N2Zyt4bWw8L2RjOmZvcm1hdD48ZGM6dHlwZSByZGY6cmVzb3VyY2U9Imh0dHA6Ly9wdXJsLm9yZy9kYy9kY21pdHlwZS9TdGlsbEltYWdlIiAvPjxkYzp0aXRsZT48L2RjOnRpdGxlPjwvY2M6V29yaz48L3JkZjpSREY+PC9tZXRhZGF0YT48ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgwLC0yODMuNzcwODMpIiBpZD0ibGF5ZXIxIiAvPjwvc3ZnPg==" placeholder layout="responsive" width="50" height="50" /><div overflow tabindex=0 role=button style="bottom:0;border-bottom:2px dotted #ccc; width:100%;"><div aria-label="' . esc_attr__( 'Click to expand', 'calculated-fields-form' ) . '" style="margin-bottom:10px;margin-left:50%;transform:translate(-50%);padding:10px 20px;background:#666;color:white;border-radius:5px;display:inline-block;">' . esc_html( __( 'Click to expand', 'calculated-fields-form' ) ) . '</div></div></amp-iframe>';
172
+ }
173
+
174
+ /**
175
+ * Includes the CSS rules for the amp version of form
176
+ *
177
+ * @param object, template.
178
+ */
179
+ public function amp_css( $template ) {
180
+ print '#cff-form-iframe{margin:0;}';
181
+ } // End amp_css
182
+
183
+ /**
184
+ * Checks if the amp-iframe.js was included, and includes it if not.
185
+ *
186
+ * @param $data, associative array.
187
+ * @return $data, associative array.
188
+ */
189
+ public function amp_iframe( $data ) {
190
+ if ( empty( $data['amp_component_scripts']['amp-iframe'] ) ) {
191
+ $data['amp_component_scripts']['amp-iframe'] = 'https://cdn.ampproject.org/v0/amp-iframe-0.1.js';
192
+ }
193
+ return $data;
194
+ } // End amp_iframe
195
+
196
+ /**
197
+ * Converts the URL parameters related with the form in the redirection process required for load the forms into the amp-frames
198
+ *
199
+ * The parameter cff-amp-form is converted in the id attribute,
200
+ * and the parameteres with the name: cff-form-attr-<param>, are converted in the attributes <param>
201
+ *
202
+ * @return array $attrs.
203
+ */
204
+ private function _params_to_attrs() {
205
+ $attrs = array();
206
+ if ( ! empty( $_GET ) ) {
207
+ foreach ( $_GET as $param => $value ) {
208
+ if ( 'cff-amp-form' == $param ) {
209
+ $attrs['id'] = @intval( $value );
210
+ } elseif ( preg_match( '/^cff\-form\-attr\-/i', $param ) ) {
211
+ $param = preg_replace( '/^cff\-form\-attr\-/i', '', $param );
212
+ $param = sanitize_text_field( $param );
213
+ $attrs[ $param ] = sanitize_text_field( $value );
214
+ }
215
+ }
216
+ }
217
+ return $attrs;
218
+ } // End _params_to_attrs
219
+
220
+ /**
221
+ * Reads the form height from the URL parameter cff-form-height, returns 500 by default.
222
+ *
223
+ * @return int.
224
+ */
225
+ private function _get_styles() {
226
+ return ( ! empty( $_GET['cff-form-height'] ) && is_numeric( $_GET['cff-form-height'] ) && ( $height = intval( $_GET['cff-form-height'] ) ) !== 0 ) ? 'overflow-x:hidden;overflow-y:auto;height:' . $height . 'px;padding:5px 32px 5px 5px;' : ''; // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments
227
+ }
228
+ }
229
+ }
inc/cpcff_auxiliary.inc.php CHANGED
@@ -1,407 +1,387 @@
1
- <?php
2
- /**
3
- * Miscellaneous operations: CPCFF_AUXILIARY class
4
- *
5
- * Metaclass with miscellanous operations used through all plugin.
6
- *
7
- * @package CFF.
8
- * @since 1.0.167
9
- */
10
-
11
- if(!class_exists('CPCFF_AUXILIARY'))
12
- {
13
- /**
14
- * Metaclass with miscellaneous operations.
15
- *
16
- * Publishes miscellanous operations to be used through all plugin's sections.
17
- *
18
- * @since 1.0.167
19
- */
20
- class CPCFF_AUXILIARY
21
- {
22
- /**
23
- * Public URL of the current blog.
24
- *
25
- * @since 1.0.167
26
- * @var string $_site_url
27
- */
28
- private static $_site_url;
29
-
30
- /**
31
- * URL to the WordPress of the current blog.
32
- *
33
- * @since 1.0.167
34
- * @var string $_wp_url
35
- */
36
- private static $_wp_url;
37
-
38
- /**
39
- * Current URL.
40
- *
41
- * @var string $_current_url
42
- */
43
- private static $_current_url;
44
-
45
- /**
46
- * ID of the current blog.
47
- *
48
- * @var string $_wp_id
49
- */
50
- private static $_wp_id;
51
-
52
- /**
53
- * Returns the id of current blog.
54
- *
55
- * If the ID was read previously, uses the value stored in class property.
56
- *
57
- * @return int.
58
- */
59
- public static function blog_id()
60
- {
61
- if(empty(self::$_wp_id)) self::$_wp_id = get_current_blog_id();
62
- return self::$_wp_id;
63
- } // End blog_id
64
-
65
- /**
66
- * Returns the public URL of the current blog.
67
- *
68
- * If the URL was read previously, uses the value stored in class property.
69
- *
70
- * @since 1.0.167
71
- * @return string.
72
- */
73
- public static function site_url( $no_protocol = false )
74
- {
75
- if(empty(self::$_site_url))
76
- {
77
- $blog = self::blog_id();
78
- self::$_site_url = get_home_url( $blog, '', is_ssl() ? 'https' : 'http');
79
- }
80
- $_site_url = rtrim(self::$_site_url, '/');
81
- if($no_protocol) $_site_url = preg_replace('/^http(s?)\:/i', '', $_site_url);
82
- return $_site_url;
83
- } // End site_url
84
-
85
- /**
86
- * Returns the URL to the WordPress of the current blog.
87
- *
88
- * If the URL was read previously, uses the value stored in class property.
89
- *
90
- * @since 1.0.167
91
- * @return string.
92
- */
93
- public static function wp_url()
94
- {
95
- if(empty(self::$_wp_url))
96
- {
97
- $blog = self::blog_id();
98
- self::$_wp_url = get_admin_url( $blog );
99
- }
100
- return rtrim(self::$_wp_url, '/');
101
- } // End wp_url
102
-
103
- /**
104
- * Returns the form editor.
105
- */
106
- public static function editor_url()
107
- {
108
- return self::wp_url().'/admin.php?page=cp_calculated_fields_form&_cpcff_nonce='.wp_create_nonce('cff-form-settings').'&cal=';
109
- } // End editor_url
110
-
111
- /**
112
- * Returns the URL to the current post url.
113
- *
114
- * @return string.
115
- */
116
- public static function wp_current_url()
117
- {
118
- if(is_admin()) return self::site_url();
119
- if(!empty(self::$_current_url)) return self::$_current_url;
120
-
121
- $protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
122
-
123
- self::$_current_url = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
124
- return self::$_current_url;
125
- } // End wp_current_url
126
-
127
- /**
128
- * Sanitizes the value received as parameter, supporting the same posts tags
129
- *
130
- * @since Pro 5.0.235, Dev 5.0.279, Plat 10.0.318
131
- *
132
- * @params mixed $v.
133
- * @return sanitized value.
134
- */
135
- public static function sanitize( $v )
136
- {
137
- $allowed_tags = wp_kses_allowed_html( 'post' );
138
-
139
- add_filter('safecss_filter_attr_allow_css', function($allow_css, $css_test_string){
140
- if(preg_match('/rgb(a)?\(/i', $css_test_string)) return true;
141
- return $allow_css;
142
- }, 10, 2);
143
-
144
- $v = wp_kses($v, $allowed_tags);
145
-
146
- // the str_replace is a patch to solve an issue with the data: part in signature fields
147
- // that are removed by wp_kse.
148
- return str_replace(
149
- array('"image/svg+xml;base64','"image/png;base64'),
150
- array('"data:image/svg+xml;base64','"data:image/png;base64'),
151
- $v
152
- );
153
- } // End sanitize
154
-
155
- /**
156
- * Removes Bom characters.
157
- *
158
- * @since 1.0.179
159
- *
160
- * @param string $str.
161
- * @return string.
162
- */
163
- public static function clean_bom($str)
164
- {
165
- $bom = pack('H*','EFBBBF');
166
- return preg_replace("/$bom/", '', $str);
167
- } // End clean_bom
168
-
169
- /**
170
- * Converts some characters in a JSON string.
171
- *
172
- * @since 1.0.169
173
- *
174
- * @param string $str JSON string.
175
- * @return string.
176
- */
177
- public static function clean_json($str)
178
- {
179
- return str_replace(
180
- array(" ", "\n", "\r"),
181
- array(" ", '\n', ''),
182
- $str
183
- );
184
- } // End clean_json
185
-
186
- /**
187
- * Set the hook for cleanning the expired transients
188
- *
189
- * @since 1.0.281
190
- */
191
- public static function clean_transients_hook()
192
- {
193
- add_action('cpcff_clean_transients', array('CPCFF_AUXILIARY', 'clean_transients'));
194
- if (!wp_next_scheduled('cpcff_clean_transients'))
195
- wp_schedule_event(time() + 5, 'daily', 'cpcff_clean_transients');
196
- } // End clean_transients_hook
197
-
198
- /**
199
- * Clean the expired transients
200
- *
201
- * @since 1.0.281
202
- */
203
- public static function clean_transients()
204
- {
205
- global $wpdb;
206
- $table = $wpdb->options;
207
-
208
- // get current PHP time, offset by a minute to avoid clashes with other tasks
209
- $threshold = time() - MINUTE_IN_SECONDS;
210
-
211
- // delete expired transients, using the paired timeout record to find them
212
- $sql = "
213
- delete from t1, t2
214
- using $table t1
215
- join $table t2 on t2.option_name = replace(t1.option_name, '_timeout', '')
216
- where t1.option_name like '\_transient\_timeout\_%'
217
- and t1.option_value < '$threshold'
218
- ";
219
- $wpdb->query($sql);
220
-
221
- // delete orphaned transient expirations
222
- $sql = "
223
- delete from $table
224
- where option_name like '\_transient\_timeout\_%'
225
- and option_value < '$threshold'
226
- ";
227
-
228
- $wpdb->query($sql);
229
- } // End clean_transients
230
-
231
- /**
232
- * Decodes a JSON string.
233
- *
234
- * Decode a JSON string, and receive a parameter to apply strip slashes first or not.
235
- *
236
- * @since 1.0.169
237
- *
238
- * @param string $str JSON string.
239
- * @param string $stripcslashes Optional. To apply a stripcslashes to the text before json_decode. Default 'unescape'.
240
- * @return mixed PHP Oject or False.
241
- */
242
- public static function json_decode($str, $stripcslashes = 'unescape')
243
- {
244
- try
245
- {
246
- $str = CPCFF_AUXILIARY::clean_json( $str );
247
- if( $stripcslashes == 'unescape')$str = stripcslashes( $str );
248
- $obj = json_decode( $str );
249
- }
250
- catch( Exception $err ){ self::write_log($err); }
251
- return ( !empty( $obj ) ) ? $obj : false;
252
- } // End unserialize
253
-
254
- /**
255
- * Replaces recursively the elements in an array by the elements in another one.
256
- *
257
- * The method will use the PHP function: array_replace_recursive if exists.
258
- *
259
- * @since 1.0.169
260
- *
261
- * @param array $array1
262
- * @param array $array2
263
- * @return array
264
- */
265
- public static function array_replace_recursive($array1, $array2)
266
- {
267
- // If the array_replace_recursive function exists, use it
268
- if(function_exists('array_replace_recursive')) return array_replace_recursive($array1, $array2);
269
- foreach( $array2 as $key1 => $val1 )
270
- {
271
- if( isset( $array1[ $key1 ] ) )
272
- {
273
- if( is_array( $val1 ) )
274
- {
275
- foreach( $val1 as $key2 => $val2)
276
- {
277
- $array1[ $key1 ][ $key2 ] = $val2;
278
- }
279
- }
280
- else
281
- {
282
- $array1[ $key1 ] = $val1;
283
- }
284
- }
285
- else
286
- {
287
- $array1[ $key1 ] = $val1;
288
- }
289
- }
290
- return $array1;
291
- } // End array_replace_recursive
292
-
293
- /**
294
- * Applies stripcslashes to the array elements recursively.
295
- *
296
- * The method checks if parameter is an array a text. If it is an array the method is called recursively.
297
- *
298
- * @since 1.0.176
299
- *
300
- * @param mixed $v array or single value.
301
- * @return mixed the array or value with the slashes stripped
302
- */
303
- public static function stripcslashes_recursive( $v )
304
- {
305
- if(is_array($v))
306
- {
307
- foreach($v as $k => $s)
308
- {
309
- $v[$k] = self::stripcslashes_recursive($s);
310
- }
311
- return $v;
312
- }
313
- else
314
- {
315
- return stripcslashes($v);
316
- }
317
- } // End stripcslashes_recursive
318
-
319
- public static function stripscript_recursive( $v )
320
- {
321
- if(is_array($v))
322
- {
323
- foreach($v as $k => $s)
324
- {
325
- $v[$k] = self::stripscript_recursive($s);
326
- }
327
- return $v;
328
- }
329
- else
330
- {
331
- return preg_replace(['/<\s*script\b.*\bscript\s*>/i', '/<\s*script[^>]*>/i'], '', $v);
332
- }
333
- } // End stripscript_recursive
334
-
335
- /**
336
- * Checks if the website is being visited by a crawler.
337
- *
338
- * Returns true if the website is being visited by a search engine spider,
339
- * and the plugin was configure for hidding the forms front them, else false.
340
- *
341
- * @since 1.0.169
342
- *
343
- * @return bool.
344
- */
345
- public static function is_crawler()
346
- {
347
- return (isset( $_SERVER['HTTP_USER_AGENT'] ) &&
348
- preg_match( '/bot|crawl|slurp|spider/i', $_SERVER[ 'HTTP_USER_AGENT' ] ) &&
349
- get_option( 'CP_CALCULATEDFIELDSF_EXCLUDE_CRAWLERS', false )
350
- );
351
- } // End is_crawler
352
-
353
- /**
354
- * Adds the attribute: property="stylesheet" to the link tag to validate the link tags into the pages' bodies.
355
- *
356
- * Checks if it is an stylesheet and adds the property if has not been included previously.
357
- *
358
- * @since 1.0.178
359
- *
360
- * @param string $tag the link tag.
361
- * @return string.
362
- */
363
- public static function complete_link_tag( $tag )
364
- {
365
- if(
366
- preg_match('/stylesheet/i', $tag) &&
367
- !preg_match('/property\s*=/i', $tag)
368
- )
369
- {
370
- return str_replace( '/>', ' property="stylesheet" />', $tag );
371
- }
372
- return $tag;
373
- } // End complete_link_tag
374
-
375
- /**
376
- * Creates a new entry in the PHP Error Logs.
377
- *
378
- * @since 1.0.167
379
- *
380
- * @param mixed $log Log message, as text, array or plain object.
381
- * @return void.
382
- */
383
- public static function write_log($log)
384
- {
385
- try{
386
- if(
387
- defined('WP_DEBUG') &&
388
- true == WP_DEBUG
389
- )
390
- {
391
- if(
392
- is_array( $log ) ||
393
- is_object( $log )
394
- )
395
- {
396
- error_log( print_r( $log, true ) );
397
- }
398
- else
399
- {
400
- error_log( $log );
401
- }
402
- }
403
- }catch(Exception $err){}
404
- } // End write_log
405
-
406
- } // End CPCFF_AUXILIARY
407
- }
1
+ <?php
2
+ /**
3
+ * Miscellaneous operations: CPCFF_AUXILIARY class
4
+ *
5
+ * Metaclass with miscellanous operations used through all plugin.
6
+ *
7
+ * @package CFF.
8
+ * @since 1.0.167
9
+ */
10
+
11
+ if ( ! class_exists( 'CPCFF_AUXILIARY' ) ) {
12
+ /**
13
+ * Metaclass with miscellaneous operations.
14
+ *
15
+ * Publishes miscellanous operations to be used through all plugin's sections.
16
+ *
17
+ * @since 1.0.167
18
+ */
19
+ class CPCFF_AUXILIARY {
20
+
21
+ /**
22
+ * Public URL of the current blog.
23
+ *
24
+ * @since 1.0.167
25
+ * @var string $_site_url
26
+ */
27
+ private static $_site_url;
28
+
29
+ /**
30
+ * URL to the WordPress of the current blog.
31
+ *
32
+ * @since 1.0.167
33
+ * @var string $_wp_url
34
+ */
35
+ private static $_wp_url;
36
+
37
+ /**
38
+ * Current URL.
39
+ *
40
+ * @var string $_current_url
41
+ */
42
+ private static $_current_url;
43
+
44
+ /**
45
+ * ID of the current blog.
46
+ *
47
+ * @var string $_wp_id
48
+ */
49
+ private static $_wp_id;
50
+
51
+ /**
52
+ * Returns the id of current blog.
53
+ *
54
+ * If the ID was read previously, uses the value stored in class property.
55
+ *
56
+ * @return int.
57
+ */
58
+ public static function blog_id() {
59
+ if ( empty( self::$_wp_id ) ) {
60
+ self::$_wp_id = get_current_blog_id();
61
+ }
62
+ return self::$_wp_id;
63
+ } // End blog_id
64
+
65
+ /**
66
+ * Returns the public URL of the current blog.
67
+ *
68
+ * If the URL was read previously, uses the value stored in class property.
69
+ *
70
+ * @since 1.0.167
71
+ * @return string.
72
+ */
73
+ public static function site_url( $no_protocol = false ) {
74
+ if ( empty( self::$_site_url ) ) {
75
+ $blog = self::blog_id();
76
+ self::$_site_url = get_home_url( $blog, '', is_ssl() ? 'https' : 'http' );
77
+ }
78
+ $_site_url = rtrim( self::$_site_url, '/' );
79
+ if ( $no_protocol ) {
80
+ $_site_url = preg_replace( '/^http(s?)\:/i', '', $_site_url );
81
+ }
82
+ return $_site_url;
83
+ } // End site_url
84
+
85
+ /**
86
+ * Returns the URL to the WordPress of the current blog.
87
+ *
88
+ * If the URL was read previously, uses the value stored in class property.
89
+ *
90
+ * @since 1.0.167
91
+ * @return string.
92
+ */
93
+ public static function wp_url() {
94
+ if ( empty( self::$_wp_url ) ) {
95
+ $blog = self::blog_id();
96
+ self::$_wp_url = get_admin_url( $blog );
97
+ }
98
+ return rtrim( self::$_wp_url, '/' );
99
+ } // End wp_url
100
+
101
+ /**
102
+ * Returns the form editor.
103
+ */
104
+ public static function editor_url() {
105
+ return self::wp_url() . '/admin.php?page=cp_calculated_fields_form&_cpcff_nonce=' . wp_create_nonce( 'cff-form-settings' ) . '&cal=';
106
+ } // End editor_url
107
+
108
+ /**
109
+ * Returns the URL to the current post url.
110
+ *
111
+ * @return string.
112
+ */
113
+ public static function wp_current_url() {
114
+ if ( is_admin() ) {
115
+ return self::site_url();
116
+ }
117
+ if ( ! empty( self::$_current_url ) ) {
118
+ return self::$_current_url;
119
+ }
120
+
121
+ $protocol = ( ( ! empty( $_SERVER['HTTPS'] ) && 'off' != $_SERVER['HTTPS'] ) || ( ! empty( $_SERVER['SERVER_PORT'] ) && 443 == $_SERVER['SERVER_PORT'] ) ) ? 'https://' : 'http://';
122
+
123
+ self::$_current_url = $protocol . ( isset( $_SERVER['HTTP_HOST'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) ) : '' ) . ( isset( $_SERVER['REQUEST_URI'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '' );
124
+ return self::$_current_url;
125
+ } // End wp_current_url
126
+
127
+ /**
128
+ * Sanitizes the value received as parameter, supporting the same posts tags
129
+ *
130
+ * @since Pro 5.0.235, Dev 5.0.279, Plat 10.0.318
131
+ *
132
+ * @params mixed $v.
133
+ * @return sanitized value.
134
+ */
135
+ public static function sanitize( $v ) {
136
+ $allowed_tags = wp_kses_allowed_html( 'post' );
137
+
138
+ add_filter(
139
+ 'safecss_filter_attr_allow_css',
140
+ function( $allow_css, $css_test_string ) {
141
+ if ( preg_match( '/rgb(a)?\(/i', $css_test_string ) ) {
142
+ return true;
143
+ }
144
+ return $allow_css;
145
+ },
146
+ 10,
147
+ 2
148
+ );
149
+
150
+ $v = wp_kses( $v, $allowed_tags );
151
+
152
+ // the str_replace is a patch to solve an issue with the data: part in signature fields
153
+ // that are removed by wp_kse.
154
+ return str_replace(
155
+ array( '"image/svg+xml;base64', '"image/png;base64' ),
156
+ array( '"data:image/svg+xml;base64', '"data:image/png;base64' ),
157
+ $v
158
+ );
159
+ } // End sanitize
160
+
161
+ /**
162
+ * Removes Bom characters.
163
+ *
164
+ * @since 1.0.179
165
+ *
166
+ * @param string $str.
167
+ * @return string.
168
+ */
169
+ public static function clean_bom( $str ) {
170
+ $bom = pack( 'H*', 'EFBBBF' );
171
+ return preg_replace( "/$bom/", '', $str );
172
+ } // End clean_bom
173
+
174
+ /**
175
+ * Converts some characters in a JSON string.
176
+ *
177
+ * @since 1.0.169
178
+ *
179
+ * @param string $str JSON string.
180
+ * @return string.
181
+ */
182
+ public static function clean_json( $str ) {
183
+ return str_replace(
184
+ array( ' ', "\n", "\r" ),
185
+ array( ' ', '\n', '' ),
186
+ $str
187
+ );
188
+ } // End clean_json
189
+
190
+ /**
191
+ * Set the hook for cleanning the expired transients
192
+ *
193
+ * @since 1.0.281
194
+ */
195
+ public static function clean_transients_hook() {
196
+ add_action( 'cpcff_clean_transients', array( 'CPCFF_AUXILIARY', 'clean_transients' ) );
197
+ if ( ! wp_next_scheduled( 'cpcff_clean_transients' ) ) {
198
+ wp_schedule_event( time() + 5, 'daily', 'cpcff_clean_transients' );
199
+ }
200
+ } // End clean_transients_hook
201
+
202
+ /**
203
+ * Clean the expired transients
204
+ *
205
+ * @since 1.0.281
206
+ */
207
+ public static function clean_transients() {
208
+ global $wpdb;
209
+ $table = $wpdb->options;
210
+
211
+ // get current PHP time, offset by a minute to avoid clashes with other tasks
212
+ $threshold = time() - MINUTE_IN_SECONDS;
213
+
214
+ // delete expired transients, using the paired timeout record to find them
215
+ $sql = "
216
+ delete from t1, t2
217
+ using $table t1
218
+ join $table t2 on t2.option_name = replace(t1.option_name, '_timeout', '')
219
+ where t1.option_name like '\_transient\_timeout\_%'
220
+ and t1.option_value < '$threshold'
221
+ ";
222
+ $wpdb->query( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
223
+
224
+ // delete orphaned transient expirations
225
+ $sql = "
226
+ delete from $table
227
+ where option_name like '\_transient\_timeout\_%'
228
+ and option_value < '$threshold'
229
+ ";
230
+
231
+ $wpdb->query( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
232
+ } // End clean_transients
233
+
234
+ /**
235
+ * Decodes a JSON string.
236
+ *
237
+ * Decode a JSON string, and receive a parameter to apply strip slashes first or not.
238
+ *
239
+ * @since 1.0.169
240
+ *
241
+ * @param string $str JSON string.
242
+ * @param string $stripcslashes Optional. To apply a stripcslashes to the text before json_decode. Default 'unescape'.
243
+ * @return mixed PHP Oject or False.
244
+ */
245
+ public static function json_decode( $str, $stripcslashes = 'unescape' ) {
246
+ try {
247
+ $str = self::clean_json( $str );
248
+ if ( 'unescape' == $stripcslashes ) {
249
+ $str = stripcslashes( $str );
250
+ }
251
+ $obj = json_decode( $str );
252
+ } catch ( Exception $err ) {
253
+ self::write_log( $err ); }
254
+ return ( ! empty( $obj ) ) ? $obj : false;
255
+ } // End unserialize
256
+
257
+ /**
258
+ * Replaces recursively the elements in an array by the elements in another one.
259
+ *
260
+ * The method will use the PHP function: array_replace_recursive if exists.
261
+ *
262
+ * @since 1.0.169
263
+ *
264
+ * @param array $array1
265
+ * @param array $array2
266
+ * @return array
267
+ */
268
+ public static function array_replace_recursive( $array1, $array2 ) {
269
+ // If the array_replace_recursive function exists, use it
270
+ if ( function_exists( 'array_replace_recursive' ) ) {
271
+ return array_replace_recursive( $array1, $array2 );
272
+ }
273
+ foreach ( $array2 as $key1 => $val1 ) {
274
+ if ( isset( $array1[ $key1 ] ) ) {
275
+ if ( is_array( $val1 ) ) {
276
+ foreach ( $val1 as $key2 => $val2 ) {
277
+ $array1[ $key1 ][ $key2 ] = $val2;
278
+ }
279
+ } else {
280
+ $array1[ $key1 ] = $val1;
281
+ }
282
+ } else {
283
+ $array1[ $key1 ] = $val1;
284
+ }
285
+ }
286
+ return $array1;
287
+ } // End array_replace_recursive
288
+
289
+ /**
290
+ * Applies stripcslashes to the array elements recursively.
291
+ *
292
+ * The method checks if parameter is an array a text. If it is an array the method is called recursively.
293
+ *
294
+ * @since 1.0.176
295
+ *
296
+ * @param mixed $v array or single value.
297
+ * @return mixed the array or value with the slashes stripped
298
+ */
299
+ public static function stripcslashes_recursive( $v ) {
300
+ if ( is_array( $v ) ) {
301
+ foreach ( $v as $k => $s ) {
302
+ $v[ $k ] = self::stripcslashes_recursive( $s );
303
+ }
304
+ return $v;
305
+ } else {
306
+ return stripcslashes( $v );
307
+ }
308
+ } // End stripcslashes_recursive
309
+
310
+ public static function stripscript_recursive( $v ) {
311
+ if ( is_array( $v ) ) {
312
+ foreach ( $v as $k => $s ) {
313
+ $v[ $k ] = self::stripscript_recursive( $s );
314
+ }
315
+ return $v;
316
+ } else {
317
+ return preg_replace( array( '/<\s*script\b.*\bscript\s*>/i', '/<\s*script[^>]*>/i' ), '', $v );
318
+ }
319
+ } // End stripscript_recursive
320
+
321
+ /**
322
+ * Checks if the website is being visited by a crawler.
323
+ *
324
+ * Returns true if the website is being visited by a search engine spider,
325
+ * and the plugin was configure for hidding the forms front them, else false.
326
+ *
327
+ * @since 1.0.169
328
+ *
329
+ * @return bool.
330
+ */
331
+ public static function is_crawler() {
332
+ return ( isset( $_SERVER['HTTP_USER_AGENT'] ) &&
333
+ preg_match( '/bot|crawl|slurp|spider/i', sanitize_text_field( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) ) &&
334
+ get_option( 'CP_CALCULATEDFIELDSF_EXCLUDE_CRAWLERS', false )
335
+ );
336
+ } // End is_crawler
337
+
338
+ /**
339
+ * Adds the attribute: property="stylesheet" to the link tag to validate the link tags into the pages' bodies.
340
+ *
341
+ * Checks if it is an stylesheet and adds the property if has not been included previously.
342
+ *
343
+ * @since 1.0.178
344
+ *
345
+ * @param string $tag the link tag.
346
+ * @return string.
347
+ */
348
+ public static function complete_link_tag( $tag ) {
349
+ if (
350
+ preg_match( '/stylesheet/i', $tag ) &&
351
+ ! preg_match( '/property\s*=/i', $tag )
352
+ ) {
353
+ return str_replace( '/>', ' property="stylesheet" />', $tag );
354
+ }
355
+ return $tag;
356
+ } // End complete_link_tag
357
+
358
+ /**
359
+ * Creates a new entry in the PHP Error Logs.
360
+ *
361
+ * @since 1.0.167
362
+ *
363
+ * @param mixed $log Log message, as text, array or plain object.
364
+ * @return void.
365
+ */
366
+ public static function write_log( $log ) {
367
+ try {
368
+ if (
369
+ defined( 'WP_DEBUG' ) &&
370
+ true == WP_DEBUG
371
+ ) {
372
+ if (
373
+ is_array( $log ) ||
374
+ is_object( $log )
375
+ ) {
376
+ error_log( print_r( $log, true ) );
377
+ } else {
378
+ error_log( $log );
379
+ }
380
+ }
381
+ } catch ( Exception $err ) {
382
+ error_log( $err->getMessage() );
383
+ }
384
+ } // End write_log
385
+
386
+ } // End CPCFF_AUXILIARY
387
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/cpcff_banner.inc.php CHANGED
@@ -1,107 +1,106 @@
1
- <?php
2
- global $codepeople_promote_banner_plugins; // Global variable shared by multiple plugins.
3
- if(empty($codepeople_promote_banner_plugins)) $codepeople_promote_banner_plugins = array();
4
- $codepeople_promote_banner_plugins[ 'codepeople-calculated-fields-form' ] = array(
5
- 'plugin_name' => 'Calculated Fields Form',
6
- 'plugin_url' => 'https://wordpress.org/support/plugin/calculated-fields-form/reviews/#new-post'
7
- );
8
-
9
- if(!function_exists( 'codepeople_add_promote_banner' ))
10
- {
11
- function codepeople_add_promote_banner($wp_admin_bar)
12
- {
13
- global $codepeople_promote_banner_plugins;
14
- if(
15
- empty($codepeople_promote_banner_plugins) ||
16
- !is_admin() ||
17
- !current_user_can( 'manage_options' )
18
- ) return;
19
-
20
- $screen = get_current_screen();
21
- if ( $screen->post_type == 'post' || $screen->post_type == 'page' ) return;
22
-
23
- // Take action over the banner
24
- if(
25
- !empty($_POST['codepeople_promote_banner_plugin']) &&
26
- !empty($codepeople_promote_banner_plugins[$_POST['codepeople_promote_banner_plugin']])
27
- )
28
- {
29
- set_transient( 'codepeople_promote_banner_'.$_POST['codepeople_promote_banner_plugin'], -1, 0);
30
- if(
31
- !empty($_POST['codepeople_promote_banner_action']) &&
32
- $_POST['codepeople_promote_banner_action'] == 'set-review' &&
33
- !empty($codepeople_promote_banner_plugins[$_POST['codepeople_promote_banner_plugin']]['plugin_url'])
34
- )
35
- {
36
- print '<script>document.location.href="'.str_replace('&amp;','&',esc_js($codepeople_promote_banner_plugins[$_POST['codepeople_promote_banner_plugin']]['plugin_url'])).'";</script>';
37
- }
38
- }
39
-
40
- $minimum_days = 86400*7;
41
- $now = time();
42
-
43
- foreach($codepeople_promote_banner_plugins as $plugin_slug => $plugin_data )
44
- {
45
- $value = get_transient( 'codepeople_promote_banner_'.$plugin_slug );
46
- if( $value === false )
47
- {
48
- $value = $now;
49
- set_transient( 'codepeople_promote_banner_'.$plugin_slug, $value, 0 );
50
- }
51
-
52
- if($minimum_days <= abs($now-$value) && 0<$value*1)
53
- {
54
- ?>
55
- <style>
56
- #codepeople-review-banner{width:calc( 100% - 20px );width:-webkit-calc( 100% - 20px );width:-moz-calc( 100% - 20px );width:-o-calc( 100% - 20px );border:10px solid #1582AB;background:#FFF;display:table;}
57
- #codepeople-review-banner form{float:left; padding:0 5px;}
58
- #codepeople-review-banner .codepeople-review-banner-picture{width:120px;padding:10px 10px 10px 10px;float:left;text-align:center;}
59
- #codepeople-review-banner .codepeople-review-banner-content{float: left;padding:10px;width: calc( 100% - 160px );width: -webkit-calc( 100% - 160px );width: -moz-calc( 100% - 160px );width: -o-calc( 100% - 160px );}
60
- #codepeople-review-banner .codepeople-review-banner-buttons{padding-top:20px;}
61
- #codepeople-review-banner .no-thank-button,
62
- #codepeople-review-banner .main-button{height: 28px;border-width:1px;border-style:solid;border-radius:5px;text-decoration: none;}
63
- #codepeople-review-banner .main-button{background: #0085ba;border-color: #0073aa #006799 #006799;-webkit-box-shadow: 0 1px 0 #006799;box-shadow: 0 1px 0 #006799;color: #fff;text-decoration: none;text-shadow: 0 -1px 1px #006799,1px 0 1px #006799,0 1px 1px #006799,-1px 0 1px #006799;}
64
- #codepeople-review-banner .no-thank-button {color: #555;border-color: #cccccc;background: #f7f7f7;-webkit-box-shadow: 0 1px 0 #cccccc;box-shadow: 0 1px 0 #cccccc;vertical-align: top;}
65
- #codepeople-review-banner .main-button:hover,#codepeople-review-banner .main-button:focus{background: #008ec2;border-color: #006799;color: #fff;}
66
- #codepeople-review-banner .no-thank-button:hover,
67
- #codepeople-review-banner .no-thank-button:focus{background: #fafafa;border-color: #999;color: #23282d;}
68
- @media screen AND (max-width:760px)
69
- {
70
- #codepeople-review-banner{position:relative;top:50px;}
71
- #codepeople-review-banner .codepeople-review-banner-picture{display:none;}
72
- #codepeople-review-banner .codepeople-review-banner-content{width:calc( 100% - 20px );width:-webkit-calc( 100% - 20px );width:-moz-calc( 100% - 20px );width:-o-calc( 100% - 20px );}
73
- }
74
- </style>
75
- <div id="codepeople-review-banner">
76
- <div class="codepeople-review-banner-picture">
77
- <img alt="" src="https://secure.gravatar.com/avatar/c0662edcefb5a4e2ab12803856ba2358?s=150&amp;d=mm&amp;r=g" style="width:80px;">
78
- </div>
79
- <div class="codepeople-review-banner-content">
80
- <div class="codepeople-review-banner-text">
81
- <p><strong>Want to help to the development of the "<?php print $plugin_data[ 'plugin_name' ]; ?>" plugin?</strong> The main features of this plugin are provided free of charge. We need your help to continue developing it and adding new features. If you want to help with the development please <span style="color:#1582AB;font-weight:bold;">add a review to support it</span>. Thank you!</p>
82
- </div>
83
- <div class="codepeople-review-banner-buttons">
84
- <form method="post" target="_blank">
85
- <button class="main-button" onclick="jQuery(this).closest('[id=\'codepeople-review-banner\']').hide();">Publish a Review</button>
86
- <input type="hidden" name="codepeople_promote_banner_plugin" value="<?php echo esc_attr($plugin_slug); ?>" />
87
- <input type="hidden" name="codepeople_promote_banner_action" value="set-review" />
88
- </form>
89
- <form method="post">
90
- <button class="no-thank-button">No Thanks</button>
91
- <input type="hidden" name="codepeople_promote_banner_plugin" value="<?php echo esc_attr($plugin_slug); ?>" />
92
- <input type="hidden" name="codepeople_promote_banner_action" value="not-thanks" />
93
- </form>
94
- <div style="clear:both;display:block;"></div>
95
- </div>
96
- <div style="clear:both;"></div>
97
- </div>
98
- <div style="clear:both;"></div>
99
- </div>
100
- <?php
101
- return;
102
- }
103
- }
104
- }
105
- add_action( 'admin_bar_menu', 'codepeople_add_promote_banner' );
106
- } // End codepeople_promote_banner block
107
- ?>
1
+ <?php
2
+ global $codepeople_promote_banner_plugins; // Global variable shared by multiple plugins.
3
+ if ( empty( $codepeople_promote_banner_plugins ) ) {
4
+ $codepeople_promote_banner_plugins = array();
5
+ }
6
+ $codepeople_promote_banner_plugins['codepeople-calculated-fields-form'] = array(
7
+ 'plugin_name' => 'Calculated Fields Form',
8
+ 'plugin_url' => 'https://wordpress.org/support/plugin/calculated-fields-form/reviews/#new-post',
9
+ );
10
+
11
+ if ( ! function_exists( 'codepeople_add_promote_banner' ) ) {
12
+ function codepeople_add_promote_banner( $wp_admin_bar ) {
13
+ global $codepeople_promote_banner_plugins;
14
+ if (
15
+ empty( $codepeople_promote_banner_plugins ) ||
16
+ ! is_admin() ||
17
+ ! current_user_can( 'manage_options' )
18
+ ) {
19
+ return;
20
+ }
21
+
22
+ $screen = get_current_screen();
23
+ if ( 'post' == $screen->post_type || 'page' == $screen->post_type ) {
24
+ return;
25
+ }
26
+
27
+ // Take action over the banner
28
+ if ( ! empty( $_POST['codepeople_promote_banner_plugin'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
29
+ $_codepeople_promote_banner_plugin = sanitize_text_field( wp_unslash( $_POST['codepeople_promote_banner_plugin'] ) ); // phpcs:ignore WordPress.Security.NonceVerification
30
+ if ( ! empty( $codepeople_promote_banner_plugins[ $_codepeople_promote_banner_plugin ] ) ) {
31
+ set_transient( 'codepeople_promote_banner_' . $_codepeople_promote_banner_plugin, -1, 0 );
32
+ if (
33
+ ! empty( $_POST['codepeople_promote_banner_action'] ) && // phpcs:ignore WordPress.Security.NonceVerification
34
+ 'set-review' == $_POST['codepeople_promote_banner_action'] && // phpcs:ignore WordPress.Security.NonceVerification
35
+ ! empty( $codepeople_promote_banner_plugins[ $_codepeople_promote_banner_plugin ]['plugin_url'] )
36
+ ) {
37
+ print '<script>document.location.href="' . esc_url( $codepeople_promote_banner_plugins[ $_codepeople_promote_banner_plugin ]['plugin_url'] ) . '";</script>';
38
+ }
39
+ }
40
+ }
41
+
42
+ $minimum_days = 86400 * 7;
43
+ $now = time();
44
+
45
+ foreach ( $codepeople_promote_banner_plugins as $plugin_slug => $plugin_data ) {
46
+ $value = get_transient( 'codepeople_promote_banner_' . $plugin_slug );
47
+ if ( false === $value ) {
48
+ $value = $now;
49
+ set_transient( 'codepeople_promote_banner_' . $plugin_slug, $value, 0 );
50
+ }
51
+
52
+ if ( $minimum_days <= abs( $now - $value ) && 0 < $value * 1 ) {
53
+ ?>
54
+ <style>
55
+ #codepeople-review-banner{width:calc( 100% - 20px );width:-webkit-calc( 100% - 20px );width:-moz-calc( 100% - 20px );width:-o-calc( 100% - 20px );border:10px solid #1582AB;background:#FFF;display:table;}
56
+ #codepeople-review-banner form{float:left; padding:0 5px;}
57
+ #codepeople-review-banner .codepeople-review-banner-picture{width:120px;padding:10px 10px 10px 10px;float:left;text-align:center;}
58
+ #codepeople-review-banner .codepeople-review-banner-content{float: left;padding:10px;width: calc( 100% - 160px );width: -webkit-calc( 100% - 160px );width: -moz-calc( 100% - 160px );width: -o-calc( 100% - 160px );}
59
+ #codepeople-review-banner .codepeople-review-banner-buttons{padding-top:20px;}
60
+ #codepeople-review-banner .no-thank-button,
61
+ #codepeople-review-banner .main-button{height: 28px;border-width:1px;border-style:solid;border-radius:5px;text-decoration: none;}
62
+ #codepeople-review-banner .main-button{background: #0085ba;border-color: #0073aa #006799 #006799;-webkit-box-shadow: 0 1px 0 #006799;box-shadow: 0 1px 0 #006799;color: #fff;text-decoration: none;text-shadow: 0 -1px 1px #006799,1px 0 1px #006799,0 1px 1px #006799,-1px 0 1px #006799;}
63
+ #codepeople-review-banner .no-thank-button {color: #555;border-color: #cccccc;background: #f7f7f7;-webkit-box-shadow: 0 1px 0 #cccccc;box-shadow: 0 1px 0 #cccccc;vertical-align: top;}
64
+ #codepeople-review-banner .main-button:hover,#codepeople-review-banner .main-button:focus{background: #008ec2;border-color: #006799;color: #fff;}
65
+ #codepeople-review-banner .no-thank-button:hover,
66
+ #codepeople-review-banner .no-thank-button:focus{background: #fafafa;border-color: #999;color: #23282d;}
67
+ @media screen AND (max-width:760px)
68
+ {
69
+ #codepeople-review-banner{position:relative;top:50px;}
70
+ #codepeople-review-banner .codepeople-review-banner-picture{display:none;}
71
+ #codepeople-review-banner .codepeople-review-banner-content{width:calc( 100% - 20px );width:-webkit-calc( 100% - 20px );width:-moz-calc( 100% - 20px );width:-o-calc( 100% - 20px );}
72
+ }
73
+ </style>
74
+ <div id="codepeople-review-banner">
75
+ <div class="codepeople-review-banner-picture">
76
+ <img alt="" src="https://secure.gravatar.com/avatar/c0662edcefb5a4e2ab12803856ba2358?s=150&amp;d=mm&amp;r=g" style="width:80px;">
77
+ </div>
78
+ <div class="codepeople-review-banner-content">
79
+ <div class="codepeople-review-banner-text">
80
+ <p><strong>Want to help to the development of the "<?php print esc_html( $plugin_data['plugin_name'] ); ?>" plugin?</strong> The main features of this plugin are provided free of charge. We need your help to continue developing it and adding new features. If you want to help with the development please <span style="color:#1582AB;font-weight:bold;">add a review to support it</span>. Thank you!</p>
81
+ </div>
82
+ <div class="codepeople-review-banner-buttons">
83
+ <form method="post" target="_blank">
84
+ <button class="main-button" onclick="jQuery(this).closest('[id=\'codepeople-review-banner\']').hide();">Publish a Review</button>
85
+ <input type="hidden" name="codepeople_promote_banner_plugin" value="<?php echo esc_attr( $plugin_slug ); ?>" />
86
+ <input type="hidden" name="codepeople_promote_banner_action" value="set-review" />
87
+ </form>
88
+ <form method="post">
89
+ <button class="no-thank-button">No Thanks</button>
90
+ <input type="hidden" name="codepeople_promote_banner_plugin" value="<?php echo esc_attr( $plugin_slug ); ?>" />
91
+ <input type="hidden" name="codepeople_promote_banner_action" value="not-thanks" />
92
+ </form>
93
+ <div style="clear:both;display:block;"></div>
94
+ </div>
95
+ <div style="clear:both;"></div>
96
+ </div>
97
+ <div style="clear:both;"></div>
98
+ </div>
99
+ <?php
100
+ return;
101
+ }
102
+ }
103
+ }
104
+ add_action( 'admin_bar_menu', 'codepeople_add_promote_banner' );
105
+ } // End codepeople_promote_banner block
106
+ ?>
 
inc/cpcff_compatibility.inc.php CHANGED
@@ -1,110 +1,100 @@
1
- <?php
2
- /**
3
- * Operations for checking the compatibility with other plugins: CPCFF_COMPATIBILITY class
4
- *
5
- * @package CFF.
6
- * @since 1.0.370
7
- */
8
-
9
- if(!class_exists('CPCFF_COMPATIBILITY'))
10
- {
11
- class CPCFF_COMPATIBILITY
12
- {
13
- private static function init()
14
- {
15
- return array(
16
- array(
17
- 'plugin' => 'Breeze - WordPress Cache Plugin',
18
- 'check' => 'BREEZE_VERSION',
19
- 'type' => 'constant',
20
- 'mssg' => __('There is active the <b>Breeze - WordPress Cache Plugin</b> plugin. If the forms are not visible, please tick the <i>"There is active an optimization plugin in WordPress"</i> and Purge the Breeze cache.', 'calculated-fields-form')
21
- ),
22
- array(
23
- 'plugin' => 'Fast Velocity Minify',
24
- 'check' => 'fvm_compat_checker',
25
- 'type' => 'function',
26
- 'mssg' => __('There is active the <b>Fast Velocity Minify</b> plugin. If the forms are not visible, please try disabling the <i>"Disable minification on JS files"</i> or <i>"Disable JavaScript processing"</i> options in the <b>Fast Velocity Minify</b> settings.', 'calculated-fields-form')
27
- ),
28
- array(
29
- 'plugin' => 'W3 Total Cache',
30
- 'check' => 'W3TC',
31
- 'type' => 'constant',
32
- 'mssg' => __('There is active the <b>W3 Total Cache</b> plugin. If the forms are not visible, please tick the checkbox.', 'calculated-fields-form')
33
- ),
34
- array(
35
- 'plugin' => 'Autoptimize',
36
- 'check' => 'autoptimize',
37
- 'type' => 'function',
38
- 'mssg' => __('There is active the <b>Autoptimize</b> plugin. If the forms are not visible, please try disabling the <i>"Force JavaScript in &lt;head&gt;"</i> option in the <b>Autoptimize</b> settings, or remove the jQuery file from the <i>"Exclude scripts from Autoptimize"</i> one.', 'calculated-fields-form')
39
- ),
40
- array(
41
- 'plugin' => 'LiteSpeed Cache',
42
- 'check' => 'run_litespeed_cache',
43
- 'type' => 'function',
44
- 'mssg' => __('There is active the <b>LiteSpeed Cache</b> plugin. If the forms are not visible, please try disabling the <i>"JS Combine"</i> option in the <b>Optimize</b> tab of <b>LiteSpeed Cache</b> settings.', 'calculated-fields-form')
45
- ),
46
- array(
47
- 'plugin' => 'WP Rocket',
48
- 'check' => 'WP_ROCKET_VERSION',
49
- 'type' => 'constant',
50
- 'mssg' => __('There is active the <b>WP Rocket</b> plugin. If the forms are not visible, please try disabling the <i>"Combine JavaScript files"</i> option in the <b>FILE OPTIMIZATION</b> tab of <b>WP Rocket</b> settings, and remember to clear the website cache.', 'calculated-fields-form')
51
- ),
52
- array(
53
- 'plugin' => 'SG Optimizer',
54
- 'check' => 'siteground_optimizer_helper',
55
- 'type' => 'object',
56
- 'mssg' => __('There is active the <b>SG Optimizer</b> plugin. If the forms are not visible, please try disabling the options: <i>"Minify the HTML Output"</i> and <i>"Minify JavaScript Files"</i> in the <b>SG Optimizer</b> settings, and remember to purge the website cache.', 'calculated-fields-form')
57
- ),
58
- array(
59
- 'plugin' => 'Hummingbird',
60
- 'check' => 'WPHB_VERSION',
61
- 'type' => 'constant',
62
- 'mssg' => __('There is active the <b>Hummingbird</b> plugin. If the forms are not visible, check the <i>"Hummingbird &gt; Asset Optimization"</i> options. Make sure that jQuery or other required scripts are not configured to load after the page loads. Remember to purge the website cache, after edit the plugin settings.', 'calculated-fields-form')
63
- ),
64
- );
65
- } // End init
66
-
67
- private static function format_warning_mssg($plugin)
68
- {
69
- return '<div class="cff-compatibility-warning">'.$plugin['mssg'].'</div>';
70
- } // End format_warning_mssg
71
-
72
- public static function warnings()
73
- {
74
- $plugins = self::init();
75
- $warning_mssgs = '';
76
- foreach($plugins as $plugin)
77
- {
78
- switch($plugin['type'])
79
- {
80
- case 'function':
81
- if(function_exists($plugin['check']))
82
- {
83
- $warning_mssgs .= self::format_warning_mssg($plugin);
84
- }
85
- break;
86
- case 'class':
87
- if(class_exists($plugin['check']))
88
- {
89
- $warning_mssgs .= self::format_warning_mssg($plugin);
90
- }
91
- break;
92
- case 'object':
93
- if(isset($GLOBALS[$plugin['check']]))
94
- {
95
- $warning_mssgs .= self::format_warning_mssg($plugin);
96
- }
97
- break;
98
- case 'constant':
99
- if(defined($plugin['check']))
100
- {
101
- $warning_mssgs .= self::format_warning_mssg($plugin);
102
- }
103
- break;
104
- }
105
- }
106
- return $warning_mssgs;
107
- } // End blog_id
108
-
109
- } // End CPCFF_COMPATIBILITY
110
- }
1
+ <?php
2
+ /**
3
+ * Operations for checking the compatibility with other plugins: CPCFF_COMPATIBILITY class
4
+ *
5
+ * @package CFF.
6
+ * @since 1.0.370
7
+ */
8
+
9
+ if ( ! class_exists( 'CPCFF_COMPATIBILITY' ) ) {
10
+ class CPCFF_COMPATIBILITY {
11
+
12
+ private static function init() {
13
+ return array(
14
+ array(
15
+ 'plugin' => 'Breeze - WordPress Cache Plugin',
16
+ 'check' => 'BREEZE_VERSION',
17
+ 'type' => 'constant',
18
+ 'mssg' => __( 'There is active the <b>Breeze - WordPress Cache Plugin</b> plugin. If the forms are not visible, please tick the <i>"There is active an optimization plugin in WordPress"</i> and Purge the Breeze cache.', 'calculated-fields-form' ),
19
+ ),
20
+ array(
21
+ 'plugin' => 'Fast Velocity Minify',
22
+ 'check' => 'fvm_compat_checker',
23
+ 'type' => 'function',
24
+ 'mssg' => __( 'There is active the <b>Fast Velocity Minify</b> plugin. If the forms are not visible, please try disabling the <i>"Disable minification on JS files"</i> or <i>"Disable JavaScript processing"</i> options in the <b>Fast Velocity Minify</b> settings.', 'calculated-fields-form' ),
25
+ ),
26
+ array(
27
+ 'plugin' => 'W3 Total Cache',
28
+ 'check' => 'W3TC',
29
+ 'type' => 'constant',
30
+ 'mssg' => __( 'There is active the <b>W3 Total Cache</b> plugin. If the forms are not visible, please tick the checkbox.', 'calculated-fields-form' ),
31
+ ),
32
+ array(
33
+ 'plugin' => 'Autoptimize',
34
+ 'check' => 'autoptimize',
35
+ 'type' => 'function',
36
+ 'mssg' => __( 'There is active the <b>Autoptimize</b> plugin. If the forms are not visible, please try disabling the <i>"Force JavaScript in &lt;head&gt;"</i> option in the <b>Autoptimize</b> settings, or remove the jQuery file from the <i>"Exclude scripts from Autoptimize"</i> one.', 'calculated-fields-form' ),
37
+ ),
38
+ array(
39
+ 'plugin' => 'LiteSpeed Cache',
40
+ 'check' => 'run_litespeed_cache',
41
+ 'type' => 'function',
42
+ 'mssg' => __( 'There is active the <b>LiteSpeed Cache</b> plugin. If the forms are not visible, please try disabling the <i>"JS Combine"</i> option in the <b>Optimize</b> tab of <b>LiteSpeed Cache</b> settings.', 'calculated-fields-form' ),
43
+ ),
44
+ array(
45
+ 'plugin' => 'WP Rocket',
46
+ 'check' => 'WP_ROCKET_VERSION',
47
+ 'type' => 'constant',
48
+ 'mssg' => __( 'There is active the <b>WP Rocket</b> plugin. If the forms are not visible, please try disabling the <i>"Combine JavaScript files"</i> option in the <b>FILE OPTIMIZATION</b> tab of <b>WP Rocket</b> settings, and remember to clear the website cache.', 'calculated-fields-form' ),
49
+ ),
50
+ array(
51
+ 'plugin' => 'SG Optimizer',
52
+ 'check' => 'siteground_optimizer_helper',
53
+ 'type' => 'object',
54
+ 'mssg' => __( 'There is active the <b>SG Optimizer</b> plugin. If the forms are not visible, please try disabling the options: <i>"Minify the HTML Output"</i> and <i>"Minify JavaScript Files"</i> in the <b>SG Optimizer</b> settings, and remember to purge the website cache.', 'calculated-fields-form' ),
55
+ ),
56
+ array(
57
+ 'plugin' => 'Hummingbird',
58
+ 'check' => 'WPHB_VERSION',
59
+ 'type' => 'constant',
60
+ 'mssg' => __( 'There is active the <b>Hummingbird</b> plugin. If the forms are not visible, check the <i>"Hummingbird &gt; Asset Optimization"</i> options. Make sure that jQuery or other required scripts are not configured to load after the page loads. Remember to purge the website cache, after edit the plugin settings.', 'calculated-fields-form' ),
61
+ ),
62
+ );
63
+ } // End init
64
+
65
+ private static function format_warning_mssg( $plugin ) {
66
+ return '<div class="cff-compatibility-warning">' . $plugin['mssg'] . '</div>';
67
+ } // End format_warning_mssg
68
+
69
+ public static function warnings() {
70
+ $plugins = self::init();
71
+ $warning_mssgs = '';
72
+ foreach ( $plugins as $plugin ) {
73
+ switch ( $plugin['type'] ) {
74
+ case 'function':
75
+ if ( function_exists( $plugin['check'] ) ) {
76
+ $warning_mssgs .= self::format_warning_mssg( $plugin );
77
+ }
78
+ break;
79
+ case 'class':
80
+ if ( class_exists( $plugin['check'] ) ) {
81
+ $warning_mssgs .= self::format_warning_mssg( $plugin );
82
+ }
83
+ break;
84
+ case 'object':
85
+ if ( isset( $GLOBALS[ $plugin['check'] ] ) ) {
86
+ $warning_mssgs .= self::format_warning_mssg( $plugin );
87
+ }
88
+ break;
89
+ case 'constant':
90
+ if ( defined( $plugin['check'] ) ) {
91
+ $warning_mssgs .= self::format_warning_mssg( $plugin );
92
+ }
93
+ break;
94
+ }
95
+ }
96
+ return $warning_mssgs;
97
+ } // End blog_id
98
+
99
+ } // End CPCFF_COMPATIBILITY
100
+ }
 
 
 
 
 
 
 
 
 
 
inc/cpcff_form.inc.php CHANGED
@@ -1,479 +1,509 @@
1
- <?php
2
- /**
3
- * Form class with database interaction, data, and methods.
4
- *
5
- * @package CFF.
6
- * @since 1.0.179
7
- */
8
- require_once dirname(__FILE__).'/cpcff_revisions.inc.php';
9
-
10
- if(!class_exists('CPCFF_FORM'))
11
- {
12
- /**
13
- * Class to create create, save, and read the forms data.
14
- *
15
- * @since 1.0.179
16
- */
17
- class CPCFF_FORM
18
- {
19
- /**
20
- * Form's id
21
- * Instance property.
22
- *
23
- * @var integer $_id
24
- */
25
- private $_id;
26
-
27
- /**
28
- * Form's settings
29
- * Instance property.
30
- *
31
- * @var array $_settings. Associative array with the form's settings.
32
- */
33
- private $_settings;
34
-
35
- /**
36
- * Form's fields
37
- * Instance property.
38
- *
39
- * @var array $_fields. Associative array with the form's fields.
40
- */
41
- private $_fields;
42
-
43
- /**
44
- * Instance of the CPCFF_REVISIONS object to interact with the form's revisions.
45
- */
46
- private $_revisions_obj;
47
- /*********************************** PUBLIC METHODS ********************************************/
48
-
49
- /**
50
- * Constructs a CPCFF_FORM object.
51
- *
52
- * @param integer $id the form's id.
53
- */
54
- public function __construct( $id )
55
- {
56
- $this->_id = $id;
57
- $this->_settings = array();
58
- $this->_fields = array();
59
- $this->_revisions_obj = new CPCFF_REVISIONS($this);
60
- } // End __construct
61
-
62
- /**
63
- * Creates a new form with the default data, and the name passed as parameter,
64
- * and returns an instance of the CPCFF_FORM class.
65
- *
66
- * @param string $form_name. The form's name displayed in the settings page of the plugin.
67
- *
68
- * @return object.
69
- */
70
- static public function create_default( $form_name, $category_name = '', $form_template = 0 )
71
- {
72
- global $wpdb, $cpcff_default_texts_array;
73
-
74
- $_form_structure = CP_CALCULATEDFIELDSF_DEFAULT_form_structure;
75
- // Get form structure from server !!!
76
- if ( ! empty( $form_template ) ) {
77
- $response = wp_remote_get(
78
- 'https://cff.dwbooster.com/forms/forms/'.$form_template.'.cpfm',
79
- array(
80
- 'sslverify' => false
81
- )
82
- );
83
-
84
- if ( ! is_wp_error( $response ) ) {
85
- $_form_structure_tmp = wp_remote_retrieve_body( $response );
86
- if ( !empty( $_form_structure_tmp ) ) {
87
- $_form_structure = $_form_structure_tmp;
88
- }
89
- }
90
- }
91
-
92
- if(
93
- $wpdb->insert(
94
- $wpdb->prefix.CP_CALCULATEDFIELDSF_FORMS_TABLE,
95
- array(
96
- // Form name
97
- 'form_name' => stripcslashes($form_name),
98
-
99
- // Form structure
100
- 'form_structure' => $_form_structure,
101
-
102
- // Notification email
103
- 'fp_from_email' => CP_CALCULATEDFIELDSF_DEFAULT_fp_from_email,
104
- 'fp_destination_emails' => CP_CALCULATEDFIELDSF_DEFAULT_fp_destination_emails,
105
- 'fp_subject' => CP_CALCULATEDFIELDSF_DEFAULT_fp_subject,
106
- 'fp_inc_additional_info' => CP_CALCULATEDFIELDSF_DEFAULT_fp_inc_additional_info,
107
- 'fp_return_page' => CP_CALCULATEDFIELDSF_DEFAULT_fp_return_page,
108
- 'fp_message' => CP_CALCULATEDFIELDSF_DEFAULT_fp_message,
109
-
110
- // Notification email copy to the user
111
- 'cu_enable_copy_to_user' => CP_CALCULATEDFIELDSF_DEFAULT_cu_enable_copy_to_user,
112
- 'cu_user_email_field' => CP_CALCULATEDFIELDSF_DEFAULT_cu_user_email_field,
113
- 'cu_subject' => CP_CALCULATEDFIELDSF_DEFAULT_cu_subject,
114
- 'cu_message' => CP_CALCULATEDFIELDSF_DEFAULT_cu_message,
115
-
116
- // Activate validation and validation's texts
117
- 'vs_use_validation' => CP_CALCULATEDFIELDSF_DEFAULT_vs_use_validation,
118
- 'vs_text_is_required' => CP_CALCULATEDFIELDSF_DEFAULT_vs_text_is_required,
119
- 'vs_text_is_email' => CP_CALCULATEDFIELDSF_DEFAULT_vs_text_is_email,
120
- 'vs_text_datemmddyyyy' => CP_CALCULATEDFIELDSF_DEFAULT_vs_text_datemmddyyyy,
121
- 'vs_text_dateddmmyyyy' => CP_CALCULATEDFIELDSF_DEFAULT_vs_text_dateddmmyyyy,
122
- 'vs_text_number' => CP_CALCULATEDFIELDSF_DEFAULT_vs_text_number,
123
- 'vs_text_digits' => CP_CALCULATEDFIELDSF_DEFAULT_vs_text_digits,
124
- 'vs_text_max' => CP_CALCULATEDFIELDSF_DEFAULT_vs_text_max,
125
- 'vs_text_min' => CP_CALCULATEDFIELDSF_DEFAULT_vs_text_min,
126
- 'vs_all_texts' => serialize($cpcff_default_texts_array),
127
-
128
- // Paypal settings
129
- 'enable_paypal' => CP_CALCULATEDFIELDSF_DEFAULT_ENABLE_PAYPAL,
130
- 'paypal_email' => CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_EMAIL,
131
- 'request_cost' => 'fieldname1',
132
- 'paypal_product_name' => CP_CALCULATEDFIELDSF_DEFAULT_PRODUCT_NAME,
133
- 'currency' => CP_CALCULATEDFIELDSF_DEFAULT_CURRENCY,
134
- 'paypal_language' => CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_LANGUAGE,
135
-
136
- // Captcha settings
137
- 'cv_enable_captcha' => CP_CALCULATEDFIELDSF_DEFAULT_cv_enable_captcha,
138
- 'cv_width' => CP_CALCULATEDFIELDSF_DEFAULT_cv_width,
139
- 'cv_height' => CP_CALCULATEDFIELDSF_DEFAULT_cv_height,
140
- 'cv_chars' => CP_CALCULATEDFIELDSF_DEFAULT_cv_chars,
141
- 'cv_font' => CP_CALCULATEDFIELDSF_DEFAULT_cv_font,
142
- 'cv_min_font_size' => CP_CALCULATEDFIELDSF_DEFAULT_cv_min_font_size,
143
- 'cv_max_font_size' => CP_CALCULATEDFIELDSF_DEFAULT_cv_max_font_size,
144
- 'cv_noise' => CP_CALCULATEDFIELDSF_DEFAULT_cv_noise,
145
- 'cv_noise_length' => CP_CALCULATEDFIELDSF_DEFAULT_cv_noise_length,
146
- 'cv_background' => CP_CALCULATEDFIELDSF_DEFAULT_cv_background,
147
- 'cv_border' => CP_CALCULATEDFIELDSF_DEFAULT_cv_border,
148
- 'cv_text_enter_valid_captcha' => CP_CALCULATEDFIELDSF_DEFAULT_cv_text_enter_valid_captcha,
149
-
150
- 'enable_submit' => CP_CALCULATEDFIELDSF_DEFAULT_display_submit_button,
151
- 'category' => $category_name
152
- ),
153
- array(
154
- '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s'
155
- )
156
- )
157
- )
158
- {
159
- return new self($wpdb->insert_id);
160
- }
161
- return false;
162
- } // End create_default
163
-
164
- /**
165
- * Sanitize the form's structure. Fields titltes and instructions for users,
166
- * form's title and description. etc.
167
- */
168
- static public function sanitize_structure($structure)
169
- {
170
- if(is_array($structure))
171
- {
172
- if(is_array($structure[0]))
173
- {
174
- foreach($structure[0] as $index => $obj)
175
- {
176
- if(isset($obj->title))
177
- $structure[0][$index]->title = CPCFF_AUXILIARY::sanitize($structure[0][$index]->title);
178
- if(isset($obj->userhelp))
179
- $structure[0][$index]->userhelp = CPCFF_AUXILIARY::sanitize($structure[0][$index]->userhelp);
180
- }
181
- }
182
-
183
- if(is_array($structure[1]) && count($structure[1]))
184
- {
185
- if(is_object($structure[1][0]))
186
- {
187
- if(isset($structure[1][0]->title))
188
- $structure[1][0]->title = CPCFF_AUXILIARY::sanitize($structure[1][0]->title);
189
- if(isset($structure[1][0]->description))
190
- $structure[1][0]->description = CPCFF_AUXILIARY::sanitize($structure[1][0]->description);
191
- }
192
- }
193
- }
194
- return $structure;
195
- } // End sanitize_structure
196
-
197
- /**
198
- * Clones the current form.
199
- *
200
- * @return mixed, a new instance of the CPCFF_FORM or false.
201
- */
202
- public function clone_form()
203
- {
204
- global $wpdb;
205
-
206
- $row = $this->_get_settings();
207
- if(!empty($row))
208
- {
209
- unset($row["id"]);
210
- $row["form_name"] = 'Cloned: '.$row["form_name"];
211
- if($wpdb->insert( $wpdb->prefix.CP_CALCULATEDFIELDSF_FORMS_TABLE, $row)) return new self($wpdb->insert_id);
212
- }
213
- return false;
214
- } // End clone_form
215
-
216
- /**
217
- * Returns the id of current form.
218
- *
219
- * @return integer
220
- */
221
- public function get_id()
222
- {
223
- return $this->_id;
224
- } // end get_id
225
-
226
- /**
227
- * Reads the corresponding attribute in the form's settings.
228
- *
229
- * Reads the attribute in the form's settings, and if it does not exists returns the default value.
230
- * Applies the filter cpcff_get_option
231
- *
232
- * @param string, name of the attribute to read.
233
- * @param mixes, default value of the attribute.
234
- * @return mixed, it depends of the option to read.
235
- */
236
- public function get_option( $option, $default )
237
- {
238
- // Initialize the value with the default values
239
- $value = $default;
240
- $this->_get_settings();
241
-
242
- if(isset($this->_settings[$option])) $value = @$this->_settings[$option];
243
-
244
- // If the form's structure is a JSON text decodes it.
245
- if(
246
- $option == 'form_structure' &&
247
- !is_array( $value )
248
- )
249
- {
250
- $form_data = CPCFF_AUXILIARY::json_decode( $value, 'normal' );
251
- if(!is_null($form_data))
252
- {
253
- $value = $this->_settings['form_structure'] = $form_data;
254
- }
255
- }
256
- // Adds to the thank you page URL a random attribute to prevent the page be cached
257
- elseif(
258
- $option == 'fp_return_page' &&
259
- !is_admin() &&
260
- get_option( 'CP_CALCULATEDFIELDSF_TYPC', CP_CALCULATEDFIELDSF_TYPC )
261
- )
262
- {
263
- if(!empty($value)) $value .= (strpos($value, '?') === false ? '?' : '&').'cff_no_cache='.time();
264
- }
265
- // If the texts where not defined previously or the thank you page is empty populate them with the default values
266
- elseif (
267
- (
268
- $option == 'vs_all_texts' ||
269
- $option == 'fp_return_page'
270
- ) &&
271
- empty( $value )
272
- )
273
- {
274
- $value = $default;
275
- }
276
-
277
- /**
278
- * Filters applied before returning a form option,
279
- * use three parameters: The value of option, the name of option and the form's id
280
- * returns the new option's value
281
- */
282
- if(!is_admin()) $value = apply_filters( 'cpcff_get_option', $value, $option, $this->_id );
283
-
284
- return $value;
285
- } // End get_option
286
-
287
- /**
288
- * Returns the list of fields in the forms.
289
- *
290
- * @return array, associative array of objects where the fields' names are the indices and fields' structures the values.
291
- */
292
- public function get_fields()
293
- {
294
- if(!empty($this->_fields)) return $this->_fields;
295
-
296
- $form_structure = $this->get_option('form_structure', array());
297
- if(!empty($form_structure[0]))
298
- {
299
- foreach($form_structure[0] as $field)
300
- $this->_fields[$field->name] = $field;
301
- }
302
- return $this->_fields;
303
- } // End get_fields
304
-
305
- public function save_settings( $params )
306
- {
307
- global $wpdb, $cpcff_default_texts_array;
308
-
309
- foreach($params as $i => $v)
310
- if($i != 'form_structure')
311
- $params[$i] = CPCFF_AUXILIARY::stripscript_recursive($v);
312
-
313
- $data = array(
314
- 'form_structure' => (isset($params['form_structure'])) ? $params['form_structure'] : CP_CALCULATEDFIELDSF_DEFAULT_form_structure,
315
-
316
- // Notification email
317
- 'fp_from_email' => (isset($params['fp_from_email']))? trim($params['fp_from_email']) : '',
318
- 'fp_destination_emails' => (isset($params['fp_destination_emails'])) ? trim($params['fp_destination_emails']) : '',
319
- 'fp_subject' => (isset($params['fp_subject'])) ? $params['fp_subject'] : '',
320
- 'fp_inc_additional_info' => (isset($params['fp_inc_additional_info']) && $params['fp_inc_additional_info'] == 'true') ? 'true' : 'false',
321
- 'fp_return_page' => (isset($params['fp_return_page'])) ? trim($params['fp_return_page']) : '',
322
- 'fp_message' => (isset($params['fp_message'])) ? $params['fp_message'] : '',
323
- 'fp_emailformat' => (isset($params['fp_emailformat']) && $params['fp_emailformat'] == 'text') ? 'text' : 'html',
324
-
325
- // Notification email copy to the user
326
- 'cu_enable_copy_to_user' => (isset($params['cu_enable_copy_to_user']) && $params['cu_enable_copy_to_user'] == 'true') ? 'true' : 'false',
327
- 'cu_user_email_field' => (!empty($params['cu_user_email_field']))? $params[ 'cu_user_email_field' ] : '',
328
- 'cu_subject' => (isset($params['cu_subject'])) ? $params['cu_subject'] : '',
329
- 'cu_message' => (isset($params['cu_message'])) ? $params['cu_message'] : '',
330
- 'cu_emailformat' => (isset($params['cu_emailformat']) && $params['cu_emailformat'] == 'text') ? 'text' : 'html',
331
-
332
- // PayPal settings
333
- 'enable_paypal' => (isset($params["enable_paypal"])) ? $params["enable_paypal"] : 0,
334
- 'paypal_email' => (isset($params["paypal_email"])) ? trim($params["paypal_email"]) : '',
335
- 'request_cost' => (isset($params["request_cost"])) ? trim($params["request_cost"]) : '',
336
- 'paypal_product_name' => (isset($params["paypal_product_name"])) ? $params["paypal_product_name"] : '',
337
- 'currency' => (isset($params["currency"])) ? trim($params["currency"]) : 'USD',
338
- 'paypal_language' => (isset($params["paypal_language"])) ? trim($params["paypal_language"]) : 'EN',
339
- 'paypal_mode' => (isset($params["paypal_mode"])) ? $params["paypal_mode"] : 'production',
340
- 'paypal_recurrent' => (isset($params["paypal_recurrent"])) ? $params["paypal_recurrent"] : 0,
341
- 'paypal_identify_prices' => (isset($params['paypal_identify_prices'])) ? $params['paypal_identify_prices'] : '0',
342
- 'paypal_zero_payment' => (isset($params["paypal_zero_payment"])) ? $params["paypal_zero_payment"] : 0,
343
-
344
- // Texts
345
- 'vs_use_validation' => CP_CALCULATEDFIELDSF_DEFAULT_vs_use_validation,
346
- 'vs_text_is_required' => (isset($params['vs_text_is_required'])) ? $params['vs_text_is_required'] : CP_CALCULATEDFIELDSF_DEFAULT_vs_text_is_required,
347
- 'vs_text_is_email' => (isset($params['vs_text_is_email'])) ? $params['vs_text_is_email'] : CP_CALCULATEDFIELDSF_DEFAULT_vs_text_is_email,
348
- 'vs_text_datemmddyyyy' => (isset($params['vs_text_datemmddyyyy'])) ? $params['vs_text_datemmddyyyy'] : CP_CALCULATEDFIELDSF_DEFAULT_vs_text_datemmddyyyy,
349
- 'vs_text_dateddmmyyyy' => (isset($params['vs_text_dateddmmyyyy'])) ? $params['vs_text_dateddmmyyyy'] : CP_CALCULATEDFIELDSF_DEFAULT_vs_text_dateddmmyyyy,
350
- 'vs_text_number' => (isset($params['vs_text_number'])) ? $params['vs_text_number'] : CP_CALCULATEDFIELDSF_DEFAULT_vs_text_number,
351
- 'vs_text_digits' => (isset($params['vs_text_digits'])) ? $params['vs_text_digits'] : CP_CALCULATEDFIELDSF_DEFAULT_vs_text_digits,
352
- 'vs_text_max' => (isset($params['vs_text_max'])) ? $params['vs_text_max'] : CP_CALCULATEDFIELDSF_DEFAULT_vs_text_max,
353
- 'vs_text_min' => (isset($params['vs_text_min'])) ? $params['vs_text_min'] : CP_CALCULATEDFIELDSF_DEFAULT_vs_text_min,
354
- 'vs_text_previousbtn' => (isset($params['vs_text_previousbtn'])) ? $params['vs_text_previousbtn'] : 'Previous',
355
- 'vs_text_nextbtn' => (isset($params['vs_text_nextbtn'])) ? $params['vs_text_nextbtn'] : 'Next',
356
- 'vs_all_texts' => (isset($params['vs_all_texts'])) ? serialize($params['vs_all_texts']) : serialize($cpcff_default_texts_array),
357
-
358
- // Captcha settings
359
- 'cv_enable_captcha' => (isset($params['cv_enable_captcha'])) ? $params['cv_enable_captcha'] : CP_CALCULATEDFIELDSF_DEFAULT_cv_enable_captcha,
360
- 'cv_width' => (isset($params['cv_width'])) ? $params['cv_width'] : CP_CALCULATEDFIELDSF_DEFAULT_cv_width,
361
- 'cv_height' => (isset($params['cv_height'])) ? $params['cv_height'] : CP_CALCULATEDFIELDSF_DEFAULT_cv_height,
362
- 'cv_chars' => (isset($params['cv_chars'])) ? $params['cv_chars'] : CP_CALCULATEDFIELDSF_DEFAULT_cv_chars,
363
- 'cv_font' => (isset($params['cv_font'])) ? $params['cv_font'] : CP_CALCULATEDFIELDSF_DEFAULT_cv_font,
364
- 'cv_min_font_size' => (isset($params['cv_min_font_size'])) ? $params['cv_min_font_size'] : CP_CALCULATEDFIELDSF_DEFAULT_cv_min_font_size,
365
- 'cv_max_font_size' => (isset($params['cv_max_font_size'])) ? $params['cv_max_font_size'] : CP_CALCULATEDFIELDSF_DEFAULT_cv_max_font_size,
366
- 'cv_noise' => (isset($params['cv_noise'])) ? $params['cv_noise'] : CP_CALCULATEDFIELDSF_DEFAULT_cv_noise,
367
- 'cv_noise_length' => (isset($params['cv_noise_length'])) ? $params['cv_noise_length'] : CP_CALCULATEDFIELDSF_DEFAULT_cv_noise_length,
368
- 'cv_background' => (isset($params['cv_background'])) ? $params['cv_background'] : CP_CALCULATEDFIELDSF_DEFAULT_cv_background,
369
- 'cv_border' => (isset($params['cv_border'])) ? $params['cv_border'] : CP_CALCULATEDFIELDSF_DEFAULT_cv_border,
370
- 'cv_text_enter_valid_captcha' => (isset($params['cv_text_enter_valid_captcha'])) ? $params['cv_text_enter_valid_captcha'] : CP_CALCULATEDFIELDSF_DEFAULT_cv_text_enter_valid_captcha,
371
- 'category' => trim(isset($params['calculated-fields-form-category']) ? $params['calculated-fields-form-category'] : '')
372
- );
373
-
374
- $updated_rows = $wpdb->update (
375
- $wpdb->prefix.CP_CALCULATEDFIELDSF_FORMS_TABLE,
376
- $data,
377
- array( 'id' => $this->_id ),
378
- array( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ),
379
- array( '%d' )
380
- );
381
-
382
- // Revisions
383
- update_option('CP_CALCULATEDFIELDSF_REVISIONS_IN_PREVIEW', isset($params['cff-revisions-in-preview']) ? true : false);
384
-
385
- if(
386
- $updated_rows !== false &&
387
- (
388
- !isset($params['preview']) ||
389
- get_option('CP_CALCULATEDFIELDSF_REVISIONS_IN_PREVIEW')
390
- ) &&
391
- get_option('CP_CALCULATEDFIELDSF_DISABLE_REVISIONS', CP_CALCULATEDFIELDSF_DISABLE_REVISIONS) == 0
392
- ) $this->_revisions_obj->create_revision();
393
- return $updated_rows;
394
- } // End save_settings
395
-
396
- /**
397
- * Gets the correspond rown in the database
398
- */
399
- public function get_raw_data()
400
- {
401
- global $wpdb;
402
- $row = $wpdb->get_row($wpdb->prepare("SELECT * FROM ".$wpdb->prefix.CP_CALCULATEDFIELDSF_FORMS_TABLE." WHERE id=%d", $this->_id), ARRAY_A);
403
- return $row;
404
- } // End get_raw_data
405
-
406
- /**
407
- * Returns an instance of the CPCFF_REVISIONS revisions object
408
- */
409
- public function get_revisions()
410
- {
411
- return $this->_revisions_obj;
412
- } // End get_revisions
413
-
414
- /**
415
- * Creates or replace the property $this->_settings with the data stored in the revisions
416
- */
417
- public function apply_revision($revision_id)
418
- {
419
- $this->_get_settings();
420
- $revision_data = $this->_revisions_obj->data($revision_id);
421
- $this->_fields = array();
422
- $this->_settings = CPCFF_AUXILIARY::array_replace_recursive($this->_settings,$revision_data);
423
- } // End apply_revision
424
-
425
- /**
426
- * Updates the form's name
427
- *
428
- * @param string $form_name
429
- *
430
- * @return bool
431
- */
432
- public function update_name($form_name)
433
- {
434
- global $wpdb;
435
- return $wpdb->update(
436
- $wpdb->prefix.CP_CALCULATEDFIELDSF_FORMS_TABLE,
437
- array('form_name'=>$form_name),
438
- array('id' => $this->_id),
439
- array('%s'),
440
- array('%d')
441
- );
442
- } // End update_name
443
-
444
- /**
445
- * Deletes the current form.
446
- *
447
- * @return mixed the number of deleted columns or false.
448
- */
449
- public function delete_form()
450
- {
451
- global $wpdb;
452
- $this->_revisions_obj->delete_form();
453
- return $wpdb->delete(
454
- $wpdb->prefix.CP_CALCULATEDFIELDSF_FORMS_TABLE,
455
- array('id' => $this->_id),
456
- array('%d')
457
- );
458
- }
459
- /*********************************** PRIVATE METHODS ********************************************/
460
-
461
- /**
462
- * Returns the form's settings.
463
- * Checks if the settings were read previously, before reading the data from database.
464
- *
465
- * @since 1.0.184
466
- *
467
- * @return array, associative array with the database row.
468
- */
469
- private function _get_settings()
470
- {
471
- if(empty($this->_settings))
472
- {
473
- $row = $this->get_raw_data();
474
- if(!empty($row)) $this->_settings = $row;
475
- }
476
- return $this->_settings;
477
- } // End _get_settings
478
- } // End CPCFF_FORM
479
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Form class with database interaction, data, and methods.
4
+ *
5
+ * @package CFF.
6
+ * @since 1.0.179
7
+ */
8
+ require_once dirname( __FILE__ ) . '/cpcff_revisions.inc.php';
9
+
10
+ if ( ! class_exists( 'CPCFF_FORM' ) ) {
11
+ /**
12
+ * Class to create create, save, and read the forms data.
13
+ *
14
+ * @since 1.0.179
15
+ */
16
+ class CPCFF_FORM {
17
+
18
+ /**
19
+ * Form's id
20
+ * Instance property.
21
+ *
22
+ * @var integer $_id
23
+ */
24
+ private $_id;
25
+
26
+ /**
27
+ * Form's settings
28
+ * Instance property.
29
+ *
30
+ * @var array $_settings. Associative array with the form's settings.
31
+ */
32
+ private $_settings;
33
+
34
+ /**
35
+ * Form's fields
36
+ * Instance property.
37
+ *
38
+ * @var array $_fields. Associative array with the form's fields.
39
+ */
40
+ private $_fields;
41
+
42
+ /**
43
+ * Instance of the CPCFF_REVISIONS object to interact with the form's revisions.
44
+ */
45
+ private $_revisions_obj;
46
+ /*********************************** PUBLIC METHODS ********************************************/
47
+
48
+ /**
49
+ * Constructs a CPCFF_FORM object.
50
+ *
51
+ * @param integer $id the form's id.
52
+ */
53
+ public function __construct( $id ) {
54
+ $this->_id = $id;
55
+ $this->_settings = array();
56
+ $this->_fields = array();
57
+ $this->_revisions_obj = new CPCFF_REVISIONS( $this );
58
+ } // End __construct
59
+
60
+ /**
61
+ * Creates a new form with the default data, and the name passed as parameter,
62
+ * and returns an instance of the CPCFF_FORM class.
63
+ *
64
+ * @param string $form_name. The form's name displayed in the settings page of the plugin.
65
+ *
66
+ * @return object.
67
+ */
68
+ public static function create_default( $form_name, $category_name = '', $form_template = 0 ) {
69
+ global $wpdb, $cpcff_default_texts_array;
70
+
71
+ $_form_structure = CP_CALCULATEDFIELDSF_DEFAULT_form_structure;
72
+ // Get form structure from server !!!
73
+ if ( ! empty( $form_template ) ) {
74
+ $response = wp_remote_get(
75
+ 'https://cff.dwbooster.com/forms/forms/' . $form_template . '.cpfm',
76
+ array(
77
+ 'sslverify' => false,
78
+ )
79
+ );
80
+
81
+ if ( ! is_wp_error( $response ) ) {
82
+ $_form_structure_tmp = wp_remote_retrieve_body( $response );
83
+ if ( ! empty( $_form_structure_tmp ) ) {
84
+ $_form_structure = $_form_structure_tmp;
85
+ }
86
+ }
87
+ }
88
+
89
+ if (
90
+ $wpdb->insert(
91
+ $wpdb->prefix . CP_CALCULATEDFIELDSF_FORMS_TABLE,
92
+ array(
93
+ // Form name
94
+ 'form_name' => stripcslashes( $form_name ),
95
+
96
+ // Form structure
97
+ 'form_structure' => $_form_structure,
98
+
99
+ // Notification email
100
+ 'fp_from_email' => CP_CALCULATEDFIELDSF_DEFAULT_fp_from_email,
101
+ 'fp_destination_emails' => CP_CALCULATEDFIELDSF_DEFAULT_fp_destination_emails,
102
+ 'fp_subject' => CP_CALCULATEDFIELDSF_DEFAULT_fp_subject,
103
+ 'fp_inc_additional_info' => CP_CALCULATEDFIELDSF_DEFAULT_fp_inc_additional_info,
104
+ 'fp_return_page' => CP_CALCULATEDFIELDSF_DEFAULT_fp_return_page,
105
+ 'fp_message' => CP_CALCULATEDFIELDSF_DEFAULT_fp_message,
106
+
107
+ // Notification email copy to the user
108
+ 'cu_enable_copy_to_user' => CP_CALCULATEDFIELDSF_DEFAULT_cu_enable_copy_to_user,
109
+ 'cu_user_email_field' => CP_CALCULATEDFIELDSF_DEFAULT_cu_user_email_field,
110
+ 'cu_subject' => CP_CALCULATEDFIELDSF_DEFAULT_cu_subject,
111
+ 'cu_message' => CP_CALCULATEDFIELDSF_DEFAULT_cu_message,
112
+
113
+ // Activate validation and validation's texts
114
+ 'vs_use_validation' => CP_CALCULATEDFIELDSF_DEFAULT_vs_use_validation,
115
+ 'vs_text_is_required' => CP_CALCULATEDFIELDSF_DEFAULT_vs_text_is_required,
116
+ 'vs_text_is_email' => CP_CALCULATEDFIELDSF_DEFAULT_vs_text_is_email,
117
+ 'vs_text_datemmddyyyy' => CP_CALCULATEDFIELDSF_DEFAULT_vs_text_datemmddyyyy,
118
+ 'vs_text_dateddmmyyyy' => CP_CALCULATEDFIELDSF_DEFAULT_vs_text_dateddmmyyyy,
119
+ 'vs_text_number' => CP_CALCULATEDFIELDSF_DEFAULT_vs_text_number,
120
+ 'vs_text_digits' => CP_CALCULATEDFIELDSF_DEFAULT_vs_text_digits,
121
+ 'vs_text_max' => CP_CALCULATEDFIELDSF_DEFAULT_vs_text_max,
122
+ 'vs_text_min' => CP_CALCULATEDFIELDSF_DEFAULT_vs_text_min,
123
+ 'vs_all_texts' => serialize( $cpcff_default_texts_array ),
124
+
125
+ // Paypal settings
126
+ 'enable_paypal' => CP_CALCULATEDFIELDSF_DEFAULT_ENABLE_PAYPAL,
127
+ 'paypal_email' => CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_EMAIL,
128
+ 'request_cost' => 'fieldname1',
129
+ 'paypal_product_name' => CP_CALCULATEDFIELDSF_DEFAULT_PRODUCT_NAME,
130
+ 'currency' => CP_CALCULATEDFIELDSF_DEFAULT_CURRENCY,
131
+ 'paypal_language' => CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_LANGUAGE,
132
+
133
+ // Captcha settings
134
+ 'cv_enable_captcha' => CP_CALCULATEDFIELDSF_DEFAULT_cv_enable_captcha,
135
+ 'cv_width' => CP_CALCULATEDFIELDSF_DEFAULT_cv_width,
136
+ 'cv_height' => CP_CALCULATEDFIELDSF_DEFAULT_cv_height,
137
+ 'cv_chars' => CP_CALCULATEDFIELDSF_DEFAULT_cv_chars,
138
+ 'cv_font' => CP_CALCULATEDFIELDSF_DEFAULT_cv_font,
139
+ 'cv_min_font_size' => CP_CALCULATEDFIELDSF_DEFAULT_cv_min_font_size,
140
+ 'cv_max_font_size' => CP_CALCULATEDFIELDSF_DEFAULT_cv_max_font_size,
141
+ 'cv_noise' => CP_CALCULATEDFIELDSF_DEFAULT_cv_noise,
142
+ 'cv_noise_length' => CP_CALCULATEDFIELDSF_DEFAULT_cv_noise_length,
143
+ 'cv_background' => CP_CALCULATEDFIELDSF_DEFAULT_cv_background,
144
+ 'cv_border' => CP_CALCULATEDFIELDSF_DEFAULT_cv_border,
145
+ 'cv_text_enter_valid_captcha' => CP_CALCULATEDFIELDSF_DEFAULT_cv_text_enter_valid_captcha,
146
+
147
+ 'enable_submit' => CP_CALCULATEDFIELDSF_DEFAULT_display_submit_button,
148
+ 'category' => $category_name,
149
+ ),
150
+ array(
151
+ '%s',
152
+ '%s',
153
+ '%s',
154
+ '%s',
155
+ '%s',
156
+ '%s',
157
+ '%s',
158
+ '%s',
159
+ '%s',
160
+ '%s',
161
+ '%s',
162
+ '%s',
163
+ '%s',
164
+ '%s',
165
+ '%s',
166
+ '%s',
167
+ '%s',
168
+ '%s',
169
+ '%s',
170
+ '%s',
171
+ '%s',
172
+ '%s',
173
+ '%s',
174
+ '%s',
175
+ '%s',
176
+ '%s',
177
+ '%s',
178
+ '%s',
179
+ '%s',
180
+ '%s',
181
+ '%s',
182
+ '%s',
183
+ '%s',
184
+ '%s',
185
+ '%s',
186
+ '%s',
187
+ '%s',
188
+ '%s',
189
+ '%s',
190
+ '%s',
191
+ '%s',
192
+ '%s',
193
+ )
194
+ )
195
+ ) {
196
+ return new self( $wpdb->insert_id );
197
+ }
198
+ return false;
199
+ } // End create_default
200
+
201
+ /**
202
+ * Sanitize the form's structure. Fields titltes and instructions for users,
203
+ * form's title and description. etc.
204
+ */
205
+ public static function sanitize_structure( $structure ) {
206
+ if ( is_array( $structure ) ) {
207
+ if ( is_array( $structure[0] ) ) {
208
+ foreach ( $structure[0] as $index => $obj ) {
209
+ if ( isset( $obj->title ) ) {
210
+ $structure[0][ $index ]->title = CPCFF_AUXILIARY::sanitize( $structure[0][ $index ]->title );
211
+ }
212
+ if ( isset( $obj->userhelp ) ) {
213
+ $structure[0][ $index ]->userhelp = CPCFF_AUXILIARY::sanitize( $structure[0][ $index ]->userhelp );
214
+ }
215
+ }
216
+ }
217
+
218
+ if ( is_array( $structure[1] ) && count( $structure[1] ) ) {
219
+ if ( is_object( $structure[1][0] ) ) {
220
+ if ( isset( $structure[1][0]->title ) ) {
221
+ $structure[1][0]->title = CPCFF_AUXILIARY::sanitize( $structure[1][0]->title );
222
+ }
223
+ if ( isset( $structure[1][0]->description ) ) {
224
+ $structure[1][0]->description = CPCFF_AUXILIARY::sanitize( $structure[1][0]->description );
225
+ }
226
+ }
227
+ }
228
+ }
229
+ return $structure;
230
+ } // End sanitize_structure
231
+
232
+ /**
233
+ * Clones the current form.
234
+ *
235
+ * @return mixed, a new instance of the CPCFF_FORM or false.
236
+ */
237
+ public function clone_form() {
238
+ global $wpdb;
239
+
240
+ $row = $this->_get_settings();
241
+ if ( ! empty( $row ) ) {
242
+ unset( $row['id'] );
243
+ $row['form_name'] = 'Cloned: ' . $row['form_name'];
244
+ if ( $wpdb->insert( $wpdb->prefix . CP_CALCULATEDFIELDSF_FORMS_TABLE, $row ) ) {
245
+ return new self( $wpdb->insert_id );
246
+ }
247
+ }
248
+ return false;
249
+ } // End clone_form
250
+
251
+ /**
252
+ * Returns the id of current form.
253
+ *
254
+ * @return integer
255
+ */
256
+ public function get_id() {
257
+ return $this->_id;
258
+ } // end get_id
259
+
260
+ /**
261
+ * Reads the corresponding attribute in the form's settings.
262
+ *
263
+ * Reads the attribute in the form's settings, and if it does not exists returns the default value.
264
+ * Applies the filter cpcff_get_option
265
+ *
266
+ * @param string, name of the attribute to read.
267
+ * @param mixes, default value of the attribute.
268
+ * @return mixed, it depends of the option to read.
269
+ */
270
+ public function get_option( $option, $default ) {
271
+ // Initialize the value with the default values
272
+ $value = $default;
273
+ $this->_get_settings();
274
+
275
+ if ( isset( $this->_settings[ $option ] ) ) {
276
+ $value = @$this->_settings[ $option ];
277
+ }
278
+
279
+ // If the form's structure is a JSON text decodes it.
280
+ if (
281
+ 'form_structure' == $option &&
282
+ ! is_array( $value )
283
+ ) {
284
+ $form_data = CPCFF_AUXILIARY::json_decode( $value, 'normal' );
285
+ if ( ! is_null( $form_data ) ) {
286
+ $value = $this->_settings['form_structure'] = $form_data; // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments
287
+ }
288
+ } elseif ( // Adds to the thank you page URL a random attribute to prevent the page be cached
289
+ 'fp_return_page' == $option &&
290
+ ! is_admin() &&
291
+ get_option( 'CP_CALCULATEDFIELDSF_TYPC', CP_CALCULATEDFIELDSF_TYPC )
292
+ ) {
293
+ if ( ! empty( $value ) ) {
294
+ $value .= ( strpos( $value, '?' ) === false ? '?' : '&' ) . 'cff_no_cache=' . time();
295
+ }
296
+ } elseif ( // If the texts where not defined previously or the thank you page is empty populate them with the default values
297
+ (
298
+ 'vs_all_texts' == $option ||
299
+ 'fp_return_page' == $option
300
+ ) &&
301
+ empty( $value )
302
+ ) {
303
+ $value = $default;
304
+ }
305
+
306
+ /**
307
+ * Filters applied before returning a form option,
308
+ * use three parameters: The value of option, the name of option and the form's id
309
+ * returns the new option's value
310
+ */
311
+ if ( ! is_admin() ) {
312
+ $value = apply_filters( 'cpcff_get_option', $value, $option, $this->_id );
313
+ }
314
+
315
+ return $value;
316
+ } // End get_option
317
+
318
+ /**
319
+ * Returns the list of fields in the forms.
320
+ *
321
+ * @return array, associative array of objects where the fields' names are the indices and fields' structures the values.
322
+ */
323
+ public function get_fields() {
324
+ if ( ! empty( $this->_fields ) ) {
325
+ return $this->_fields;
326
+ }
327
+
328
+ $form_structure = $this->get_option( 'form_structure', array() );
329
+ if ( ! empty( $form_structure[0] ) ) {
330
+ foreach ( $form_structure[0] as $field ) {
331
+ $this->_fields[ $field->name ] = $field;
332
+ }
333
+ }
334
+ return $this->_fields;
335
+ } // End get_fields
336
+
337
+ public function save_settings( $params ) {
338
+ global $wpdb, $cpcff_default_texts_array;
339
+
340
+ foreach ( $params as $i => $v ) {
341
+ if ( 'form_structure' != $i ) {
342
+ $params[ $i ] = CPCFF_AUXILIARY::stripscript_recursive( $v );
343
+ }
344
+ }
345
+
346
+ $data = array(
347
+ 'form_structure' => ( isset( $params['form_structure'] ) ) ? $params['form_structure'] : CP_CALCULATEDFIELDSF_DEFAULT_form_structure,
348
+
349
+ // Notification email
350
+ 'fp_from_email' => ( isset( $params['fp_from_email'] ) ) ? trim( $params['fp_from_email'] ) : '',
351
+ 'fp_destination_emails' => ( isset( $params['fp_destination_emails'] ) ) ? trim( $params['fp_destination_emails'] ) : '',
352
+ 'fp_subject' => ( isset( $params['fp_subject'] ) ) ? $params['fp_subject'] : '',
353
+ 'fp_inc_additional_info' => ( isset( $params['fp_inc_additional_info'] ) && 'true' == $params['fp_inc_additional_info'] ) ? 'true' : 'false',
354
+ 'fp_return_page' => ( isset( $params['fp_return_page'] ) ) ? trim( $params['fp_return_page'] ) : '',
355
+ 'fp_message' => ( isset( $params['fp_message'] ) ) ? $params['fp_message'] : '',
356
+ 'fp_emailformat' => ( isset( $params['fp_emailformat'] ) && 'text' == $params['fp_emailformat'] ) ? 'text' : 'html',
357
+
358
+ // Notification email copy to the user
359
+ 'cu_enable_copy_to_user' => ( isset( $params['cu_enable_copy_to_user'] ) && 'true' == $params['cu_enable_copy_to_user'] ) ? 'true' : 'false',
360
+ 'cu_user_email_field' => ( ! empty( $params['cu_user_email_field'] ) ) ? $params['cu_user_email_field'] : '',
361
+ 'cu_subject' => ( isset( $params['cu_subject'] ) ) ? $params['cu_subject'] : '',
362
+ 'cu_message' => ( isset( $params['cu_message'] ) ) ? $params['cu_message'] : '',
363
+ 'cu_emailformat' => ( isset( $params['cu_emailformat'] ) && 'text' == $params['cu_emailformat'] ) ? 'text' : 'html',
364
+
365
+ // PayPal settings
366
+ 'enable_paypal' => ( isset( $params['enable_paypal'] ) ) ? $params['enable_paypal'] : 0,
367
+ 'paypal_email' => ( isset( $params['paypal_email'] ) ) ? trim( $params['paypal_email'] ) : '',
368
+ 'request_cost' => ( isset( $params['request_cost'] ) ) ? trim( $params['request_cost'] ) : '',
369
+ 'paypal_product_name' => ( isset( $params['paypal_product_name'] ) ) ? $params['paypal_product_name'] : '',
370
+ 'currency' => ( isset( $params['currency'] ) ) ? trim( $params['currency'] ) : 'USD',
371
+ 'paypal_language' => ( isset( $params['paypal_language'] ) ) ? trim( $params['paypal_language'] ) : 'EN',
372
+ 'paypal_mode' => ( isset( $params['paypal_mode'] ) ) ? $params['paypal_mode'] : 'production',
373
+ 'paypal_recurrent' => ( isset( $params['paypal_recurrent'] ) ) ? $params['paypal_recurrent'] : 0,
374
+ 'paypal_identify_prices' => ( isset( $params['paypal_identify_prices'] ) ) ? $params['paypal_identify_prices'] : '0',
375
+ 'paypal_zero_payment' => ( isset( $params['paypal_zero_payment'] ) ) ? $params['paypal_zero_payment'] : 0,
376
+
377
+ // Texts
378
+ 'vs_use_validation' => CP_CALCULATEDFIELDSF_DEFAULT_vs_use_validation,
379
+ 'vs_text_is_required' => ( isset( $params['vs_text_is_required'] ) ) ? $params['vs_text_is_required'] : CP_CALCULATEDFIELDSF_DEFAULT_vs_text_is_required,
380
+ 'vs_text_is_email' => ( isset( $params['vs_text_is_email'] ) ) ? $params['vs_text_is_email'] : CP_CALCULATEDFIELDSF_DEFAULT_vs_text_is_email,
381
+ 'vs_text_datemmddyyyy' => ( isset( $params['vs_text_datemmddyyyy'] ) ) ? $params['vs_text_datemmddyyyy'] : CP_CALCULATEDFIELDSF_DEFAULT_vs_text_datemmddyyyy,
382
+ 'vs_text_dateddmmyyyy' => ( isset( $params['vs_text_dateddmmyyyy'] ) ) ? $params['vs_text_dateddmmyyyy'] : CP_CALCULATEDFIELDSF_DEFAULT_vs_text_dateddmmyyyy,
383
+ 'vs_text_number' => ( isset( $params['vs_text_number'] ) ) ? $params['vs_text_number'] : CP_CALCULATEDFIELDSF_DEFAULT_vs_text_number,
384
+ 'vs_text_digits' => ( isset( $params['vs_text_digits'] ) ) ? $params['vs_text_digits'] : CP_CALCULATEDFIELDSF_DEFAULT_vs_text_digits,
385
+ 'vs_text_max' => ( isset( $params['vs_text_max'] ) ) ? $params['vs_text_max'] : CP_CALCULATEDFIELDSF_DEFAULT_vs_text_max,
386
+ 'vs_text_min' => ( isset( $params['vs_text_min'] ) ) ? $params['vs_text_min'] : CP_CALCULATEDFIELDSF_DEFAULT_vs_text_min,
387
+ 'vs_text_previousbtn' => ( isset( $params['vs_text_previousbtn'] ) ) ? $params['vs_text_previousbtn'] : 'Previous',
388
+ 'vs_text_nextbtn' => ( isset( $params['vs_text_nextbtn'] ) ) ? $params['vs_text_nextbtn'] : 'Next',
389
+ 'vs_all_texts' => ( isset( $params['vs_all_texts'] ) ) ? serialize( $params['vs_all_texts'] ) : serialize( $cpcff_default_texts_array ),
390
+
391
+ // Captcha settings
392
+ 'cv_enable_captcha' => ( isset( $params['cv_enable_captcha'] ) ) ? $params['cv_enable_captcha'] : CP_CALCULATEDFIELDSF_DEFAULT_cv_enable_captcha,
393
+ 'cv_width' => ( isset( $params['cv_width'] ) ) ? $params['cv_width'] : CP_CALCULATEDFIELDSF_DEFAULT_cv_width,
394
+ 'cv_height' => ( isset( $params['cv_height'] ) ) ? $params['cv_height'] : CP_CALCULATEDFIELDSF_DEFAULT_cv_height,
395
+ 'cv_chars' => ( isset( $params['cv_chars'] ) ) ? $params['cv_chars'] : CP_CALCULATEDFIELDSF_DEFAULT_cv_chars,
396
+ 'cv_font' => ( isset( $params['cv_font'] ) ) ? $params['cv_font'] : CP_CALCULATEDFIELDSF_DEFAULT_cv_font,
397
+ 'cv_min_font_size' => ( isset( $params['cv_min_font_size'] ) ) ? $params['cv_min_font_size'] : CP_CALCULATEDFIELDSF_DEFAULT_cv_min_font_size,
398
+ 'cv_max_font_size' => ( isset( $params['cv_max_font_size'] ) ) ? $params['cv_max_font_size'] : CP_CALCULATEDFIELDSF_DEFAULT_cv_max_font_size,
399
+ 'cv_noise' => ( isset( $params['cv_noise'] ) ) ? $params['cv_noise'] : CP_CALCULATEDFIELDSF_DEFAULT_cv_noise,
400
+ 'cv_noise_length' => ( isset( $params['cv_noise_length'] ) ) ? $params['cv_noise_length'] : CP_CALCULATEDFIELDSF_DEFAULT_cv_noise_length,
401
+ 'cv_background' => ( isset( $params['cv_background'] ) ) ? $params['cv_background'] : CP_CALCULATEDFIELDSF_DEFAULT_cv_background,
402
+ 'cv_border' => ( isset( $params['cv_border'] ) ) ? $params['cv_border'] : CP_CALCULATEDFIELDSF_DEFAULT_cv_border,
403
+ 'cv_text_enter_valid_captcha' => ( isset( $params['cv_text_enter_valid_captcha'] ) ) ? $params['cv_text_enter_valid_captcha'] : CP_CALCULATEDFIELDSF_DEFAULT_cv_text_enter_valid_captcha,
404
+ 'category' => trim( isset( $params['calculated-fields-form-category'] ) ? $params['calculated-fields-form-category'] : '' ),
405
+ );
406
+
407
+ $updated_rows = $wpdb->update(
408
+ $wpdb->prefix . CP_CALCULATEDFIELDSF_FORMS_TABLE,
409
+ $data,
410
+ array( 'id' => $this->_id ),
411
+ array( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ),
412
+ array( '%d' )
413
+ );
414
+
415
+ // Revisions
416
+ update_option( 'CP_CALCULATEDFIELDSF_REVISIONS_IN_PREVIEW', isset( $params['cff-revisions-in-preview'] ) ? true : false );
417
+
418
+ if (
419
+ false !== $updated_rows &&
420
+ (
421
+ ! isset( $params['preview'] ) ||
422
+ get_option( 'CP_CALCULATEDFIELDSF_REVISIONS_IN_PREVIEW' )
423
+ ) &&
424
+ get_option( 'CP_CALCULATEDFIELDSF_DISABLE_REVISIONS', CP_CALCULATEDFIELDSF_DISABLE_REVISIONS ) == 0
425
+ ) {
426
+ $this->_revisions_obj->create_revision();
427
+ }
428
+ return $updated_rows;
429
+ } // End save_settings
430
+
431
+ /**
432
+ * Gets the correspond rown in the database
433
+ */
434
+ public function get_raw_data() {
435
+ global $wpdb;
436
+ $row = $wpdb->get_row( $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . CP_CALCULATEDFIELDSF_FORMS_TABLE . ' WHERE id=%d', $this->_id ), ARRAY_A ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
437
+ return $row;
438
+ } // End get_raw_data
439
+
440
+ /**
441
+ * Returns an instance of the CPCFF_REVISIONS revisions object
442
+ */
443
+ public function get_revisions() {
444
+ return $this->_revisions_obj;
445
+ } // End get_revisions
446
+
447
+ /**
448
+ * Creates or replace the property $this->_settings with the data stored in the revisions
449
+ */
450
+ public function apply_revision( $revision_id ) {
451
+ $this->_get_settings();
452
+ $revision_data = $this->_revisions_obj->data( $revision_id );
453
+ $this->_fields = array();
454
+ $this->_settings = CPCFF_AUXILIARY::array_replace_recursive( $this->_settings, $revision_data );
455
+ } // End apply_revision
456
+
457
+ /**
458
+ * Updates the form's name
459
+ *
460
+ * @param string $form_name
461
+ *
462
+ * @return bool
463
+ */
464
+ public function update_name( $form_name ) {
465
+ global $wpdb;
466
+ return $wpdb->update(
467
+ $wpdb->prefix . CP_CALCULATEDFIELDSF_FORMS_TABLE,
468
+ array( 'form_name' => $form_name ),
469
+ array( 'id' => $this->_id ),
470
+ array( '%s' ),
471
+ array( '%d' )
472
+ );
473
+ } // End update_name
474
+
475
+ /**
476
+ * Deletes the current form.
477
+ *
478
+ * @return mixed the number of deleted columns or false.
479
+ */
480
+ public function delete_form() {
481
+ global $wpdb;
482
+ $this->_revisions_obj->delete_form();
483
+ return $wpdb->delete(
484
+ $wpdb->prefix . CP_CALCULATEDFIELDSF_FORMS_TABLE,
485
+ array( 'id' => $this->_id ),
486
+ array( '%d' )
487
+ );
488
+ }
489
+ /*********************************** PRIVATE METHODS ********************************************/
490
+
491
+ /**
492
+ * Returns the form's settings.
493
+ * Checks if the settings were read previously, before reading the data from database.
494
+ *
495
+ * @since 1.0.184
496
+ *
497
+ * @return array, associative array with the database row.
498
+ */
499
+ private function _get_settings() {
500
+ if ( empty( $this->_settings ) ) {
501
+ $row = $this->get_raw_data();
502
+ if ( ! empty( $row ) ) {
503
+ $this->_settings = $row;
504
+ }
505
+ }
506
+ return $this->_settings;
507
+ } // End _get_settings
508
+ } // End CPCFF_FORM
509
+ }
inc/cpcff_install_uninstall.inc.php CHANGED
@@ -1,337 +1,323 @@
1
- <?php
2
- /**
3
- * Install/Uninstall plugin: CPCFF_INSTALLER class
4
- *
5
- * Contains the CPCFF_INSTALLER metaclass for install and uninstall the plugin.
6
- *
7
- * @package CFF
8
- * @since 1.0.168
9
- */
10
-
11
- if(!class_exists('CPCFF_INSTALLER'))
12
- {
13
- /**
14
- * Installs/Uninstalls the plugin.
15
- *
16
- * Metaclass to creates the database's tables, with the predefined forms, and create the resource files.
17
- *
18
- * @since 1.0.168
19
- */
20
- class CPCFF_INSTALLER
21
- {
22
- /**
23
- * Creates the database structure and resource files in every new blog.
24
- * The method is called by the 'wpmu_new_blog' hook.
25
- *
26
- * @param int $blog_id Blog ID.
27
- * @param int $user_id User ID.
28
- * @param string $domain Site domain.
29
- * @param string $path Site path.
30
- * @param int $site_id Site ID. Only relevant on multi-network installs.
31
- * @param array $meta Meta data. Used to set initial site options.
32
- */
33
- public static function new_blog($blog_id, $user_id, $domain, $path, $site_id, $meta)
34
- {
35
- if (is_plugin_active_for_network('calculated-fields-form/cp_calculatedfieldsf_free.php'))
36
- {
37
- global $wpdb;
38
- $old_blog = $wpdb->blogid;
39
- switch_to_blog($blog_id);
40
- self::_db_structure();
41
- switch_to_blog($old_blog);
42
- }
43
- } // End new_blog
44
-
45
- /**
46
- * Creates the database tables and resources in every existent blog on website.
47
- *
48
- * @param bool $networkwide Multisite installation.
49
- */
50
- public static function install($networkwide)
51
- {
52
- // check if it is a network activation - if so, run the activation function for each blog id
53
- if(
54
- function_exists('is_multisite') &&
55
- is_multisite() &&
56
- $networkwide
57
- )
58
- {
59
- global $wpdb;
60
- $old_blog = $wpdb->blogid;
61
-
62
- // Get all blog ids
63
- $blogids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
64
- foreach ($blogids as $blog_id)
65
- {
66
- switch_to_blog($blog_id);
67
- self::_db_structure();
68
- }
69
- switch_to_blog($old_blog);
70
- return;
71
- }
72
- self::_db_structure();
73
- } //End install
74
-
75
- /**
76
- * Creates a backup of the insert_in_database file.
77
- */
78
- public static function uninstall()
79
- {
80
- } // End uninstall
81
-
82
- /**
83
- * Creates the database tables used by the plugin's core.
84
- *
85
- * Creates the database tables, alters the tables created by the free version of the plugin.
86
- *
87
- * @access private.
88
- * @return void.
89
- */
90
- private static function _db_structure()
91
- {
92
- require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
93
-
94
- global $wpdb;
95
- $charset_collate = $wpdb->get_charset_collate();
96
-
97
- $db_queries = array();
98
-
99
- // Posts table
100
- $db_queries[] = "CREATE TABLE ".$wpdb->prefix.CP_CALCULATEDFIELDSF_POSTS_TABLE_NAME_NO_PREFIX." (
101
- id mediumint(9) NOT NULL AUTO_INCREMENT,
102
- formid INT NOT NULL,
103
- time datetime,
104
- ipaddr VARCHAR(41) DEFAULT '' NOT NULL,
105
- notifyto VARCHAR(250) DEFAULT '' NOT NULL,
106
- data mediumtext,
107
- paypal_post mediumtext,
108
- paid INT DEFAULT 0 NOT NULL,
109
- UNIQUE KEY id (id)
110
- ) $charset_collate;";
111
-
112
- // Discounts table
113
- $db_queries[] = "CREATE TABLE ".$wpdb->prefix.CP_CALCULATEDFIELDSF_DISCOUNT_CODES_TABLE_NAME_NO_PREFIX." (
114
- id mediumint(9) NOT NULL AUTO_INCREMENT,
115
- form_id mediumint(9) NOT NULL DEFAULT 1,
116
- code VARCHAR(250) DEFAULT '' NOT NULL,
117
- discount VARCHAR(250) DEFAULT '' NOT NULL,
118
- expires datetime,
119
- availability int(10) unsigned NOT NULL DEFAULT 0,
120
- used int(10) unsigned NOT NULL DEFAULT 0,
121
- UNIQUE KEY id (id)
122
- ) $charset_collate;";
123
-
124
- // CHANGE ROW_FORMAT ONLY ONCE
125
- if(get_option($wpdb->prefix.CP_CALCULATEDFIELDSF_FORMS_TABLE.'_ROW_FORMAT', 0) == 0)
126
- {
127
- update_option($wpdb->prefix.CP_CALCULATEDFIELDSF_FORMS_TABLE.'_ROW_FORMAT', 1);
128
- $check_table_exists = $wpdb->get_results('SHOW TABLES LIKE "'.$wpdb->prefix.CP_CALCULATEDFIELDSF_FORMS_TABLE.'"');
129
- if(count($check_table_exists))
130
- {
131
- $wpdb->query("ALTER TABLE ".$wpdb->prefix.CP_CALCULATEDFIELDSF_FORMS_TABLE." ROW_FORMAT=DYNAMIC");
132
- }
133
- }
134
-
135
- // Forms structures table
136
- $db_queries[] = "CREATE TABLE ".$wpdb->prefix.CP_CALCULATEDFIELDSF_FORMS_TABLE." (
137
- id mediumint(9) NOT NULL AUTO_INCREMENT,
138
- form_name VARCHAR(250) DEFAULT '' NOT NULL,
139
- form_structure mediumtext,
140
- fp_from_email VARCHAR(250) DEFAULT '' NOT NULL,
141
- fp_destination_emails TEXT,
142
- fp_subject TEXT,
143
- fp_inc_additional_info VARCHAR(10) DEFAULT '' NOT NULL,
144
- fp_return_page VARCHAR(250) DEFAULT '' NOT NULL,
145
- fp_message mediumtext,
146
- fp_emailformat VARCHAR(10) DEFAULT '' NOT NULL,
147
- cu_enable_copy_to_user VARCHAR(10) DEFAULT '' NOT NULL,
148
- cu_user_email_field TEXT DEFAULT '' NOT NULL,
149
- cu_subject TEXT,
150
- cu_message mediumtext,
151
- cu_emailformat VARCHAR(10) DEFAULT '' NOT NULL,
152
- fp_emailfrommethod VARCHAR(10) DEFAULT '' NOT NULL,
153
- enable_paypal_option_yes VARCHAR(250) DEFAULT '' NOT NULL,
154
- enable_paypal_option_no VARCHAR(250) DEFAULT '' NOT NULL,
155
- vs_use_validation VARCHAR(10) DEFAULT '' NOT NULL,
156
- vs_text_is_required VARCHAR(250) DEFAULT '' NOT NULL,
157
- vs_text_is_email VARCHAR(250) DEFAULT '' NOT NULL,
158
- vs_text_datemmddyyyy VARCHAR(250) DEFAULT '' NOT NULL,
159
- vs_text_dateddmmyyyy VARCHAR(250) DEFAULT '' NOT NULL,
160
- vs_text_number VARCHAR(250) DEFAULT '' NOT NULL,
161
- vs_text_digits VARCHAR(250) DEFAULT '' NOT NULL,
162
- vs_text_max VARCHAR(250) DEFAULT '' NOT NULL,
163
- vs_text_min VARCHAR(250) DEFAULT '' NOT NULL,
164
- vs_text_submitbtn VARCHAR(250) DEFAULT '' NOT NULL,
165
- vs_text_previousbtn VARCHAR(250) DEFAULT '' NOT NULL,
166
- vs_text_nextbtn VARCHAR(250) DEFAULT '' NOT NULL,
167
- vs_all_texts text DEFAULT '' NOT NULL,
168
- enable_paypal varchar(10) DEFAULT '' NOT NULL,
169
- enable_submit varchar(10) DEFAULT '' NOT NULL,
170
- paypal_notiemails varchar(10) DEFAULT '' NOT NULL,
171
- paypal_email varchar(255) DEFAULT '' NOT NULL ,
172
- request_cost varchar(255) DEFAULT '' NOT NULL ,
173
- paypal_product_name varchar(255) DEFAULT '' NOT NULL,
174
- currency varchar(10) DEFAULT '' NOT NULL,
175
- paypal_language varchar(10) DEFAULT '' NOT NULL,
176
- paypal_mode varchar(20) DEFAULT '' NOT NULL ,
177
- paypal_recurrent varchar(20) DEFAULT '' NOT NULL ,
178
- paypal_recurrent_setup varchar(20) DEFAULT '' NOT NULL ,
179
- paypal_recurrent_setup_days varchar(20) DEFAULT '' NOT NULL ,
180
- paypal_recurrent_times varchar(20) DEFAULT '' NOT NULL ,
181
- paypal_recurrent_times_field varchar(20) DEFAULT '' NOT NULL ,
182
- paypal_identify_prices varchar(20) DEFAULT '' NOT NULL ,
183
- paypal_zero_payment varchar(10) DEFAULT '' NOT NULL ,
184
- paypal_base_amount VARCHAR(250),
185
- paypal_address TINYINT DEFAULT 1 NOT NULL,
186
- cv_enable_captcha VARCHAR(20) DEFAULT '' NOT NULL,
187
- cv_width VARCHAR(20) DEFAULT '' NOT NULL,
188
- cv_height VARCHAR(20) DEFAULT '' NOT NULL,
189
- cv_chars VARCHAR(20) DEFAULT '' NOT NULL,
190
- cv_font VARCHAR(20) DEFAULT '' NOT NULL,
191
- cv_min_font_size VARCHAR(20) DEFAULT '' NOT NULL,
192
- cv_max_font_size VARCHAR(20) DEFAULT '' NOT NULL,
193
- cv_noise VARCHAR(20) DEFAULT '' NOT NULL,
194
- cv_noise_length VARCHAR(20) DEFAULT '' NOT NULL,
195
- cv_background VARCHAR(20) DEFAULT '' NOT NULL,
196
- cv_border VARCHAR(20) DEFAULT '' NOT NULL,
197
- cv_text_enter_valid_captcha VARCHAR(200) DEFAULT '' NOT NULL,
198
- category VARCHAR(250),
199
- cache longtext DEFAULT '' NOT NULL,
200
- UNIQUE KEY id (id)
201
- ) $charset_collate ROW_FORMAT=DYNAMIC;";
202
-
203
- // Revisions table
204
- $db_queries[] = "CREATE TABLE ".$wpdb->prefix.CP_CALCULATEDFIELDSF_FORMS_REVISIONS_TABLE." (
205
- id mediumint(9) NOT NULL AUTO_INCREMENT,
206
- formid mediumint(9) NOT NULL,
207
- time datetime,
208
- revision longtext NOT NULL,
209
- UNIQUE KEY id (id)
210
- ) $charset_collate;";
211
-
212
- dbDelta($db_queries); // Running the queries
213
-
214
- // Alter table
215
- self::_alter_table($wpdb->prefix.CP_CALCULATEDFIELDSF_FORMS_TABLE, ['category'=>'VARCHAR(250)']);
216
-
217
- // Insert the predefined forms into the forms table
218
- self::_predefined_forms();
219
- } // End _db_structure
220
-
221
- private static function _alter_table ($table, $new_columns = [])
222
- {
223
- try
224
- {
225
- if(count($new_columns))
226
- {
227
- global $wpdb;
228
- $current_columns = [];
229
-
230
- $columns = $wpdb->get_results("SHOW columns FROM `".$table."`");
231
- foreach( $columns as $column ) $current_columns[$column->Field] = $column->Field;
232
-
233
- foreach($new_columns as $column_name => $column_settings)
234
- {
235
- if(!isset($current_columns[$column_name]))
236
- {
237
- $sql = "ALTER TABLE `".$table."` ADD `".$column_name."` ".$column_settings;
238
- $wpdb->query($sql);
239
- }
240
- }
241
- }
242
- } catch (Exception $err) {error_log($err->getMessage());}
243
- } // End _alter_table
244
-
245
- /**
246
- * Inserts the predefined forms into the Forms table
247
- */
248
- private static function _predefined_forms()
249
- {
250
- global $wpdb;
251
- $table_name = $wpdb->prefix.CP_CALCULATEDFIELDSF_FORMS_TABLE;
252
- $count = $wpdb->get_var("SELECT COUNT(id) FROM ".$table_name);
253
- if(!$count)
254
- {
255
- cpcff_init_constants();
256
- $values = array( 'fp_from_email' => CP_CALCULATEDFIELDSF_DEFAULT_fp_from_email,
257
- 'fp_destination_emails' => CP_CALCULATEDFIELDSF_DEFAULT_fp_destination_emails,
258
- 'fp_subject' => CP_CALCULATEDFIELDSF_DEFAULT_fp_subject,
259
- 'fp_inc_additional_info' => CP_CALCULATEDFIELDSF_DEFAULT_fp_inc_additional_info,
260
- 'fp_return_page' => CP_CALCULATEDFIELDSF_DEFAULT_fp_return_page,
261
- 'fp_message' => CP_CALCULATEDFIELDSF_DEFAULT_fp_message,
262
- 'fp_emailformat' => CP_CALCULATEDFIELDSF_DEFAULT_email_format,
263
-
264
- 'cu_enable_copy_to_user' => CP_CALCULATEDFIELDSF_DEFAULT_cu_enable_copy_to_user,
265
- 'cu_user_email_field' => CP_CALCULATEDFIELDSF_DEFAULT_cu_user_email_field,
266
- 'cu_subject' => CP_CALCULATEDFIELDSF_DEFAULT_cu_subject,
267
- 'cu_message' => CP_CALCULATEDFIELDSF_DEFAULT_cu_message,
268
- 'cu_emailformat' => CP_CALCULATEDFIELDSF_DEFAULT_email_format,
269
-
270
- 'vs_use_validation' => CP_CALCULATEDFIELDSF_DEFAULT_vs_use_validation,
271
- 'vs_text_is_required' => CP_CALCULATEDFIELDSF_DEFAULT_vs_text_is_required,
272
- 'vs_text_is_email' => CP_CALCULATEDFIELDSF_DEFAULT_vs_text_is_email,
273
- 'vs_text_datemmddyyyy' => CP_CALCULATEDFIELDSF_DEFAULT_vs_text_datemmddyyyy,
274
- 'vs_text_dateddmmyyyy' => CP_CALCULATEDFIELDSF_DEFAULT_vs_text_dateddmmyyyy,
275
- 'vs_text_number' => CP_CALCULATEDFIELDSF_DEFAULT_vs_text_number,
276
- 'vs_text_digits' => CP_CALCULATEDFIELDSF_DEFAULT_vs_text_digits,
277
- 'vs_text_max' => CP_CALCULATEDFIELDSF_DEFAULT_vs_text_max,
278
- 'vs_text_min' => CP_CALCULATEDFIELDSF_DEFAULT_vs_text_min,
279
- 'vs_text_submitbtn' => 'Submit',
280
- 'vs_text_previousbtn' => 'Previous',
281
- 'vs_text_nextbtn' => 'Next',
282
-
283
- 'enable_paypal' => CP_CALCULATEDFIELDSF_DEFAULT_ENABLE_PAYPAL,
284
- 'enable_submit' => '',
285
- 'paypal_notiemails' => '0',
286
- 'paypal_email' => CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_EMAIL,
287
- 'request_cost' => CP_CALCULATEDFIELDSF_DEFAULT_COST,
288
- 'paypal_product_name' => CP_CALCULATEDFIELDSF_DEFAULT_PRODUCT_NAME,
289
- 'currency' => CP_CALCULATEDFIELDSF_DEFAULT_CURRENCY,
290
- 'paypal_language' => CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_LANGUAGE,
291
- 'paypal_mode' => CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_MODE,
292
- 'paypal_recurrent' => CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_RECURRENT,
293
- 'paypal_recurrent_setup' => '',
294
- 'paypal_recurrent_setup_days' => '15',
295
- 'paypal_recurrent_times' => '0',
296
- 'paypal_recurrent_times_field' => '',
297
- 'paypal_identify_prices' => CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_IDENTIFY_PRICES,
298
- 'paypal_zero_payment' => CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_ZERO_PAYMENT,
299
-
300
- 'cv_enable_captcha' => CP_CALCULATEDFIELDSF_DEFAULT_cv_enable_captcha,
301
- 'cv_width' => CP_CALCULATEDFIELDSF_DEFAULT_cv_width,
302
- 'cv_height' => CP_CALCULATEDFIELDSF_DEFAULT_cv_height,
303
- 'cv_chars' => CP_CALCULATEDFIELDSF_DEFAULT_cv_chars,
304
- 'cv_font' => CP_CALCULATEDFIELDSF_DEFAULT_cv_font,
305
- 'cv_min_font_size' => CP_CALCULATEDFIELDSF_DEFAULT_cv_min_font_size,
306
- 'cv_max_font_size' => CP_CALCULATEDFIELDSF_DEFAULT_cv_max_font_size,
307
- 'cv_noise' => CP_CALCULATEDFIELDSF_DEFAULT_cv_noise,
308
- 'cv_noise_length' => CP_CALCULATEDFIELDSF_DEFAULT_cv_noise_length,
309
- 'cv_background' => CP_CALCULATEDFIELDSF_DEFAULT_cv_background,
310
- 'cv_border' => CP_CALCULATEDFIELDSF_DEFAULT_cv_border,
311
- 'cv_text_enter_valid_captcha' => CP_CALCULATEDFIELDSF_DEFAULT_cv_text_enter_valid_captcha
312
- );
313
- $values['id'] = 1;
314
- $values['form_name'] = 'Simple Operations';
315
- $values['form_structure'] = CP_CALCULATEDFIELDSF_DEFAULT_form_structure1;
316
- $wpdb->insert( $table_name, $values );
317
- $values['id'] = 2;
318
- $values['form_name'] = 'Calculation with Dates';
319
- $values['form_structure'] = CP_CALCULATEDFIELDSF_DEFAULT_form_structure2;
320
- $wpdb->insert( $table_name, $values );
321
- $values['id'] = 3;
322
- $values['form_name'] = 'Ideal Weight Calculator';
323
- $values['form_structure'] = CP_CALCULATEDFIELDSF_DEFAULT_form_structure3;
324
- $wpdb->insert( $table_name, $values );
325
- $values['id'] = 4;
326
- $values['form_name'] = 'Pregnancy Calculator';
327
- $values['form_structure'] = CP_CALCULATEDFIELDSF_DEFAULT_form_structure4;
328
- $wpdb->insert( $table_name, $values );
329
- $values['id'] = 5;
330
- $values['form_name'] = 'Lease Calculator';
331
- $values['form_structure'] = CP_CALCULATEDFIELDSF_DEFAULT_form_structure5;
332
- $wpdb->insert( $table_name, $values );
333
- }
334
- } // End _predefined_forms
335
-
336
- } // End class CPCFF_INSTALLER
337
- }
1
+ <?php
2
+ /**
3
+ * Install/Uninstall plugin: CPCFF_INSTALLER class
4
+ *
5
+ * Contains the CPCFF_INSTALLER metaclass for install and uninstall the plugin.
6
+ *
7
+ * @package CFF
8
+ * @since 1.0.168
9
+ */
10
+
11
+ if ( ! class_exists( 'CPCFF_INSTALLER' ) ) {
12
+ /**
13
+ * Installs/Uninstalls the plugin.
14
+ *
15
+ * Metaclass to creates the database's tables, with the predefined forms, and create the resource files.
16
+ *
17
+ * @since 1.0.168
18
+ */
19
+ class CPCFF_INSTALLER {
20
+
21
+ /**
22
+ * Creates the database structure and resource files in every new blog.
23
+ * The method is called by the 'wpmu_new_blog' hook.
24
+ *
25
+ * @param int $blog_id Blog ID.
26
+ * @param int $user_id User ID.
27
+ * @param string $domain Site domain.
28
+ * @param string $path Site path.
29
+ * @param int $site_id Site ID. Only relevant on multi-network installs.
30
+ * @param array $meta Meta data. Used to set initial site options.
31
+ */
32
+ public static function new_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
33
+ if ( is_plugin_active_for_network( 'calculated-fields-form/cp_calculatedfieldsf_free.php' ) ) {
34
+ global $wpdb;
35
+ $old_blog = $wpdb->blogid;
36
+ switch_to_blog( $blog_id );
37
+ self::_db_structure();
38
+ switch_to_blog( $old_blog );
39
+ }
40
+ } // End new_blog
41
+
42
+ /**
43
+ * Creates the database tables and resources in every existent blog on website.
44
+ *
45
+ * @param bool $networkwide Multisite installation.
46
+ */
47
+ public static function install( $networkwide ) {
48
+ // check if it is a network activation - if so, run the activation function for each blog id
49
+ if (
50
+ function_exists( 'is_multisite' ) &&
51
+ is_multisite() &&
52
+ $networkwide
53
+ ) {
54
+ global $wpdb;
55
+ $old_blog = $wpdb->blogid;
56
+
57
+ // Get all blog ids
58
+ $blogids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
59
+ foreach ( $blogids as $blog_id ) {
60
+ switch_to_blog( $blog_id );
61
+ self::_db_structure();
62
+ }
63
+ switch_to_blog( $old_blog );
64
+ return;
65
+ }
66
+ self::_db_structure();
67
+ } //End install
68
+
69
+ /**
70
+ * Creates a backup of the insert_in_database file.
71
+ */
72
+ public static function uninstall() { } // End uninstall
73
+
74
+ /**
75
+ * Creates the database tables used by the plugin's core.
76
+ *
77
+ * Creates the database tables, alters the tables created by the free version of the plugin.
78
+ *
79
+ * @access private.
80
+ * @return void.
81
+ */
82
+ private static function _db_structure() {
83
+ require_once ABSPATH . 'wp-admin/includes/upgrade.php';
84
+
85
+ global $wpdb;
86
+ $charset_collate = $wpdb->get_charset_collate();
87
+
88
+ $db_queries = array();
89
+
90
+ // Posts table
91
+ $db_queries[] = 'CREATE TABLE ' . $wpdb->prefix . CP_CALCULATEDFIELDSF_POSTS_TABLE_NAME_NO_PREFIX . " (
92
+ id mediumint(9) NOT NULL AUTO_INCREMENT,
93
+ formid INT NOT NULL,
94
+ time datetime,
95
+ ipaddr VARCHAR(41) DEFAULT '' NOT NULL,
96
+ notifyto VARCHAR(250) DEFAULT '' NOT NULL,
97
+ data mediumtext,
98
+ paypal_post mediumtext,
99
+ paid INT DEFAULT 0 NOT NULL,
100
+ UNIQUE KEY id (id)
101
+ ) $charset_collate;";
102
+
103
+ // Discounts table
104
+ $db_queries[] = 'CREATE TABLE ' . $wpdb->prefix . CP_CALCULATEDFIELDSF_DISCOUNT_CODES_TABLE_NAME_NO_PREFIX . " (
105
+ id mediumint(9) NOT NULL AUTO_INCREMENT,
106
+ form_id mediumint(9) NOT NULL DEFAULT 1,
107
+ code VARCHAR(250) DEFAULT '' NOT NULL,
108
+ discount VARCHAR(250) DEFAULT '' NOT NULL,
109
+ expires datetime,
110
+ availability int(10) unsigned NOT NULL DEFAULT 0,
111
+ used int(10) unsigned NOT NULL DEFAULT 0,
112
+ UNIQUE KEY id (id)
113
+ ) $charset_collate;";
114
+
115
+ // CHANGE ROW_FORMAT ONLY ONCE
116
+ if ( get_option( $wpdb->prefix . CP_CALCULATEDFIELDSF_FORMS_TABLE . '_ROW_FORMAT', 0 ) == 0 ) {
117
+ update_option( $wpdb->prefix . CP_CALCULATEDFIELDSF_FORMS_TABLE . '_ROW_FORMAT', 1 );
118
+ $check_table_exists = $wpdb->get_results( 'SHOW TABLES LIKE "' . $wpdb->prefix . CP_CALCULATEDFIELDSF_FORMS_TABLE . '"' ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
119
+ if ( count( $check_table_exists ) ) {
120
+ $wpdb->query( 'ALTER TABLE ' . $wpdb->prefix . CP_CALCULATEDFIELDSF_FORMS_TABLE . ' ROW_FORMAT=DYNAMIC' ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
121
+ }
122
+ }
123
+
124
+ // Forms structures table
125
+ $db_queries[] = 'CREATE TABLE ' . $wpdb->prefix . CP_CALCULATEDFIELDSF_FORMS_TABLE . " (
126
+ id mediumint(9) NOT NULL AUTO_INCREMENT,
127
+ form_name VARCHAR(250) DEFAULT '' NOT NULL,
128
+ form_structure mediumtext,
129
+ fp_from_email VARCHAR(250) DEFAULT '' NOT NULL,
130
+ fp_destination_emails TEXT,
131
+ fp_subject TEXT,
132
+ fp_inc_additional_info VARCHAR(10) DEFAULT '' NOT NULL,
133
+ fp_return_page VARCHAR(250) DEFAULT '' NOT NULL,
134
+ fp_message mediumtext,
135
+ fp_emailformat VARCHAR(10) DEFAULT '' NOT NULL,
136
+ cu_enable_copy_to_user VARCHAR(10) DEFAULT '' NOT NULL,
137
+ cu_user_email_field TEXT DEFAULT '' NOT NULL,
138
+ cu_subject TEXT,
139
+ cu_message mediumtext,
140
+ cu_emailformat VARCHAR(10) DEFAULT '' NOT NULL,
141
+ fp_emailfrommethod VARCHAR(10) DEFAULT '' NOT NULL,
142
+ enable_paypal_option_yes VARCHAR(250) DEFAULT '' NOT NULL,
143
+ enable_paypal_option_no VARCHAR(250) DEFAULT '' NOT NULL,
144
+ vs_use_validation VARCHAR(10) DEFAULT '' NOT NULL,
145
+ vs_text_is_required VARCHAR(250) DEFAULT '' NOT NULL,
146
+ vs_text_is_email VARCHAR(250) DEFAULT '' NOT NULL,
147
+ vs_text_datemmddyyyy VARCHAR(250) DEFAULT '' NOT NULL,
148
+ vs_text_dateddmmyyyy VARCHAR(250) DEFAULT '' NOT NULL,
149
+ vs_text_number VARCHAR(250) DEFAULT '' NOT NULL,
150
+ vs_text_digits VARCHAR(250) DEFAULT '' NOT NULL,
151
+ vs_text_max VARCHAR(250) DEFAULT '' NOT NULL,
152
+ vs_text_min VARCHAR(250) DEFAULT '' NOT NULL,
153
+ vs_text_submitbtn VARCHAR(250) DEFAULT '' NOT NULL,
154
+ vs_text_previousbtn VARCHAR(250) DEFAULT '' NOT NULL,
155
+ vs_text_nextbtn VARCHAR(250) DEFAULT '' NOT NULL,
156
+ vs_all_texts text DEFAULT '' NOT NULL,
157
+ enable_paypal varchar(10) DEFAULT '' NOT NULL,
158
+ enable_submit varchar(10) DEFAULT '' NOT NULL,
159
+ paypal_notiemails varchar(10) DEFAULT '' NOT NULL,
160
+ paypal_email varchar(255) DEFAULT '' NOT NULL ,
161
+ request_cost varchar(255) DEFAULT '' NOT NULL ,
162
+ paypal_product_name varchar(255) DEFAULT '' NOT NULL,
163
+ currency varchar(10) DEFAULT '' NOT NULL,
164
+ paypal_language varchar(10) DEFAULT '' NOT NULL,
165
+ paypal_mode varchar(20) DEFAULT '' NOT NULL ,
166
+ paypal_recurrent varchar(20) DEFAULT '' NOT NULL ,
167
+ paypal_recurrent_setup varchar(20) DEFAULT '' NOT NULL ,
168
+ paypal_recurrent_setup_days varchar(20) DEFAULT '' NOT NULL ,
169
+ paypal_recurrent_times varchar(20) DEFAULT '' NOT NULL ,
170
+ paypal_recurrent_times_field varchar(20) DEFAULT '' NOT NULL ,
171
+ paypal_identify_prices varchar(20) DEFAULT '' NOT NULL ,
172
+ paypal_zero_payment varchar(10) DEFAULT '' NOT NULL ,
173
+ paypal_base_amount VARCHAR(250),
174
+ paypal_address TINYINT DEFAULT 1 NOT NULL,
175
+ cv_enable_captcha VARCHAR(20) DEFAULT '' NOT NULL,
176
+ cv_width VARCHAR(20) DEFAULT '' NOT NULL,
177
+ cv_height VARCHAR(20) DEFAULT '' NOT NULL,
178
+ cv_chars VARCHAR(20) DEFAULT '' NOT NULL,
179
+ cv_font VARCHAR(20) DEFAULT '' NOT NULL,
180
+ cv_min_font_size VARCHAR(20) DEFAULT '' NOT NULL,
181
+ cv_max_font_size VARCHAR(20) DEFAULT '' NOT NULL,
182
+ cv_noise VARCHAR(20) DEFAULT '' NOT NULL,
183
+ cv_noise_length VARCHAR(20) DEFAULT '' NOT NULL,
184
+ cv_background VARCHAR(20) DEFAULT '' NOT NULL,
185
+ cv_border VARCHAR(20) DEFAULT '' NOT NULL,
186
+ cv_text_enter_valid_captcha VARCHAR(200) DEFAULT '' NOT NULL,
187
+ category VARCHAR(250),
188
+ cache longtext DEFAULT '' NOT NULL,
189
+ UNIQUE KEY id (id)
190
+ ) $charset_collate ROW_FORMAT=DYNAMIC;";
191
+
192
+ // Revisions table
193
+ $db_queries[] = 'CREATE TABLE ' . $wpdb->prefix . CP_CALCULATEDFIELDSF_FORMS_REVISIONS_TABLE . " (
194
+ id mediumint(9) NOT NULL AUTO_INCREMENT,
195
+ formid mediumint(9) NOT NULL,
196
+ time datetime,
197
+ revision longtext NOT NULL,
198
+ UNIQUE KEY id (id)
199
+ ) $charset_collate;";
200
+
201
+ dbDelta( $db_queries ); // Running the queries
202
+
203
+ // Alter table
204
+ self::_alter_table( $wpdb->prefix . CP_CALCULATEDFIELDSF_FORMS_TABLE, array( 'category' => 'VARCHAR(250)' ) );
205
+
206
+ // Insert the predefined forms into the forms table
207
+ self::_predefined_forms();
208
+ } // End _db_structure
209
+
210
+ private static function _alter_table( $table, $new_columns = array() ) {
211
+ try {
212
+ if ( count( $new_columns ) ) {
213
+ global $wpdb;
214
+ $current_columns = array();
215
+
216
+ $columns = $wpdb->get_results( 'SHOW columns FROM `' . $table . '`' ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
217
+ foreach ( $columns as $column ) {
218
+ $current_columns[ $column->Field ] = $column->Field;
219
+ }
220
+
221
+ foreach ( $new_columns as $column_name => $column_settings ) {
222
+ if ( ! isset( $current_columns[ $column_name ] ) ) {
223
+ $sql = 'ALTER TABLE `' . $table . '` ADD `' . $column_name . '` ' . $column_settings;
224
+ $wpdb->query( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
225
+ }
226
+ }
227
+ }
228
+ } catch ( Exception $err ) {
229
+ error_log( $err->getMessage() );}
230
+ } // End _alter_table
231
+
232
+ /**
233
+ * Inserts the predefined forms into the Forms table
234
+ */
235
+ private static function _predefined_forms() {
236
+ global $wpdb;
237
+ $table_name = $wpdb->prefix . CP_CALCULATEDFIELDSF_FORMS_TABLE;
238
+ $count = $wpdb->get_var( 'SELECT COUNT(id) FROM ' . $table_name ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
239
+ if ( ! $count ) {
240
+ cpcff_init_constants();
241
+ $values = array(
242
+ 'fp_from_email' => CP_CALCULATEDFIELDSF_DEFAULT_fp_from_email,
243
+ 'fp_destination_emails' => CP_CALCULATEDFIELDSF_DEFAULT_fp_destination_emails,
244
+ 'fp_subject' => CP_CALCULATEDFIELDSF_DEFAULT_fp_subject,
245
+ 'fp_inc_additional_info' => CP_CALCULATEDFIELDSF_DEFAULT_fp_inc_additional_info,
246
+ 'fp_return_page' => CP_CALCULATEDFIELDSF_DEFAULT_fp_return_page,
247
+ 'fp_message' => CP_CALCULATEDFIELDSF_DEFAULT_fp_message,
248
+ 'fp_emailformat' => CP_CALCULATEDFIELDSF_DEFAULT_email_format,
249
+
250
+ 'cu_enable_copy_to_user' => CP_CALCULATEDFIELDSF_DEFAULT_cu_enable_copy_to_user,
251
+ 'cu_user_email_field' => CP_CALCULATEDFIELDSF_DEFAULT_cu_user_email_field,
252
+ 'cu_subject' => CP_CALCULATEDFIELDSF_DEFAULT_cu_subject,
253
+ 'cu_message' => CP_CALCULATEDFIELDSF_DEFAULT_cu_message,
254
+ 'cu_emailformat' => CP_CALCULATEDFIELDSF_DEFAULT_email_format,
255
+
256
+ 'vs_use_validation' => CP_CALCULATEDFIELDSF_DEFAULT_vs_use_validation,
257
+ 'vs_text_is_required' => CP_CALCULATEDFIELDSF_DEFAULT_vs_text_is_required,
258
+ 'vs_text_is_email' => CP_CALCULATEDFIELDSF_DEFAULT_vs_text_is_email,
259
+ 'vs_text_datemmddyyyy' => CP_CALCULATEDFIELDSF_DEFAULT_vs_text_datemmddyyyy,
260
+ 'vs_text_dateddmmyyyy' => CP_CALCULATEDFIELDSF_DEFAULT_vs_text_dateddmmyyyy,
261
+ 'vs_text_number' => CP_CALCULATEDFIELDSF_DEFAULT_vs_text_number,
262
+ 'vs_text_digits' => CP_CALCULATEDFIELDSF_DEFAULT_vs_text_digits,
263
+ 'vs_text_max' => CP_CALCULATEDFIELDSF_DEFAULT_vs_text_max,
264
+ 'vs_text_min' => CP_CALCULATEDFIELDSF_DEFAULT_vs_text_min,
265
+ 'vs_text_submitbtn' => 'Submit',
266
+ 'vs_text_previousbtn' => 'Previous',
267
+ 'vs_text_nextbtn' => 'Next',
268
+
269
+ 'enable_paypal' => CP_CALCULATEDFIELDSF_DEFAULT_ENABLE_PAYPAL,
270
+ 'enable_submit' => '',
271
+ 'paypal_notiemails' => '0',
272
+ 'paypal_email' => CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_EMAIL,
273
+ 'request_cost' => CP_CALCULATEDFIELDSF_DEFAULT_COST,
274
+ 'paypal_product_name' => CP_CALCULATEDFIELDSF_DEFAULT_PRODUCT_NAME,
275
+ 'currency' => CP_CALCULATEDFIELDSF_DEFAULT_CURRENCY,
276
+ 'paypal_language' => CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_LANGUAGE,
277
+ 'paypal_mode' => CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_MODE,
278
+ 'paypal_recurrent' => CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_RECURRENT,
279
+ 'paypal_recurrent_setup' => '',
280
+ 'paypal_recurrent_setup_days' => '15',
281
+ 'paypal_recurrent_times' => '0',
282
+ 'paypal_recurrent_times_field' => '',
283
+ 'paypal_identify_prices' => CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_IDENTIFY_PRICES,
284
+ 'paypal_zero_payment' => CP_CALCULATEDFIELDSF_DEFAULT_PAYPAL_ZERO_PAYMENT,
285
+
286
+ 'cv_enable_captcha' => CP_CALCULATEDFIELDSF_DEFAULT_cv_enable_captcha,
287
+ 'cv_width' => CP_CALCULATEDFIELDSF_DEFAULT_cv_width,
288
+ 'cv_height' => CP_CALCULATEDFIELDSF_DEFAULT_cv_height,
289
+ 'cv_chars' => CP_CALCULATEDFIELDSF_DEFAULT_cv_chars,
290
+ 'cv_font' => CP_CALCULATEDFIELDSF_DEFAULT_cv_font,
291
+ 'cv_min_font_size' => CP_CALCULATEDFIELDSF_DEFAULT_cv_min_font_size,
292
+ 'cv_max_font_size' => CP_CALCULATEDFIELDSF_DEFAULT_cv_max_font_size,
293
+ 'cv_noise' => CP_CALCULATEDFIELDSF_DEFAULT_cv_noise,
294
+ 'cv_noise_length' => CP_CALCULATEDFIELDSF_DEFAULT_cv_noise_length,
295
+ 'cv_background' => CP_CALCULATEDFIELDSF_DEFAULT_cv_background,
296
+ 'cv_border' => CP_CALCULATEDFIELDSF_DEFAULT_cv_border,
297
+ 'cv_text_enter_valid_captcha' => CP_CALCULATEDFIELDSF_DEFAULT_cv_text_enter_valid_captcha,
298
+ );
299
+ $values['id'] = 1;
300
+ $values['form_name'] = 'Simple Operations';
301
+ $values['form_structure'] = CP_CALCULATEDFIELDSF_DEFAULT_form_structure1;
302
+ $wpdb->insert( $table_name, $values );
303
+ $values['id'] = 2;
304
+ $values['form_name'] = 'Calculation with Dates';
305
+ $values['form_structure'] = CP_CALCULATEDFIELDSF_DEFAULT_form_structure2;
306
+ $wpdb->insert( $table_name, $values );
307
+ $values['id'] = 3;
308
+ $values['form_name'] = 'Ideal Weight Calculator';
309
+ $values['form_structure'] = CP_CALCULATEDFIELDSF_DEFAULT_form_structure3;
310
+ $wpdb->insert( $table_name, $values );
311
+ $values['id'] = 4;
312
+ $values['form_name'] = 'Pregnancy Calculator';
313
+ $values['form_structure'] = CP_CALCULATEDFIELDSF_DEFAULT_form_structure4;
314
+ $wpdb->insert( $table_name, $values );
315
+ $values['id'] = 5;
316
+ $values['form_name'] = 'Lease Calculator';
317
+ $values['form_structure'] = CP_CALCULATEDFIELDSF_DEFAULT_form_structure5;
318
+ $wpdb->insert( $table_name, $values );
319
+ }
320
+ } // End _predefined_forms
321
+
322
+ } // End class CPCFF_INSTALLER
323
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/cpcff_main.inc.php CHANGED
@@ -1,1093 +1,1074 @@
1
- <?php
2
- /**
3
- * Main class with main actions and filters: CPCFF_MAIN class
4
- *
5
- * @package CFF.
6
- * @since 1.0.170
7
- */
8
-
9
- if(!class_exists('CPCFF_MAIN'))
10
- {
11
- /**
12
- * Class that defines the main actions and filters, and plugin's functionalities.
13
- *
14
- * @since 1.0.170
15
- */
16
- class CPCFF_MAIN
17
- {
18
- /**
19
- * Counter of forms in a same page
20
- * Metaclass property.
21
- *
22
- * @since 1.0.170
23
- * @var int $form_counter
24
- */
25
- public static $form_counter = 0;
26
-
27
- /**
28
- * Instance of the CPCFF_MAIN class
29
- * Metaclass property to implement a singleton.
30
- *
31
- * @since 1.0.179
32
- * @var object $_instance
33
- */
34
- private static $_instance;
35
-
36
- /**
37
- * Identifies if the class was instanciated from the public website or WordPress
38
- * Instance property.
39
- *
40
- * @sinze 1.0.170
41
- * @var bool $_is_admin
42
- */
43
- private $_is_admin = false;
44
-
45
- /**
46
- * Plugin URL
47
- * Instance property.
48
- *
49
- * @sinze 1.0.170
50
- * @var string $_plugin_url
51
- */
52
- private $_plugin_url;
53
-
54
- /**
55
- * Flag to know if the public resources were included
56
- * Instance property.
57
- *
58
- * @sinze 1.0.170
59
- * @var bool $_are_resources_loaded default false
60
- */
61
- private $_are_resources_loaded = false;
62
-
63
- /**
64
- * Forms list.
65
- * List of instances of the CPCFF_FORM class.
66
- * Instance property.
67
- *
68
- * @sinze 1.0.179
69
- * @var object $_active_form
70
- */
71
- private $_forms = array();
72
-
73
- /**
74
- * Instance of the CPCFF_AMP class to manage the forms in AMP pages
75
- * Instance property.
76
- *
77
- * @sinze 1.0.230
78
- * @var object $_amp
79
- */
80
- private $_amp;
81
-
82
- /**
83
- * Constructs a CPCFF_MAIN object, and define the hooks to the filters and actions.
84
- * The constructor is private because this class is a singleton
85
- */
86
- private function __construct()
87
- {
88
- require_once CP_CALCULATEDFIELDSF_BASE_PATH.'/inc/cpcff_form.inc.php';
89
- require_once CP_CALCULATEDFIELDSF_BASE_PATH.'/inc/cpcff_amp.inc.php';
90
-
91
- // Initializes the $_is_admin property
92
- $this->_is_admin = is_admin();
93
-
94
- // Initializes the $_plugin_url property
95
- $this->_plugin_url = plugin_dir_url(CP_CALCULATEDFIELDSF_MAIN_FILE_PATH);
96
-
97
- // Plugin activation/deactivation
98
- $this->_activate_deactivate();
99
-
100
- // Load the language file
101
- add_action( 'plugins_loaded', array($this, 'plugins_loaded') );
102
-
103
- // Instanciate the AMP object
104
- $this->_amp = new CPCFF_AMP($this);
105
-
106
- // Run the initialization code
107
- add_action( 'init', array($this, 'init'), 1 );
108
-
109
- // Run the initialization code of widgets
110
- add_action( 'widgets_init', array($this, 'widgets_init'), 1 );
111
-
112
- // Integration with Page Builders
113
- require_once CP_CALCULATEDFIELDSF_BASE_PATH.'/inc/cpcff_page_builders.inc.php';
114
- CPCFF_PAGE_BUILDERS::run();
115
-
116
- } // End __construct
117
-
118
- /**
119
- * Returns the instance of the singleton.
120
- *
121
- * @since 1.0.179
122
- * @return object self::$_instance
123
- */
124
- public static function instance()
125
- {
126
- if(!isset(self::$_instance))
127
- {
128
- self::$_instance = new self();
129
- }
130
- return self::$_instance;
131
- } // End instance
132
-
133
- /**
134
- * Loads the primary resources, previous to the plugin's initialization
135
- *
136
- * Loads resources like the laguages files, etc.
137
- *
138
- * @return void.
139
- */
140
- public function plugins_loaded()
141
- {
142
- // Fix different troubleshoots
143
- $this->troubleshoots();
144
-
145
- // Load the language file
146
- $this->_textdomain();
147
-
148
- // Load controls scripts
149
- $this->_load_controls_scrips();
150
- } // End plugins_loaded
151
-
152
- /**
153
- * Initializes the plugin, runs as soon as possible.
154
- *
155
- * Initilize the plugin's sections, intercepts the submissions, generates the resources etc.
156
- *
157
- * @return void.
158
- */
159
- public function init()
160
- {
161
- CPCFF_AUXILIARY::clean_transients_hook(); // Set the hook for clearing the expired transients
162
-
163
- if ( $this->_is_admin ) // Initializes the WordPress modules.
164
- {
165
- if(
166
- false === ($CP_CALCULATEDFIELDSF_VERSION = get_option('CP_CALCULATEDFIELDSF_VERSION')) ||
167
- $CP_CALCULATEDFIELDSF_VERSION != CP_CALCULATEDFIELDSF_VERSION
168
- )
169
- {
170
- if(class_exists('CPCFF_INSTALLER')) CPCFF_INSTALLER::install(is_multisite());
171
- update_option('CP_CALCULATEDFIELDSF_VERSION', CP_CALCULATEDFIELDSF_VERSION);
172
- }
173
-
174
- // Update metabox status if corresponds
175
- $this->update_metabox_status();
176
-
177
- // Adds the plugin links in the plugins sections
178
- add_filter( 'plugin_action_links_'.CP_CALCULATEDFIELDSF_BASE_NAME, array($this, 'links' ) );
179
-
180
- // Creates the menu entries in the WordPress menu.
181
- add_action( 'admin_menu', array( $this, 'admin_menu' ) );
182
-
183
- // Displays the shortcode insertion buttons.
184
- add_action( 'media_buttons', array( $this, 'media_buttons' ) );
185
-
186
- // Loads the admin resources
187
- add_action( 'admin_enqueue_scripts', array( $this, 'admin_resources' ), 1 );
188
- }
189
- $this->_define_shortcodes();
190
- add_action('wp_enqueue_scripts', array($this, 'enqueue_loader') );
191
- } // End init
192
-
193
- /**
194
- * Registers the widgets.
195
- *
196
- * Registers the widget to include the forms on sidebars, and for loading the data collected by the forms in the dashboard.
197
- *
198
- * @since 1.0.178
199
- *
200
- * @return void.
201
- */
202
- public function widgets_init()
203
- {
204
- // Replace the shortcodes into the text widgets.
205
- if(!$this->_is_admin) add_filter('widget_text', 'do_shortcode');
206
- } // End widgets_init
207
-
208
- /**
209
- * Adds the plugin's links in the plugins section.
210
- *
211
- * Links for accessing to the help, settings, developers website, etc.
212
- *
213
- * @param array $links.
214
- *
215
- * @return array.
216
- */
217
- public function links( $links )
218
- {
219
- array_unshift(
220
- $links,
221
- '<a href="https://cff.dwbooster.com/customization" target="_blank">'.__('Request custom changes').'</a>',
222
- '<a href="admin.php?page=cp_calculated_fields_form">'.__('Settings').'</a>',
223
- '<a href="https://cff.dwbooster.com/download" target="_blank">'.__('Upgrade').'</a>',
224
- '<a href="https://wordpress.org/support/plugin/calculated-fields-form#new-post" target="_blank">'.__('Help').'</a>'
225
- );
226
- return $links;
227
- } // End links
228
-
229
- /**
230
- * Prints the buttons for inserting the different shortcodes into the pages/posts contents.
231
- *
232
- * Prints the HTML code that appears beside the media button with the icons and code to insert the shortcodes:
233
- *
234
- * - CP_CALCULATED_FIELDS
235
- * - CP_CALCULATED_FIELDS_VAR
236
- *
237
- * @return void.
238
- */
239
- public function media_buttons()
240
- {
241
- print '<a href="javascript:cp_calculatedfieldsf_insertForm();" title="'.esc_attr__('Insert Calculated Fields Form', 'calculated-fields-form' ).'"><img src="'.$this->_plugin_url.'images/cp_form.gif" alt="'.esc_attr__('Insert Calculated Fields Form', 'calculated-fields-form' ).'" /></a><a href="javascript:cp_calculatedfieldsf_insertVar();" title="'.esc_attr__('Create a JavaScript var from POST, GET, SESSION, or COOKIE var', 'calculated-fields-form' ).'"><img src="'.$this->_plugin_url.'images/cp_var.gif" alt="'.esc_attr__('Create a JavaScript var from POST, GET, SESSION, or COOKIE var', 'calculated-fields-form' ).'" /></a>';
242
- } // End media_buttons
243
-
244
- /**
245
- * Generates the entries in the WordPress menu.
246
- *
247
- * @return void.
248
- */
249
- public function admin_menu()
250
- {
251
- // Settings page
252
- add_options_page('Calculated Fields Form Options', 'Calculated Fields Form', 'manage_options', 'cp_calculated_fields_form', array($this, 'admin_pages') );
253
-
254
- // Menu option
255
- add_menu_page( 'Calculated Fields Form Options', 'Calculated Fields Form', 'manage_options', 'cp_calculated_fields_form', array($this, 'admin_pages') );
256
-
257
- // Submenu options
258
- add_submenu_page( 'cp_calculated_fields_form', 'Upgrade', 'Upgrade', 'manage_options', "cp_calculated_fields_form_sub3", array($this, 'admin_pages') );
259
-
260
- add_submenu_page( 'cp_calculated_fields_form', 'Marketplace', 'Marketplace', 'manage_options', "cp_calculated_fields_form_sub5", array($this, 'admin_pages') );
261
-
262
- add_submenu_page( 'cp_calculated_fields_form', 'Documentation', 'Documentation', 'manage_options', "cp_calculated_fields_form_sub2", array($this, 'admin_pages') );
263
-
264
- add_submenu_page( 'cp_calculated_fields_form', 'Online Help', 'Online Help', 'manage_options', "cp_calculated_fields_form_sub4", array($this, 'admin_pages') );
265
- } // End admin_menu
266
-
267
- /**
268
- * Loads the corresponding pages in the WordPress or redirects the user to the external URLs.
269
- *
270
- * Loads the webpage with the list of forms, addons activation, general settings, etc.
271
- * or redirects to external webpages like plugin's documentation
272
- *
273
- * @since 1.0.181
274
- */
275
- public function admin_pages()
276
- {
277
- // Settings page of the plugin
278
- if (isset($_GET["cal"]) && $_GET["cal"] != '')
279
- {
280
- @include_once CP_CALCULATEDFIELDSF_BASE_PATH . '/inc/cpcff_admin_int.inc.php';
281
- }
282
- else
283
- {
284
- // Redirecting outer website
285
- if (isset($_GET["page"]) && $_GET["page"] == 'cp_calculated_fields_form_sub3')
286
- {
287
- if(@wp_redirect('https://cff.dwbooster.com/download')) exit;
288
- }
289
- else if (isset($_GET["page"]) && $_GET["page"] == 'cp_calculated_fields_form_sub2')
290
- {
291
- if(@wp_redirect('https://cff.dwbooster.com/documentation')) exit;
292
- }
293
- else if (isset($_GET["page"]) && $_GET["page"] == 'cp_calculated_fields_form_sub4')
294
- {
295
- if(@wp_redirect('https://wordpress.org/support/plugin/calculated-fields-form#new-post')) exit;
296
- }
297
- else
298
- @include_once CP_CALCULATEDFIELDSF_BASE_PATH . '/inc/cpcff_admin_int_list.inc.php';
299
- }
300
- } // End admin_pages
301
-
302
- /**
303
- * Loads the javascript and style files.
304
- *
305
- * Checks if there is the settings page of the plugin for loading the corresponding JS and CSS files,
306
- * or if it is a post or page the script for inserting the shortcodes in the content's editor.
307
- *
308
- * @since 1.0.171
309
- *
310
- * @param string $hook.
311
- * @return void.
312
- */
313
- public function admin_resources( $hook )
314
- {
315
- // Checks if it is the plugin's page
316
- if(isset($_GET['page']))
317
- {
318
- if('cp_calculated_fields_form' == $_GET['page'])
319
- {
320
- wp_deregister_script( 'tribe-events-bootstrap-datepicker' );
321
- wp_register_script('tribe-events-bootstrap-datepicker', plugins_url('/js/nope.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH));
322
-
323
- wp_enqueue_script( "jquery" );
324
- wp_enqueue_script( "jquery-ui-core" );
325
- wp_enqueue_script( "jquery-ui-sortable" );
326
- wp_enqueue_script( "jquery-ui-tabs" );
327
- wp_enqueue_script( "jquery-ui-droppable" );
328
- wp_enqueue_script( "jquery-ui-button" );
329
- wp_enqueue_script( "jquery-ui-datepicker" );
330
- wp_deregister_script('query-stringify');
331
- wp_register_script('query-stringify', plugins_url('/vendors/jQuery.stringify.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH));
332
- wp_enqueue_script( "query-stringify" );
333
-
334
- //ULR to the admin resources
335
- $admin_resources = admin_url( "admin.php?page=cp_calculated_fields_form&cp_cff_resources=admin" );
336
- wp_enqueue_script( 'cp_calculatedfieldsf_builder_script', $admin_resources, array("jquery","jquery-ui-core","jquery-ui-sortable","jquery-ui-tabs","jquery-ui-droppable","jquery-ui-button", "jquery-ui-accordion","jquery-ui-datepicker","query-stringify"), CP_CALCULATEDFIELDSF_VERSION );
337
-
338
- wp_enqueue_script( 'cp_calculatedfieldsf_builder_library_script', plugins_url('/js/library.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH), array("cp_calculatedfieldsf_builder_script"), CP_CALCULATEDFIELDSF_VERSION );
339
-
340
- wp_localize_script('cp_calculatedfieldsf_builder_library_script', 'cpcff_forms_library_config', array(
341
- 'version' => 'free',
342
- 'website_url' => 'admin.php?page=cp_calculated_fields_form&a=1&_cpcff_nonce=' . wp_create_nonce( 'cff-add-form' )
343
- ));
344
-
345
- wp_enqueue_script( 'cp_calculatedfieldsf_builder_script_caret', plugins_url('/vendors/jquery.caret.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH),array("jquery"), CP_CALCULATEDFIELDSF_VERSION );
346
- wp_enqueue_style('cp_calculatedfieldsf_builder_style', plugins_url('/css/style.css', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH), array(), CP_CALCULATEDFIELDSF_VERSION);
347
- wp_enqueue_style('cp_calculatedfieldsf_builder_library_style', plugins_url('/css/stylelibrary.css', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH), array('cp_calculatedfieldsf_builder_style'), CP_CALCULATEDFIELDSF_VERSION);
348
- wp_enqueue_style('jquery-style', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css', array(), CP_CALCULATEDFIELDSF_VERSION);
349
- }
350
- // Checks if it is to an external page
351
- elseif(
352
- in_array(
353
- $_GET["page"],
354
- array(
355
- 'cp_calculated_fields_form_sub2',
356
- 'cp_calculated_fields_form_sub3',
357
- 'cp_calculated_fields_form_sub4',
358
- 'cp_calculated_fields_form_sub5'
359
- )
360
- )
361
- )
362
- {
363
- $cpcff_redirect = array();
364
- switch($_GET["page"])
365
- {
366
- case 'cp_calculated_fields_form_sub2':
367
- $cpcff_redirect['url'] = 'https://cff.dwbooster.com/documentation';
368
- break;
369
- case 'cp_calculated_fields_form_sub3':
370
- $cpcff_redirect['url'] = 'https://cff.dwbooster.com/download';
371
- break;
372
- case 'cp_calculated_fields_form_sub4':
373
- $cpcff_redirect['url'] = 'https://wordpress.org/support/plugin/calculated-fields-form#new-post';
374
- break;
375
- case 'cp_calculated_fields_form_sub5':
376
- $cpcff_redirect['url'] = 'https://cff-bundles.dwbooster.com';
377
- break;
378
- }
379
- wp_enqueue_script('cp_calculatedfieldsf_redirect_script', plugins_url('/js/redirect_script.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH));
380
- wp_localize_script(
381
- 'cp_calculatedfieldsf_redirect_script',
382
- 'cpcff_redirect',
383
- $cpcff_redirect
384
- );
385
- }
386
- }
387
-
388
- // Checks if it is a page or post
389
- if( 'post.php' == $hook || 'post-new.php' == $hook )
390
- {
391
- wp_enqueue_script( 'cp_calculatedfieldsf_script', plugins_url('/js/cp_calculatedfieldsf_scripts.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH) );
392
- }
393
- } // End admin_resources
394
-
395
- public function metabox_status( $metabox_id )
396
- {
397
- $statuses = get_option( 'cff-metaboxes-statuses', [] );
398
- return ( ! empty( $statuses ) && is_array( $statuses ) && isset( $statuses[ $metabox_id ] ) && $statuses[ $metabox_id ] == 0) ? 'cff-metabox-closed' : 'cff-metabox-opened';
399
- } // End metabox_status
400
-
401
- private function update_metabox_status()
402
- {
403
- if(
404
- ! empty( $_POST['cff-metabox-nonce'] ) &&
405
- wp_verify_nonce( $_POST['cff-metabox-nonce'], 'cff-metabox-status' ) &&
406
- isset( $_POST['cff-metabox-id'] ) &&
407
- isset( $_POST['cff-metabox-action'] )
408
- )
409
- {
410
- $metabox_id = sanitize_text_field( wp_unslash( $_POST['cff-metabox-id'] ) );
411
- $metabox_action = sanitize_text_field( wp_unslash( $_POST['cff-metabox-action'] ) );
412
-
413
- if( ! empty( $metabox_id ) ) {
414
- $statuses = get_option( 'cff-metaboxes-statuses', [] );
415
- if( empty( $statuses ) || ! is_array( $statuses ) )
416
- {
417
- $statuses = [];
418
- }
419
- $statuses[$metabox_id] = $metabox_action == 'open' ? 1 : 0;
420
- update_option( 'cff-metaboxes-statuses', $statuses );
421
- }
422
- }
423
- } // End update_metabox_status
424
-
425
- public function form_preview( $atts )
426
- {
427
- if(isset($atts['shortcode_atts']))
428
- {
429
- error_reporting(E_ERROR|E_PARSE);
430
- global $wp_styles, $wp_scripts;
431
- if(!empty($wp_scripts)) $wp_scripts->reset();
432
- $message = $this->public_form($atts['shortcode_atts']);
433
- ob_start();
434
- if(!empty($wp_styles)) $wp_styles->do_items();
435
- if(!empty($wp_scripts)) $wp_scripts->do_items();
436
- if(class_exists('Error'))
437
- {
438
- try{ wp_footer(); } catch(Error $err) {}
439
- }
440
- $message .= ob_get_contents();
441
- ob_end_clean();
442
- $page_title = (!empty($atts['page_title'])) ? $atts['page_title'] : '';
443
- remove_all_actions('shutdown');
444
- if(!empty($atts['wp_die']))
445
- {
446
- wp_die($message.'<style>body{margin:2em !important;max-width:100% !important;box-shadow:none !important;background:white !important}html{background:white !important;}.wp-die-message>*:not(form){visibility: hidden;} .pac-container, .ui-tooltip, .ui-tooltip *,.ui-datepicker,.ui-datepicker *{visibility: visible;}</style>'.apply_filters('cpcff_form_preview_resources', ''), $page_title, 200);
447
- }
448
- elseif(!empty($atts['page']))
449
- {
450
- print '<!DOCTYPE html><html><head profile="http://gmpg.org/xfn/11"><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1"></head><body>';
451
- print $message;
452
- print '<style>body>*:not(form){visibility: hidden;} .pac-container, .ui-tooltip, .ui-tooltip *,.ui-datepicker,.ui-datepicker *{visibility: visible;}</style>'.apply_filters('cpcff_form_preview_resources', '').'</body></html>';
453
- exit;
454
- }
455
- else
456
- {
457
- print $message;
458
- exit;
459
- }
460
- }
461
- } // End form_preview
462
-
463
- public function enqueue_loader()
464
- {
465
- global $post;
466
-
467
- if(!empty($post) && has_shortcode($post->post_content, 'CP_CALCULATED_FIELDS'))
468
- wp_enqueue_style( 'cpcff_loader', plugins_url('/css/loader.css', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH), array(), CP_CALCULATEDFIELDSF_VERSION );
469
- } // End enqueue_loader
470
-
471
- /**
472
- * Returns the public version of the form wih its resources.
473
- *
474
- * The method calls the filters: cpcff_pre_form, and cpcff_the_form
475
- * @since 1.0.171
476
- * @param array $atts includes the attributes required to identify the form, and create the variables.
477
- * @return string $content a text with the public version of the form and resources.
478
- */
479
- public function public_form( $atts )
480
- {
481
- // If the website is being visited by crawler, display empty text.
482
- if( CPCFF_AUXILIARY::is_crawler() ) return '';
483
- if( empty($atts) ) $atts = array();
484
- if(!$this->_is_admin && $this->_amp->is_amp())
485
- {
486
- $content = $this->_amp->get_iframe($atts);
487
- }
488
- else
489
- {
490
- global $wpdb, $cpcff_default_texts_array;
491
-
492
- if( empty( $atts[ 'id' ] ) ) // if was not passed the form's id get all.
493
- {
494
- $myrow = $wpdb->get_row( "SELECT * FROM ".$wpdb->prefix.CP_CALCULATEDFIELDSF_FORMS_TABLE );
495
- }
496
- else
497
- {
498
- $myrow = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM ".$wpdb->prefix.CP_CALCULATEDFIELDSF_FORMS_TABLE." WHERE id=%d",$atts[ 'id' ] ) );
499
- }
500
-
501
- if( empty( $myrow ) ) return ''; // The form does not exists, or there are no forms.
502
- $atts[ 'id' ] = $myrow->id; // If was not passed the form's id, uses the if of first form.
503
- $id = $atts[ 'id' ]; // Alias for the $atts[ 'id' ] variable.
504
-
505
- // Initializing the $form_counter
506
- if(!isset($GLOBALS['codepeople_form_sequence_number'])) $GLOBALS['codepeople_form_sequence_number'] = 0;
507
- $GLOBALS['codepeople_form_sequence_number']++;
508
- self::$form_counter = $GLOBALS['codepeople_form_sequence_number']; // Current form
509
-
510
- /**
511
- * Filters applied before generate the form,
512
- * is passed as parameter an array with the forms attributes, and return the list of attributes
513
- */
514
- $atts = apply_filters( 'cpcff_pre_form', $atts );
515
-
516
- ob_start();
517
-
518
- // Constant defined to protect the "inc/cpcff_public_int.inc.php" file against direct accesses.
519
- if ( !defined('CP_AUTH_INCLUDE') ) define('CP_AUTH_INCLUDE', true);
520
-
521
- $this->_public_resources($id); // Load form scripts and other resources
522
-
523
- /* TO-DO: This method should be analyzed after moving other functions to the main class . */
524
- @include CP_CALCULATEDFIELDSF_BASE_PATH . '/inc/cpcff_public_int.inc.php';
525
-
526
- $content = ob_get_contents();
527
-
528
- // The attributes excepting "id" are converted in javascript variables with a global scope
529
- if( count( $atts ) > 1 )
530
- {
531
- $content .= '<script>';
532
- foreach( $atts as $i => $v )
533
- {
534
- if( $i != 'id' && $i != 'class' && !is_numeric( $i ) )
535
- {
536
- $nV = ( is_numeric( $v ) ) ? $v : json_encode( $v ); // Sanitizing the attribute's value
537
- $content .= $i.'='.$nV.';';
538
- $content .= 'if(typeof '.$i.'_arr == "undefined") '.$i.'_arr={}; '.$i.'_arr["_'.self::$form_counter.'"]='.$nV.';';
539
- }
540
- }
541
- $content .= '</script>';
542
- }
543
- ob_end_clean();
544
-
545
- /**
546
- * Filters applied after generate the form,
547
- * is passed as parameter the HTML code of the form with the corresponding <LINK> and <SCRIPT> tags,
548
- * and returns the HTML code to includes in the webpage
549
- */
550
- $content = apply_filters( 'cpcff_the_form', $content, $atts[ 'id' ] );
551
- }
552
-
553
- return $content;
554
- } // End public_form
555
-
556
- /**
557
- * Creates a javascript variable, from: Post, Get, Session or Cookie or directly.
558
- *
559
- * If the webpage is visited from a crawler or search engine spider, the shortcode is replaced by an empty text.
560
- *
561
- * @since 1.0.175
562
- * @param array $atts includes the records:
563
- * - name, the variable's name.
564
- * - value, to create a variable splicitly with the value passed as attribute.
565
- * - from, identifies the variable source (POST, GET, SESSION or COOKIE), it is optional.
566
- * - default_value, used in combination with the from attribute to populate the variable
567
- * with the default value of the source does not exist.
568
- *
569
- * @return string <script> tag with the variable's definition.
570
- */
571
- public function create_variable_shortcode( $atts )
572
- {
573
- if(
574
- !CPCFF_AUXILIARY::is_crawler() && // Checks for crawlers or search engine spiders
575
- !empty($atts[ 'name' ]) &&
576
- ($var = trim($atts[ 'name' ])) != ''
577
- )
578
- {
579
- if( isset( $atts[ 'value' ] ) )
580
- {
581
- $value = json_encode( $atts[ 'value' ] );
582
- }
583
- else
584
- {
585
- $from = '_';
586
- if( isset($atts['from'])) $from .= strtoupper(trim($atts['from']));
587
- if( in_array( $from, array( '_POST', '_GET', '_SESSION', '_COOKIE' ) ) )
588
- {
589
- if( isset( $GLOBALS[ $from ][ $var ] ) ) $value = json_encode($GLOBALS[ $from ][ $var ]);
590
- elseif( isset( $atts[ 'default_value' ] ) ) $value = json_encode($atts[ 'default_value' ]);
591
- }
592
- else
593
- {
594
- if( isset( $_POST[ $var ] ) ) $value = json_encode($_POST[ $var ]);
595
- elseif( isset( $_GET[ $var ] ) ) $value = json_encode($_GET[ $var ]);
596
- elseif( isset( $_SESSION[ $var ] ) ) $value = json_encode($_SESSION[ $var ]);
597
- elseif( isset( $_COOKIE[ $var ] ) ) $value = json_encode($_COOKIE[ $var ]);
598
- elseif( isset( $atts[ 'default_value' ] ) ) $value = json_encode($atts[ 'default_value' ]);
599
- }
600
- }
601
- if(isset( $value ))
602
- {
603
- return '
604
- <script>
605
- try{
606
- window["'.esc_js($var).'"]='.$value.';
607
- }catch( err ){}
608
- </script>
609
- ';
610
- }
611
- }
612
- return '';
613
- } // End create_variable_shortcode
614
-
615
- /**
616
- * Return the list of categories associted with the forms
617
- */
618
- public function get_categories($html = '', &$current = NULL)
619
- {
620
- global $wpdb;
621
- $categories = $wpdb->get_results('SELECT DISTINCT category FROM '.$wpdb->prefix.CP_CALCULATEDFIELDSF_FORMS_TABLE.' WHERE category IS NOT NULL AND category <> ""', ARRAY_A);
622
-
623
- if(empty($html)) return $categories;
624
-
625
- $output = '';
626
- $flag = false;
627
-
628
- if(!empty($categories))
629
- {
630
- foreach($categories as $category)
631
- {
632
- $selected = '';
633
-
634
- if($current === $category['category'])
635
- {
636
- $selected = 'SELECTED';
637
- $flag = true;
638
- }
639
-
640
- if($html == 'SELECT')
641
- {
642
- $output .= '<option value="'.esc_attr($category['category']).'" '.$selected.' >'.esc_html($category['category']).'</option>';
643
- }
644
- else // DATALIST
645
- {
646
- $output .= '<option value="'.esc_attr($category['category']).'">';
647
- }
648
- }
649
- }
650
-
651
- if(!$flag) $current = '';
652
-
653
- return $output;
654
- } // End get_categories
655
-
656
- /**
657
- * Returns an instance of the active form
658
- *
659
- * If there is not an active form generates the instance.
660
- *
661
- * @since 1.0.179
662
- * @return object
663
- */
664
- public function get_form( $id )
665
- {
666
- if(!isset($this->_forms[$id]))
667
- {
668
- $this->_forms[$id] = new CPCFF_FORM($id);
669
- }
670
- return $this->_forms[$id];
671
- } // End get_active_form
672
-
673
- /**
674
- * Creates a new form calling the static method CPCFF_FORM::create_default
675
- *
676
- * @since 1.0.179
677
- *
678
- * @param string $form_name, the name of form.
679
- * @return mixed, an instance of the created form or false.
680
- */
681
- public function create_form($form_name, $category_name = '', $form_template = 0)
682
- {
683
- $form = CPCFF_FORM::create_default($form_name, $category_name, $form_template);
684
- if($form) $this->_forms[$form->get_id()] = $form;
685
- return $form;
686
- } // End create_form
687
-
688
- /**
689
- * Deletes the form.
690
- * The methods throw the cpcff_delete_form hook after delete the form.
691
- *
692
- * @since 1.0.179
693
- * @param integer $id, the form's id.
694
- * @return mixed, the number of delete rows or false.
695
- */
696
- public function delete_form( $id )
697
- {
698
- $deleted = $this->get_form($id)->delete_form();
699
- if($deleted)
700
- {
701
- do_action( 'cpcff_delete_form', $id);
702
- unset( $this->_forms[$id]);
703
- }
704
- return $deleted;
705
- } // End delete_form
706
-
707
- /**
708
- * Clones a form.
709
- *
710
- * @since 1.0.179
711
- * @param integer $id, the form's id.
712
- * @return mixed, an instance of cloned form or false.
713
- */
714
- public function clone_form($id)
715
- {
716
- if(!isset($this->_forms[$id])) $this->_forms[$id] = new CPCFF_FORM($id);
717
- $cloned_form = $this->_forms[$id]->clone_form();
718
- if($cloned_form)
719
- {
720
- /**
721
- * Passes as parameter the original form's id, and the new form's id
722
- */
723
- do_action( 'cpcff_clone_form', $id, $cloned_form->get_id());
724
- }
725
- return $cloned_form;
726
- } // End clone_form
727
-
728
- /*********************************** PRIVATE METHODS ********************************************/
729
-
730
- /**
731
- * Defines the activativation/deactivation hooks, and new blog hook.
732
- *
733
- * Requires the cpcff_install_uninstall.inc.php file with the activate/deactivate code, and the code to run with new blogs.
734
- *
735
- * @sinze 1.0.171
736
- * @return void.
737
- */
738
- private function _activate_deactivate()
739
- {
740
- require_once CP_CALCULATEDFIELDSF_BASE_PATH.'/inc/cpcff_install_uninstall.inc.php';
741
- register_activation_hook(CP_CALCULATEDFIELDSF_MAIN_FILE_PATH,array('CPCFF_INSTALLER','install'));
742
- register_deactivation_hook(CP_CALCULATEDFIELDSF_MAIN_FILE_PATH,array('CPCFF_INSTALLER','uninstall'));
743
- add_action('wpmu_new_blog', array('CPCFF_INSTALLER', 'new_blog'), 10, 6);
744
- } // End _activate_deactivate
745
-
746
- /**
747
- * Loads the language file.
748
- *
749
- * Loads the language file associated to the plugin, and creates the textdomain.
750
- *
751
- * @return void.
752
- */
753
- private function _textdomain()
754
- {
755
- load_plugin_textdomain( 'calculated-fields-form', FALSE, dirname( CP_CALCULATEDFIELDSF_BASE_NAME ) . '/languages/' );
756
- } // End _textdomain
757
-
758
- /**
759
- * Loads the controls scripts.
760
- *
761
- * Checks if there is defined the "cp_cff_resources" parameter, and loads the public or admin scripsts for the controls.
762
- * If the scripsts are loaded the plugin exits the PHP execution.
763
- *
764
- * @return void.
765
- */
766
- private function _load_controls_scrips()
767
- {
768
- if( isset( $_REQUEST[ 'cp_cff_resources' ] ) )
769
- {
770
- if(!defined('WP_DEBUG') || true != WP_DEBUG)
771
- {
772
- error_reporting(E_ERROR|E_PARSE);
773
- }
774
- // Set the corresponding header
775
- if(!headers_sent())
776
- {
777
- header("Content-type: application/javascript");
778
- }
779
-
780
- if(!$this->_is_admin || $_REQUEST[ 'cp_cff_resources' ] == 'public')
781
- {
782
- require_once CP_CALCULATEDFIELDSF_BASE_PATH.'/js/fbuilder-loader-public.php';
783
- }
784
- else
785
- {
786
- require_once CP_CALCULATEDFIELDSF_BASE_PATH.'/js/fbuilder-loader-admin.php';
787
- }
788
- remove_all_actions('shutdown');
789
- exit;
790
- }
791
- } // End _load_controls_scrips
792
-
793
- /**
794
- * Defines the shortcodes used by the plugin's code:
795
- *
796
- * - CP_CALCULATED_FIELDS
797
- * - CP_CALCULATED_FIELDS_VAR
798
- *
799
- * @return void.
800
- */
801
- private function _define_shortcodes()
802
- {
803
- add_shortcode( 'CP_CALCULATED_FIELDS', array($this,'public_form') );
804
- add_shortcode( 'CP_CALCULATED_FIELDS_VAR', array($this,'create_variable_shortcode') );
805
- } // End _define_shortcodes
806
- /**
807
- * Returns a JSON object with the configuration object.
808
- *
809
- * Uses the global variable $cpcff_default_texts_array, defined in the "config/cpcff_config.cfg.php"
810
- *
811
- * @sinze 1.0.171
812
- * @param int $formid the form's id.
813
- * @return string $json
814
- */
815
- private function _get_form_configuration( $formid )
816
- {
817
- global $cpcff_default_texts_array;
818
- $form_obj = $this->get_form($formid);
819
- $previous_label = $form_obj->get_option('vs_text_previousbtn', 'Previous');
820
- $previous_label = ( $previous_label=='' ? 'Previous' : $previous_label );
821
- $next_label = $form_obj->get_option('vs_text_nextbtn', 'Next');
822
- $next_label = ( $next_label == '' ? 'Next' : $next_label );
823
-
824
- $cpcff_texts_array = $form_obj->get_option('vs_all_texts', $cpcff_default_texts_array);
825
- $cpcff_texts_array = CPCFF_AUXILIARY::array_replace_recursive(
826
- $cpcff_default_texts_array,
827
- ( is_string( $cpcff_texts_array ) && is_array( unserialize( $cpcff_texts_array ) ) )
828
- ? unserialize( $cpcff_texts_array )
829
- : ( ( is_array( $cpcff_texts_array ) ) ? $cpcff_texts_array : array() )
830
- );
831
-
832
- $obj = array(
833
- "pub"=>true,
834
- "identifier"=>'_'.self::$form_counter,
835
- "messages"=> array(
836
- "required" => $form_obj->get_option('vs_text_is_required', CP_CALCULATEDFIELDSF_DEFAULT_vs_text_is_required),
837
- "email" => $form_obj->get_option('vs_text_is_email', CP_CALCULATEDFIELDSF_DEFAULT_vs_text_is_email),
838
- "datemmddyyyy" => $form_obj->get_option('vs_text_datemmddyyyy', CP_CALCULATEDFIELDSF_DEFAULT_vs_text_datemmddyyyy),
839
- "dateddmmyyyy" => $form_obj->get_option('vs_text_dateddmmyyyy', CP_CALCULATEDFIELDSF_DEFAULT_vs_text_dateddmmyyyy),
840
- "number" => $form_obj->get_option('vs_text_number', CP_CALCULATEDFIELDSF_DEFAULT_vs_text_number),
841
- "digits" => $form_obj->get_option('vs_text_digits', CP_CALCULATEDFIELDSF_DEFAULT_vs_text_digits),
842
- "max" => $form_obj->get_option('vs_text_max', CP_CALCULATEDFIELDSF_DEFAULT_vs_text_max),
843
- "min" => $form_obj->get_option('vs_text_min', CP_CALCULATEDFIELDSF_DEFAULT_vs_text_min),
844
- "previous" => $previous_label,
845
- "next" => $next_label,
846
- "pageof" => $cpcff_texts_array[ 'page_of_text' ][ 'text' ],
847
- "audio_tutorial" => $cpcff_texts_array[ 'audio_tutorial_text' ][ 'text' ],
848
- "minlength" => $cpcff_texts_array[ 'errors' ][ 'minlength' ][ 'text' ],
849
- "maxlength" => $cpcff_texts_array[ 'errors' ][ 'maxlength' ][ 'text' ],
850
- "equalTo" => $cpcff_texts_array[ 'errors' ][ 'equalTo' ][ 'text' ],
851
- "accept" => $cpcff_texts_array[ 'errors' ][ 'accept' ][ 'text' ],
852
- "upload_size" => $cpcff_texts_array[ 'errors' ][ 'upload_size' ][ 'text' ],
853
- "phone" => $cpcff_texts_array[ 'errors' ][ 'phone' ][ 'text' ],
854
- "currency" => $cpcff_texts_array[ 'errors' ][ 'currency' ][ 'text' ]
855
- )
856
- );
857
- return json_encode( $obj );
858
- } // End _get_form_configuration
859
-
860
- /**
861
- * Loads the javascript and style files used by the public forms.
862
- *
863
- * Checks if the plugin was configured for loading HTML tags directly, or to use the WordPress functions.
864
- *
865
- * @since 1.0.171
866
- * @param int $formid the form's id.
867
- * @return void.
868
- */
869
- private function _public_resources( $formid )
870
- {
871
- if(
872
- get_option( 'CP_CALCULATEDFIELDSF_USE_CACHE', CP_CALCULATEDFIELDSF_USE_CACHE ) &&
873
- file_exists( CP_CALCULATEDFIELDSF_BASE_PATH.'/js/cache/all.js' )
874
- )
875
- {
876
- $public_js_path = plugins_url('/js/cache/all.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH);
877
- }
878
-
879
- if(empty($public_js_path))
880
- {
881
- global $cff_backend_script_generator, $cff_script_generator_min;
882
-
883
- $cff_backend_script_generator = 1;
884
- $cff_script_generator_min = get_option( 'CP_CALCULATEDFIELDSF_USE_CACHE', CP_CALCULATEDFIELDSF_USE_CACHE );
885
- include_once CP_CALCULATEDFIELDSF_BASE_PATH.'/js/fbuilder-loader-public.php';
886
- }
887
-
888
- if(
889
- file_exists( CP_CALCULATEDFIELDSF_BASE_PATH.'/js/cache/all.js' )
890
- )
891
- {
892
- $public_js_path = plugins_url('/js/cache/all.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH);
893
- }
894
- else
895
- {
896
- $public_js_path = CPCFF_AUXILIARY::wp_current_url().((strpos(CPCFF_AUXILIARY::wp_current_url(),'?') === false) ? '?' : '&').'cp_cff_resources=public&min='.get_option('CP_CALCULATEDFIELDSF_USE_CACHE', CP_CALCULATEDFIELDSF_USE_CACHE);
897
- }
898
-
899
- $config_json = $this->_get_form_configuration($formid);
900
-
901
- if ($GLOBALS['CP_CALCULATEDFIELDSF_DEFAULT_DEFER_SCRIPTS_LOADING'])
902
- {
903
- wp_enqueue_script( "jquery" );
904
- wp_enqueue_script( "jquery-ui-core" );
905
- wp_enqueue_script( "jquery-ui-button" );
906
- wp_enqueue_script( "jquery-ui-widget" );
907
- wp_enqueue_script( "jquery-ui-position" );
908
- wp_enqueue_script( "jquery-ui-tooltip" );
909
- wp_enqueue_script( "jquery-ui-datepicker" );
910
- wp_enqueue_script( "jquery-ui-slider" );
911
-
912
- wp_deregister_script('query-stringify');
913
- wp_register_script('query-stringify', plugins_url('/vendors/jQuery.stringify.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH), array('jquery'), 'pro');
914
-
915
- wp_deregister_script('cp_calculatedfieldsf_validate_script');
916
- wp_register_script('cp_calculatedfieldsf_validate_script', plugins_url('/vendors/jquery.validate.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH), array('jquery'), 'pro');
917
- wp_enqueue_script( 'cp_calculatedfieldsf_builder_script', $public_js_path, array("jquery","jquery-ui-core","jquery-ui-button","jquery-ui-widget","jquery-ui-position","jquery-ui-tooltip","query-stringify","cp_calculatedfieldsf_validate_script", "jquery-ui-datepicker", "jquery-ui-slider"), CP_CALCULATEDFIELDSF_VERSION, true );
918
-
919
- wp_localize_script('cp_calculatedfieldsf_builder_script', 'cp_calculatedfieldsf_fbuilder_config_'.self::$form_counter, array('obj' => $config_json));
920
- }
921
- else
922
- {
923
- // This code won't be used in most cases. This code is for preventing problems in wrong WP themes and conflicts with third party plugins.
924
- if( !$this->_are_resources_loaded ) // Load the resources only one time
925
- {
926
- global $wp_version;
927
- $this->_are_resources_loaded = true; // Resources loaded
928
-
929
- $includes_url = includes_url();
930
-
931
- // Used for compatibility with old versions of WordPress
932
- $prefix_ui = (@file_exists(CP_CALCULATEDFIELDSF_BASE_PATH.'/../../../wp-includes/js/jquery/ui/jquery.ui.core.min.js')) ? 'jquery.ui.' : '';
933
-
934
- if(!wp_script_is('jquery', 'done'))
935
- print '<script type="text/javascript" src="'.$includes_url.'js/jquery/jquery.js"></script>';
936
- if(!wp_script_is('jquery-ui-core', 'done'))
937
- print '<script type="text/javascript" src="'.$includes_url.'js/jquery/ui/'.$prefix_ui.'core.min.js"></script>';
938
- if(!wp_script_is('jquery-ui-datepicker', 'done'))
939
- print '<script type="text/javascript" src="'.$includes_url.'js/jquery/ui/'.$prefix_ui.'datepicker.min.js"></script>';
940
-
941
- if(version_compare($wp_version,'5.5.4', '<'))
942
- {
943
- if(!wp_script_is('jquery-ui-widget', 'done'))
944
- print '<script type="text/javascript" src="'.$includes_url.'js/jquery/ui/'.$prefix_ui.'widget.min.js"></script>';
945
- if(!wp_script_is('jquery-ui-position', 'done'))
946
- print '<script type="text/javascript" src="'.$includes_url.'js/jquery/ui/'.$prefix_ui.'position.min.js"></script>';
947
- }
948
-
949
- if(!wp_script_is('jquery-ui-tooltip', 'done'))
950
- print '<script type="text/javascript" src="'.$includes_url.'js/jquery/ui/'.$prefix_ui.'tooltip.min.js"></script>';
951
- if(!wp_script_is('jquery-ui-mouse', 'done'))
952
- print '<script type="text/javascript" src="'.$includes_url.'js/jquery/ui/'.$prefix_ui.'mouse.min.js"></script>';
953
- if(!wp_script_is('jquery-ui-slider', 'done'))
954
- print '<script type="text/javascript" src="'.$includes_url.'js/jquery/ui/'.$prefix_ui.'slider.min.js"></script>';
955
- ?>
956
- <script>if( typeof fbuilderjQuery == 'undefined') var fbuilderjQuery = jQuery.noConflict( );</script>
957
- <script type='text/javascript' src='<?php echo plugins_url('vendors/jquery.validate.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH); ?>'></script>
958
- <script type='text/javascript' src='<?php echo plugins_url('vendors/jQuery.stringify.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH); ?>'></script>
959
- <script type='text/javascript' src='<?php echo $public_js_path.(( strpos( $public_js_path, '?' ) == false ) ? '?' : '&' ).'ver='.CP_CALCULATEDFIELDSF_VERSION; ?>'></script>
960
- <?php
961
- }
962
- ?>
963
- <pre style="display:none !important;"><script type='text/javascript'>
964
- /* <![CDATA[ */
965
- <?php
966
- print 'var cp_calculatedfieldsf_fbuilder_config_'.self::$form_counter.'={"obj":'.$config_json.'};';
967
- ?>
968
- /* ]]> */
969
- </script></pre>
970
- <?php
971
- }
972
- } // End _public_resources
973
-
974
- /** TROUBLESHOOTS SECTION **/
975
- public function compatibility_warnings()
976
- {
977
- require_once CP_CALCULATEDFIELDSF_BASE_PATH.'/inc/cpcff_compatibility.inc.php';
978
- return CPCFF_COMPATIBILITY::warnings();
979
- } // End compatibility_warnings
980
-
981
- private function troubleshoots()
982
- {
983
- if(!$this->_is_admin)
984
- {
985
- if(get_option('CP_CALCULATEDFIELDSF_OPTIMIZATION_PLUGIN', CP_CALCULATEDFIELDSF_OPTIMIZATION_PLUGIN)*1)
986
- {
987
- // Solves a conflict caused by the "Speed Booster Pack" plugin
988
- add_filter('option_sbp_settings', 'CPCFF_MAIN::speed_booster_pack_troubleshoot');
989
-
990
- // Solves a conflict caused by the "Autoptimize" plugin
991
- if(class_exists('autoptimizeOptionWrapper'))
992
- {
993
- $GLOBALS['CP_CALCULATEDFIELDSF_DEFAULT_DEFER_SCRIPTS_LOADING'] = true;
994
- add_filter('cpcff_pre_form', function($atts){
995
- add_filter('autoptimize_js_include_inline', function($p){return false;});
996
- add_filter('autoptimize_filter_js_noptimize', function($p1, $p2){return true;}, 10, 2);
997
- add_filter('autoptimize_filter_html_noptimize', function($p1, $p2){return true;}, 10, 2);
998
- return $atts;
999
- });
1000
- }
1001
-
1002
- // Solves conflicts with "LiteSpeed Cache" plugin
1003
- if(function_exists('run_litespeed_cache'))
1004
- {
1005
- add_action('the_post', 'CPCFF_MAIN::litespeed_control_set_nocache');
1006
- }
1007
-
1008
- // Solves a conflict caused by the "WP Rocket" plugin
1009
- add_filter( 'rocket_exclude_js', 'CPCFF_MAIN::rocket_exclude_js' );
1010
- add_filter( 'rocket_exclude_defer_js', 'CPCFF_MAIN::rocket_exclude_js' );
1011
- add_filter( 'rocket_delay_js_exclusions', 'CPCFF_MAIN::rocket_exclude_js' );
1012
-
1013
- // Some "WP Rocket" functions can be use with "WP-Optimize"
1014
- add_filter( 'wp-optimize-minify-blacklist', 'CPCFF_MAIN::rocket_exclude_js' );
1015
- add_filter( 'wp-optimize-minify-default-exclusions', 'CPCFF_MAIN::rocket_exclude_js' );
1016
- }
1017
- add_filter( 'rocket_excluded_inline_js_content', 'CPCFF_MAIN::rocket_exclude_inline_js' );
1018
- add_filter( 'rocket_defer_inline_exclusions', 'CPCFF_MAIN::rocket_exclude_inline_js' );
1019
- add_filter( 'rocket_delay_js_exclusions', 'CPCFF_MAIN::rocket_exclude_inline_js' );
1020
-
1021
- // For Breeze conflicts
1022
- if ( defined( 'BREEZE_VERSION' ) ) {
1023
- add_filter( 'breeze_filter_html_before_minify', 'CPCFF_MAIN::breeze_check_content', 10 );
1024
- add_filter( 'breeze_html_after_minify', 'CPCFF_MAIN::breeze_return_content', 10 );
1025
- }
1026
- }
1027
- } // End troubleshoots
1028
-
1029
- public static function litespeed_control_set_nocache(&$post)
1030
- {
1031
- try
1032
- {
1033
- if(
1034
- is_object($post) &&
1035
- isset($post->post_content) &&
1036
- stripos($post->post_content, '[CP_CALCULATED_FIELDS') !== false
1037
- ) do_action( 'litespeed_control_set_nocache', 'nocache CFF Form' );
1038
- }
1039
- catch(Exception $err){error_log($err->getMessage());}
1040
- return $post;
1041
- } // End litespeed_control_set_nocache
1042
-
1043
- public static function speed_booster_pack_troubleshoot($option)
1044
- {
1045
- if(is_array($option) && isset($option['jquery_to_footer'])) unset($option['jquery_to_footer']);
1046
- return $option;
1047
- } // End speed_booster_pack_troubleshoot
1048
-
1049
- public static function rocket_exclude_js($excluded_js)
1050
- {
1051
- $excluded_js[] = '/jquery.js';
1052
- $excluded_js[] = '/jquery.min.js';
1053
- $excluded_js[] = '/jquery/';
1054
- $excluded_js[] = '/calculated-fields-form/';
1055
-
1056
- $excluded_js[] = '/jquery/(.*)';
1057
- $excluded_js[] = '(.*)/jquery.js';
1058
- $excluded_js[] = '(.*)/jquery.min.js';
1059
- $excluded_js[] = '(.*)/jquery/(.*)';
1060
- $excluded_js[] = '(.*)/calculated-fields-form/(.*)';
1061
- return $excluded_js;
1062
- } // End rocket_exclude_js
1063
-
1064
- public static function rocket_exclude_inline_js($excluded_js = [])
1065
- {
1066
- $excluded_js[] = 'form_structure_';
1067
- $excluded_js[] = 'doValidate_';
1068
- $excluded_js[] = 'cpcff_default';
1069
- $excluded_js[] = 'cp_calculatedfieldsf_fbuilder_config_';
1070
- $excluded_js[] = 'form_structure(.*)';
1071
- $excluded_js[] = 'doValidate(.*)';
1072
- $excluded_js[] = 'cp_calculatedfieldsf_fbuilder_config(.*)';
1073
- return $excluded_js;
1074
- } // End rocket_exclude_inline_js
1075
-
1076
- public static function breeze_check_content( $content ) {
1077
- if ( strpos( $content, 'form_structure_' ) !== false ) {
1078
- global $cff_breeze_content_bk;
1079
- $cff_breeze_content_bk = $content;
1080
- }
1081
- return $content;
1082
- } // End breeze_check_content
1083
-
1084
- public static function breeze_return_content( $content ) {
1085
- global $cff_breeze_content_bk;
1086
- if( ! empty( $cff_breeze_content_bk ) ) {
1087
- $content = $cff_breeze_content_bk;
1088
- unset( $cff_breeze_content_bk );
1089
- }
1090
- return $content;
1091
- } // End breeze_return_content
1092
- } // End CPCFF_MAIN
1093
- }
1
+ <?php
2
+ /**
3
+ * Main class with main actions and filters: CPCFF_MAIN class
4
+ *
5
+ * @package CFF.
6
+ * @since 1.0.170
7
+ */
8
+
9
+ if ( ! class_exists( 'CPCFF_MAIN' ) ) {
10
+ /**
11
+ * Class that defines the main actions and filters, and plugin's functionalities.
12
+ *
13
+ * @since 1.0.170
14
+ */
15
+ class CPCFF_MAIN {
16
+
17
+ /**
18
+ * Counter of forms in a same page
19
+ * Metaclass property.
20
+ *
21
+ * @since 1.0.170
22
+ * @var int $form_counter
23
+ */
24
+ public static $form_counter = 0;
25
+
26
+ /**
27
+ * Instance of the CPCFF_MAIN class
28
+ * Metaclass property to implement a singleton.
29
+ *
30
+ * @since 1.0.179
31
+ * @var object $_instance
32
+ */
33
+ private static $_instance;
34
+
35
+ /**
36
+ * Identifies if the class was instanciated from the public website or WordPress
37
+ * Instance property.
38
+ *
39
+ * @sinze 1.0.170
40
+ * @var bool $_is_admin
41
+ */
42
+ private $_is_admin = false;
43
+
44
+ /**
45
+ * Plugin URL
46
+ * Instance property.
47
+ *
48
+ * @sinze 1.0.170
49
+ * @var string $_plugin_url
50
+ */
51
+ private $_plugin_url;
52
+
53
+ /**
54
+ * Flag to know if the public resources were included
55
+ * Instance property.
56
+ *
57
+ * @sinze 1.0.170
58
+ * @var bool $_are_resources_loaded default false
59
+ */
60
+ private $_are_resources_loaded = false;
61
+
62
+ /**
63
+ * Forms list.
64
+ * List of instances of the CPCFF_FORM class.
65
+ * Instance property.
66
+ *
67
+ * @sinze 1.0.179
68
+ * @var object $_active_form
69
+ */
70
+ private $_forms = array();
71
+
72
+ /**
73
+ * Instance of the CPCFF_AMP class to manage the forms in AMP pages
74
+ * Instance property.
75
+ *
76
+ * @sinze 1.0.230
77
+ * @var object $_amp
78
+ */
79
+ private $_amp;
80
+
81
+ /**
82
+ * Constructs a CPCFF_MAIN object, and define the hooks to the filters and actions.
83
+ * The constructor is private because this class is a singleton
84
+ */
85
+ private function __construct() {
86
+ require_once CP_CALCULATEDFIELDSF_BASE_PATH . '/inc/cpcff_form.inc.php';
87
+ require_once CP_CALCULATEDFIELDSF_BASE_PATH . '/inc/cpcff_amp.inc.php';
88
+
89
+ // Initializes the $_is_admin property
90
+ $this->_is_admin = is_admin();
91
+
92
+ // Initializes the $_plugin_url property
93
+ $this->_plugin_url = plugin_dir_url( CP_CALCULATEDFIELDSF_MAIN_FILE_PATH );
94
+
95
+ // Plugin activation/deactivation
96
+ $this->_activate_deactivate();
97
+
98
+ // Load the language file
99
+ add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) );
100
+
101
+ // Instanciate the AMP object
102
+ $this->_amp = new CPCFF_AMP( $this );
103
+
104
+ // Run the initialization code
105
+ add_action( 'init', array( $this, 'init' ), 1 );
106
+
107
+ // Run the initialization code of widgets
108
+ add_action( 'widgets_init', array( $this, 'widgets_init' ), 1 );
109
+
110
+ // Integration with Page Builders
111
+ require_once CP_CALCULATEDFIELDSF_BASE_PATH . '/inc/cpcff_page_builders.inc.php';
112
+ CPCFF_PAGE_BUILDERS::run();
113
+
114
+ } // End __construct
115
+
116
+ /**
117
+ * Returns the instance of the singleton.
118
+ *
119
+ * @since 1.0.179
120
+ * @return object self::$_instance
121
+ */
122
+ public static function instance() {
123
+ if ( ! isset( self::$_instance ) ) {
124
+ self::$_instance = new self();
125
+ }
126
+ return self::$_instance;
127
+ } // End instance
128
+
129
+ /**
130
+ * Loads the primary resources, previous to the plugin's initialization
131
+ *
132
+ * Loads resources like the laguages files, etc.
133
+ *
134
+ * @return void.
135
+ */
136
+ public function plugins_loaded() {
137
+ // Fix different troubleshoots
138
+ $this->troubleshoots();
139
+
140
+ // Load the language file
141
+ $this->_textdomain();
142
+
143
+ // Load controls scripts
144
+ $this->_load_controls_scrips();
145
+ } // End plugins_loaded
146
+
147
+ /**
148
+ * Initializes the plugin, runs as soon as possible.
149
+ *
150
+ * Initilize the plugin's sections, intercepts the submissions, generates the resources etc.
151
+ *
152
+ * @return void.
153
+ */
154
+ public function init() {
155
+ CPCFF_AUXILIARY::clean_transients_hook(); // Set the hook for clearing the expired transients
156
+
157
+ if ( $this->_is_admin ) {
158
+ if (
159
+ false === ( $CP_CALCULATEDFIELDSF_VERSION = get_option( 'CP_CALCULATEDFIELDSF_VERSION' ) ) || // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments
160
+ CP_CALCULATEDFIELDSF_VERSION != $CP_CALCULATEDFIELDSF_VERSION
161
+ ) {
162
+ if ( class_exists( 'CPCFF_INSTALLER' ) ) {
163
+ CPCFF_INSTALLER::install( is_multisite() );
164
+ }
165
+ update_option( 'CP_CALCULATEDFIELDSF_VERSION', CP_CALCULATEDFIELDSF_VERSION );
166
+ }
167
+
168
+ // Update metabox status if corresponds
169
+ $this->update_metabox_status();
170
+
171
+ // Adds the plugin links in the plugins sections
172
+ add_filter( 'plugin_action_links_' . CP_CALCULATEDFIELDSF_BASE_NAME, array( $this, 'links' ) );
173
+
174
+ // Creates the menu entries in the WordPress menu.
175
+ add_action( 'admin_menu', array( $this, 'admin_menu' ) );
176
+
177
+ // Displays the shortcode insertion buttons.
178
+ add_action( 'media_buttons', array( $this, 'media_buttons' ) );
179
+
180
+ // Loads the admin resources
181
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_resources' ), 1 );
182
+ }
183
+ $this->_define_shortcodes();
184
+ add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_loader' ) );
185
+ } // End init
186
+
187
+ /**
188
+ * Registers the widgets.
189
+ *
190
+ * Registers the widget to include the forms on sidebars, and for loading the data collected by the forms in the dashboard.
191
+ *
192
+ * @since 1.0.178
193
+ *
194
+ * @return void.
195
+ */
196
+ public function widgets_init() {
197
+ // Replace the shortcodes into the text widgets.
198
+ if ( ! $this->_is_admin ) {
199
+ add_filter( 'widget_text', 'do_shortcode' );
200
+ }
201
+ } // End widgets_init
202
+
203
+ /**
204
+ * Adds the plugin's links in the plugins section.
205
+ *
206
+ * Links for accessing to the help, settings, developers website, etc.
207
+ *
208
+ * @param array $links.
209
+ *
210
+ * @return array.
211
+ */
212
+ public function links( $links ) {
213
+ array_unshift(
214
+ $links,
215
+ '<a href="https://cff.dwbooster.com/customization" target="_blank">' . __( 'Request custom changes' ) . '</a>',
216
+ '<a href="admin.php?page=cp_calculated_fields_form">' . __( 'Settings' ) . '</a>',
217
+ '<a href="https://cff.dwbooster.com/download" target="_blank">' . __( 'Upgrade' ) . '</a>',
218
+ '<a href="https://wordpress.org/support/plugin/calculated-fields-form#new-post" target="_blank">' . __( 'Help' ) . '</a>'
219
+ );
220
+ return $links;
221
+ } // End links
222
+
223
+ /**
224
+ * Prints the buttons for inserting the different shortcodes into the pages/posts contents.
225
+ *
226
+ * Prints the HTML code that appears beside the media button with the icons and code to insert the shortcodes:
227
+ *
228
+ * - CP_CALCULATED_FIELDS
229
+ * - CP_CALCULATED_FIELDS_VAR
230
+ *
231
+ * @return void.
232
+ */
233
+ public function media_buttons() {
234
+ print '<a href="javascript:cp_calculatedfieldsf_insertForm();" title="' . esc_attr__( 'Insert Calculated Fields Form', 'calculated-fields-form' ) . '"><img src="' . esc_attr( $this->_plugin_url ) . 'images/cp_form.gif" alt="' . esc_attr__( 'Insert Calculated Fields Form', 'calculated-fields-form' ) . '" /></a><a href="javascript:cp_calculatedfieldsf_insertVar();" title="' . esc_attr__( 'Create a JavaScript var from POST, GET, SESSION, or COOKIE var', 'calculated-fields-form' ) . '"><img src="' . esc_attr( $this->_plugin_url ) . 'images/cp_var.gif" alt="' . esc_attr__( 'Create a JavaScript var from POST, GET, SESSION, or COOKIE var', 'calculated-fields-form' ) . '" /></a>';
235
+ } // End media_buttons
236
+
237
+ /**
238
+ * Generates the entries in the WordPress menu.
239
+ *
240
+ * @return void.
241
+ */
242
+ public function admin_menu() {
243
+ // Settings page
244
+ add_options_page( 'Calculated Fields Form Options', 'Calculated Fields Form', 'manage_options', 'cp_calculated_fields_form', array( $this, 'admin_pages' ) );
245
+
246
+ // Menu option
247
+ add_menu_page( 'Calculated Fields Form Options', 'Calculated Fields Form', 'manage_options', 'cp_calculated_fields_form', array( $this, 'admin_pages' ) );
248
+
249
+ // Submenu options
250
+ add_submenu_page( 'cp_calculated_fields_form', 'Upgrade', 'Upgrade', 'manage_options', 'cp_calculated_fields_form_sub3', array( $this, 'admin_pages' ) );
251
+
252
+ add_submenu_page( 'cp_calculated_fields_form', 'Marketplace', 'Marketplace', 'manage_options', 'cp_calculated_fields_form_sub5', array( $this, 'admin_pages' ) );
253
+
254
+ add_submenu_page( 'cp_calculated_fields_form', 'Documentation', 'Documentation', 'manage_options', 'cp_calculated_fields_form_sub2', array( $this, 'admin_pages' ) );
255
+
256
+ add_submenu_page( 'cp_calculated_fields_form', 'Online Help', 'Online Help', 'manage_options', 'cp_calculated_fields_form_sub4', array( $this, 'admin_pages' ) );
257
+ } // End admin_menu
258
+
259
+ /**
260
+ * Loads the corresponding pages in the WordPress or redirects the user to the external URLs.
261
+ *
262
+ * Loads the webpage with the list of forms, addons activation, general settings, etc.
263
+ * or redirects to external webpages like plugin's documentation
264
+ *
265
+ * @since 1.0.181
266
+ */
267
+ public function admin_pages() {
268
+ // Settings page of the plugin
269
+ if ( isset( $_GET['cal'] ) && '' != $_GET['cal'] ) {
270
+ @include_once CP_CALCULATEDFIELDSF_BASE_PATH . '/inc/cpcff_admin_int.inc.php';
271
+ } else {
272
+ // Redirecting outer website
273
+ if ( isset( $_GET['page'] ) && 'cp_calculated_fields_form_sub3' == $_GET['page'] ) {
274
+ if ( @wp_redirect( 'https://cff.dwbooster.com/download' ) ) {
275
+ exit;
276
+ }
277
+ } elseif ( isset( $_GET['page'] ) && 'cp_calculated_fields_form_sub2' == $_GET['page'] ) {
278
+ if ( @wp_redirect( 'https://cff.dwbooster.com/documentation' ) ) {
279
+ exit;
280
+ }
281
+ } elseif ( isset( $_GET['page'] ) && 'cp_calculated_fields_form_sub4' == $_GET['page'] ) {
282
+ if ( @wp_redirect( 'https://wordpress.org/support/plugin/calculated-fields-form#new-post' ) ) {
283
+ exit;
284
+ }
285
+ } else {
286
+ @include_once CP_CALCULATEDFIELDSF_BASE_PATH . '/inc/cpcff_admin_int_list.inc.php';
287
+ }
288
+ }
289
+ } // End admin_pages
290
+
291
+ /**
292
+ * Loads the javascript and style files.
293
+ *
294
+ * Checks if there is the settings page of the plugin for loading the corresponding JS and CSS files,
295
+ * or if it is a post or page the script for inserting the shortcodes in the content's editor.
296
+ *
297
+ * @since 1.0.171
298
+ *
299
+ * @param string $hook.
300
+ * @return void.
301
+ */
302
+ public function admin_resources( $hook ) {
303
+ // Checks if it is the plugin's page
304
+ if ( isset( $_GET['page'] ) ) {
305
+ if ( 'cp_calculated_fields_form' == $_GET['page'] ) {
306
+ wp_deregister_script( 'tribe-events-bootstrap-datepicker' );
307
+ wp_register_script( 'tribe-events-bootstrap-datepicker', plugins_url( '/js/nope.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ), array(), CP_CALCULATEDFIELDSF_VERSION );
308
+
309
+ wp_enqueue_script( 'jquery' );
310
+ wp_enqueue_script( 'jquery-ui-core' );
311
+ wp_enqueue_script( 'jquery-ui-sortable' );
312
+ wp_enqueue_script( 'jquery-ui-tabs' );
313
+ wp_enqueue_script( 'jquery-ui-droppable' );
314
+ wp_enqueue_script( 'jquery-ui-button' );
315
+ wp_enqueue_script( 'jquery-ui-datepicker' );
316
+ wp_deregister_script( 'query-stringify' );
317
+ wp_register_script( 'query-stringify', plugins_url( '/vendors/jQuery.stringify.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ), array(), CP_CALCULATEDFIELDSF_VERSION );
318
+ wp_enqueue_script( 'query-stringify' );
319
+
320
+ // ULR to the admin resources
321
+ $admin_resources = admin_url( 'admin.php?page=cp_calculated_fields_form&cp_cff_resources=admin' );
322
+ wp_enqueue_script( 'cp_calculatedfieldsf_builder_script', $admin_resources, array( 'jquery', 'jquery-ui-core', 'jquery-ui-sortable', 'jquery-ui-tabs', 'jquery-ui-droppable', 'jquery-ui-button', 'jquery-ui-accordion', 'jquery-ui-datepicker', 'query-stringify' ), CP_CALCULATEDFIELDSF_VERSION );
323
+
324
+ wp_enqueue_script( 'cp_calculatedfieldsf_builder_library_script', plugins_url( '/js/library.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ), array( 'cp_calculatedfieldsf_builder_script' ), CP_CALCULATEDFIELDSF_VERSION );
325
+
326
+ wp_localize_script(
327
+ 'cp_calculatedfieldsf_builder_library_script',
328
+ 'cpcff_forms_library_config',
329
+ array(
330
+ 'version' => 'free',
331
+ 'website_url' => 'admin.php?page=cp_calculated_fields_form&a=1&_cpcff_nonce=' . wp_create_nonce( 'cff-add-form' ),
332
+ )
333
+ );
334
+
335
+ wp_enqueue_script( 'cp_calculatedfieldsf_builder_script_caret', plugins_url( '/vendors/jquery.caret.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ), array( 'jquery' ), CP_CALCULATEDFIELDSF_VERSION );
336
+ wp_enqueue_style( 'cp_calculatedfieldsf_builder_style', plugins_url( '/css/style.css', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ), array(), CP_CALCULATEDFIELDSF_VERSION );
337
+ wp_enqueue_style( 'cp_calculatedfieldsf_builder_library_style', plugins_url( '/css/stylelibrary.css', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ), array( 'cp_calculatedfieldsf_builder_style' ), CP_CALCULATEDFIELDSF_VERSION );
338
+ wp_enqueue_style( 'jquery-style', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css', array(), CP_CALCULATEDFIELDSF_VERSION );
339
+ } elseif (
340
+ in_array(
341
+ $_GET['page'],
342
+ array(
343
+ 'cp_calculated_fields_form_sub2',
344
+ 'cp_calculated_fields_form_sub3',
345
+ 'cp_calculated_fields_form_sub4',
346
+ 'cp_calculated_fields_form_sub5',
347
+ )
348
+ )
349
+ ) {
350
+ $cpcff_redirect = array();
351
+ switch ( $_GET['page'] ) {
352
+ case 'cp_calculated_fields_form_sub2':
353
+ $cpcff_redirect['url'] = 'https://cff.dwbooster.com/documentation';
354
+ break;
355
+ case 'cp_calculated_fields_form_sub3':
356
+ $cpcff_redirect['url'] = 'https://cff.dwbooster.com/download';
357
+ break;
358
+ case 'cp_calculated_fields_form_sub4':
359
+ $cpcff_redirect['url'] = 'https://wordpress.org/support/plugin/calculated-fields-form#new-post';
360
+ break;
361
+ case 'cp_calculated_fields_form_sub5':
362
+ $cpcff_redirect['url'] = 'https://cff-bundles.dwbooster.com';
363
+ break;
364
+ }
365
+ wp_enqueue_script( 'cp_calculatedfieldsf_redirect_script', plugins_url( '/js/redirect_script.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ), array(), CP_CALCULATEDFIELDSF_VERSION );
366
+ wp_localize_script(
367
+ 'cp_calculatedfieldsf_redirect_script',
368
+ 'cpcff_redirect',
369
+ $cpcff_redirect
370
+ );
371
+ }
372
+ }
373
+
374
+ // Checks if it is a page or post
375
+ if ( 'post.php' == $hook || 'post-new.php' == $hook ) {
376
+ wp_enqueue_script( 'cp_calculatedfieldsf_script', plugins_url( '/js/cp_calculatedfieldsf_scripts.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ), array(), CP_CALCULATEDFIELDSF_VERSION );
377
+ }
378
+ } // End admin_resources
379
+
380
+ public function metabox_status( $metabox_id ) {
381
+ $statuses = get_option( 'cff-metaboxes-statuses', array() );
382
+ return ( ! empty( $statuses ) && is_array( $statuses ) && isset( $statuses[ $metabox_id ] ) && 0 == $statuses[ $metabox_id ] ) ? 'cff-metabox-closed' : 'cff-metabox-opened';
383
+ } // End metabox_status
384
+
385
+ private function update_metabox_status() {
386
+ if (
387
+ ! empty( $_POST['cff-metabox-nonce'] ) &&
388
+ wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['cff-metabox-nonce'] ) ), 'cff-metabox-status' ) &&
389
+ isset( $_POST['cff-metabox-id'] ) &&
390
+ isset( $_POST['cff-metabox-action'] )
391
+ ) {
392
+ $metabox_id = sanitize_text_field( wp_unslash( $_POST['cff-metabox-id'] ) );
393
+ $metabox_action = sanitize_text_field( wp_unslash( $_POST['cff-metabox-action'] ) );
394
+
395
+ if ( ! empty( $metabox_id ) ) {
396
+ $statuses = get_option( 'cff-metaboxes-statuses', array() );
397
+ if ( empty( $statuses ) || ! is_array( $statuses ) ) {
398
+ $statuses = array();
399
+ }
400
+ $statuses[ $metabox_id ] = $metabox_action == 'open' ? 1 : 0; // phpcs:ignore WordPress.PHP.YodaConditions
401
+ update_option( 'cff-metaboxes-statuses', $statuses );
402
+ }
403
+ }
404
+ } // End update_metabox_status
405
+
406
+ public function form_preview( $atts ) {
407
+ if ( isset( $atts['shortcode_atts'] ) ) {
408
+ error_reporting( E_ERROR | E_PARSE );
409
+ global $wp_styles, $wp_scripts;
410
+ if ( ! empty( $wp_scripts ) ) {
411
+ $wp_scripts->reset();
412
+ }
413
+ $message = $this->public_form( $atts['shortcode_atts'] );
414
+ ob_start();
415
+ if ( ! empty( $wp_styles ) ) {
416
+ $wp_styles->do_items();
417
+ }
418
+ if ( ! empty( $wp_scripts ) ) {
419
+ $wp_scripts->do_items();
420
+ }
421
+ if ( class_exists( 'Error' ) ) {
422
+ try {
423
+ wp_footer(); } catch ( Error $err ) {
424
+ error_log( $err->getMessage() );
425
+ }
426
+ }
427
+ $message .= ob_get_contents();
428
+ ob_end_clean();
429
+ $page_title = ( ! empty( $atts['page_title'] ) ) ? $atts['page_title'] : '';
430
+ remove_all_actions( 'shutdown' );
431
+ if ( ! empty( $atts['wp_die'] ) ) {
432
+ wp_die( $message . '<style>body{margin:2em !important;max-width:100% !important;box-shadow:none !important;background:white !important}html{background:white !important;}.wp-die-message>*:not(form){visibility: hidden;} .pac-container, .ui-tooltip, .ui-tooltip *,.ui-datepicker,.ui-datepicker *{visibility: visible;}</style>' . apply_filters( 'cpcff_form_preview_resources', '' ), esc_html( $page_title ), 200 ); // phpcs:ignore WordPress.Security.EscapeOutput
433
+ } elseif ( ! empty( $atts['page'] ) ) {
434
+ print '<!DOCTYPE html><html><head profile="http://gmpg.org/xfn/11"><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1"></head><body>';
435
+ print $message; // phpcs:ignore WordPress.Security.EscapeOutput
436
+ print '<style>body>*:not(form){visibility: hidden;} .pac-container, .ui-tooltip, .ui-tooltip *,.ui-datepicker,.ui-datepicker *{visibility: visible;}</style>' . apply_filters( 'cpcff_form_preview_resources', '' ) . '</body></html>'; // phpcs:ignore WordPress.Security.EscapeOutput
437
+ exit;
438
+ } else {
439
+ print $message; // phpcs:ignore WordPress.Security.EscapeOutput
440
+ exit;
441
+ }
442
+ }
443
+ } // End form_preview
444
+
445
+ public function enqueue_loader() {
446
+ global $post;
447
+
448
+ if ( ! empty( $post ) && has_shortcode( $post->post_content, 'CP_CALCULATED_FIELDS' ) ) {
449
+ wp_enqueue_style( 'cpcff_loader', plugins_url( '/css/loader.css', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ), array(), CP_CALCULATEDFIELDSF_VERSION );
450
+ }
451
+ } // End enqueue_loader
452
+
453
+ /**
454
+ * Returns the public version of the form wih its resources.
455
+ *
456
+ * The method calls the filters: cpcff_pre_form, and cpcff_the_form
457
+ *
458
+ * @since 1.0.171
459
+ * @param array $atts includes the attributes required to identify the form, and create the variables.
460
+ * @return string $content a text with the public version of the form and resources.
461
+ */
462
+ public function public_form( $atts ) {
463
+ // If the website is being visited by crawler, display empty text.
464
+ if ( CPCFF_AUXILIARY::is_crawler() ) {
465
+ return '';
466
+ }
467
+ if ( empty( $atts ) ) {
468
+ $atts = array();
469
+ }
470
+ if ( ! $this->_is_admin && $this->_amp->is_amp() ) {
471
+ $content = $this->_amp->get_iframe( $atts );
472
+ } else {
473
+ global $wpdb, $cpcff_default_texts_array;
474
+
475
+ if ( empty( $atts['id'] ) ) {
476
+ $myrow = $wpdb->get_row( 'SELECT * FROM ' . $wpdb->prefix . CP_CALCULATEDFIELDSF_FORMS_TABLE ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
477
+ } else {
478
+ $myrow = $wpdb->get_row( $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . CP_CALCULATEDFIELDSF_FORMS_TABLE . ' WHERE id=%d', $atts['id'] ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
479
+ }
480
+
481
+ if ( empty( $myrow ) ) {
482
+ return ''; // The form does not exists, or there are no forms.
483
+ }
484
+ $atts['id'] = $myrow->id; // If was not passed the form's id, uses the if of first form.
485
+ $id = $atts['id']; // Alias for the $atts[ 'id' ] variable.
486
+
487
+ // Initializing the $form_counter
488
+ if ( ! isset( $GLOBALS['codepeople_form_sequence_number'] ) ) {
489
+ $GLOBALS['codepeople_form_sequence_number'] = 0;
490
+ }
491
+ $GLOBALS['codepeople_form_sequence_number']++;
492
+ self::$form_counter = $GLOBALS['codepeople_form_sequence_number']; // Current form
493
+
494
+ /**
495
+ * Filters applied before generate the form,
496
+ * is passed as parameter an array with the forms attributes, and return the list of attributes
497
+ */
498
+ $atts = apply_filters( 'cpcff_pre_form', $atts );
499
+
500
+ ob_start();
501
+
502
+ // Constant defined to protect the "inc/cpcff_public_int.inc.php" file against direct accesses.
503
+ if ( ! defined( 'CP_AUTH_INCLUDE' ) ) {
504
+ define( 'CP_AUTH_INCLUDE', true );
505
+ }
506
+
507
+ $this->_public_resources( $id ); // Load form scripts and other resources
508
+
509
+ /* TO-DO: This method should be analyzed after moving other functions to the main class . */
510
+ @include CP_CALCULATEDFIELDSF_BASE_PATH . '/inc/cpcff_public_int.inc.php';
511
+
512
+ $content = ob_get_contents();
513
+
514
+ // The attributes excepting "id" are converted in javascript variables with a global scope
515
+ if ( count( $atts ) > 1 ) {
516
+ $content .= '<script>';
517
+ foreach ( $atts as $i => $v ) {
518
+ if ( 'id' != $i && 'class' != $i && ! is_numeric( $i ) ) {
519
+ $nV = ( is_numeric( $v ) ) ? $v : json_encode( $v ); // Sanitizing the attribute's value
520
+ $content .= $i . '=' . $nV . ';';
521
+ $content .= 'if(typeof ' . $i . '_arr == "undefined") ' . $i . '_arr={}; ' . $i . '_arr["_' . self::$form_counter . '"]=' . $nV . ';';
522
+ }
523
+ }
524
+ $content .= '</script>';
525
+ }
526
+ ob_end_clean();
527
+
528
+ /**
529
+ * Filters applied after generate the form,
530
+ * is passed as parameter the HTML code of the form with the corresponding <LINK> and <SCRIPT> tags,
531
+ * and returns the HTML code to includes in the webpage
532
+ */
533
+ $content = apply_filters( 'cpcff_the_form', $content, $atts['id'] );
534
+ }
535
+
536
+ return $content;
537
+ } // End public_form
538
+
539
+ /**
540
+ * Creates a javascript variable, from: Post, Get, Session or Cookie or directly.
541
+ *
542
+ * If the webpage is visited from a crawler or search engine spider, the shortcode is replaced by an empty text.
543
+ *
544
+ * @since 1.0.175
545
+ * @param array $atts includes the records:
546
+ * - name, the variable's name.
547
+ * - value, to create a variable splicitly with the value passed as attribute.
548
+ * - from, identifies the variable source (POST, GET, SESSION or COOKIE), it is optional.
549
+ * - default_value, used in combination with the from attribute to populate the variable
550
+ * with the default value of the source does not exist.
551
+ *
552
+ * @return string <script> tag with the variable's definition.
553
+ */
554
+ public function create_variable_shortcode( $atts ) {
555
+ if (
556
+ ! CPCFF_AUXILIARY::is_crawler() && // Checks for crawlers or search engine spiders
557
+ ! empty( $atts['name'] ) &&
558
+ ( $var = trim( $atts['name'] ) ) != '' // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments
559
+ ) {
560
+ if ( isset( $atts['value'] ) ) {
561
+ $value = json_encode( $atts['value'] );
562
+ } else {
563
+ $from = '_';
564
+ if ( isset( $atts['from'] ) ) {
565
+ $from .= strtoupper( trim( $atts['from'] ) );
566
+ }
567
+ if ( in_array( $from, array( '_POST', '_GET', '_SESSION', '_COOKIE' ) ) ) {
568
+ if ( isset( $GLOBALS[ $from ][ $var ] ) ) {
569
+ $value = json_encode( $GLOBALS[ $from ][ $var ] );
570
+ } elseif ( isset( $atts['default_value'] ) ) {
571
+ $value = json_encode( $atts['default_value'] );
572
+ }
573
+ } else {
574
+ if ( isset( $_POST[ $var ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
575
+ $value = json_encode( $_POST[ $var ] ); // @codingStandardsIgnoreLine.
576
+ } elseif ( isset( $_GET[ $var ] ) ) {
577
+ $value = json_encode( $_GET[ $var ] ); // @codingStandardsIgnoreLine.
578
+ } elseif ( isset( $_SESSION[ $var ] ) ) {
579
+ $value = json_encode( $_SESSION[ $var ] );
580
+ } elseif ( isset( $_COOKIE[ $var ] ) ) {
581
+ $value = json_encode( sanitize_text_field( wp_unslash( $_COOKIE[ $var ] ) ) );
582
+ } elseif ( isset( $atts['default_value'] ) ) {
583
+ $value = json_encode( $atts['default_value'] );
584
+ }
585
+ }
586
+ }
587
+ if ( isset( $value ) ) {
588
+ return '
589
+ <script>
590
+ try{
591
+ window["' . esc_js( $var ) . '"]=' . $value . ';
592
+ }catch( err ){}
593
+ </script>
594
+ ';
595
+ }
596
+ }
597
+ return '';
598
+ } // End create_variable_shortcode
599
+
600
+ /**
601
+ * Return the list of categories associted with the forms
602
+ */
603
+ public function get_categories( $html = '', &$current = null ) {
604
+ global $wpdb;
605
+ $categories = $wpdb->get_results( 'SELECT DISTINCT category FROM ' . $wpdb->prefix . CP_CALCULATEDFIELDSF_FORMS_TABLE . ' WHERE category IS NOT NULL AND category <> ""', ARRAY_A ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
606
+
607
+ if ( empty( $html ) ) {
608
+ return $categories;
609
+ }
610
+
611
+ $output = '';
612
+ $flag = false;
613
+
614
+ if ( ! empty( $categories ) ) {
615
+ foreach ( $categories as $category ) {
616
+ $selected = '';
617
+
618
+ if ( $current === $category['category'] ) {
619
+ $selected = 'SELECTED';
620
+ $flag = true;
621
+ }
622
+
623
+ if ( 'SELECT' == $html ) {
624
+ $output .= '<option value="' . esc_attr( $category['category'] ) . '" ' . $selected . ' >' . esc_html( $category['category'] ) . '</option>';
625
+ } else // DATALIST
626
+ {
627
+ $output .= '<option value="' . esc_attr( $category['category'] ) . '">';
628
+ }
629
+ }
630
+ }
631
+
632
+ if ( ! $flag ) {
633
+ $current = '';
634
+ }
635
+
636
+ return $output;
637
+ } // End get_categories
638
+
639
+ /**
640
+ * Returns an instance of the active form
641
+ *
642
+ * If there is not an active form generates the instance.
643
+ *
644
+ * @since 1.0.179
645
+ * @return object
646
+ */
647
+ public function get_form( $id ) {
648
+ if ( ! isset( $this->_forms[ $id ] ) ) {
649
+ $this->_forms[ $id ] = new CPCFF_FORM( $id );
650
+ }
651
+ return $this->_forms[ $id ];
652
+ } // End get_active_form
653
+
654
+ /**
655
+ * Creates a new form calling the static method CPCFF_FORM::create_default
656
+ *
657
+ * @since 1.0.179
658
+ *
659
+ * @param string $form_name, the name of form.
660
+ * @return mixed, an instance of the created form or false.
661
+ */
662
+ public function create_form( $form_name, $category_name = '', $form_template = 0 ) {
663
+ $form = CPCFF_FORM::create_default( $form_name, $category_name, $form_template );
664
+ if ( $form ) {
665
+ $this->_forms[ $form->get_id() ] = $form;
666
+ }
667
+ return $form;
668
+ } // End create_form
669
+
670
+ /**
671
+ * Deletes the form.
672
+ * The methods throw the cpcff_delete_form hook after delete the form.
673
+ *
674
+ * @since 1.0.179
675
+ * @param integer $id, the form's id.
676
+ * @return mixed, the number of delete rows or false.
677
+ */
678
+ public function delete_form( $id ) {
679
+ $deleted = $this->get_form( $id )->delete_form();
680
+ if ( $deleted ) {
681
+ do_action( 'cpcff_delete_form', $id );
682
+ unset( $this->_forms[ $id ] );
683
+ }
684
+ return $deleted;
685
+ } // End delete_form
686
+
687
+ /**
688
+ * Clones a form.
689
+ *
690
+ * @since 1.0.179
691
+ * @param integer $id, the form's id.
692
+ * @return mixed, an instance of cloned form or false.
693
+ */
694
+ public function clone_form( $id ) {
695
+ if ( ! isset( $this->_forms[ $id ] ) ) {
696
+ $this->_forms[ $id ] = new CPCFF_FORM( $id );
697
+ }
698
+ $cloned_form = $this->_forms[ $id ]->clone_form();
699
+ if ( $cloned_form ) {
700
+ /**
701
+ * Passes as parameter the original form's id, and the new form's id
702
+ */
703
+ do_action( 'cpcff_clone_form', $id, $cloned_form->get_id() );
704
+ }
705
+ return $cloned_form;
706
+ } // End clone_form
707
+
708
+ /*********************************** PRIVATE METHODS ********************************************/
709
+
710
+ /**
711
+ * Defines the activativation/deactivation hooks, and new blog hook.
712
+ *
713
+ * Requires the cpcff_install_uninstall.inc.php file with the activate/deactivate code, and the code to run with new blogs.
714
+ *
715
+ * @sinze 1.0.171
716
+ * @return void.
717
+ */
718
+ private function _activate_deactivate() {
719
+ require_once CP_CALCULATEDFIELDSF_BASE_PATH . '/inc/cpcff_install_uninstall.inc.php';
720
+ register_activation_hook( CP_CALCULATEDFIELDSF_MAIN_FILE_PATH, array( 'CPCFF_INSTALLER', 'install' ) );
721
+ register_deactivation_hook( CP_CALCULATEDFIELDSF_MAIN_FILE_PATH, array( 'CPCFF_INSTALLER', 'uninstall' ) );
722
+ add_action( 'wpmu_new_blog', array( 'CPCFF_INSTALLER', 'new_blog' ), 10, 6 );
723
+ } // End _activate_deactivate
724
+
725
+ /**
726
+ * Loads the language file.
727
+ *
728
+ * Loads the language file associated to the plugin, and creates the textdomain.
729
+ *
730
+ * @return void.
731
+ */
732
+ private function _textdomain() {
733
+ load_plugin_textdomain( 'calculated-fields-form', false, dirname( CP_CALCULATEDFIELDSF_BASE_NAME ) . '/languages/' );
734
+ } // End _textdomain
735
+
736
+ /**
737
+ * Loads the controls scripts.
738
+ *
739
+ * Checks if there is defined the "cp_cff_resources" parameter, and loads the public or admin scripsts for the controls.
740
+ * If the scripsts are loaded the plugin exits the PHP execution.
741
+ *
742
+ * @return void.
743
+ */
744
+ private function _load_controls_scrips() {
745
+ if ( isset( $_REQUEST['cp_cff_resources'] ) ) {
746
+ if ( ! defined( 'WP_DEBUG' ) || true != WP_DEBUG ) {
747
+ error_reporting( E_ERROR | E_PARSE );
748
+ }
749
+ // Set the corresponding header
750
+ if ( ! headers_sent() ) {
751
+ header( 'Content-type: application/javascript' );
752
+ }
753
+
754
+ if ( ! $this->_is_admin || 'public' == $_REQUEST['cp_cff_resources'] ) {
755
+ require_once CP_CALCULATEDFIELDSF_BASE_PATH . '/js/fbuilder-loader-public.php';
756
+ } else {
757
+ require_once CP_CALCULATEDFIELDSF_BASE_PATH . '/js/fbuilder-loader-admin.php';
758
+ }
759
+ remove_all_actions( 'shutdown' );
760
+ exit;
761
+ }
762
+ } // End _load_controls_scrips
763
+
764
+ /**
765
+ * Defines the shortcodes used by the plugin's code:
766
+ *
767
+ * - CP_CALCULATED_FIELDS
768
+ * - CP_CALCULATED_FIELDS_VAR
769
+ *
770
+ * @return void.
771
+ */
772
+ private function _define_shortcodes() {
773
+ add_shortcode( 'CP_CALCULATED_FIELDS', array( $this, 'public_form' ) );
774
+ add_shortcode( 'CP_CALCULATED_FIELDS_VAR', array( $this, 'create_variable_shortcode' ) );
775
+ } // End _define_shortcodes
776
+ /**
777
+ * Returns a JSON object with the configuration object.
778
+ *
779
+ * Uses the global variable $cpcff_default_texts_array, defined in the "config/cpcff_config.cfg.php"
780
+ *
781
+ * @sinze 1.0.171
782
+ * @param int $formid the form's id.
783
+ * @return string $json
784
+ */
785
+ private function _get_form_configuration( $formid ) {
786
+ global $cpcff_default_texts_array;
787
+ $form_obj = $this->get_form( $formid );
788
+ $previous_label = $form_obj->get_option( 'vs_text_previousbtn', 'Previous' );
789
+ $previous_label = ( '' == $previous_label ? 'Previous' : $previous_label );
790
+ $next_label = $form_obj->get_option( 'vs_text_nextbtn', 'Next' );
791
+ $next_label = ( '' == $next_label ? 'Next' : $next_label );
792
+
793
+ $cpcff_texts_array = $form_obj->get_option( 'vs_all_texts', $cpcff_default_texts_array );
794
+ $cpcff_texts_array = CPCFF_AUXILIARY::array_replace_recursive(
795
+ $cpcff_default_texts_array,
796
+ ( is_string( $cpcff_texts_array ) && is_array( unserialize( $cpcff_texts_array ) ) )
797
+ ? unserialize( $cpcff_texts_array )
798
+ : ( ( is_array( $cpcff_texts_array ) ) ? $cpcff_texts_array : array() )
799
+ );
800
+
801
+ $obj = array(
802
+ 'pub' => true,
803
+ 'identifier' => '_' . self::$form_counter,
804
+ 'messages' => array(
805
+ 'required' => $form_obj->get_option( 'vs_text_is_required', CP_CALCULATEDFIELDSF_DEFAULT_vs_text_is_required ),
806
+ 'email' => $form_obj->get_option( 'vs_text_is_email', CP_CALCULATEDFIELDSF_DEFAULT_vs_text_is_email ),
807
+ 'datemmddyyyy' => $form_obj->get_option( 'vs_text_datemmddyyyy', CP_CALCULATEDFIELDSF_DEFAULT_vs_text_datemmddyyyy ),
808
+ 'dateddmmyyyy' => $form_obj->get_option( 'vs_text_dateddmmyyyy', CP_CALCULATEDFIELDSF_DEFAULT_vs_text_dateddmmyyyy ),
809
+ 'number' => $form_obj->get_option( 'vs_text_number', CP_CALCULATEDFIELDSF_DEFAULT_vs_text_number ),
810
+ 'digits' => $form_obj->get_option( 'vs_text_digits', CP_CALCULATEDFIELDSF_DEFAULT_vs_text_digits ),
811
+ 'max' => $form_obj->get_option( 'vs_text_max', CP_CALCULATEDFIELDSF_DEFAULT_vs_text_max ),
812
+ 'min' => $form_obj->get_option( 'vs_text_min', CP_CALCULATEDFIELDSF_DEFAULT_vs_text_min ),
813
+ 'previous' => $previous_label,
814
+ 'next' => $next_label,
815
+ 'pageof' => $cpcff_texts_array['page_of_text']['text'],
816
+ 'audio_tutorial' => $cpcff_texts_array['audio_tutorial_text']['text'],
817
+ 'minlength' => $cpcff_texts_array['errors']['minlength']['text'],
818
+ 'maxlength' => $cpcff_texts_array['errors']['maxlength']['text'],
819
+ 'equalTo' => $cpcff_texts_array['errors']['equalTo']['text'],
820
+ 'accept' => $cpcff_texts_array['errors']['accept']['text'],
821
+ 'upload_size' => $cpcff_texts_array['errors']['upload_size']['text'],
822
+ 'phone' => $cpcff_texts_array['errors']['phone']['text'],
823
+ 'currency' => $cpcff_texts_array['errors']['currency']['text'],
824
+ ),
825
+ );
826
+ return json_encode( $obj );
827
+ } // End _get_form_configuration
828
+
829
+ /**
830
+ * Loads the javascript and style files used by the public forms.
831
+ *
832
+ * Checks if the plugin was configured for loading HTML tags directly, or to use the WordPress functions.
833
+ *
834
+ * @since 1.0.171
835
+ * @param int $formid the form's id.
836
+ * @return void.
837
+ */
838
+ private function _public_resources( $formid ) {
839
+ if (
840
+ get_option( 'CP_CALCULATEDFIELDSF_USE_CACHE', CP_CALCULATEDFIELDSF_USE_CACHE ) &&
841
+ file_exists( CP_CALCULATEDFIELDSF_BASE_PATH . '/js/cache/all.js' )
842
+ ) {
843
+ $public_js_path = plugins_url( '/js/cache/all.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH );
844
+ }
845
+
846
+ if ( empty( $public_js_path ) ) {
847
+ global $cff_backend_script_generator, $cff_script_generator_min;
848
+
849
+ $cff_backend_script_generator = 1;
850
+ $cff_script_generator_min = get_option( 'CP_CALCULATEDFIELDSF_USE_CACHE', CP_CALCULATEDFIELDSF_USE_CACHE );
851
+ include_once CP_CALCULATEDFIELDSF_BASE_PATH . '/js/fbuilder-loader-public.php';
852
+ }
853
+
854
+ if (
855
+ file_exists( CP_CALCULATEDFIELDSF_BASE_PATH . '/js/cache/all.js' )
856
+ ) {
857
+ $public_js_path = plugins_url( '/js/cache/all.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH );
858
+ } else {
859
+ $public_js_path = CPCFF_AUXILIARY::wp_current_url() . ( ( strpos( CPCFF_AUXILIARY::wp_current_url(), '?' ) === false ) ? '?' : '&' ) . 'cp_cff_resources=public&min=' . get_option( 'CP_CALCULATEDFIELDSF_USE_CACHE', CP_CALCULATEDFIELDSF_USE_CACHE );
860
+ }
861
+
862
+ $config_json = $this->_get_form_configuration( $formid );
863
+
864
+ if ( $GLOBALS['CP_CALCULATEDFIELDSF_DEFAULT_DEFER_SCRIPTS_LOADING'] ) {
865
+ wp_enqueue_script( 'jquery' );
866
+ wp_enqueue_script( 'jquery-ui-core' );
867
+ wp_enqueue_script( 'jquery-ui-button' );
868
+ wp_enqueue_script( 'jquery-ui-widget' );
869
+ wp_enqueue_script( 'jquery-ui-position' );
870
+ wp_enqueue_script( 'jquery-ui-tooltip' );
871
+ wp_enqueue_script( 'jquery-ui-datepicker' );
872
+ wp_enqueue_script( 'jquery-ui-slider' );
873
+
874
+ wp_deregister_script( 'query-stringify' );
875
+ wp_register_script( 'query-stringify', plugins_url( '/vendors/jQuery.stringify.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ), array( 'jquery' ), 'pro' );
876
+
877
+ wp_deregister_script( 'cp_calculatedfieldsf_validate_script' );
878
+ wp_register_script( 'cp_calculatedfieldsf_validate_script', plugins_url( '/vendors/jquery.validate.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ), array( 'jquery' ), 'pro' );
879
+ wp_enqueue_script( 'cp_calculatedfieldsf_builder_script', $public_js_path, array( 'jquery', 'jquery-ui-core', 'jquery-ui-button', 'jquery-ui-widget', 'jquery-ui-position', 'jquery-ui-tooltip', 'query-stringify', 'cp_calculatedfieldsf_validate_script', 'jquery-ui-datepicker', 'jquery-ui-slider' ), CP_CALCULATEDFIELDSF_VERSION, true );
880
+
881
+ wp_localize_script( 'cp_calculatedfieldsf_builder_script', 'cp_calculatedfieldsf_fbuilder_config_' . self::$form_counter, array( 'obj' => $config_json ) );
882
+ } else {
883
+ // This code won't be used in most cases. This code is for preventing problems in wrong WP themes and conflicts with third party plugins.
884
+ if ( ! $this->_are_resources_loaded ) {
885
+ global $wp_version;
886
+ $this->_are_resources_loaded = true; // Resources loaded
887
+
888
+ $includes_url = includes_url();
889
+
890
+ // Used for compatibility with old versions of WordPress
891
+ $prefix_ui = ( @file_exists( CP_CALCULATEDFIELDSF_BASE_PATH . '/../../../wp-includes/js/jquery/ui/jquery.ui.core.min.js' ) ) ? 'jquery.ui.' : '';
892
+
893
+ if ( ! wp_script_is( 'jquery', 'done' ) ) {
894
+ print '<script type="text/javascript" src="' . esc_attr( $includes_url ) . 'js/jquery/jquery.js"></script>'; // phpcs:ignore WordPress.WP.EnqueuedResources
895
+ }
896
+ if ( ! wp_script_is( 'jquery-ui-core', 'done' ) ) {
897
+ print '<script type="text/javascript" src="' . esc_attr( $includes_url ) . 'js/jquery/ui/' . esc_attr( $prefix_ui ) . 'core.min.js"></script>'; // phpcs:ignore WordPress.WP.EnqueuedResources
898
+ }
899
+ if ( ! wp_script_is( 'jquery-ui-datepicker', 'done' ) ) {
900
+ print '<script type="text/javascript" src="' . esc_attr( $includes_url ) . 'js/jquery/ui/' . esc_attr( $prefix_ui ) . 'datepicker.min.js"></script>'; // phpcs:ignore WordPress.WP.EnqueuedResources
901
+ }
902
+
903
+ if ( version_compare( $wp_version, '5.5.4', '<' ) ) {
904
+ if ( ! wp_script_is( 'jquery-ui-widget', 'done' ) ) {
905
+ print '<script type="text/javascript" src="' . esc_attr( $includes_url ) . 'js/jquery/ui/' . esc_attr( $prefix_ui ) . 'widget.min.js"></script>'; // phpcs:ignore WordPress.WP.EnqueuedResources
906
+ }
907
+ if ( ! wp_script_is( 'jquery-ui-position', 'done' ) ) {
908
+ print '<script type="text/javascript" src="' . esc_attr( $includes_url ) . 'js/jquery/ui/' . esc_attr( $prefix_ui ) . 'position.min.js"></script>'; // phpcs:ignore WordPress.WP.EnqueuedResources
909
+ }
910
+ }
911
+
912
+ if ( ! wp_script_is( 'jquery-ui-tooltip', 'done' ) ) {
913
+ print '<script type="text/javascript" src="' . esc_attr( $includes_url ) . 'js/jquery/ui/' . esc_attr( $prefix_ui ) . 'tooltip.min.js"></script>'; // phpcs:ignore WordPress.WP.EnqueuedResources
914
+ }
915
+ if ( ! wp_script_is( 'jquery-ui-mouse', 'done' ) ) {
916
+ print '<script type="text/javascript" src="' . esc_attr( $includes_url ) . 'js/jquery/ui/' . esc_attr( $prefix_ui ) . 'mouse.min.js"></script>'; // phpcs:ignore WordPress.WP.EnqueuedResources
917
+ }
918
+ if ( ! wp_script_is( 'jquery-ui-slider', 'done' ) ) {
919
+ print '<script type="text/javascript" src="' . esc_attr( $includes_url ) . 'js/jquery/ui/' . esc_attr( $prefix_ui ) . 'slider.min.js"></script>'; // phpcs:ignore WordPress.WP.EnqueuedResources
920
+ }
921
+ ?>
922
+ <script>if( typeof fbuilderjQuery == 'undefined') var fbuilderjQuery = jQuery.noConflict( );</script>
923
+ <script type='text/javascript' src='<?php echo esc_attr( plugins_url( 'vendors/jquery.validate.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ) ); // phpcs:ignore WordPress.WP.EnqueuedResources ?>'></script>
924
+ <script type='text/javascript' src='<?php echo esc_attr( plugins_url( 'vendors/jQuery.stringify.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ) ); // phpcs:ignore WordPress.WP.EnqueuedResources ?>'></script>
925
+ <script type='text/javascript' src='<?php echo esc_attr( $public_js_path . ( ( strpos( $public_js_path, '?' ) == false ) ? '?' : '&' ) . 'ver=' . CP_CALCULATEDFIELDSF_VERSION ); // phpcs:ignore WordPress.WP.EnqueuedResources ?>'></script>
926
+ <?php
927
+ }
928
+ ?>
929
+ <pre style="display:none !important;"><script type='text/javascript'>
930
+ /* <![CDATA[ */
931
+ <?php
932
+ print 'var cp_calculatedfieldsf_fbuilder_config_' . esc_js( self::$form_counter ) . '={"obj":' . $config_json . '};'; // phpcs:ignore WordPress.Security.EscapeOutput
933
+ ?>
934
+ /* ]]> */
935
+ </script></pre>
936
+ <?php
937
+ }
938
+ } // End _public_resources
939
+
940
+ /** TROUBLESHOOTS SECTION **/
941
+ public function compatibility_warnings() {
942
+ require_once CP_CALCULATEDFIELDSF_BASE_PATH . '/inc/cpcff_compatibility.inc.php';
943
+ return CPCFF_COMPATIBILITY::warnings();
944
+ } // End compatibility_warnings
945
+
946
+ private function troubleshoots() {
947
+ if ( ! $this->_is_admin ) {
948
+ if ( get_option( 'CP_CALCULATEDFIELDSF_OPTIMIZATION_PLUGIN', CP_CALCULATEDFIELDSF_OPTIMIZATION_PLUGIN ) * 1 ) {
949
+ // Solves a conflict caused by the "Speed Booster Pack" plugin
950
+ add_filter( 'option_sbp_settings', 'CPCFF_MAIN::speed_booster_pack_troubleshoot' );
951
+
952
+ // Solves a conflict caused by the "Autoptimize" plugin
953
+ if ( class_exists( 'autoptimizeOptionWrapper' ) ) {
954
+ $GLOBALS['CP_CALCULATEDFIELDSF_DEFAULT_DEFER_SCRIPTS_LOADING'] = true;
955
+ add_filter(
956
+ 'cpcff_pre_form',
957
+ function( $atts ) {
958
+ add_filter(
959
+ 'autoptimize_js_include_inline',
960
+ function( $p ) {
961
+ return false;
962
+ }
963
+ );
964
+ add_filter(
965
+ 'autoptimize_filter_js_noptimize',
966
+ function( $p1, $p2 ) {
967
+ return true;
968
+ },
969
+ 10,
970
+ 2
971
+ );
972
+ add_filter(
973
+ 'autoptimize_filter_html_noptimize',
974
+ function( $p1, $p2 ) {
975
+ return true;
976
+ },
977
+ 10,
978
+ 2
979
+ );
980
+ return $atts;
981
+ }
982
+ );
983
+ }
984
+
985
+ // Solves conflicts with "LiteSpeed Cache" plugin
986
+ if ( function_exists( 'run_litespeed_cache' ) ) {
987
+ add_action( 'the_post', 'CPCFF_MAIN::litespeed_control_set_nocache' );
988
+ }
989
+
990
+ // Solves a conflict caused by the "WP Rocket" plugin
991
+ add_filter( 'rocket_exclude_js', 'CPCFF_MAIN::rocket_exclude_js' );
992
+ add_filter( 'rocket_exclude_defer_js', 'CPCFF_MAIN::rocket_exclude_js' );
993
+ add_filter( 'rocket_delay_js_exclusions', 'CPCFF_MAIN::rocket_exclude_js' );
994
+
995
+ // Some "WP Rocket" functions can be use with "WP-Optimize"
996
+ add_filter( 'wp-optimize-minify-blacklist', 'CPCFF_MAIN::rocket_exclude_js' );
997
+ add_filter( 'wp-optimize-minify-default-exclusions', 'CPCFF_MAIN::rocket_exclude_js' );
998
+ }
999
+ add_filter( 'rocket_excluded_inline_js_content', 'CPCFF_MAIN::rocket_exclude_inline_js' );
1000
+ add_filter( 'rocket_defer_inline_exclusions', 'CPCFF_MAIN::rocket_exclude_inline_js' );
1001
+ add_filter( 'rocket_delay_js_exclusions', 'CPCFF_MAIN::rocket_exclude_inline_js' );
1002
+
1003
+ // For Breeze conflicts
1004
+ if ( defined( 'BREEZE_VERSION' ) ) {
1005
+ add_filter( 'breeze_filter_html_before_minify', 'CPCFF_MAIN::breeze_check_content', 10 );
1006
+ add_filter( 'breeze_html_after_minify', 'CPCFF_MAIN::breeze_return_content', 10 );
1007
+ }
1008
+ }
1009
+ } // End troubleshoots
1010
+
1011
+ public static function litespeed_control_set_nocache( &$post ) {
1012
+ try {
1013
+ if (
1014
+ is_object( $post ) &&
1015
+ isset( $post->post_content ) &&
1016
+ stripos( $post->post_content, '[CP_CALCULATED_FIELDS' ) !== false
1017
+ ) {
1018
+ do_action( 'litespeed_control_set_nocache', 'nocache CFF Form' );
1019
+ }
1020
+ } catch ( Exception $err ) {
1021
+ error_log( $err->getMessage() );}
1022
+ return $post;
1023
+ } // End litespeed_control_set_nocache
1024
+
1025
+ public static function speed_booster_pack_troubleshoot( $option ) {
1026
+ if ( is_array( $option ) && isset( $option['jquery_to_footer'] ) ) {
1027
+ unset( $option['jquery_to_footer'] );
1028
+ }
1029
+ return $option;
1030
+ } // End speed_booster_pack_troubleshoot
1031
+
1032
+ public static function rocket_exclude_js( $excluded_js ) {
1033
+ $excluded_js[] = '/jquery.js';
1034
+ $excluded_js[] = '/jquery.min.js';
1035
+ $excluded_js[] = '/jquery/';
1036
+ $excluded_js[] = '/calculated-fields-form/';
1037
+
1038
+ $excluded_js[] = '/jquery/(.*)';
1039
+ $excluded_js[] = '(.*)/jquery.js';
1040
+ $excluded_js[] = '(.*)/jquery.min.js';
1041
+ $excluded_js[] = '(.*)/jquery/(.*)';
1042
+ $excluded_js[] = '(.*)/calculated-fields-form/(.*)';
1043
+ return $excluded_js;
1044
+ } // End rocket_exclude_js
1045
+
1046
+ public static function rocket_exclude_inline_js( $excluded_js = array() ) {
1047
+ $excluded_js[] = 'form_structure_';
1048
+ $excluded_js[] = 'doValidate_';
1049
+ $excluded_js[] = 'cpcff_default';
1050
+ $excluded_js[] = 'cp_calculatedfieldsf_fbuilder_config_';
1051
+ $excluded_js[] = 'form_structure(.*)';
1052
+ $excluded_js[] = 'doValidate(.*)';
1053
+ $excluded_js[] = 'cp_calculatedfieldsf_fbuilder_config(.*)';
1054
+ return $excluded_js;
1055
+ } // End rocket_exclude_inline_js
1056
+
1057
+ public static function breeze_check_content( $content ) {
1058
+ if ( strpos( $content, 'form_structure_' ) !== false ) {
1059
+ global $cff_breeze_content_bk;
1060
+ $cff_breeze_content_bk = $content;
1061
+ }
1062
+ return $content;
1063
+ } // End breeze_check_content
1064
+
1065
+ public static function breeze_return_content( $content ) {
1066
+ global $cff_breeze_content_bk;
1067
+ if ( ! empty( $cff_breeze_content_bk ) ) {
1068
+ $content = $cff_breeze_content_bk;
1069
+ unset( $cff_breeze_content_bk );
1070
+ }
1071
+ return $content;
1072
+ } // End breeze_return_content
1073
+ } // End CPCFF_MAIN
1074
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/cpcff_page_builders.inc.php CHANGED
@@ -1,210 +1,187 @@
1
- <?php
2
- /**
3
- * Main class to interace with the different Content Editors: CPCFF_PAGE_BUILDERS class
4
- *
5
- */
6
- if(!class_exists('CPCFF_PAGE_BUILDERS'))
7
- {
8
- class CPCFF_PAGE_BUILDERS
9
- {
10
- private static $_instance;
11
- private $wptexturize_flag = false;
12
-
13
- private function __construct(){}
14
- private static function instance()
15
- {
16
- if(!isset(self::$_instance)) self::$_instance = new self();
17
- return self::$_instance;
18
- } // End instance
19
-
20
- public static function run()
21
- {
22
- $instance = self::instance();
23
- add_action('init', array($instance, 'init'));
24
- add_action('after_setup_theme', array($instance, 'after_setup_theme'));
25
- }
26
-
27
- public function init()
28
- {
29
- $instance = $instance = self::instance();
30
-
31
- // Gutenberg editor
32
- add_action( 'enqueue_block_editor_assets', array($instance,'gutenberg_editor' ) );
33
- add_filter( 'render_block', array($instance, 'gutenberg_dissable_wptexturize'), 10, 2 );
34
- if(
35
- isset($_REQUEST['cff-action']) &&
36
- $_REQUEST['cff-action'] == 'cff-gutenberg-editor-config' &&
37
- current_user_can( 'edit_posts' )
38
- )
39
- {
40
- remove_all_actions('shutdown');
41
- die(json_encode($this->gutenberg_editor_config()));
42
- }
43
-
44
- // Elementor
45
- add_action( 'elementor/widgets/widgets_registered', array($instance, 'elementor_editor') );
46
- add_action( 'elementor/elements/categories_registered', array($instance, 'elementor_editor_category') );
47
-
48
- // Beaver builder
49
- if(class_exists('FLBuilder'))
50
- {
51
- include_once CP_CALCULATEDFIELDSF_BASE_PATH.'/pagebuilders/beaverbuilder/cff/cff.inc.php';
52
- include_once CP_CALCULATEDFIELDSF_BASE_PATH.'/pagebuilders/beaverbuilder/cffvar/cffvar.inc.php';
53
- }
54
-
55
- // DIVI
56
- add_action( 'et_builder_ready', array($instance, 'divi_editor') );
57
-
58
- } // End init
59
-
60
- public function after_setup_theme()
61
- {
62
- $instance = $instance = self::instance();
63
-
64
- // SiteOrigin
65
- add_filter('siteorigin_widgets_widget_folders', array($instance, 'siteorigin_widgets_collection'));
66
- add_filter('siteorigin_panels_widget_dialog_tabs', array($instance, 'siteorigin_panels_widget_dialog_tabs'));
67
-
68
- // Visual Composer
69
- add_action('vcv:api', array($instance, 'visualcomposer_editor'));
70
- } // End after_setup_theme
71
-
72
- /**************************** DIVI ****************************/
73
-
74
- public function divi_editor()
75
- {
76
- if(class_exists('ET_Builder_Module'))
77
- {
78
- if(isset($_GET['et_fb']))
79
- {
80
- wp_enqueue_script('cp_calculatedfieldsf_divi_editor', plugins_url('/pagebuilders/divi/cff.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH), array('react'), null, true);
81
- }
82
- require_once CP_CALCULATEDFIELDSF_BASE_PATH.'/pagebuilders/divi/cff.pb.php';
83
- }
84
- } // End divi_editor
85
-
86
- /**************************** GUTENBERG ****************************/
87
- private function gutenberg_editor_config()
88
- {
89
- global $wpdb;
90
-
91
- $url = CPCFF_AUXILIARY::site_url();
92
- $url .= ((strpos($url, '?') === false) ? '?' : '&').'cff-editor-preview=1&cff-amp-redirected=1&cff-amp-form=';
93
- $config = array(
94
- 'url' => $url,
95
- 'is_admin' => current_user_can( 'manage_options' ),
96
- 'editor' => CPCFF_AUXILIARY::editor_url(),
97
- 'forms' => array(),
98
- 'labels' => array(
99
- 'required_form' => __('Select a form', 'calculated-fields-form'),
100
- 'forms' => __('Forms', 'calculated-fields-form'),
101
- 'attributes' => __('Additional attributes', 'calculated-fields-form'),
102
- 'edit_form' => __('Edit form', 'calculated-fields-form')
103
- )
104
- );
105
-
106
- $forms = $wpdb->get_results( "SELECT id, form_name FROM ".$wpdb->prefix.CP_CALCULATEDFIELDSF_FORMS_TABLE );
107
-
108
- foreach ($forms as $form)
109
- $config['forms'][$form->id] = esc_attr('('.$form->id.') '.$form->form_name);
110
-
111
- return $config;
112
- } // End gutenberg_integration_config
113
-
114
- /**
115
- * Loads the javascript resources to integrate the plugin with the Gutenberg editor
116
- */
117
- public function gutenberg_editor()
118
- {
119
-
120
- wp_enqueue_style('cp_calculatedfieldsf_gutenberg_editor_css', plugins_url('/pagebuilders/gutenberg/assets/css/gutenberg.css', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH));
121
- wp_enqueue_script('cp_calculatedfieldsf_gutenberg_editor', plugins_url('/pagebuilders/gutenberg/assets/js/gutenberg.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH));
122
-
123
- wp_localize_script('cp_calculatedfieldsf_gutenberg_editor', 'cpcff_gutenberg_editor_config', $this->gutenberg_editor_config());
124
- } // End gutenberg_editor
125
-
126
- public function gutenberg_dissable_wptexturize($block_content, $block)
127
- {
128
- if (
129
- 'cpcff/form-summary-shortcode' === $block['blockName'] ||
130
- 'cpcff/form-summary-list-shortcode' === $block['blockName']
131
- )
132
- {
133
- if(has_filter( 'the_content', 'wptexturize' ))
134
- {
135
- $this->wptexturize_flag = true;
136
- remove_filter('the_content', 'wptexturize');
137
- }
138
- }
139
- elseif($this->wptexturize_flag && !has_filter( 'the_content', 'wptexturize' ))
140
- {
141
- add_filter( 'the_content', 'wpautop' );
142
- }
143
-
144
- return $block_content;
145
- } // End gutenberg_dissable_wptexturize
146
-
147
- /**************************** ELEMENTOR ****************************/
148
-
149
- public function elementor_editor_category()
150
- {
151
- require_once CP_CALCULATEDFIELDSF_BASE_PATH.'/pagebuilders/elementor/elementor_category.pb.php';
152
- } // End elementor_editor
153
-
154
- public function elementor_editor()
155
- {
156
- if(is_admin())
157
- {
158
- wp_enqueue_script('cp_calculatedfieldsf_elementor_editor_js', plugins_url('/pagebuilders/elementor/assets/elementor.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH));
159
- wp_enqueue_style('cp_calculatedfieldsf_elementor_editor_css', plugins_url('/pagebuilders/elementor/assets/elementor.css', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH));
160
-
161
- if ( current_user_can( 'manage_options' ) ) {
162
- wp_localize_script(
163
- 'cp_calculatedfieldsf_elementor_editor_js',
164
- 'cp_calculatedfieldsf_elementor',
165
- array(
166
- 'url' => CPCFF_AUXILIARY::editor_url()
167
- )
168
- );
169
- }
170
- }
171
- require_once CP_CALCULATEDFIELDSF_BASE_PATH.'/pagebuilders/elementor/elementor.pb.php';
172
- } // End elementor_editor
173
-
174
- /**************************** SITEORIGIN ****************************/
175
-
176
- public function siteorigin_widgets_collection($folders)
177
- {
178
- $folders[] = CP_CALCULATEDFIELDSF_BASE_PATH.'/pagebuilders/siteorigin/';
179
- return $folders;
180
- } // End siteorigin_widgets_collection
181
-
182
- public function siteorigin_panels_widget_dialog_tabs($tabs)
183
- {
184
- $tabs[] = array(
185
- 'title' => __('Calculated Fields Form', 'calculated-fields-form'),
186
- 'filter' => array(
187
- 'groups' => array('calculated-fields-form')
188
- )
189
- );
190
-
191
- return $tabs;
192
- } // End siteorigin_panels_widget_dialog_tabs
193
-
194
- /**************************** VISUAL COMPOSER ****************************/
195
-
196
- public function visualcomposer_editor($api)
197
- {
198
- $elementsToRegister = array('CFFForm');
199
- $pluginBaseUrl = rtrim(plugins_url('/pagebuilders/visualcomposer/', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH), '\\/');
200
- $elementsApi = $api->elements;
201
- foreach ($elementsToRegister as $tag)
202
- {
203
- $manifestPath = CP_CALCULATEDFIELDSF_BASE_PATH . '/pagebuilders/visualcomposer/' . $tag . '/manifest.json';
204
- $elementBaseUrl = $pluginBaseUrl . '/' . $tag;
205
- $elementsApi->add($manifestPath, $elementBaseUrl);
206
- }
207
- } // End visualcomposer_editor
208
-
209
- } // End CPCFF_PAGE_BUILDERS
210
- }
1
+ <?php
2
+ /**
3
+ * Main class to interace with the different Content Editors: CPCFF_PAGE_BUILDERS class
4
+ */
5
+ if ( ! class_exists( 'CPCFF_PAGE_BUILDERS' ) ) {
6
+ class CPCFF_PAGE_BUILDERS {
7
+
8
+ private static $_instance;
9
+ private $wptexturize_flag = false;
10
+
11
+ private function __construct(){}
12
+ private static function instance() {
13
+ if ( ! isset( self::$_instance ) ) {
14
+ self::$_instance = new self();
15
+ }
16
+ return self::$_instance;
17
+ } // End instance
18
+
19
+ public static function run() {
20
+ $instance = self::instance();
21
+ add_action( 'init', array( $instance, 'init' ) );
22
+ add_action( 'after_setup_theme', array( $instance, 'after_setup_theme' ) );
23
+ }
24
+
25
+ public function init() {
26
+ $instance = $instance = self::instance(); // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments
27
+
28
+ // Gutenberg editor
29
+ add_action( 'enqueue_block_editor_assets', array( $instance, 'gutenberg_editor' ) );
30
+ add_filter( 'render_block', array( $instance, 'gutenberg_dissable_wptexturize' ), 10, 2 );
31
+ if (
32
+ isset( $_REQUEST['cff-action'] ) &&
33
+ 'cff-gutenberg-editor-config' == $_REQUEST['cff-action'] &&
34
+ current_user_can( 'edit_posts' )
35
+ ) {
36
+ remove_all_actions( 'shutdown' );
37
+ die( json_encode( $this->gutenberg_editor_config() ) );
38
+ }
39
+
40
+ // Elementor
41
+ add_action( 'elementor/widgets/widgets_registered', array( $instance, 'elementor_editor' ) );
42
+ add_action( 'elementor/elements/categories_registered', array( $instance, 'elementor_editor_category' ) );
43
+
44
+ // Beaver builder
45
+ if ( class_exists( 'FLBuilder' ) ) {
46
+ include_once CP_CALCULATEDFIELDSF_BASE_PATH . '/pagebuilders/beaverbuilder/cff/cff.inc.php';
47
+ include_once CP_CALCULATEDFIELDSF_BASE_PATH . '/pagebuilders/beaverbuilder/cffvar/cffvar.inc.php';
48
+ }
49
+
50
+ // DIVI
51
+ add_action( 'et_builder_ready', array( $instance, 'divi_editor' ) );
52
+
53
+ } // End init
54
+
55
+ public function after_setup_theme() {
56
+ $instance = $instance = self::instance(); // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments
57
+
58
+ // SiteOrigin
59
+ add_filter( 'siteorigin_widgets_widget_folders', array( $instance, 'siteorigin_widgets_collection' ) );
60
+ add_filter( 'siteorigin_panels_widget_dialog_tabs', array( $instance, 'siteorigin_panels_widget_dialog_tabs' ) );
61
+
62
+ // Visual Composer
63
+ add_action( 'vcv:api', array( $instance, 'visualcomposer_editor' ) );
64
+ } // End after_setup_theme
65
+
66
+ /**************************** DIVI ****************************/
67
+
68
+ public function divi_editor() {
69
+ if ( class_exists( 'ET_Builder_Module' ) ) {
70
+ if ( isset( $_GET['et_fb'] ) ) {
71
+ wp_enqueue_script( 'cp_calculatedfieldsf_divi_editor', plugins_url( '/pagebuilders/divi/cff.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ), array( 'react' ), CP_CALCULATEDFIELDSF_VERSION, true );
72
+ }
73
+ require_once CP_CALCULATEDFIELDSF_BASE_PATH . '/pagebuilders/divi/cff.pb.php';
74
+ }
75
+ } // End divi_editor
76
+
77
+ /**************************** GUTENBERG ****************************/
78
+ private function gutenberg_editor_config() {
79
+ global $wpdb;
80
+
81
+ $url = CPCFF_AUXILIARY::site_url();
82
+ $url .= ( ( strpos( $url, '?' ) === false ) ? '?' : '&' ) . 'cff-editor-preview=1&cff-amp-redirected=1&cff-amp-form=';
83
+ $config = array(
84
+ 'url' => $url,
85
+ 'is_admin' => current_user_can( 'manage_options' ),
86
+ 'editor' => CPCFF_AUXILIARY::editor_url(),
87
+ 'forms' => array(),
88
+ 'labels' => array(
89
+ 'required_form' => __( 'Select a form', 'calculated-fields-form' ),
90
+ 'forms' => __( 'Forms', 'calculated-fields-form' ),
91
+ 'attributes' => __( 'Additional attributes', 'calculated-fields-form' ),
92
+ 'edit_form' => __( 'Edit form', 'calculated-fields-form' ),
93
+ ),
94
+ );
95
+
96
+ $forms = $wpdb->get_results( 'SELECT id, form_name FROM ' . $wpdb->prefix . CP_CALCULATEDFIELDSF_FORMS_TABLE ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
97
+
98
+ foreach ( $forms as $form ) {
99
+ $config['forms'][ $form->id ] = esc_attr( '(' . $form->id . ') ' . $form->form_name );
100
+ }
101
+
102
+ return $config;
103
+ } // End gutenberg_integration_config
104
+
105
+ /**
106
+ * Loads the javascript resources to integrate the plugin with the Gutenberg editor
107
+ */
108
+ public function gutenberg_editor() {
109
+ wp_enqueue_style( 'cp_calculatedfieldsf_gutenberg_editor_css', plugins_url( '/pagebuilders/gutenberg/assets/css/gutenberg.css', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ), array(), CP_CALCULATEDFIELDSF_VERSION );
110
+ wp_enqueue_script( 'cp_calculatedfieldsf_gutenberg_editor', plugins_url( '/pagebuilders/gutenberg/assets/js/gutenberg.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ), array(), CP_CALCULATEDFIELDSF_VERSION );
111
+
112
+ wp_localize_script( 'cp_calculatedfieldsf_gutenberg_editor', 'cpcff_gutenberg_editor_config', $this->gutenberg_editor_config() );
113
+ } // End gutenberg_editor
114
+
115
+ public function gutenberg_dissable_wptexturize( $block_content, $block ) {
116
+ if (
117
+ 'cpcff/form-summary-shortcode' === $block['blockName'] ||
118
+ 'cpcff/form-summary-list-shortcode' === $block['blockName']
119
+ ) {
120
+ if ( has_filter( 'the_content', 'wptexturize' ) ) {
121
+ $this->wptexturize_flag = true;
122
+ remove_filter( 'the_content', 'wptexturize' );
123
+ }
124
+ } elseif ( $this->wptexturize_flag && ! has_filter( 'the_content', 'wptexturize' ) ) {
125
+ add_filter( 'the_content', 'wpautop' );
126
+ }
127
+
128
+ return $block_content;
129
+ } // End gutenberg_dissable_wptexturize
130
+
131
+ /**************************** ELEMENTOR ****************************/
132
+
133
+ public function elementor_editor_category() {
134
+ require_once CP_CALCULATEDFIELDSF_BASE_PATH . '/pagebuilders/elementor/elementor_category.pb.php';
135
+ } // End elementor_editor
136
+
137
+ public function elementor_editor() {
138
+ if ( is_admin() ) {
139
+ wp_enqueue_script( 'cp_calculatedfieldsf_elementor_editor_js', plugins_url( '/pagebuilders/elementor/assets/elementor.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ), array(), CP_CALCULATEDFIELDSF_VERSION );
140
+ wp_enqueue_style( 'cp_calculatedfieldsf_elementor_editor_css', plugins_url( '/pagebuilders/elementor/assets/elementor.css', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ), array(), CP_CALCULATEDFIELDSF_VERSION );
141
+
142
+ if ( current_user_can( 'manage_options' ) ) {
143
+ wp_localize_script(
144
+ 'cp_calculatedfieldsf_elementor_editor_js',
145
+ 'cp_calculatedfieldsf_elementor',
146
+ array(
147
+ 'url' => CPCFF_AUXILIARY::editor_url(),
148
+ )
149
+ );
150
+ }
151
+ }
152
+ require_once CP_CALCULATEDFIELDSF_BASE_PATH . '/pagebuilders/elementor/elementor.pb.php';
153
+ } // End elementor_editor
154
+
155
+ /**************************** SITEORIGIN ****************************/
156
+
157
+ public function siteorigin_widgets_collection( $folders ) {
158
+ $folders[] = CP_CALCULATEDFIELDSF_BASE_PATH . '/pagebuilders/siteorigin/';
159
+ return $folders;
160
+ } // End siteorigin_widgets_collection
161
+
162
+ public function siteorigin_panels_widget_dialog_tabs( $tabs ) {
163
+ $tabs[] = array(
164
+ 'title' => __( 'Calculated Fields Form', 'calculated-fields-form' ),
165
+ 'filter' => array(
166
+ 'groups' => array( 'calculated-fields-form' ),
167
+ ),
168
+ );
169
+
170
+ return $tabs;
171
+ } // End siteorigin_panels_widget_dialog_tabs
172
+
173
+ /**************************** VISUAL COMPOSER ****************************/
174
+
175
+ public function visualcomposer_editor( $api ) {
176
+ $elementsToRegister = array( 'CFFForm' );
177
+ $pluginBaseUrl = rtrim( plugins_url( '/pagebuilders/visualcomposer/', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ), '\\/' );
178
+ $elementsApi = $api->elements;
179
+ foreach ( $elementsToRegister as $tag ) {
180
+ $manifestPath = CP_CALCULATEDFIELDSF_BASE_PATH . '/pagebuilders/visualcomposer/' . $tag . '/manifest.json';
181
+ $elementBaseUrl = $pluginBaseUrl . '/' . $tag;
182
+ $elementsApi->add( $manifestPath, $elementBaseUrl );
183
+ }
184
+ } // End visualcomposer_editor
185
+
186
+ } // End CPCFF_PAGE_BUILDERS
187
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/cpcff_public_int.inc.php CHANGED
@@ -1,86 +1,81 @@
1
- <?php
2
- if ( !defined('CP_AUTH_INCLUDE') )
3
- {
4
- print 'Direct access not allowed.';
5
- exit;
6
- }
7
-
8
- // Required scripts
9
- require_once CP_CALCULATEDFIELDSF_BASE_PATH.'/inc/cpcff_templates.inc.php';
10
-
11
- // Corrects a conflict with W3 Total Cache
12
- if( function_exists( 'w3_instance' ) )
13
- {
14
- try
15
- {
16
- $w3_config = w3_instance( 'W3_Config' );
17
- $w3_config->set( 'minify.html.enable', false );
18
- }
19
- catch( Exception $err )
20
- {
21
-
22
- }
23
- }
24
-
25
- add_filter( 'style_loader_tag', array('CPCFF_AUXILIARY', 'complete_link_tag') );
26
-
27
- wp_enqueue_style( 'cpcff_stylepublic', plugins_url('/css/stylepublic.css', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH), array(), CP_CALCULATEDFIELDSF_VERSION );
28
- wp_enqueue_style( 'cpcff_jquery_ui', plugins_url('/vendors/jquery-ui/jquery-ui.min.css', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH), array(), CP_CALCULATEDFIELDSF_VERSION );
29
-
30
- $cpcff_main = CPCFF_MAIN::instance();
31
- $form_obj = $cpcff_main->get_form($id);
32
-
33
- $form_data = $form_obj->get_option('form_structure', CP_CALCULATEDFIELDSF_DEFAULT_form_structure);
34
-
35
- if(!wp_script_is('select2'))
36
- {
37
- wp_enqueue_style( 'cpcff_select2_css', plugins_url('/vendors/select2/select2.min.css', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH), array(), CP_CALCULATEDFIELDSF_VERSION );
38
- wp_enqueue_script( 'cpcff_select2_js', plugins_url('/vendors/select2/select2.min.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH), array(), CP_CALCULATEDFIELDSF_VERSION, true );
39
- }
40
-
41
- if( !empty( $form_data ) )
42
- {
43
- if( isset( $form_data[ 1 ] ) && isset( $form_data[ 1 ][ 0 ] ) )
44
- {
45
- if(!empty( $form_data[ 1 ][ 0 ]->formtemplate ))
46
- {
47
- CPCFF_TEMPLATES::enqueue_template_resources($form_data[ 1 ][ 0 ]->formtemplate);
48
- }
49
-
50
- if(!empty($form_data[ 1 ][ 0 ]->customstyles))
51
- {
52
- print '<style>'.$form_data[ 1 ][ 0 ]->customstyles.'</style>';
53
- }
54
- }
55
- if(isset($form_data[ 1 ]) && is_object($form_data[ 1 ])) $form_data[ 1 ] = (array) $form_data[ 1 ];
56
- $form_data[ 1 ][ 'formid' ]="cp_calculatedfieldsf_pform_".CPCFF_MAIN::$form_counter;
57
- ?>
58
- <form name="<?php echo $form_data[ 1 ][ 'formid' ]; ?>" id="<?php echo $form_data[ 1 ][ 'formid' ]; ?>" action="?" method="post" enctype="multipart/form-data" class="cff-form <?php
59
- if(!empty($form_data[1][0]) && !empty($form_data[1][0]->persistence)) echo ' persist-form';
60
- if(!empty($atts) && !empty($atts['class'])) echo ' '.esc_attr($atts['class']);
61
- ?>">
62
- <input type="hidden" name="cp_calculatedfieldsf_pform_psequence" value="_<?php echo CPCFF_MAIN::$form_counter; ?>" />
63
- <input type="hidden" name="cp_calculatedfieldsf_id" value="<?php echo $id; ?>" /><pre style="display:none !important;"><script type="text/javascript">form_structure_<?php echo CPCFF_MAIN::$form_counter; ?>=<?php print str_replace( array( "\n", "\r" ), " ", ((version_compare(CP_CFF_PHPVERSION,"5.3.0")>=0)?json_encode($form_data, JSON_HEX_QUOT|JSON_HEX_TAG):json_encode($form_data)) ); ?>;</script></pre>
64
- <div id="fbuilder">
65
- <?php
66
- if(
67
- !empty($form_data) &&
68
- !empty($form_data[1]) &&
69
- !empty($form_data[1][0]) &&
70
- !empty($form_data[1][0]->loading_animation)
71
- )
72
- {
73
- print '<div class="cff-processing-form"></div>';
74
- }
75
  ?>
76
- <div id="fbuilder_<?php echo CPCFF_MAIN::$form_counter; ?>">
77
- <div id="formheader_<?php echo CPCFF_MAIN::$form_counter; ?>"></div>
78
- <div id="fieldlist_<?php echo CPCFF_MAIN::$form_counter; ?>"></div>
79
- <div class="clearer"></div>
80
- </div>
81
- </div>
82
- <div class="clearer"></div>
83
- </form>
84
- <?php
85
- }
86
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'CP_AUTH_INCLUDE' ) ) {
3
+ print 'Direct access not allowed.';
4
+ exit;
5
+ }
6
+
7
+ // Required scripts
8
+ require_once CP_CALCULATEDFIELDSF_BASE_PATH . '/inc/cpcff_templates.inc.php';
9
+
10
+ // Corrects a conflict with W3 Total Cache
11
+ if ( function_exists( 'w3_instance' ) ) {
12
+ try {
13
+ $w3_config = w3_instance( 'W3_Config' );
14
+ $w3_config->set( 'minify.html.enable', false );
15
+ } catch ( Exception $err ) {
16
+ error_log( $err->getMessage() );
17
+ }
18
+ }
19
+
20
+ add_filter( 'style_loader_tag', array( 'CPCFF_AUXILIARY', 'complete_link_tag' ) );
21
+
22
+ wp_enqueue_style( 'cpcff_stylepublic', plugins_url( '/css/stylepublic.css', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ), array(), CP_CALCULATEDFIELDSF_VERSION );
23
+ wp_enqueue_style( 'cpcff_jquery_ui', plugins_url( '/vendors/jquery-ui/jquery-ui.min.css', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ), array(), CP_CALCULATEDFIELDSF_VERSION );
24
+
25
+ $cpcff_main = CPCFF_MAIN::instance();
26
+ $form_obj = $cpcff_main->get_form( $id );
27
+
28
+ $form_data = $form_obj->get_option( 'form_structure', CP_CALCULATEDFIELDSF_DEFAULT_form_structure );
29
+
30
+ if ( ! wp_script_is( 'select2' ) ) {
31
+ wp_enqueue_style( 'cpcff_select2_css', plugins_url( '/vendors/select2/select2.min.css', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ), array(), CP_CALCULATEDFIELDSF_VERSION );
32
+ wp_enqueue_script( 'cpcff_select2_js', plugins_url( '/vendors/select2/select2.min.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ), array(), CP_CALCULATEDFIELDSF_VERSION, true );
33
+ }
34
+
35
+ if ( ! empty( $form_data ) ) {
36
+ if ( isset( $form_data[1] ) && isset( $form_data[1][0] ) ) {
37
+ if ( ! empty( $form_data[1][0]->formtemplate ) ) {
38
+ CPCFF_TEMPLATES::enqueue_template_resources( $form_data[1][0]->formtemplate );
39
+ }
40
+
41
+ if ( ! empty( $form_data[1][0]->customstyles ) ) {
42
+ print '<style>' . wp_strip_all_tags( $form_data[1][0]->customstyles ) . '</style>'; // phpcs:ignore WordPress.Security.EscapeOutput
43
+ }
44
+ }
45
+ if ( isset( $form_data[1] ) && is_object( $form_data[1] ) ) {
46
+ $form_data[1] = (array) $form_data[1];
47
+ }
48
+ $form_data[1]['formid'] = 'cp_calculatedfieldsf_pform_' . CPCFF_MAIN::$form_counter;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  ?>
50
+ <form name="<?php echo esc_attr( $form_data[1]['formid'] ); ?>" id="<?php echo esc_attr( $form_data[1]['formid'] ); ?>" action="?" method="post" enctype="multipart/form-data" class="cff-form <?php
51
+ if ( ! empty( $form_data[1][0] ) && ! empty( $form_data[1][0]->persistence ) ) {
52
+ echo ' persist-form';
53
+ }
54
+ if ( ! empty( $atts ) && ! empty( $atts['class'] ) ) {
55
+ echo ' ' . esc_attr( $atts['class'] );
56
+ }
57
+ ?>">
58
+ <input type="hidden" name="cp_calculatedfieldsf_pform_psequence" value="_<?php echo esc_attr( CPCFF_MAIN::$form_counter ); ?>" />
59
+ <input type="hidden" name="cp_calculatedfieldsf_id" value="<?php echo esc_attr( $id ); ?>" /><pre style="display:none !important;"><script type="text/javascript">form_structure_<?php echo esc_js( CPCFF_MAIN::$form_counter ); ?>=<?php print str_replace( array( "\n", "\r" ), ' ', ( ( version_compare( CP_CFF_PHPVERSION, '5.3.0' ) >= 0 ) ? json_encode( $form_data, JSON_HEX_QUOT | JSON_HEX_TAG ) : json_encode( $form_data ) ) ); // phpcs:ignore WordPress.Security.EscapeOutput ?>;</script></pre>
60
+ <div id="fbuilder">
61
+ <?php
62
+ if (
63
+ ! empty( $form_data ) &&
64
+ ! empty( $form_data[1] ) &&
65
+ ! empty( $form_data[1][0] ) &&
66
+ ! empty( $form_data[1][0]->loading_animation )
67
+ ) {
68
+ print '<div class="cff-processing-form"></div>';
69
+ }
70
+ ?>
71
+ <div id="fbuilder_<?php echo esc_attr( CPCFF_MAIN::$form_counter ); ?>">
72
+ <div id="formheader_<?php echo esc_attr( CPCFF_MAIN::$form_counter ); ?>"></div>
73
+ <div id="fieldlist_<?php echo esc_attr( CPCFF_MAIN::$form_counter ); ?>"></div>
74
+ <div class="clearer"></div>
75
+ </div>
76
+ </div>
77
+ <div class="clearer"></div>
78
+ </form>
79
+ <?php
80
+ }
81
+ ?>
inc/cpcff_revisions.inc.php CHANGED
@@ -1,158 +1,148 @@
1
- <?php
2
- /**
3
- * Revisions class with database interaction, data, and methods.
4
- *
5
- * @package CFF.
6
- * @since 1.0.232
7
- */
8
-
9
- if(!class_exists('CPCFF_REVISIONS'))
10
- {
11
- class CPCFF_REVISIONS
12
- {
13
- /**
14
- * CPCFF_FORM instance
15
- */
16
- private $_form_obj;
17
-
18
- /**
19
- * List of revisions rows corresponding to the form
20
- */
21
- private $_revisions;
22
-
23
- /**
24
- * Instance of the $wpdb object
25
- */
26
- private $_db;
27
-
28
- /**
29
- * Name of revisions table
30
- */
31
- private $_table;
32
-
33
- /**
34
- * The number of revisions per form
35
- */
36
- private $_max = 20;
37
-
38
- /**
39
- * Constructs a CPCFF_REVISIONS object.
40
- *
41
- * @param integer $form_obj instance of CPCFF_FORM
42
- */
43
- public function __construct($form_obj)
44
- {
45
- global $wpdb;
46
- $this->_db = $wpdb;
47
- $this->_table = $wpdb->prefix.CP_CALCULATEDFIELDSF_FORMS_REVISIONS_TABLE;
48
- $this->_form_obj = $form_obj;
49
- } // End construct
50
-
51
- /**
52
- * Returns the list of revisions rows in the database as array
53
- */
54
- public function revisions_list()
55
- {
56
- if(empty($this->_revisions))
57
- {
58
- $results = $this->_db->get_results(
59
- $this->_db->prepare(
60
- 'SELECT * FROM '.$this->_table.' WHERE formid=%d ORDER BY time DESC',
61
- $this->_form_obj->get_id()
62
- ),
63
- ARRAY_A
64
- );
65
- $this->_revisions = array();
66
- foreach($results as $revision)
67
- {
68
- $this->_revisions[$revision['id']] = $revision;
69
- }
70
- }
71
- return $this->_revisions;
72
-
73
- } // End revisions_list
74
-
75
- /**
76
- * Creates a new entry in the revisions table, if there are more than _max revisions remove the older.
77
- *
78
- * @return int returns the revision's id or false if fails.
79
- */
80
- public function create_revision()
81
- {
82
- $form_data = $this->_form_obj->get_raw_data();
83
-
84
- $data = array(
85
- 'formid' => $this->_form_obj->get_id(),
86
- 'time' => current_time('mysql'),
87
- 'revision' => serialize($form_data)
88
- );
89
-
90
- if(
91
- $this->_db->insert(
92
- $this->_table,
93
- $data,
94
- array('%d','%s','%s')
95
- )
96
- )
97
- {
98
- $this->revisions_list();
99
- $data['id'] = $this->_db->insert_id;
100
- $this->_revisions[$data['id']] = $data;
101
- krsort($this->_revisions);
102
- if($this->_max < count($this->_revisions))
103
- {
104
- array_splice($this->_revisions,$this->_max);
105
- $this->_delete_older();
106
- }
107
- return $data['id'];
108
- }
109
- return false;
110
- } // End create_revision
111
-
112
- /**
113
- * returns the form data unserialized or an empty array
114
- */
115
- public function data( $revision_id )
116
- {
117
- $this->revisions_list();
118
- if(
119
- !empty($this->_revisions) &&
120
- isset($this->_revisions[$revision_id])
121
- )
122
- {
123
- return unserialize($this->_revisions[$revision_id]['revision']);
124
- }
125
- return array();
126
- } // End data
127
-
128
- /**
129
- * Deletes the list of revisions belonging to the form
130
- */
131
- public function delete_form()
132
- {
133
- $this->_db->delete(
134
- $this->_table,
135
- array('formid' => $this->_form_obj->get_id()),
136
- array('%d')
137
- );
138
- $this->_revisions = array();
139
- } // End delete_form
140
-
141
-
142
- /*********************************** PRIVATE METHODS ********************************************/
143
-
144
- /**
145
- * Deletes the older revisions, leaving only the _max
146
- */
147
- private function _delete_older()
148
- {
149
- $formid = $this->_form_obj->get_id();
150
- $this->_db->query(
151
- $this->_db->prepare(
152
- 'DELETE FROM '.$this->_table.' WHERE formid=%d AND id IN (SELECT * FROM (SELECT id FROM '.$this->_table.' WHERE formid=%d ORDER BY time DESC LIMIT %d,18446744073709551615) AS tmp)',
153
- $formid,$formid,$this->_max
154
- )
155
- );
156
- } // End _delete_older
157
- } // End CPCFF_REVISIONS
158
- }
1
+ <?php
2
+ /**
3
+ * Revisions class with database interaction, data, and methods.
4
+ *
5
+ * @package CFF.
6
+ * @since 1.0.232
7
+ */
8
+
9
+ if ( ! class_exists( 'CPCFF_REVISIONS' ) ) {
10
+ class CPCFF_REVISIONS {
11
+
12
+ /**
13
+ * CPCFF_FORM instance
14
+ */
15
+ private $_form_obj;
16
+
17
+ /**
18
+ * List of revisions rows corresponding to the form
19
+ */
20
+ private $_revisions;
21
+
22
+ /**
23
+ * Instance of the $wpdb object
24
+ */
25
+ private $_db;
26
+
27
+ /**
28
+ * Name of revisions table
29
+ */
30
+ private $_table;
31
+
32
+ /**
33
+ * The number of revisions per form
34
+ */
35
+ private $_max = 20;
36
+
37
+ /**
38
+ * Constructs a CPCFF_REVISIONS object.
39
+ *
40
+ * @param integer $form_obj instance of CPCFF_FORM
41
+ */
42
+ public function __construct( $form_obj ) {
43
+ global $wpdb;
44
+ $this->_db = $wpdb;
45
+ $this->_table = $wpdb->prefix . CP_CALCULATEDFIELDSF_FORMS_REVISIONS_TABLE;
46
+ $this->_form_obj = $form_obj;
47
+ } // End construct
48
+
49
+ /**
50
+ * Returns the list of revisions rows in the database as array
51
+ */
52
+ public function revisions_list() {
53
+ if ( empty( $this->_revisions ) ) {
54
+ $results = $this->_db->get_results(
55
+ $this->_db->prepare(
56
+ 'SELECT * FROM ' . $this->_table . ' WHERE formid=%d ORDER BY time DESC',
57
+ $this->_form_obj->get_id()
58
+ ),
59
+ ARRAY_A
60
+ );
61
+ $this->_revisions = array();
62
+ foreach ( $results as $revision ) {
63
+ $this->_revisions[ $revision['id'] ] = $revision;
64
+ }
65
+ }
66
+ return $this->_revisions;
67
+
68
+ } // End revisions_list
69
+
70
+ /**
71
+ * Creates a new entry in the revisions table, if there are more than _max revisions remove the older.
72
+ *
73
+ * @return int returns the revision's id or false if fails.
74
+ */
75
+ public function create_revision() {
76
+ $form_data = $this->_form_obj->get_raw_data();
77
+
78
+ $data = array(
79
+ 'formid' => $this->_form_obj->get_id(),
80
+ 'time' => current_time( 'mysql' ),
81
+ 'revision' => serialize( $form_data ),
82
+ );
83
+
84
+ if (
85
+ $this->_db->insert(
86
+ $this->_table,
87
+ $data,
88
+ array( '%d', '%s', '%s' )
89
+ )
90
+ ) {
91
+ $this->revisions_list();
92
+ $data['id'] = $this->_db->insert_id;
93
+ $this->_revisions[ $data['id'] ] = $data;
94
+ krsort( $this->_revisions );
95
+ if ( $this->_max < count( $this->_revisions ) ) {
96
+ array_splice( $this->_revisions, $this->_max );
97
+ $this->_delete_older();
98
+ }
99
+ return $data['id'];
100
+ }
101
+ return false;
102
+ } // End create_revision
103
+
104
+ /**
105
+ * returns the form data unserialized or an empty array
106
+ */
107
+ public function data( $revision_id ) {
108
+ $this->revisions_list();
109
+ if (
110
+ ! empty( $this->_revisions ) &&
111
+ isset( $this->_revisions[ $revision_id ] )
112
+ ) {
113
+ return unserialize( $this->_revisions[ $revision_id ]['revision'] );
114
+ }
115
+ return array();
116
+ } // End data
117
+
118
+ /**
119
+ * Deletes the list of revisions belonging to the form
120
+ */
121
+ public function delete_form() {
122
+ $this->_db->delete(
123
+ $this->_table,
124
+ array( 'formid' => $this->_form_obj->get_id() ),
125
+ array( '%d' )
126
+ );
127
+ $this->_revisions = array();
128
+ } // End delete_form
129
+
130
+
131
+ /*********************************** PRIVATE METHODS ********************************************/
132
+
133
+ /**
134
+ * Deletes the older revisions, leaving only the _max
135
+ */
136
+ private function _delete_older() {
137
+ $formid = $this->_form_obj->get_id();
138
+ $this->_db->query(
139
+ $this->_db->prepare(
140
+ 'DELETE FROM ' . $this->_table . ' WHERE formid=%d AND id IN (SELECT * FROM (SELECT id FROM ' . $this->_table . ' WHERE formid=%d ORDER BY time DESC LIMIT %d,18446744073709551615) AS tmp)',
141
+ $formid,
142
+ $formid,
143
+ $this->_max
144
+ )
145
+ );
146
+ } // End _delete_older
147
+ } // End CPCFF_REVISIONS
148
+ }
 
 
 
 
 
 
 
 
 
 
inc/cpcff_session.inc.php CHANGED
@@ -1,195 +1,185 @@
1
- <?php
2
- /**
3
- * CodePeople Session.
4
- *
5
- * Standardizes WordPress session data using database-backed options for storage.
6
- * for storing user session information.
7
- */
8
-
9
- if( !defined( 'CP_COOKIE_NAME' ) )
10
- {
11
- define( 'CP_COOKIE_NAME', 'CP5XKN6QLDFWUC' );
12
- }
13
-
14
- if( !class_exists( 'CP_SESSION' ) )
15
- {
16
- class CP_SESSION
17
- {
18
-
19
- /************** STATIC PROPERTIES **************/
20
- private static $instance = false;
21
-
22
- /************** INSTANCE PROPERTIES **************/
23
- private $session_id;
24
- private $expiration;
25
- private $cleaned_expired_vars = false;
26
- private $expiration_interval = 86400; // 24 Hours
27
-
28
- /************** CONSTRUCT **************/
29
-
30
- private function __construct()
31
- {
32
- if(!is_admin()) return;
33
- if(session_id() == "" && !headers_sent()) @session_start();
34
-
35
- if( isset( $_SESSION[CP_COOKIE_NAME] ) || isset( $_COOKIE[CP_COOKIE_NAME] ) )
36
- {
37
- $cookie = stripslashes( ( isset( $_SESSION[CP_COOKIE_NAME] ) ) ? $_SESSION[CP_COOKIE_NAME] : $_COOKIE[CP_COOKIE_NAME] );
38
-
39
- $cookie_crumbs = explode( '||', $cookie );
40
-
41
- $this->session_id = $cookie_crumbs[0];
42
- $this->expiration = $cookie_crumbs[1];
43
- }
44
- else
45
- {
46
- $this->session_id = $this->_generate_session_id();
47
- $this->expiration = $this->expiration_interval;
48
- $this->_set_cookie();
49
- }
50
-
51
- }
52
-
53
- /************** PRIVATE INSTANCE METHODS **************/
54
- private function _generate_session_id()
55
- {
56
- require_once( ABSPATH . 'wp-includes/class-phpass.php' );
57
- $hash = new PasswordHash( 8, false );
58
-
59
- return md5( $hash->get_random_bytes( 32 ) );
60
- }
61
-
62
- private function _set_cookie()
63
- {
64
- try
65
- {
66
- $_SESSION[CP_COOKIE_NAME] = $this->session_id . '||' . $this->expiration;
67
- if(!headers_sent())
68
- @setcookie( CP_COOKIE_NAME, $this->session_id . '||' . $this->expiration, 0, '/' );
69
- }
70
- catch( Exception $err ){}
71
- }
72
-
73
- private function _get_var_name( $name )
74
- {
75
- return CP_COOKIE_NAME.'_'.$this->session_id.'_'.$name;
76
- }
77
-
78
- private function _set_var( $name, $value )
79
- {
80
- $_SESSION[ $name ] = $value;
81
- $transient = $this->_get_var_name( $name );
82
- set_transient( $transient, $value, $this->expiration );
83
- }
84
-
85
- private function _get_var( $name )
86
- {
87
- if( isset( $_SESSION[ $name ] ) ) return $_SESSION[ $name ];
88
- $transient = $this->_get_var_name( $name );
89
- return get_transient( $transient );
90
- }
91
-
92
- private function _unset_var( $name )
93
- {
94
- if(isset($_SESSION[$name])) unset( $_SESSION[ $name ] );
95
- $transient = $this->_get_var_name( $name );
96
- delete_transient( $transient );
97
- }
98
-
99
- private function _clean_expired_vars()
100
- {
101
- if($this->cleaned_expired_vars) return;
102
- $this->cleaned_expired_vars = true;
103
-
104
- global $wpdb;
105
-
106
- $expiration = time()-$this->expiration_interval;
107
- try
108
- {
109
- $transients = $wpdb->get_col(
110
- $wpdb->prepare( "SELECT REPLACE(option_name, '_transient_timeout_', '') AS transient_name FROM {$wpdb->options} WHERE option_name LIKE %s AND option_value < %s", "_transient_timeout_".$wpdb->esc_like(CP_COOKIE_NAME)."%", $expiration)
111
- );
112
-
113
- $options_names = array();
114
- foreach($transients as $transient)
115
- {
116
- if( strpos( $transient, $this->session_id ) === false )
117
- {
118
- $options_names[] = '_transient_' . $transient;
119
- $options_names[] = '_transient_timeout_' . $transient;
120
- }
121
- }
122
-
123
- if ( !empty($options_names) )
124
- {
125
- $options_names = array_map('esc_sql', $options_names);
126
- $options_names = "'". implode("','", $options_names) ."'";
127
- $result = $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name IN ({$options_names})" );
128
-
129
- }
130
- }
131
- catch( Exception $err ) {}
132
- }
133
- /************** PUBLIC INSTANCE METHODS **************/
134
-
135
- /************** PRIVATE STATIC METHODS **************/
136
-
137
- private static function _get_instance() {
138
- if ( ! self::$instance ) {
139
- self::$instance = new self();
140
- }
141
- self::$instance->_clean_expired_vars();
142
- return self::$instance;
143
- }
144
-
145
-
146
- /************** PUBLIC STATIC METHODS **************/
147
-
148
- public static function session_start()
149
- {
150
- $instance = self::_get_instance();
151
- }
152
-
153
- public static function session_id()
154
- {
155
- $instance = self::_get_instance();
156
- return $instance->session_id;
157
- }
158
-
159
- public static function set_var( $name, $value )
160
- {
161
- $instance = self::_get_instance();
162
- $instance->_set_var( $name, $value );
163
- }
164
-
165
- public static function get_var( $name )
166
- {
167
- $instance = self::_get_instance();
168
- return $instance->_get_var( $name );
169
- }
170
-
171
- public static function unset_var( $name )
172
- {
173
- $instance = self::_get_instance();
174
- $instance->_unset_var( $name );
175
- }
176
-
177
- // Special methods for registering and recovering the forms submissions
178
- public static function register_event($eventid, $formid)
179
- {
180
- $cp_cff_form_data = self::get_var('cp_cff_form_data');
181
- if(empty($cp_cff_form_data)) $cp_cff_form_data = array();
182
-
183
- $cp_cff_form_data[$formid] = $eventid;
184
- $cp_cff_form_data['latest'] = $formid;
185
-
186
- self::set_var('cp_cff_form_data', $cp_cff_form_data);
187
- }
188
-
189
- public static function registered_events()
190
- {
191
- return self::get_var('cp_cff_form_data');
192
- }
193
- } // End clss
194
- }
195
- ?>
1
+ <?php
2
+ /**
3
+ * CodePeople Session.
4
+ *
5
+ * Standardizes WordPress session data using database-backed options for storage.
6
+ * for storing user session information.
7
+ */
8
+
9
+ if ( ! defined( 'CP_COOKIE_NAME' ) ) {
10
+ define( 'CP_COOKIE_NAME', 'CP5XKN6QLDFWUC' );
11
+ }
12
+
13
+ if ( ! class_exists( 'CP_SESSION' ) ) {
14
+ class CP_SESSION {
15
+
16
+
17
+ /************** STATIC PROPERTIES **************/
18
+ private static $instance = false;
19
+
20
+ /************** INSTANCE PROPERTIES **************/
21
+ private $session_id;
22
+ private $expiration;
23
+ private $cleaned_expired_vars = false;
24
+ private $expiration_interval = 86400; // 24 Hours
25
+
26
+ /************** CONSTRUCT **************/
27
+
28
+ private function __construct() {
29
+ if ( ! is_admin() ) {
30
+ return;
31
+ }
32
+ if ( session_id() == '' && ! headers_sent() ) {
33
+ @session_start();
34
+ }
35
+
36
+ if ( isset( $_SESSION[ CP_COOKIE_NAME ] ) || isset( $_COOKIE[ CP_COOKIE_NAME ] ) ) {
37
+ $cookie = sanitize_text_field( wp_unslash( ( isset( $_SESSION[ CP_COOKIE_NAME ] ) ) ? $_SESSION[ CP_COOKIE_NAME ] : $_COOKIE[ CP_COOKIE_NAME ] ) );
38
+
39
+ $cookie_crumbs = explode( '||', $cookie );
40
+
41
+ $this->session_id = $cookie_crumbs[0];
42
+ $this->expiration = $cookie_crumbs[1];
43
+ } else {
44
+ $this->session_id = $this->_generate_session_id();
45
+ $this->expiration = $this->expiration_interval;
46
+ $this->_set_cookie();
47
+ }
48
+
49
+ }
50
+
51
+ /************** PRIVATE INSTANCE METHODS **************/
52
+ private function _generate_session_id() {
53
+ require_once ABSPATH . 'wp-includes/class-phpass.php';
54
+ $hash = new PasswordHash( 8, false );
55
+
56
+ return md5( $hash->get_random_bytes( 32 ) );
57
+ }
58
+
59
+ private function _set_cookie() {
60
+ try {
61
+ $_SESSION[ CP_COOKIE_NAME ] = $this->session_id . '||' . $this->expiration;
62
+ if ( ! headers_sent() ) {
63
+ @setcookie( CP_COOKIE_NAME, $this->session_id . '||' . $this->expiration, 0, '/' );
64
+ }
65
+ } catch ( Exception $err ) {
66
+ error_log( $err->getMessage() );
67
+ }
68
+ }
69
+
70
+ private function _get_var_name( $name ) {
71
+ return CP_COOKIE_NAME . '_' . $this->session_id . '_' . $name;
72
+ }
73
+
74
+ private function _set_var( $name, $value ) {
75
+ $_SESSION[ $name ] = $value;
76
+ $transient = $this->_get_var_name( $name );
77
+ set_transient( $transient, $value, $this->expiration );
78
+ }
79
+
80
+ private function _get_var( $name ) {
81
+ if ( isset( $_SESSION[ $name ] ) ) {
82
+ return $_SESSION[ $name ];
83
+ }
84
+ $transient = $this->_get_var_name( $name );
85
+ return get_transient( $transient );
86
+ }
87
+
88
+ private function _unset_var( $name ) {
89
+ if ( isset( $_SESSION[ $name ] ) ) {
90
+ unset( $_SESSION[ $name ] );
91
+ }
92
+ $transient = $this->_get_var_name( $name );
93
+ delete_transient( $transient );
94
+ }
95
+
96
+ private function _clean_expired_vars() {
97
+ if ( $this->cleaned_expired_vars ) {
98
+ return;
99
+ }
100
+ $this->cleaned_expired_vars = true;
101
+
102
+ global $wpdb;
103
+
104
+ $expiration = time() - $this->expiration_interval;
105
+ try {
106
+ $transients = $wpdb->get_col(
107
+ $wpdb->prepare( "SELECT REPLACE(option_name, '_transient_timeout_', '') AS transient_name FROM {$wpdb->options} WHERE option_name LIKE %s AND option_value < %s", '_transient_timeout_' . $wpdb->esc_like( CP_COOKIE_NAME ) . '%', $expiration )
108
+ );
109
+
110
+ $options_names = array();
111
+ foreach ( $transients as $transient ) {
112
+ if ( strpos( $transient, $this->session_id ) === false ) {
113
+ $options_names[] = '_transient_' . $transient;
114
+ $options_names[] = '_transient_timeout_' . $transient;
115
+ }
116
+ }
117
+
118
+ if ( ! empty( $options_names ) ) {
119
+ $options_names = array_map( 'esc_sql', $options_names );
120
+ $options_names = "'" . implode( "','", $options_names ) . "'";
121
+ $result = $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name IN ({$options_names})" ); // @codingStandardsIgnoreLine.
122
+
123
+ }
124
+ } catch ( Exception $err ) {
125
+ error_log( $err->getMassage() );
126
+ }
127
+ }
128
+ /************** PUBLIC INSTANCE METHODS **************/
129
+
130
+ /************** PRIVATE STATIC METHODS **************/
131
+
132
+ private static function _get_instance() {
133
+ if ( ! self::$instance ) {
134
+ self::$instance = new self();
135
+ }
136
+ self::$instance->_clean_expired_vars();
137
+ return self::$instance;
138
+ }
139
+
140
+
141
+ /************** PUBLIC STATIC METHODS **************/
142
+
143
+ public static function session_start() {
144
+ $instance = self::_get_instance();
145
+ }
146
+
147
+ public static function session_id() {
148
+ $instance = self::_get_instance();
149
+ return $instance->session_id;
150
+ }
151
+
152
+ public static function set_var( $name, $value ) {
153
+ $instance = self::_get_instance();
154
+ $instance->_set_var( $name, $value );
155
+ }
156
+
157
+ public static function get_var( $name ) {
158
+ $instance = self::_get_instance();
159
+ return $instance->_get_var( $name );
160
+ }
161
+
162
+ public static function unset_var( $name ) {
163
+ $instance = self::_get_instance();
164
+ $instance->_unset_var( $name );
165
+ }
166
+
167
+ // Special methods for registering and recovering the forms submissions
168
+ public static function register_event( $eventid, $formid ) {
169
+ $cp_cff_form_data = self::get_var( 'cp_cff_form_data' );
170
+ if ( empty( $cp_cff_form_data ) ) {
171
+ $cp_cff_form_data = array();
172
+ }
173
+
174
+ $cp_cff_form_data[ $formid ] = $eventid;
175
+ $cp_cff_form_data['latest'] = $formid;
176
+
177
+ self::set_var( 'cp_cff_form_data', $cp_cff_form_data );
178
+ }
179
+
180
+ public static function registered_events() {
181
+ return self::get_var( 'cp_cff_form_data' );
182
+ }
183
+ } // End clss
184
+ }
185
+
 
 
 
 
 
 
 
 
 
 
inc/cpcff_templates.inc.php CHANGED
@@ -1,175 +1,154 @@
1
- <?php
2
- /**
3
- * Templates operations: CPCFF_TEMPLATES class
4
- *
5
- * Implements the access to forms templates.
6
- *
7
- * @package CFF.
8
- * @since 1.0.175
9
- */
10
-
11
- if(!class_exists('CPCFF_TEMPLATES'))
12
- {
13
- class CPCFF_TEMPLATES
14
- {
15
- /**
16
- * Flag to know if the templates directory was checked and the templates loaded
17
- * Metaclass property.
18
- *
19
- * @var bool $_are_templates_loaded default false
20
- */
21
- private static $_are_templates_loaded = false;
22
-
23
- /**
24
- * Templates list
25
- * Metaclass property.
26
- *
27
- * @var array $_templates_list default empty array
28
- */
29
- private static $_templates_list = array();
30
-
31
- /**
32
- * List of templates whose resources were enqueued or sent to the browser
33
- * Metaclass property.
34
- *
35
- * @var array $_enqueued_list default empty array
36
- */
37
- private static $_enqueued_list = array();
38
-
39
- /**
40
- * Loads the templates list
41
- *
42
- * Walks through the "templates" directory for reading and parsing the corresponding config.ini files to identify the
43
- * the styles files, the javascript files, the templates' thumbnails, and the prefixes to identify the templates
44
- * and grouping the CSS rules to apply for the templates.
45
- *
46
- * @return array of associative arrays with the templates attributess.
47
- */
48
- public static function load_templates()
49
- {
50
- if( !self::$_are_templates_loaded )
51
- {
52
- self::$_are_templates_loaded = true;
53
- $tpls_dir_paths = [
54
- [
55
- 'path' => CP_CALCULATEDFIELDSF_BASE_PATH.'/templates',
56
- 'url' => plugins_url( 'templates', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH )
57
- ]
58
- ];
59
-
60
- $upload_dir = wp_upload_dir();
61
-
62
- if(
63
- !$upload_dir['error'] &&
64
- file_exists($upload_dir['basedir'].'/calculated-fields-form/templates') &&
65
- is_dir($upload_dir['basedir'].'/calculated-fields-form/templates')
66
- )
67
- {
68
- $tpls_dir_paths[] = [
69
- 'path' => $upload_dir['basedir'].'/calculated-fields-form/templates',
70
- 'url' => $upload_dir['baseurl'].'/calculated-fields-form/templates'
71
- ];
72
- }
73
-
74
- foreach($tpls_dir_paths as $path)
75
- {
76
- $tpls_dir = dir( $path['path'] );
77
- while( false !== ( $entry = $tpls_dir->read() ) )
78
- {
79
- if (
80
- $entry != '.' &&
81
- $entry != '..' &&
82
- is_dir( $tpls_dir->path.'/'.$entry ) &&
83
- file_exists( $tpls_dir->path.'/'.$entry.'/config.ini' )
84
- )
85
- {
86
- if(
87
- (function_exists('parse_ini_file') && ( $ini_array = parse_ini_file( $tpls_dir->path.'/'.$entry.'/config.ini' ) ) != false) ||
88
- (function_exists('parse_ini_string') && ( $ini_array = parse_ini_string( file_get_contents( $tpls_dir->path.'/'.$entry.'/config.ini' ) ) ) != false)
89
- )
90
- {
91
- if(
92
- isset($ini_array[ 'prefix' ]) &&
93
- ($prefix = trim($ini_array[ 'prefix' ])) != ''
94
- )
95
- {
96
- // Url to the CSS file
97
- if( !empty( $ini_array['file'] ) ) $ini_array['file'] = $path['url'].'/'.$entry.'/'.$ini_array['file'];
98
-
99
- // Url to the JS file
100
- if( !empty( $ini_array['js'] ) ) $ini_array[ 'js' ] = $path['url'].'/'.$entry.'/'.$ini_array['js'];
101
-
102
- // Url to the thumbnail file
103
- if( !empty( $ini_array['thumbnail'] ) ) $ini_array['thumbnail'] = $path['url'].'/'.$entry.'/'.$ini_array['thumbnail'];
104
-
105
- // Required attribute to identify the template
106
- // and it is used as super-class-name for grouping styles to apply for the template
107
- self::$_templates_list[$prefix] = $ini_array;
108
- }
109
- }
110
- }
111
- }
112
- }
113
- }
114
-
115
- return self::$_templates_list;
116
- } // End load_templates
117
-
118
- /**
119
- * Enqueues or sends to the browser the template's resources (CSS and JS files)
120
- *
121
- * Loads the templates if they have not been loaded previously.
122
- * Checks if the resources of current template were enqueued previously to prevent to load the resources by duplicated.
123
- * Checks if the resources should be enqueued, or sent to the browser directly.
124
- *
125
- * @return void.
126
- */
127
- public static function enqueue_template_resources( $template )
128
- {
129
- $template = trim($template);
130
- $templates = self::load_templates();
131
-
132
- if(in_array($template, self::$_enqueued_list)) return;
133
- self::$_enqueued_list[] = $template; // The template's resources were enqueued
134
-
135
- if(!empty($templates[$template]))
136
- {
137
- $template_info = $templates[$template];
138
-
139
- if(
140
- !empty($template_info['file']) &&
141
- ($css = trim($template_info['file'])) != ''
142
- )
143
- {
144
- if($GLOBALS['CP_CALCULATEDFIELDSF_DEFAULT_DEFER_SCRIPTS_LOADING'])
145
- {
146
- wp_enqueue_style( 'cpcff_template_css'.$template, $css, array(), CP_CALCULATEDFIELDSF_VERSION );
147
- }
148
- else
149
- {
150
- $css .= (strpos($css,'?') === false) ? '?' : '&';
151
- print '<link href="'.esc_attr(esc_url($css)).'ver='.CP_CALCULATEDFIELDSF_VERSION.'" type="text/css" rel="stylesheet" property="stylesheet" />';
152
- }
153
- }
154
-
155
- if(
156
- !empty($template_info['js']) &&
157
- ($js = trim($template_info['js'])) != ''
158
- )
159
- {
160
- if($GLOBALS['CP_CALCULATEDFIELDSF_DEFAULT_DEFER_SCRIPTS_LOADING'])
161
- {
162
- wp_enqueue_script( 'cpcff_template_js'.$template, $js, array(), CP_CALCULATEDFIELDSF_VERSION );
163
- }
164
- else
165
- {
166
- $js .= (strpos($js,'?') === false) ? '?' : '&';
167
- print '<script src="'.esc_attr(esc_url($js)).'ver='.CP_CALCULATEDFIELDSF_VERSION.'"></script>';
168
- }
169
- }
170
- }
171
- } // End enqueue_template_resources
172
-
173
- } // End CPCFF_TEMPLATES
174
- }
175
- ?>
1
+ <?php
2
+ /**
3
+ * Templates operations: CPCFF_TEMPLATES class
4
+ *
5
+ * Implements the access to forms templates.
6
+ *
7
+ * @package CFF.
8
+ * @since 1.0.175
9
+ */
10
+
11
+ if ( ! class_exists( 'CPCFF_TEMPLATES' ) ) {
12
+ class CPCFF_TEMPLATES {
13
+
14
+ /**
15
+ * Flag to know if the templates directory was checked and the templates loaded
16
+ * Metaclass property.
17
+ *
18
+ * @var bool $_are_templates_loaded default false
19
+ */
20
+ private static $_are_templates_loaded = false;
21
+
22
+ /**
23
+ * Templates list
24
+ * Metaclass property.
25
+ *
26
+ * @var array $_templates_list default empty array
27
+ */
28
+ private static $_templates_list = array();
29
+
30
+ /**
31
+ * List of templates whose resources were enqueued or sent to the browser
32
+ * Metaclass property.
33
+ *
34
+ * @var array $_enqueued_list default empty array
35
+ */
36
+ private static $_enqueued_list = array();
37
+
38
+ /**
39
+ * Loads the templates list
40
+ *
41
+ * Walks through the "templates" directory for reading and parsing the corresponding config.ini files to identify the
42
+ * the styles files, the javascript files, the templates' thumbnails, and the prefixes to identify the templates
43
+ * and grouping the CSS rules to apply for the templates.
44
+ *
45
+ * @return array of associative arrays with the templates attributess.
46
+ */
47
+ public static function load_templates() {
48
+ if ( ! self::$_are_templates_loaded ) {
49
+ self::$_are_templates_loaded = true;
50
+ $tpls_dir_paths = array(
51
+ array(
52
+ 'path' => CP_CALCULATEDFIELDSF_BASE_PATH . '/templates',
53
+ 'url' => plugins_url( 'templates', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ),
54
+ ),
55
+ );
56
+
57
+ $upload_dir = wp_upload_dir();
58
+
59
+ if (
60
+ ! $upload_dir['error'] &&
61
+ file_exists( $upload_dir['basedir'] . '/calculated-fields-form/templates' ) &&
62
+ is_dir( $upload_dir['basedir'] . '/calculated-fields-form/templates' )
63
+ ) {
64
+ $tpls_dir_paths[] = array(
65
+ 'path' => $upload_dir['basedir'] . '/calculated-fields-form/templates',
66
+ 'url' => $upload_dir['baseurl'] . '/calculated-fields-form/templates',
67
+ );
68
+ }
69
+
70
+ foreach ( $tpls_dir_paths as $path ) {
71
+ $tpls_dir = dir( $path['path'] );
72
+ while ( false !== ( $entry = $tpls_dir->read() ) ) {
73
+ if (
74
+ '.' != $entry &&
75
+ '..' != $entry &&
76
+ is_dir( $tpls_dir->path . '/' . $entry ) &&
77
+ file_exists( $tpls_dir->path . '/' . $entry . '/config.ini' )
78
+ ) {
79
+ if (
80
+ ( function_exists( 'parse_ini_file' ) && ( $ini_array = parse_ini_file( $tpls_dir->path . '/' . $entry . '/config.ini' ) ) != false ) || ( function_exists( 'parse_ini_string' ) && ( $ini_array = parse_ini_string( file_get_contents( $tpls_dir->path . '/' . $entry . '/config.ini' ) ) ) != false ) // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments
81
+ ) {
82
+ if ( isset( $ini_array['prefix'] ) && ( $prefix = trim( $ini_array['prefix'] ) ) != '' ) { // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments
83
+ // Url to the CSS file
84
+ if ( ! empty( $ini_array['file'] ) ) {
85
+ $ini_array['file'] = $path['url'] . '/' . $entry . '/' . $ini_array['file'];
86
+ }
87
+
88
+ // Url to the JS file
89
+ if ( ! empty( $ini_array['js'] ) ) {
90
+ $ini_array['js'] = $path['url'] . '/' . $entry . '/' . $ini_array['js'];
91
+ }
92
+
93
+ // Url to the thumbnail file
94
+ if ( ! empty( $ini_array['thumbnail'] ) ) {
95
+ $ini_array['thumbnail'] = $path['url'] . '/' . $entry . '/' . $ini_array['thumbnail'];
96
+ }
97
+
98
+ // Required attribute to identify the template
99
+ // and it is used as super-class-name for grouping styles to apply for the template
100
+ self::$_templates_list[ $prefix ] = $ini_array;
101
+ }
102
+ }
103
+ }
104
+ }
105
+ }
106
+ }
107
+
108
+ return self::$_templates_list;
109
+ } // End load_templates
110
+
111
+ /**
112
+ * Enqueues or sends to the browser the template's resources (CSS and JS files)
113
+ *
114
+ * Loads the templates if they have not been loaded previously.
115
+ * Checks if the resources of current template were enqueued previously to prevent to load the resources by duplicated.
116
+ * Checks if the resources should be enqueued, or sent to the browser directly.
117
+ *
118
+ * @return void.
119
+ */
120
+ public static function enqueue_template_resources( $template ) {
121
+ $template = trim( $template );
122
+ $templates = self::load_templates();
123
+
124
+ if ( in_array( $template, self::$_enqueued_list ) ) {
125
+ return;
126
+ }
127
+ self::$_enqueued_list[] = $template; // The template's resources were enqueued
128
+
129
+ if ( ! empty( $templates[ $template ] ) ) {
130
+ $template_info = $templates[ $template ];
131
+
132
+ if ( ! empty( $template_info['file'] ) && ( $css = trim( $template_info['file'] ) ) != '' ) { // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments
133
+ if ( $GLOBALS['CP_CALCULATEDFIELDSF_DEFAULT_DEFER_SCRIPTS_LOADING'] ) {
134
+ wp_enqueue_style( 'cpcff_template_css' . $template, $css, array(), CP_CALCULATEDFIELDSF_VERSION );
135
+ } else {
136
+ $css .= ( strpos( $css, '?' ) === false ) ? '?' : '&';
137
+ print '<link href="' . esc_attr( esc_url( $css ) ) . 'ver=' . esc_attr( CP_CALCULATEDFIELDSF_VERSION ) . '" type="text/css" rel="stylesheet" property="stylesheet" />'; // phpcs:ignore WordPress.WP.EnqueuedResources
138
+ }
139
+ }
140
+
141
+ if ( ! empty( $template_info['js'] ) && ( $js = trim( $template_info['js'] ) ) != '' ) { // phpcs:ignore Squiz.PHP.DisallowMultipleAssignments
142
+ if ( $GLOBALS['CP_CALCULATEDFIELDSF_DEFAULT_DEFER_SCRIPTS_LOADING'] ) {
143
+ wp_enqueue_script( 'cpcff_template_js' . $template, $js, array(), CP_CALCULATEDFIELDSF_VERSION );
144
+ } else {
145
+ $js .= ( strpos( $js, '?' ) === false ) ? '?' : '&';
146
+ print '<script src="' . esc_attr( esc_url( $js ) ) . 'ver=' . esc_attr( CP_CALCULATEDFIELDSF_VERSION ) . '"></script>'; // phpcs:ignore WordPress.WP.EnqueuedResources
147
+ }
148
+ }
149
+ }
150
+ } // End enqueue_template_resources
151
+
152
+ } // End CPCFF_TEMPLATES
153
+ }
154
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/cpcff_trial.php CHANGED
@@ -1,61 +1,66 @@
1
- <?php
2
- /**
3
- * Allows to install the trial version of Professional distribution: CPCFF_TRIAL class
4
- * @package CFF.
5
- * @since 1.1.14
6
- */
7
-
8
- if(!class_exists('CPCFF_TRIAL'))
9
- {
10
- class CPCFF_TRIAL
11
- {
12
- /**
13
- * Main plugin object
14
- */
15
- private $_main_obj;
16
- private $_url = 'https://wordpress.dwbooster.com/trial/get.php';
17
-
18
- public function __construct()
19
- {
20
- add_action( 'admin_init', array($this, 'init') );
21
- } // End __construct
22
-
23
- /**
24
- * Install TRIAL
25
- * @return void.
26
- */
27
- public function init()
28
- {
29
- if(!empty($_GET['cff-install-trial']) && current_user_can('manage_options')) $this->_install_plugin();
30
- } // End init
31
-
32
- private function _install_plugin()
33
- {
34
- try
35
- {
36
- $response = wp_remote_get($this->_url.'?action=check', array('body'=>array('u'=>CPCFF_AUXILIARY::site_url()),'sslverify'=>false));
37
- if(!is_wp_error($response))
38
- {
39
- $body = wp_remote_retrieve_body($response);
40
- if($body != 'ok') update_option('cff-t-t', $body);
41
- else
42
- {
43
- include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
44
- wp_cache_flush();
45
- $installer = new Plugin_Upgrader();
46
- $installed = $installer->install($this->_url, ['overwrite_package' => true]);
47
- if($installed)
48
- {
49
- update_option('cff-t-d', time());
50
- print '<script>document.location.href="'.esc_js(remove_query_arg('cff-install-trial', false)).'#cff-upgrade-frame";</script>';
51
- exit;
52
- }
53
- }
54
- }
55
- }
56
- catch(Exception $err){print $err->getMessage();exit;}
57
- } // End _install_plugin
58
- } // End Class CPCFF_TRIAL
59
-
60
- new CPCFF_TRIAL();
61
- }
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Allows to install the trial version of Professional distribution: CPCFF_TRIAL class
4
+ *
5
+ * @package CFF.
6
+ * @since 1.1.14
7
+ */
8
+
9
+ if ( ! class_exists( 'CPCFF_TRIAL' ) ) {
10
+ class CPCFF_TRIAL {
11
+
12
+ /**
13
+ * Main plugin object
14
+ */
15
+ private $_main_obj;
16
+ private $_url = 'https://wordpress.dwbooster.com/trial/get.php';
17
+
18
+ public function __construct() {
19
+ add_action( 'admin_init', array( $this, 'init' ) );
20
+ } // End __construct
21
+
22
+ /**
23
+ * Install TRIAL
24
+ *
25
+ * @return void.
26
+ */
27
+ public function init() {
28
+ if ( ! empty( $_GET['cff-install-trial'] ) && current_user_can( 'manage_options' ) ) {
29
+ $this->_install_plugin();
30
+ }
31
+ } // End init
32
+
33
+ private function _install_plugin() {
34
+ try {
35
+ $response = wp_remote_get(
36
+ $this->_url . '?action=check',
37
+ array(
38
+ 'body' => array( 'u' => CPCFF_AUXILIARY::site_url() ),
39
+ 'sslverify' => false,
40
+ )
41
+ );
42
+ if ( ! is_wp_error( $response ) ) {
43
+ $body = wp_remote_retrieve_body( $response );
44
+ if ( 'ok' != $body ) {
45
+ update_option( 'cff-t-t', $body );
46
+ } else {
47
+ include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
48
+ wp_cache_flush();
49
+ $installer = new Plugin_Upgrader();
50
+ $installed = $installer->install( $this->_url, array( 'overwrite_package' => true ) );
51
+ if ( $installed ) {
52
+ update_option( 'cff-t-d', time() );
53
+ print '<script>document.location.href="' . esc_js( remove_query_arg( 'cff-install-trial', false ) ) . '#cff-upgrade-frame";</script>';
54
+ exit;
55
+ }
56
+ }
57
+ }
58
+ } catch ( Exception $err ) {
59
+ print esc_html( $err->getMessage() );
60
+ exit;
61
+ }
62
+ } // End _install_plugin
63
+ } // End Class CPCFF_TRIAL
64
+
65
+ new CPCFF_TRIAL();
66
+ }
js/JSMin.php CHANGED
@@ -55,374 +55,365 @@
55
  */
56
 
57
  class JSMin {
58
- const ORD_LF = 10;
59
- const ORD_SPACE = 32;
60
- const ACTION_KEEP_A = 1;
61
- const ACTION_DELETE_A = 2;
62
- const ACTION_DELETE_A_B = 3;
63
 
64
- protected $a = "\n";
65
- protected $b = '';
66
- protected $input = '';
67
- protected $inputIndex = 0;
68
- protected $inputLength = 0;
69
- protected $lookAhead = null;
70
- protected $output = '';
71
- protected $lastByteOut = '';
72
- protected $keptComment = '';
73
 
74
- /**
75
- * Minify Javascript.
76
- *
77
- * @param string $js Javascript to be minified
78
- *
79
- * @return string
80
- */
81
- public static function minify($js)
82
- {
83
- $jsmin = new JSMin($js);
84
- return $jsmin->min();
85
- }
86
 
87
- /**
88
- * @param string $input
89
- */
90
- public function __construct($input)
91
- {
92
- $this->input = $input;
93
- }
94
 
95
- /**
96
- * Perform minification, return result
97
- *
98
- * @return string
99
- */
100
- public function min()
101
- {
102
- if ($this->output !== '') { // min already run
103
- return $this->output;
104
- }
105
 
106
- $mbIntEnc = null;
107
- $this->input = str_replace("\r\n", "\n", $this->input);
108
- $this->inputLength = strlen($this->input);
109
 
110
- $this->action(self::ACTION_DELETE_A_B);
111
 
112
- while ($this->a !== null) {
113
- // determine next command
114
- $command = self::ACTION_KEEP_A; // default
115
- if ($this->a === ' ') {
116
- if (($this->lastByteOut === '+' || $this->lastByteOut === '-')
117
- && ($this->b === $this->lastByteOut)) {
118
- // Don't delete this space. If we do, the addition/subtraction
119
- // could be parsed as a post-increment
120
- } elseif (! $this->isAlphaNum($this->b)) {
121
- $command = self::ACTION_DELETE_A;
122
- }
123
- } elseif ($this->a === "\n") {
124
- if ($this->b === ' ') {
125
- $command = self::ACTION_DELETE_A_B;
126
- } elseif ($this->b === null
127
- || (false === strpos('{[(+-!~', $this->b)
128
- && ! $this->isAlphaNum($this->b))) {
129
- $command = self::ACTION_DELETE_A;
130
- }
131
- } elseif (! $this->isAlphaNum($this->a)) {
132
- if ($this->b === ' '
133
- || ($this->b === "\n"
134
- && (false === strpos('}])+-"\'', $this->a)))) {
135
- $command = self::ACTION_DELETE_A_B;
136
- }
137
- }
138
- $this->action($command);
139
- }
140
- $this->output = trim($this->output);
141
 
142
- if ($mbIntEnc !== null) {
143
- mb_internal_encoding($mbIntEnc);
144
- }
145
- return $this->output;
146
- }
147
 
148
- /**
149
- * ACTION_KEEP_A = Output A. Copy B to A. Get the next B.
150
- * ACTION_DELETE_A = Copy B to A. Get the next B.
151
- * ACTION_DELETE_A_B = Get the next B.
152
- *
153
- * @param int $command
154
- * @throws JSMin_UnterminatedRegExpException|JSMin_UnterminatedStringException
155
- */
156
- protected function action($command)
157
- {
158
- // make sure we don't compress "a + ++b" to "a+++b", etc.
159
- if ($command === self::ACTION_DELETE_A_B
160
- && $this->b === ' '
161
- && ($this->a === '+' || $this->a === '-')) {
162
- // Note: we're at an addition/substraction operator; the inputIndex
163
- // will certainly be a valid index
164
- if ($this->input[$this->inputIndex] === $this->a) {
165
- // This is "+ +" or "- -". Don't delete the space.
166
- $command = self::ACTION_KEEP_A;
167
- }
168
- }
169
 
170
- switch ($command) {
171
- case self::ACTION_KEEP_A: // 1
172
- $this->output .= $this->a;
173
 
174
- if ($this->keptComment) {
175
- $this->output = rtrim($this->output, "\n");
176
- $this->output .= $this->keptComment;
177
- $this->keptComment = '';
178
- }
179
 
180
- $this->lastByteOut = $this->a;
181
 
182
- // fallthrough intentional
183
- case self::ACTION_DELETE_A: // 2
184
- $this->a = $this->b;
185
- if ($this->a === "'" || $this->a === '"') { // string literal
186
- $str = $this->a; // in case needed for exception
187
- for(;;) {
188
- $this->output .= $this->a;
189
- $this->lastByteOut = $this->a;
190
 
191
- $this->a = $this->get();
192
- if ($this->a === $this->b) { // end quote
193
- break;
194
- }
195
- if ($this->isEOF($this->a)) {
196
- throw new JSMin_UnterminatedStringException(
197
- "JSMin: Unterminated String at byte {$this->inputIndex}: {$str}");
198
- }
199
- $str .= $this->a;
200
- if ($this->a === '\\') {
201
- $this->output .= $this->a;
202
- $this->lastByteOut = $this->a;
 
203
 
204
- $this->a = $this->get();
205
- $str .= $this->a;
206
- }
207
- }
208
- }
209
 
210
- // fallthrough intentional
211
- case self::ACTION_DELETE_A_B: // 3
212
- $this->b = $this->next();
213
- if ($this->b === '/' && $this->isRegexpLiteral()) {
214
- $this->output .= $this->a . $this->b;
215
- $pattern = '/'; // keep entire pattern in case we need to report it in the exception
216
- for(;;) {
217
- $this->a = $this->get();
218
- $pattern .= $this->a;
219
- if ($this->a === '[') {
220
- for(;;) {
221
- $this->output .= $this->a;
222
- $this->a = $this->get();
223
- $pattern .= $this->a;
224
- if ($this->a === ']') {
225
- break;
226
- }
227
- if ($this->a === '\\') {
228
- $this->output .= $this->a;
229
- $this->a = $this->get();
230
- $pattern .= $this->a;
231
- }
232
- if ($this->isEOF($this->a)) {
233
- throw new JSMin_UnterminatedRegExpException(
234
- "JSMin: Unterminated set in RegExp at byte "
235
- . $this->inputIndex .": {$pattern}");
236
- }
237
- }
238
- }
 
239
 
240
- if ($this->a === '/') { // end pattern
241
- break; // while (true)
242
- } elseif ($this->a === '\\') {
243
- $this->output .= $this->a;
244
- $this->a = $this->get();
245
- $pattern .= $this->a;
246
- } elseif ($this->isEOF($this->a)) {
247
- throw new JSMin_UnterminatedRegExpException(
248
- "JSMin: Unterminated RegExp at byte {$this->inputIndex}: {$pattern}");
249
- }
250
- $this->output .= $this->a;
251
- $this->lastByteOut = $this->a;
252
- }
253
- $this->b = $this->next();
254
- }
255
- // end case ACTION_DELETE_A_B
256
- }
257
- }
 
258
 
259
- /**
260
- * @return bool
261
- */
262
- protected function isRegexpLiteral()
263
- {
264
- if (false !== strpos("(,=:[!&|?+-~*{;", $this->a)) {
265
- // we obviously aren't dividing
266
- return true;
267
- }
268
- if ($this->a === ' ' || $this->a === "\n") {
269
- $length = strlen($this->output);
270
- if ($length < 2) { // weird edge case
271
- return true;
272
- }
273
- // you can't divide a keyword
274
- if (preg_match('/(?:case|else|in|return|typeof)$/', $this->output, $m)) {
275
- if ($this->output === $m[0]) { // odd but could happen
276
- return true;
277
- }
278
- // make sure it's a keyword, not end of an identifier
279
- $charBeforeKeyword = substr($this->output, $length - strlen($m[0]) - 1, 1);
280
- if (! $this->isAlphaNum($charBeforeKeyword)) {
281
- return true;
282
- }
283
- }
284
- }
285
- return false;
286
- }
287
 
288
- /**
289
- * Return the next character from stdin. Watch out for lookahead. If the character is a control character,
290
- * translate it to a space or linefeed.
291
- *
292
- * @return string
293
- */
294
- protected function get()
295
- {
296
- $c = $this->lookAhead;
297
- $this->lookAhead = null;
298
- if ($c === null) {
299
- // getc(stdin)
300
- if ($this->inputIndex < $this->inputLength) {
301
- $c = $this->input[$this->inputIndex];
302
- $this->inputIndex += 1;
303
- } else {
304
- $c = null;
305
- }
306
- }
307
- if (ord($c) >= self::ORD_SPACE || $c === "\n" || $c === null) {
308
- return $c;
309
- }
310
- if ($c === "\r") {
311
- return "\n";
312
- }
313
- return ' ';
314
- }
315
 
316
- /**
317
- * Does $a indicate end of input?
318
- *
319
- * @param string $a
320
- * @return bool
321
- */
322
- protected function isEOF($a)
323
- {
324
- return ord($a) <= self::ORD_LF;
325
- }
326
 
327
- /**
328
- * Get next char (without getting it). If is ctrl character, translate to a space or newline.
329
- *
330
- * @return string
331
- */
332
- protected function peek()
333
- {
334
- $this->lookAhead = $this->get();
335
- return $this->lookAhead;
336
- }
337
 
338
- /**
339
- * Return true if the character is a letter, digit, underscore, dollar sign, or non-ASCII character.
340
- *
341
- * @param string $c
342
- *
343
- * @return bool
344
- */
345
- protected function isAlphaNum($c)
346
- {
347
- return (preg_match('/^[a-z0-9A-Z_\\$\\\\]$/', $c) || ord($c) > 126);
348
- }
349
 
350
- /**
351
- * Consume a single line comment from input (possibly retaining it)
352
- */
353
- protected function consumeSingleLineComment()
354
- {
355
- $comment = '';
356
- while (true) {
357
- $get = $this->get();
358
- $comment .= $get;
359
- if (ord($get) <= self::ORD_LF) { // end of line reached
360
- // if IE conditional comment
361
- if (preg_match('/^\\/@(?:cc_on|if|elif|else|end)\\b/', $comment)) {
362
- $this->keptComment .= "/{$comment}";
363
- }
364
- return;
365
- }
366
- }
367
- }
368
 
369
- /**
370
- * Consume a multiple line comment from input (possibly retaining it)
371
- *
372
- * @throws JSMin_UnterminatedCommentException
373
- */
374
- protected function consumeMultipleLineComment()
375
- {
376
- $this->get();
377
- $comment = '';
378
- for(;;) {
379
- $get = $this->get();
380
- if ($get === '*') {
381
- if ($this->peek() === '/') { // end of comment reached
382
- $this->get();
383
- if (0 === strpos($comment, '!')) {
384
- // preserved by YUI Compressor
385
- if (!$this->keptComment) {
386
- // don't prepend a newline if two comments right after one another
387
- $this->keptComment = "\n";
388
- }
389
- $this->keptComment .= "/*!" . substr($comment, 1) . "*/\n";
390
- } else if (preg_match('/^@(?:cc_on|if|elif|else|end)\\b/', $comment)) {
391
- // IE conditional
392
- $this->keptComment .= "/*{$comment}*/";
393
- }
394
- return;
395
- }
396
- } elseif ($get === null) {
397
- throw new JSMin_UnterminatedCommentException(
398
- "JSMin: Unterminated comment at byte {$this->inputIndex}: /*{$comment}");
399
- }
400
- $comment .= $get;
401
- }
402
- }
403
 
404
- /**
405
- * Get the next character, skipping over comments. Some comments may be preserved.
406
- *
407
- * @return string
408
- */
409
- protected function next()
410
- {
411
- $get = $this->get();
412
- if ($get === '/') {
413
- switch ($this->peek()) {
414
- case '/':
415
- $this->consumeSingleLineComment();
416
- $get = "\n";
417
- break;
418
- case '*':
419
- $this->consumeMultipleLineComment();
420
- $get = ' ';
421
- break;
422
- }
423
- }
424
- return $get;
425
- }
426
  }
427
 
428
  class JSMin_UnterminatedStringException extends Exception {}
55
  */
56
 
57
  class JSMin {
58
+ const ORD_LF = 10;
59
+ const ORD_SPACE = 32;
60
+ const ACTION_KEEP_A = 1;
61
+ const ACTION_DELETE_A = 2;
62
+ const ACTION_DELETE_A_B = 3;
63
 
64
+ protected $a = "\n";
65
+ protected $b = '';
66
+ protected $input = '';
67
+ protected $inputIndex = 0;
68
+ protected $inputLength = 0;
69
+ protected $lookAhead = null;
70
+ protected $output = '';
71
+ protected $lastByteOut = '';
72
+ protected $keptComment = '';
73
 
74
+ /**
75
+ * Minify Javascript.
76
+ *
77
+ * @param string $js Javascript to be minified
78
+ *
79
+ * @return string
80
+ */
81
+ public static function minify( $js ) {
82
+ $jsmin = new JSMin( $js );
83
+ return $jsmin->min();
84
+ }
 
85
 
86
+ /**
87
+ * @param string $input
88
+ */
89
+ public function __construct( $input ) {
90
+ $this->input = $input;
91
+ }
 
92
 
93
+ /**
94
+ * Perform minification, return result
95
+ *
96
+ * @return string
97
+ */
98
+ public function min() {
99
+ if ( '' !== $this->output ) { // min already run
100
+ return $this->output;
101
+ }
 
102
 
103
+ $mbIntEnc = null;
104
+ $this->input = str_replace( "\r\n", "\n", $this->input );
105
+ $this->inputLength = strlen( $this->input );
106
 
107
+ $this->action( self::ACTION_DELETE_A_B );
108
 
109
+ while ( null !== $this->a ) {
110
+ // determine next command
111
+ $command = self::ACTION_KEEP_A; // default
112
+ if ( ' ' === $this->a ) {
113
+ if ( ( '+' === $this->lastByteOut || '-' === $this->lastByteOut ) && $this->b === $this->lastByteOut ) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement
114
+ // Don't delete this space. If we do, the addition/subtraction
115
+ // could be parsed as a post-increment
116
+ } elseif ( ! $this->isAlphaNum( $this->b ) ) {
117
+ $command = self::ACTION_DELETE_A;
118
+ }
119
+ } elseif ( "\n" === $this->a ) {
120
+ if ( ' ' === $this->b ) {
121
+ $command = self::ACTION_DELETE_A_B;
122
+ } elseif ( null === $this->b
123
+ || ( false === strpos( '{[(+-!~', $this->b )
124
+ && ! $this->isAlphaNum( $this->b ) ) ) {
125
+ $command = self::ACTION_DELETE_A;
126
+ }
127
+ } elseif ( ! $this->isAlphaNum( $this->a ) ) {
128
+ if ( ' ' === $this->b
129
+ || ( "\n" === $this->b
130
+ && ( false === strpos( '}])+-"\'', $this->a ) ) ) ) {
131
+ $command = self::ACTION_DELETE_A_B;
132
+ }
133
+ }
134
+ $this->action( $command );
135
+ }
136
+ $this->output = trim( $this->output );
 
137
 
138
+ if ( null !== $mbIntEnc ) {
139
+ mb_internal_encoding( $mbIntEnc );
140
+ }
141
+ return $this->output;
142
+ }
143
 
144
+ /**
145
+ * ACTION_KEEP_A = Output A. Copy B to A. Get the next B.
146
+ * ACTION_DELETE_A = Copy B to A. Get the next B.
147
+ * ACTION_DELETE_A_B = Get the next B.
148
+ *
149
+ * @param int $command
150
+ * @throws JSMin_UnterminatedRegExpException|JSMin_UnterminatedStringException
151
+ */
152
+ protected function action( $command ) {
153
+ // make sure we don't compress "a + ++b" to "a+++b", etc.
154
+ if ( self::ACTION_DELETE_A_B === $command
155
+ && ' ' === $this->b
156
+ && ( '+' === $this->a || '-' === $this->a ) ) {
157
+ // Note: we're at an addition/substraction operator; the inputIndex
158
+ // will certainly be a valid index
159
+ if ( $this->input[ $this->inputIndex ] === $this->a ) {
160
+ // This is "+ +" or "- -". Don't delete the space.
161
+ $command = self::ACTION_KEEP_A;
162
+ }
163
+ }
 
164
 
165
+ switch ( $command ) {
166
+ case self::ACTION_KEEP_A: // 1
167
+ $this->output .= $this->a;
168
 
169
+ if ( $this->keptComment ) {
170
+ $this->output = rtrim( $this->output, "\n" );
171
+ $this->output .= $this->keptComment;
172
+ $this->keptComment = '';
173
+ }
174
 
175
+ $this->lastByteOut = $this->a;
176
 
177
+ // fallthrough intentional
178
+ case self::ACTION_DELETE_A: // 2
179
+ $this->a = $this->b;
180
+ if ( "'" === $this->a || '"' === $this->a ) { // string literal
181
+ $str = $this->a; // in case needed for exception
182
+ for ( ;; ) {
183
+ $this->output .= $this->a;
184
+ $this->lastByteOut = $this->a;
185
 
186
+ $this->a = $this->get();
187
+ if ( $this->a === $this->b ) { // end quote
188
+ break;
189
+ }
190
+ if ( $this->isEOF( $this->a ) ) {
191
+ throw new JSMin_UnterminatedStringException(
192
+ "JSMin: Unterminated String at byte {$this->inputIndex}: {$str}"
193
+ );
194
+ }
195
+ $str .= $this->a;
196
+ if ( '\\' === $this->a ) {
197
+ $this->output .= $this->a;
198
+ $this->lastByteOut = $this->a;
199
 
200
+ $this->a = $this->get();
201
+ $str .= $this->a;
202
+ }
203
+ }
204
+ }
205
 
206
+ // fallthrough intentional
207
+ case self::ACTION_DELETE_A_B: // 3
208
+ $this->b = $this->next();
209
+ if ( '/' === $this->b && $this->isRegexpLiteral() ) {
210
+ $this->output .= $this->a . $this->b;
211
+ $pattern = '/'; // keep entire pattern in case we need to report it in the exception
212
+ for ( ;; ) {
213
+ $this->a = $this->get();
214
+ $pattern .= $this->a;
215
+ if ( '[' === $this->a ) {
216
+ for ( ;; ) {
217
+ $this->output .= $this->a;
218
+ $this->a = $this->get();
219
+ $pattern .= $this->a;
220
+ if ( ']' === $this->a ) {
221
+ break;
222
+ }
223
+ if ( '\\' === $this->a ) {
224
+ $this->output .= $this->a;
225
+ $this->a = $this->get();
226
+ $pattern .= $this->a;
227
+ }
228
+ if ( $this->isEOF( $this->a ) ) {
229
+ throw new JSMin_UnterminatedRegExpException(
230
+ 'JSMin: Unterminated set in RegExp at byte '
231
+ . $this->inputIndex . ": {$pattern}"
232
+ );
233
+ }
234
+ }
235
+ }
236
 
237
+ if ( '/' === $this->a ) { // end pattern
238
+ break; // while (true)
239
+ } elseif ( '\\' === $this->a ) {
240
+ $this->output .= $this->a;
241
+ $this->a = $this->get();
242
+ $pattern .= $this->a;
243
+ } elseif ( $this->isEOF( $this->a ) ) {
244
+ throw new JSMin_UnterminatedRegExpException(
245
+ "JSMin: Unterminated RegExp at byte {$this->inputIndex}: {$pattern}"
246
+ );
247
+ }
248
+ $this->output .= $this->a;
249
+ $this->lastByteOut = $this->a;
250
+ }
251
+ $this->b = $this->next();
252
+ }
253
+ // end case ACTION_DELETE_A_B
254
+ }
255
+ }
256
 
257
+ /**
258
+ * @return bool
259
+ */
260
+ protected function isRegexpLiteral() {
261
+ if ( false !== strpos( '(,=:[!&|?+-~*{;', $this->a ) ) {
262
+ // we obviously aren't dividing
263
+ return true;
264
+ }
265
+ if ( ' ' === $this->a || "\n" === $this->a ) {
266
+ $length = strlen( $this->output );
267
+ if ( $length < 2 ) { // weird edge case
268
+ return true;
269
+ }
270
+ // you can't divide a keyword
271
+ if ( preg_match( '/(?:case|else|in|return|typeof)$/', $this->output, $m ) ) {
272
+ if ( $this->output === $m[0] ) { // odd but could happen
273
+ return true;
274
+ }
275
+ // make sure it's a keyword, not end of an identifier
276
+ $charBeforeKeyword = substr( $this->output, $length - strlen( $m[0] ) - 1, 1 );
277
+ if ( ! $this->isAlphaNum( $charBeforeKeyword ) ) {
278
+ return true;
279
+ }
280
+ }
281
+ }
282
+ return false;
283
+ }
 
284
 
285
+ /**
286
+ * Return the next character from stdin. Watch out for lookahead. If the character is a control character,
287
+ * translate it to a space or linefeed.
288
+ *
289
+ * @return string
290
+ */
291
+ protected function get() {
292
+ $c = $this->lookAhead;
293
+ $this->lookAhead = null;
294
+ if ( null === $c ) {
295
+ // getc(stdin)
296
+ if ( $this->inputIndex < $this->inputLength ) {
297
+ $c = $this->input[ $this->inputIndex ];
298
+ $this->inputIndex += 1;
299
+ } else {
300
+ $c = null;
301
+ }
302
+ }
303
+ if ( ord( $c ) >= self::ORD_SPACE || "\n" === $c || null === $c ) {
304
+ return $c;
305
+ }
306
+ if ( "\r" === $c ) {
307
+ return "\n";
308
+ }
309
+ return ' ';
310
+ }
 
311
 
312
+ /**
313
+ * Does $a indicate end of input?
314
+ *
315
+ * @param string $a
316
+ * @return bool
317
+ */
318
+ protected function isEOF( $a ) {
319
+ return ord( $a ) <= self::ORD_LF;
320
+ }
 
321
 
322
+ /**
323
+ * Get next char (without getting it). If is ctrl character, translate to a space or newline.
324
+ *
325
+ * @return string
326
+ */
327
+ protected function peek() {
328
+ $this->lookAhead = $this->get();
329
+ return $this->lookAhead;
330
+ }
 
331
 
332
+ /**
333
+ * Return true if the character is a letter, digit, underscore, dollar sign, or non-ASCII character.
334
+ *
335
+ * @param string $c
336
+ *
337
+ * @return bool
338
+ */
339
+ protected function isAlphaNum( $c ) {
340
+ return ( preg_match( '/^[a-z0-9A-Z_\\$\\\\]$/', $c ) || ord( $c ) > 126 );
341
+ }
 
342
 
343
+ /**
344
+ * Consume a single line comment from input (possibly retaining it)
345
+ */
346
+ protected function consumeSingleLineComment() {
347
+ $comment = '';
348
+ while ( true ) {
349
+ $get = $this->get();
350
+ $comment .= $get;
351
+ if ( ord( $get ) <= self::ORD_LF ) { // end of line reached
352
+ // if IE conditional comment
353
+ if ( preg_match( '/^\\/@(?:cc_on|if|elif|else|end)\\b/', $comment ) ) {
354
+ $this->keptComment .= "/{$comment}";
355
+ }
356
+ return;
357
+ }
358
+ }
359
+ }
 
360
 
361
+ /**
362
+ * Consume a multiple line comment from input (possibly retaining it)
363
+ *
364
+ * @throws JSMin_UnterminatedCommentException
365
+ */
366
+ protected function consumeMultipleLineComment() {
367
+ $this->get();
368
+ $comment = '';
369
+ for ( ;; ) {
370
+ $get = $this->get();
371
+ if ( '*' === $get ) {
372
+ if ( '/' === $this->peek() ) { // end of comment reached
373
+ $this->get();
374
+ if ( 0 === strpos( $comment, '!' ) ) {
375
+ // preserved by YUI Compressor
376
+ if ( ! $this->keptComment ) {
377
+ // don't prepend a newline if two comments right after one another
378
+ $this->keptComment = "\n";
379
+ }
380
+ $this->keptComment .= '/*!' . substr( $comment, 1 ) . "*/\n";
381
+ } elseif ( preg_match( '/^@(?:cc_on|if|elif|else|end)\\b/', $comment ) ) {
382
+ // IE conditional
383
+ $this->keptComment .= "/*{$comment}*/";
384
+ }
385
+ return;
386
+ }
387
+ } elseif ( null === $get ) {
388
+ throw new JSMin_UnterminatedCommentException(
389
+ "JSMin: Unterminated comment at byte {$this->inputIndex}: /*{$comment}"
390
+ );
391
+ }
392
+ $comment .= $get;
393
+ }
394
+ }
395
 
396
+ /**
397
+ * Get the next character, skipping over comments. Some comments may be preserved.
398
+ *
399
+ * @return string
400
+ */
401
+ protected function next() {
402
+ $get = $this->get();
403
+ if ( '/' === $get ) {
404
+ switch ( $this->peek() ) {
405
+ case '/':
406
+ $this->consumeSingleLineComment();
407
+ $get = "\n";
408
+ break;
409
+ case '*':
410
+ $this->consumeMultipleLineComment();
411
+ $get = ' ';
412
+ break;
413
+ }
414
+ }
415
+ return $get;
416
+ }
 
417
  }
418
 
419
  class JSMin_UnterminatedStringException extends Exception {}
js/fbuilder-loader-admin.php CHANGED
@@ -1,91 +1,74 @@
1
- <?php
2
- error_reporting(E_ERROR|E_PARSE);
3
- header('Content-Type: application/x-javascript; charset=UTF-8');
4
- ?>
5
- fbuilderjQuery = (typeof fbuilderjQuery != 'undefined' ) ? fbuilderjQuery : jQuery;
6
- fbuilderjQuery.fbuilderjQueryGenerator = function(){
7
- if('fbuilderGeneratorFlag' in fbuilderjQuery) return;
8
- (function($) {
9
- // Namespace of fbuilder
10
- $.fbuilder = $.fbuilder || {};
11
- $.fbuilder.default_template = '<?php print esc_js(CP_CALCULATEDFIELDSF_DEFAULT_template); ?>';
12
- $.fbuilder[ 'objName' ] = 'fbuilderjQuery';
13
- <?php
14
- // Load Module files
15
- try
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  {
17
- $md = dir( dirname( __FILE__ )."/modules");
18
- $modules_files = array();
19
- while( false !== ( $entry = $md->read() ) )
20
- {
21
- if ( strlen( $entry ) > 3 && is_dir( $md->path.'/'.$entry ) )
22
- {
23
- if ( file_exists( $md->path.'/'.$entry.'/admin' ) )
24
- {
25
- $m = dir( $md->path.'/'.$entry.'/admin' );
26
- while( false !== ( $mentry = $m->read() ) )
27
- {
28
- if( strlen( $mentry ) > 3 && strtolower( substr( $mentry, strlen( $mentry ) - 3 ) ) == '.js' )
29
- {
30
- $modules_files[] = $m->path.'/'.$mentry;
31
- }
32
- }
33
- }
34
-
35
- }
36
- }
37
- sort( $modules_files );
38
- foreach( $modules_files as $file )
39
- {
40
- require $file;
41
- }
42
  }
43
- catch (Exception $e)
44
- {
45
- // ignore the error
46
- }
47
-
48
- // Load Control files
49
- require 'fbuilder-pro-admin.jquery.js';
50
- try
51
- {
52
- $d = dir( dirname( __FILE__ )."/fields-admin" );
53
- $controls_files = array();
54
- while (false !== ($entry = $d->read()))
55
- {
56
- if (strlen($entry) > 3 && strtolower(substr($entry,strlen($entry)-3)) == '.js')
57
- {
58
- if (file_exists( $d->path.'/'.$entry ) )
59
- {
60
- $controls_files[] = $d->path.'/'.$entry;
61
- }
62
- }
63
- }
64
- sort( $controls_files );
65
- foreach( $controls_files as $file )
66
- {
67
- require $file;
68
- }
69
-
70
- do_action('cpcff_load_controls_admin');
71
- }
72
- catch (Exception $e)
73
- {
74
- // ignore the error
75
- }
76
-
77
- do_action( 'cpcff_additional_admin_scripts' );
78
- ?>
79
- })(fbuilderjQuery);
80
- fbuilderjQuery.fbuilderGeneratorFlag = 1;
81
- };
82
- fbuilderjQuery(fbuilderjQuery.fbuilderjQueryGenerator);
83
- fbuilderjQuery(window).on('load',function(){
84
- fbuilderjQuery.fbuilderjQueryGenerator();
85
- if(!fbuilderjQuery('[href*="jquery-ui"]').length)
86
- {
87
- fbuilderjQuery('body').append(
88
- '<link href="<?php print esc_attr(plugins_url('/vendors/jquery-ui/jquery-ui.min.css', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH)); ?>" type="text/css" rel="stylesheet" property="stylesheet" />'
89
- );
90
- }
91
- });
1
+ <?php
2
+ error_reporting( E_ERROR | E_PARSE );
3
+ header( 'Content-Type: application/x-javascript; charset=UTF-8' );
4
+ ?>
5
+ fbuilderjQuery = (typeof fbuilderjQuery != 'undefined' ) ? fbuilderjQuery : jQuery;
6
+ fbuilderjQuery.fbuilderjQueryGenerator = function(){
7
+ if('fbuilderGeneratorFlag' in fbuilderjQuery) return;
8
+ (function($) {
9
+ // Namespace of fbuilder
10
+ $.fbuilder = $.fbuilder || {};
11
+ $.fbuilder.default_template = '<?php print esc_js( CP_CALCULATEDFIELDSF_DEFAULT_template ); ?>';
12
+ $.fbuilder[ 'objName' ] = 'fbuilderjQuery';
13
+ <?php
14
+ // Load Module files
15
+ try {
16
+ $md = dir( dirname( __FILE__ ) . '/modules' );
17
+ $modules_files = array();
18
+ while ( false !== ( $entry = $md->read() ) ) {
19
+ if ( strlen( $entry ) > 3 && is_dir( $md->path . '/' . $entry ) ) {
20
+ if ( file_exists( $md->path . '/' . $entry . '/admin' ) ) {
21
+ $m = dir( $md->path . '/' . $entry . '/admin' ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride
22
+ while ( false !== ( $mentry = $m->read() ) ) {
23
+ if ( strlen( $mentry ) > 3 && strtolower( substr( $mentry, strlen( $mentry ) - 3 ) ) == '.js' ) {
24
+ $modules_files[] = $m->path . '/' . $mentry;
25
+ }
26
+ }
27
+ }
28
+ }
29
+ }
30
+ sort( $modules_files );
31
+ foreach ( $modules_files as $file ) {
32
+ require $file;
33
+ }
34
+ } catch ( Exception $e ) {
35
+ error_log( $e->getMessage() );
36
+ }
37
+
38
+ // Load Control files
39
+ require 'fbuilder-pro-admin.jquery.js';
40
+ try {
41
+ $d = dir( dirname( __FILE__ ) . '/fields-admin' );
42
+ $controls_files = array();
43
+ while ( false !== ( $entry = $d->read() ) ) {
44
+ if ( strlen( $entry ) > 3 && strtolower( substr( $entry, strlen( $entry ) - 3 ) ) == '.js' ) {
45
+ if ( file_exists( $d->path . '/' . $entry ) ) {
46
+ $controls_files[] = $d->path . '/' . $entry;
47
+ }
48
+ }
49
+ }
50
+ sort( $controls_files );
51
+ foreach ( $controls_files as $file ) {
52
+ require $file;
53
+ }
54
+
55
+ do_action( 'cpcff_load_controls_admin' );
56
+ } catch ( Exception $e ) {
57
+ error_log( $e->getMessage() );
58
+ }
59
+
60
+ do_action( 'cpcff_additional_admin_scripts' );
61
+ ?>
62
+ })(fbuilderjQuery);
63
+ fbuilderjQuery.fbuilderGeneratorFlag = 1;
64
+ };
65
+ fbuilderjQuery(fbuilderjQuery.fbuilderjQueryGenerator);
66
+ fbuilderjQuery(window).on('load',function(){
67
+ fbuilderjQuery.fbuilderjQueryGenerator();
68
+ if(!fbuilderjQuery('[href*="jquery-ui"]').length)
69
  {
70
+ fbuilderjQuery('body').append(
71
+ '<link href="<?php print esc_attr( plugins_url( '/vendors/jquery-ui/jquery-ui.min.css', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ) ); // phpcs:ignore WordPress.WP.EnqueuedResources ?>" type="text/css" rel="stylesheet" property="stylesheet" />'
72
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  }
74
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/fbuilder-loader-public.php CHANGED
@@ -1,158 +1,155 @@
1
- <?php
2
- global $cff_backend_script_generator, $cff_script_generator_min;
3
-
4
- error_reporting(E_ERROR|E_PARSE);
5
-
6
- if(empty($cff_backend_script_generator)) header('Content-Type: application/x-javascript; charset=UTF-8');
7
-
8
- ob_start(); // Turn on output buffering
9
- ?>
10
- fbuilderjQuery = (typeof fbuilderjQuery != 'undefined' ) ? fbuilderjQuery : jQuery;
11
- fbuilderjQuery(window).bind( 'pageshow', function( event ){ if( typeof event.originalEvent[ 'persisted' ] != 'undefined' && event.originalEvent[ 'persisted' ] ) location.reload(); } );
12
- fbuilderjQuery.fbuilderjQueryGenerator = function(){
13
- (function($) {
14
- // Namespace of fbuilder
15
- if(!('fbuilder' in $))
16
- {
17
- $.fbuilder = $.fbuilder || {};
18
- $.fbuilder[ 'objName' ] = 'fbuilderjQuery';
19
-
20
- <?php
21
- // Load Module files
22
- try
23
- {
24
- $md = dir( dirname( __FILE__ )."/modules" );
25
- $modules_files = array();
26
- while( false !== ( $entry = $md->read() ) )
27
  {
28
- if ( strlen( $entry ) > 3 && is_dir( $md->path.'/'.$entry ) )
29
- {
30
- if ( file_exists( $md->path.'/'.$entry.'/public' ) )
31
- {
32
- $m = dir( $md->path.'/'.$entry.'/public' );
33
- while( false !== ( $mentry = $m->read() ) )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  {
35
- if( strlen( $mentry ) > 3 && strtolower( substr( $mentry, strlen( $mentry ) - 3 ) ) == '.js' )
36
  {
37
- $modules_files[] = $m->path.'/'.$mentry;
 
 
 
 
 
 
 
 
 
 
 
38
  }
39
  }
40
- }
41
-
42
- }
43
- }
44
- sort( $modules_files );
45
- foreach( $modules_files as $file )
46
- {
47
- require $file;
48
- }
49
- }
50
- catch (Exception $e)
51
- {
52
- // ignore the error
53
- }
54
-
55
- // Load Control files
56
- require 'fbuilder-pro-public.jquery.js';
57
- try {
58
- $d = dir( dirname( __FILE__ )."/fields-public" );
59
- $controls_files = array();
60
- while (false !== ($entry = $d->read())) {
61
- if (strlen($entry) > 3 && strtolower(substr($entry,strlen($entry)-3)) == '.js')
62
- if ( file_exists( $d->path.'/'.$entry ) )
63
- $controls_files[] = $d->path.'/'.$entry;
64
- }
65
- sort( $controls_files );
66
- foreach( $controls_files as $file )
67
- {
68
- require $file;
69
- }
70
-
71
- do_action('cpcff_load_controls_public');
72
- } catch (Exception $e) {
73
- // ignore the error
74
- }
75
- ?>
76
- $.fbuilder.generate_form = function(fnum){
77
- try {
78
- var cp_calculatedfieldsf_fbuilder_config = window["cp_calculatedfieldsf_fbuilder_config"+fnum];
79
- if(
80
- cp_calculatedfieldsf_fbuilder_config &&
81
- $("#fbuilder"+fnum).length &&
82
- $("#fbuilder"+fnum).attr('data-processed') == undefined
83
- )
84
- {
85
- if($("#fbuilder"+fnum).is(':visible'))
86
- {
87
- var f = $("#fbuilder"+fnum).fbuilder(( typeof cp_calculatedfieldsf_fbuilder_config.obj == 'string' ) ? $.parseJSON(cp_calculatedfieldsf_fbuilder_config.obj) : cp_calculatedfieldsf_fbuilder_config.obj );
88
- f.attr('data-processed', 1);
89
- f.fBuild.loadData("form_structure"+fnum);
90
- }
91
- else
92
- {
93
- $.fbuilder.form_become_visible(
94
- "#fbuilder"+fnum,
95
- (function(n){ return function(){
96
- $.fbuilder.generate_form(n);};
97
- })(fnum)
98
- );
99
- }
100
- }
101
- } catch (e) {if(typeof console != 'undefined') console.log(e);}
102
- }; // End generate_form
103
-
104
- $.fbuilder.form_become_visible = function(element, callback){
105
- if(!('hidden_forms' in $.fbuilder)) $.fbuilder.hidden_forms = [];
106
- $.fbuilder.hidden_forms.push({'element':element, 'callback':callback});
107
-
108
- if('form_become_visible_interval' in $.fbuilder) clearInterval($.fbuilder['form_become_visible_interval']);
109
-
110
- $.fbuilder['form_become_visible_interval'] = setInterval(function(){
111
- for(var i = $.fbuilder.hidden_forms.length - 1; 0<=i; i--)
112
- {
113
- if($($.fbuilder.hidden_forms[i]['element']).is(':visible'))
114
- {
115
- $.fbuilder.hidden_forms[i]['callback'].call();
116
- $.fbuilder.hidden_forms.splice(i,1);
117
- }
118
- }
119
- if($.fbuilder.hidden_forms.length == 0) clearInterval($.fbuilder['form_become_visible_interval']);
120
- }, 500);
121
- }; // End form_become_visible
122
-
123
- } // End if(!('fbuilder' in $))
124
-
125
- var fcount = 1;
126
- var fnum = "_"+fcount;
127
-
128
- while(typeof window["cp_calculatedfieldsf_fbuilder_config"+fnum] != 'undefined' || fcount < 10 )
129
- {
130
- $.fbuilder.generate_form(fnum);
131
- fcount++;
132
- fnum = "_"+fcount;
133
- }
134
- })(fbuilderjQuery);
135
- };
136
- fbuilderjQuery(fbuilderjQuery.fbuilderjQueryGenerator);
137
- fbuilderjQuery(window).on('load',fbuilderjQuery.fbuilderjQueryGenerator);
138
- <?php
139
- $buffered_contents = ob_get_contents();
140
- ob_end_clean(); // Clean the output buffer and turn off output buffering
141
- if(!empty($_REQUEST['min']) || !empty($cff_script_generator_min))
142
- {
143
- if( !class_exists( 'JSMin' ) )
144
  {
145
- require_once rtrim( dirname( __FILE__ ), '/' ).'/JSMin.php';
 
 
146
  }
147
-
148
- try{
149
- $buffered_contents = JSMin::minify( $buffered_contents );
150
- }catch( Exception $err){}
151
- }
152
-
153
- try{
154
- $all_js_path = rtrim( dirname( __FILE__ ), '/' ).'/cache/all.js';
155
- @file_put_contents( $all_js_path, $buffered_contents );
156
- }catch( Exception $err){}
157
-
158
- if(empty($cff_backend_script_generator)) print $buffered_contents;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ global $cff_backend_script_generator, $cff_script_generator_min;
3
+
4
+ error_reporting( E_ERROR | E_PARSE );
5
+
6
+ if ( empty( $cff_backend_script_generator ) ) {
7
+ header( 'Content-Type: application/x-javascript; charset=UTF-8' );
8
+ }
9
+
10
+ ob_start(); // Turn on output buffering
11
+ ?>
12
+ fbuilderjQuery = (typeof fbuilderjQuery != 'undefined' ) ? fbuilderjQuery : jQuery;
13
+ fbuilderjQuery(window).bind( 'pageshow', function( event ){ if( typeof event.originalEvent[ 'persisted' ] != 'undefined' && event.originalEvent[ 'persisted' ] ) location.reload(); } );
14
+ fbuilderjQuery.fbuilderjQueryGenerator = function(){
15
+ (function($) {
16
+ // Namespace of fbuilder
17
+ if(!('fbuilder' in $))
 
 
 
 
 
 
 
 
 
18
  {
19
+ $.fbuilder = $.fbuilder || {};
20
+ $.fbuilder[ 'objName' ] = 'fbuilderjQuery';
21
+
22
+ <?php
23
+ // Load Module files
24
+ try {
25
+ $md = dir( dirname( __FILE__ ) . '/modules' );
26
+ $modules_files = array();
27
+ while ( false !== ( $entry = $md->read() ) ) {
28
+ if ( strlen( $entry ) > 3 && is_dir( $md->path . '/' . $entry ) ) {
29
+ if ( file_exists( $md->path . '/' . $entry . '/public' ) ) {
30
+ $m = dir( $md->path . '/' . $entry . '/public' ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride
31
+ while ( false !== ( $mentry = $m->read() ) ) {
32
+ if ( strlen( $mentry ) > 3 && strtolower( substr( $mentry, strlen( $mentry ) - 3 ) ) == '.js' ) {
33
+ $modules_files[] = $m->path . '/' . $mentry;
34
+ }
35
+ }
36
+ }
37
+ }
38
+ }
39
+ sort( $modules_files );
40
+ foreach ( $modules_files as $file ) {
41
+ require $file;
42
+ }
43
+ } catch ( Exception $e ) {
44
+ error_log( $e->getMessage() );
45
+ }
46
+
47
+ // Load Control files
48
+ require 'fbuilder-pro-public.jquery.js';
49
+ try {
50
+ $d = dir( dirname( __FILE__ ) . '/fields-public' );
51
+ $controls_files = array();
52
+ while ( false !== ( $entry = $d->read() ) ) {
53
+ if ( strlen( $entry ) > 3 && strtolower( substr( $entry, strlen( $entry ) - 3 ) ) == '.js' ) {
54
+ if ( file_exists( $d->path . '/' . $entry ) ) {
55
+ $controls_files[] = $d->path . '/' . $entry;
56
+ }
57
+ }
58
+ }
59
+ sort( $controls_files );
60
+ foreach ( $controls_files as $file ) {
61
+ require $file;
62
+ }
63
+
64
+ do_action( 'cpcff_load_controls_public' );
65
+ } catch ( Exception $e ) {
66
+ error_log( $e->getMessage() );
67
+ }
68
+ ?>
69
+ $.fbuilder.generate_form = function(fnum){
70
+ try {
71
+ var cp_calculatedfieldsf_fbuilder_config = window["cp_calculatedfieldsf_fbuilder_config"+fnum];
72
+ if(
73
+ cp_calculatedfieldsf_fbuilder_config &&
74
+ $("#fbuilder"+fnum).length &&
75
+ $("#fbuilder"+fnum).attr('data-processed') == undefined
76
+ )
77
  {
78
+ if($("#fbuilder"+fnum).is(':visible'))
79
  {
80
+ var f = $("#fbuilder"+fnum).fbuilder(( typeof cp_calculatedfieldsf_fbuilder_config.obj == 'string' ) ? $.parseJSON(cp_calculatedfieldsf_fbuilder_config.obj) : cp_calculatedfieldsf_fbuilder_config.obj );
81
+ f.attr('data-processed', 1);
82
+ f.fBuild.loadData("form_structure"+fnum);
83
+ }
84
+ else
85
+ {
86
+ $.fbuilder.form_become_visible(
87
+ "#fbuilder"+fnum,
88
+ (function(n){ return function(){
89
+ $.fbuilder.generate_form(n);};
90
+ })(fnum)
91
+ );
92
  }
93
  }
94
+ } catch (e) {if(typeof console != 'undefined') console.log(e);}
95
+ }; // End generate_form
96
+
97
+ $.fbuilder.form_become_visible = function(element, callback){
98
+ if(!('hidden_forms' in $.fbuilder)) $.fbuilder.hidden_forms = [];
99
+ $.fbuilder.hidden_forms.push({'element':element, 'callback':callback});
100
+
101
+ if('form_become_visible_interval' in $.fbuilder) clearInterval($.fbuilder['form_become_visible_interval']);
102
+
103
+ $.fbuilder['form_become_visible_interval'] = setInterval(function(){
104
+ for(var i = $.fbuilder.hidden_forms.length - 1; 0<=i; i--)
105
+ {
106
+ if($($.fbuilder.hidden_forms[i]['element']).is(':visible'))
107
+ {
108
+ $.fbuilder.hidden_forms[i]['callback'].call();
109
+ $.fbuilder.hidden_forms.splice(i,1);
110
+ }
111
+ }
112
+ if($.fbuilder.hidden_forms.length == 0) clearInterval($.fbuilder['form_become_visible_interval']);
113
+ }, 500);
114
+ }; // End form_become_visible
115
+
116
+ } // End if(!('fbuilder' in $))
117
+
118
+ var fcount = 1;
119
+ var fnum = "_"+fcount;
120
+
121
+ while(typeof window["cp_calculatedfieldsf_fbuilder_config"+fnum] != 'undefined' || fcount < 10 )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  {
123
+ $.fbuilder.generate_form(fnum);
124
+ fcount++;
125
+ fnum = "_"+fcount;
126
  }
127
+ })(fbuilderjQuery);
128
+ };
129
+ fbuilderjQuery(fbuilderjQuery.fbuilderjQueryGenerator);
130
+ fbuilderjQuery(window).on('load',fbuilderjQuery.fbuilderjQueryGenerator);
131
+ <?php
132
+ $buffered_contents = ob_get_contents();
133
+ ob_end_clean(); // Clean the output buffer and turn off output buffering
134
+ if ( ! empty( $_REQUEST['min'] ) || ! empty( $cff_script_generator_min ) ) {
135
+ if ( ! class_exists( 'JSMin' ) ) {
136
+ require_once rtrim( dirname( __FILE__ ), '/' ) . '/JSMin.php';
137
+ }
138
+
139
+ try {
140
+ $buffered_contents = JSMin::minify( $buffered_contents );
141
+ } catch ( Exception $err ) {
142
+ error_log( $err->getMessage() );
143
+ }
144
+ }
145
+
146
+ try {
147
+ $all_js_path = rtrim( dirname( __FILE__ ), '/' ) . '/cache/all.js';
148
+ @file_put_contents( $all_js_path, $buffered_contents );
149
+ } catch ( Exception $err ) {
150
+ error_log( $err->getMessage() );
151
+ }
152
+
153
+ if ( empty( $cff_backend_script_generator ) ) {
154
+ print $buffered_contents; // phpcs:ignore WordPress.Security.EscapeOutput
155
+ }
languages/calculated-fields-form-en_US.mo CHANGED
Binary file
languages/calculated-fields-form-en_US.po CHANGED
@@ -1,8 +1,8 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: \n"
4
- "POT-Creation-Date: 2022-08-28 15:56+0200\n"
5
- "PO-Revision-Date: 2022-08-28 15:56+0200\n"
6
  "Last-Translator: CodePeople\n"
7
  "Language-Team: \n"
8
  "Language: en_US\n"
@@ -12,14 +12,14 @@ msgstr ""
12
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
13
  "X-Generator: Poedit 3.1.1\n"
14
  "X-Poedit-Basepath: ..\n"
15
- "X-Poedit-KeywordsList: __;_e;esc_attr__;esc_attr_e\n"
16
  "X-Poedit-SearchPath-0: .\n"
17
 
18
- #: cp_calculatedfieldsf_free.php:80
19
  msgid "Form Preview"
20
  msgstr ""
21
 
22
- #: cp_calculatedfieldsf_free.php:118
23
  msgid ""
24
  "<div class=\"error-text\">The data cannot be stored in database because has "
25
  "occurred an error with the database structure. Please, go to the plugins "
@@ -28,7 +28,7 @@ msgid ""
28
  "please <a href=\"https://cff.dwbooster.com/contact-us\">contact us</a></div>"
29
  msgstr ""
30
 
31
- #: cp_calculatedfieldsf_free.php:134
32
  msgid ""
33
  "<div class=\"error-text\">The data cannot be stored in database because has "
34
  "occurred an error with the form structure. Please, try to save the data "
@@ -41,18 +41,18 @@ msgstr ""
41
  msgid "Settings saved"
42
  msgstr ""
43
 
44
- #: inc/cpcff_admin_int.inc.php:50 inc/cpcff_admin_int_list.inc.php:157
45
- #: inc/cpcff_page_builders.inc.php:185
46
  #: pagebuilders/beaverbuilder/cff/cff/cff.php:9
47
  #: pagebuilders/beaverbuilder/cff/cff/cff.php:11
48
  #: pagebuilders/beaverbuilder/cff/cff/cff.php:12
49
  #: pagebuilders/beaverbuilder/cffvar/cffvar/cffvar.php:11
50
  #: pagebuilders/beaverbuilder/cffvar/cffvar/cffvar.php:12
51
- #: pagebuilders/elementor/elementor.pb.php:42
52
  msgid "Calculated Fields Form"
53
  msgstr ""
54
 
55
- #: inc/cpcff_admin_int.inc.php:50
56
  msgid "Form"
57
  msgstr ""
58
 
@@ -64,7 +64,7 @@ msgstr ""
64
  msgid "Back to items list..."
65
  msgstr ""
66
 
67
- #: inc/cpcff_admin_int.inc.php:70 inc/cpcff_admin_int.inc.php:232
68
  msgid "Form Settings"
69
  msgstr ""
70
 
@@ -90,20 +90,20 @@ msgstr ""
90
  msgid "Select a revision"
91
  msgstr ""
92
 
93
- #: inc/cpcff_admin_int.inc.php:109 inc/cpcff_admin_int.inc.php:252
94
- #: inc/cpcff_admin_int.inc.php:654
95
  msgid "Preview"
96
  msgstr ""
97
 
98
- #: inc/cpcff_admin_int.inc.php:109
99
  msgid "Saves the form's structure only, and opens a preview windows"
100
  msgstr ""
101
 
102
- #: inc/cpcff_admin_int.inc.php:110
103
  msgid "Fields List"
104
  msgstr ""
105
 
106
- #: inc/cpcff_admin_int.inc.php:121
107
  msgid ""
108
  "If the form is not loading in the public website, go to the settings page of "
109
  "the plugin through the menu option: \"Settings/Calculated Fields Form\", "
@@ -111,7 +111,7 @@ msgid ""
111
  "press the \"Update\" button."
112
  msgstr ""
113
 
114
- #: inc/cpcff_admin_int.inc.php:121
115
  msgid ""
116
  "If you need also the form to be sent to the server side for processing (for "
117
  "example to deliver emails) then the <a href=\"https://cff.dwbooster.com/"
@@ -119,68 +119,68 @@ msgid ""
119
  "required."
120
  msgstr ""
121
 
122
- #: inc/cpcff_admin_int.inc.php:138
123
  msgid ""
124
  "The action will load the revision selected, the data are not stored will be "
125
  "lose. Do you want continue?"
126
  msgstr ""
127
 
128
- #: inc/cpcff_admin_int.inc.php:195
129
  msgid ""
130
  "These features aren't available in this version. Do you want to open the "
131
  "plugin's page to check other versions?"
132
  msgstr ""
133
 
134
- #: inc/cpcff_admin_int.inc.php:230
135
  msgid "Add a Field"
136
  msgstr ""
137
 
138
- #: inc/cpcff_admin_int.inc.php:231
139
  msgid "Field Settings"
140
  msgstr ""
141
 
142
- #: inc/cpcff_admin_int.inc.php:251 inc/cpcff_admin_int.inc.php:383
143
- #: inc/cpcff_admin_int.inc.php:698
144
  msgid "Save Changes"
145
  msgstr ""
146
 
147
- #: inc/cpcff_admin_int.inc.php:258
148
  msgid "Generate revisions in the form preview as well"
149
  msgstr ""
150
 
151
- #: inc/cpcff_admin_int.inc.php:263
152
  msgid "Texts definition"
153
  msgstr ""
154
 
155
- #: inc/cpcff_admin_int.inc.php:264
156
  msgid "Error texts"
157
  msgstr ""
158
 
159
- #: inc/cpcff_admin_int.inc.php:265
160
  msgid "General payment settings"
161
  msgstr ""
162
 
163
- #: inc/cpcff_admin_int.inc.php:266
164
  msgid "PayPal integration"
165
  msgstr ""
166
 
167
- #: inc/cpcff_admin_int.inc.php:267
168
  msgid "Notification email"
169
  msgstr ""
170
 
171
- #: inc/cpcff_admin_int.inc.php:268
172
  msgid "Email copy to user"
173
  msgstr ""
174
 
175
- #: inc/cpcff_admin_int.inc.php:269
176
  msgid "Captcha settings"
177
  msgstr ""
178
 
179
- #: inc/cpcff_admin_int.inc.php:272
180
  msgid "Define Texts"
181
  msgstr ""
182
 
183
- #: inc/cpcff_admin_int.inc.php:276
184
  msgid "Previous button label (text)"
185
  msgstr ""
186
 
@@ -188,76 +188,76 @@ msgstr ""
188
  msgid "Next button label (text)"
189
  msgstr ""
190
 
191
- #: inc/cpcff_admin_int.inc.php:285
192
  msgid ""
193
  "- The styles can be applied into any of the CSS files of your theme or into "
194
  "the CSS file <em>\"calculated-fields-form\\css\\stylepublic.css\"</em>."
195
  msgstr ""
196
 
197
- #: inc/cpcff_admin_int.inc.php:286
198
  msgid ""
199
  "- For general CSS styles modifications to the form and samples <a href="
200
  "\"https://cff.dwbooster.com/faq#q82\" target=\"_blank\">check this FAQ</a>."
201
  msgstr ""
202
 
203
- #: inc/cpcff_admin_int.inc.php:304 inc/cpcff_admin_int.inc.php:368
204
- #: inc/cpcff_admin_int.inc.php:455 inc/cpcff_admin_int.inc.php:529
205
- #: inc/cpcff_admin_int.inc.php:578 inc/cpcff_admin_int.inc.php:620
206
- #: inc/cpcff_admin_int.inc.php:687
207
  msgid "Up to form structure"
208
  msgstr ""
209
 
210
- #: inc/cpcff_admin_int.inc.php:309
211
  msgid "Validation Settings"
212
  msgstr ""
213
 
214
- #: inc/cpcff_admin_int.inc.php:313
215
  msgid "\"is required\" text"
216
  msgstr ""
217
 
218
- #: inc/cpcff_admin_int.inc.php:317
219
  msgid "\"is email\" text"
220
  msgstr ""
221
 
222
- #: inc/cpcff_admin_int.inc.php:321
223
  msgid "\"is valid captcha\" text"
224
  msgstr ""
225
 
226
- #: inc/cpcff_admin_int.inc.php:326
227
  msgid "\"is valid date (mm/dd/yyyy)\" text"
228
  msgstr ""
229
 
230
- #: inc/cpcff_admin_int.inc.php:330
231
  msgid "\"is valid date (dd/mm/yyyy)\" text"
232
  msgstr ""
233
 
234
- #: inc/cpcff_admin_int.inc.php:334
235
  msgid "\"is number\" text"
236
  msgstr ""
237
 
238
- #: inc/cpcff_admin_int.inc.php:338
239
  msgid "\"only digits\" text"
240
  msgstr ""
241
 
242
- #: inc/cpcff_admin_int.inc.php:342
243
  msgid "\"under maximum\" text"
244
  msgstr ""
245
 
246
- #: inc/cpcff_admin_int.inc.php:346
247
  msgid "\"over minimum\" text"
248
  msgstr ""
249
 
250
- #: inc/cpcff_admin_int.inc.php:373
251
  msgid "Note"
252
  msgstr ""
253
 
254
- #: inc/cpcff_admin_int.inc.php:375
255
  msgid ""
256
  "To display the form in a post/page, enter your shortcode in the post/page "
257
  "content:"
258
  msgstr ""
259
 
260
- #: inc/cpcff_admin_int.inc.php:377
261
  msgid ""
262
  "The CFF plugin implements widgets and blocks to allow inserting the form "
263
  "visually with the most popular page builders such as Gutenberg Editor, "
@@ -265,141 +265,153 @@ msgid ""
265
  "Divi, and for the other page builders insert the shortcode directly."
266
  msgstr ""
267
 
268
- #: inc/cpcff_admin_int.inc.php:386 inc/cpcff_admin_int.inc.php:701
269
  #: inc/cpcff_admin_int_list.inc.php:436
270
  msgid "Request Custom Modifications"
271
  msgstr ""
272
 
273
- #: inc/cpcff_admin_int.inc.php:386 inc/cpcff_admin_int.inc.php:701
274
- #: inc/cpcff_admin_int_list.inc.php:436 inc/cpcff_main.inc.php:224
275
  msgid "Help"
276
  msgstr ""
277
 
278
- #: inc/cpcff_admin_int.inc.php:393
279
  msgid ""
280
  "The following features are available in the commercial version of the <a "
281
  "href=\"https://cff.dwbooster.com/download\" target=\"_blank\" style=\"text-"
282
  "decoration:none;\">\"Calculated Fields Form\"</a>"
283
  msgstr ""
284
 
285
- #: inc/cpcff_admin_int.inc.php:394
286
  msgid "Pay only ONCE, use it FOREVER"
287
  msgstr ""
288
 
289
- #: inc/cpcff_admin_int.inc.php:403
290
  msgid "Form Processing and Payment Settings"
291
  msgstr ""
292
 
293
- #: inc/cpcff_admin_int.inc.php:407
294
  msgid "Payment Settings"
295
  msgstr ""
296
 
297
- #: inc/cpcff_admin_int.inc.php:412
298
  msgid "Request cost"
299
  msgstr ""
300
 
301
- #: inc/cpcff_admin_int.inc.php:417
302
  msgid "Currency"
303
  msgstr ""
304
 
305
- #: inc/cpcff_admin_int.inc.php:424
 
 
 
 
 
 
 
 
 
 
 
 
306
  msgid "Base amount"
307
  msgstr ""
308
 
309
- #: inc/cpcff_admin_int.inc.php:425
310
  msgid ""
311
  "Minimum amount to charge. If the final price is lesser than this number, the "
312
  "base amount will be applied."
313
  msgstr ""
314
 
315
- #: inc/cpcff_admin_int.inc.php:430
316
  msgid "Paypal product name"
317
  msgstr ""
318
 
319
- #: inc/cpcff_admin_int.inc.php:435
320
  msgid "Discount Codes"
321
  msgstr ""
322
 
323
- #: inc/cpcff_admin_int.inc.php:437
324
  msgid "This feature isn't available in this version."
325
  msgstr ""
326
 
327
- #: inc/cpcff_admin_int.inc.php:440
328
  msgid "Add new discount code"
329
  msgstr ""
330
 
331
- #: inc/cpcff_admin_int.inc.php:442
332
  msgid "Code"
333
  msgstr ""
334
 
335
- #: inc/cpcff_admin_int.inc.php:443
336
  msgid "Discount"
337
  msgstr ""
338
 
339
- #: inc/cpcff_admin_int.inc.php:444
340
  msgid "Percent"
341
  msgstr ""
342
 
343
- #: inc/cpcff_admin_int.inc.php:445
344
  msgid "Fixed Value"
345
  msgstr ""
346
 
347
- #: inc/cpcff_admin_int.inc.php:448
348
  msgid "Valid until"
349
  msgstr ""
350
 
351
- #: inc/cpcff_admin_int.inc.php:449
352
  msgid "Add"
353
  msgstr ""
354
 
355
- #: inc/cpcff_admin_int.inc.php:451
356
  msgid "Note: Expiration date based in server time. Server time now is"
357
  msgstr ""
358
 
359
- #: inc/cpcff_admin_int.inc.php:460
360
  msgid "Paypal Payment Configuration"
361
  msgstr ""
362
 
363
- #: inc/cpcff_admin_int.inc.php:465
364
  msgid "Enable Paypal Payments?"
365
  msgstr ""
366
 
367
- #: inc/cpcff_admin_int.inc.php:467 inc/cpcff_admin_int.inc.php:555
368
- #: inc/cpcff_admin_int.inc.php:593 inc/cpcff_admin_int.inc.php:634
369
  msgid "No"
370
  msgstr ""
371
 
372
- #: inc/cpcff_admin_int.inc.php:469
373
  msgid ""
374
  "Note: If \"Optional\" is selected, a radiobutton will appear in the form to "
375
  "select if the payment will be made with PayPal or not."
376
  msgstr ""
377
 
378
- #: inc/cpcff_admin_int.inc.php:471
379
  msgid "Label for the \"<strong>Pay with PayPal</strong>\" option"
380
  msgstr ""
381
 
382
- #: inc/cpcff_admin_int.inc.php:477
383
  msgid "Paypal Mode"
384
  msgstr ""
385
 
386
- #: inc/cpcff_admin_int.inc.php:479
387
  msgid "Production - real payments processed"
388
  msgstr ""
389
 
390
- #: inc/cpcff_admin_int.inc.php:480
391
  msgid "SandBox - PayPal testing sandbox area"
392
  msgstr ""
393
 
394
- #: inc/cpcff_admin_int.inc.php:486
395
  msgid "Paypal email"
396
  msgstr ""
397
 
398
- #: inc/cpcff_admin_int.inc.php:491
399
  msgid "A $0 amount to pay means"
400
  msgstr ""
401
 
402
- #: inc/cpcff_admin_int.inc.php:493
403
  msgid "Let the user enter any amount at PayPal (ex: for a donation)"
404
  msgstr ""
405
 
@@ -415,202 +427,202 @@ msgstr ""
415
  msgid "Payment frequency"
416
  msgstr ""
417
 
418
- #: inc/cpcff_admin_int.inc.php:509
419
  msgid "One time payment (default option, user is billed only once)"
420
  msgstr ""
421
 
422
- #: inc/cpcff_admin_int.inc.php:510
423
  msgid "Bill the user every 1 month"
424
  msgstr ""
425
 
426
- #: inc/cpcff_admin_int.inc.php:511
427
  msgid "Bill the user every 3 months"
428
  msgstr ""
429
 
430
- #: inc/cpcff_admin_int.inc.php:512
431
  msgid "Bill the user every 6 months"
432
  msgstr ""
433
 
434
- #: inc/cpcff_admin_int.inc.php:513
435
  msgid "Bill the user every 12 months"
436
  msgstr ""
437
 
438
- #: inc/cpcff_admin_int.inc.php:518
439
  msgid "Paypal prompt buyers for shipping address"
440
  msgstr ""
441
 
442
- #: inc/cpcff_admin_int.inc.php:522
443
  msgid "Do not prompt for an address"
444
  msgstr ""
445
 
446
- #: inc/cpcff_admin_int.inc.php:523
447
  msgid "Prompt for an address, but do not require one"
448
  msgstr ""
449
 
450
- #: inc/cpcff_admin_int.inc.php:524
451
  msgid "Prompt for an address and require one"
452
  msgstr ""
453
 
454
- #: inc/cpcff_admin_int.inc.php:534
455
  msgid "Form Processing / Email Settings"
456
  msgstr ""
457
 
458
- #: inc/cpcff_admin_int.inc.php:538
459
  msgid "\"From\" email"
460
  msgstr ""
461
 
462
- #: inc/cpcff_admin_int.inc.php:539
463
  msgid ""
464
  "This email is required if the \"From fixed email address\" option is "
465
  "selected, or it is enabled the email copy to the user."
466
  msgstr ""
467
 
468
- #: inc/cpcff_admin_int.inc.php:542
469
  msgid "Destination emails (comma separated)"
470
  msgstr ""
471
 
472
- #: inc/cpcff_admin_int.inc.php:546 inc/cpcff_admin_int.inc.php:602
473
  msgid "Email subject"
474
  msgstr ""
475
 
476
- #: inc/cpcff_admin_int.inc.php:550
477
  msgid "Include additional information?"
478
  msgstr ""
479
 
480
- #: inc/cpcff_admin_int.inc.php:554 inc/cpcff_admin_int.inc.php:592
481
- #: inc/cpcff_admin_int.inc.php:633
482
  msgid "Yes"
483
  msgstr ""
484
 
485
- #: inc/cpcff_admin_int.inc.php:556
486
  msgid ""
487
  "If the \"No\" option is selected the plugin won't capture the IP address of "
488
  "users."
489
  msgstr ""
490
 
491
- #: inc/cpcff_admin_int.inc.php:560
492
  msgid "Thank you page (after sending the message)"
493
  msgstr ""
494
 
495
- #: inc/cpcff_admin_int.inc.php:564 inc/cpcff_admin_int.inc.php:606
496
  msgid "Email format?"
497
  msgstr ""
498
 
499
- #: inc/cpcff_admin_int.inc.php:568 inc/cpcff_admin_int.inc.php:610
500
  msgid "Plain Text (default)"
501
  msgstr ""
502
 
503
- #: inc/cpcff_admin_int.inc.php:569 inc/cpcff_admin_int.inc.php:611
504
  msgid "HTML (use html in the textarea below)"
505
  msgstr ""
506
 
507
- #: inc/cpcff_admin_int.inc.php:574 inc/cpcff_admin_int.inc.php:616
508
  msgid "Message"
509
  msgstr ""
510
 
511
- #: inc/cpcff_admin_int.inc.php:584
512
  msgid "Email Copy to User"
513
  msgstr ""
514
 
515
- #: inc/cpcff_admin_int.inc.php:588
516
  msgid "Send confirmation/thank you message to user?"
517
  msgstr ""
518
 
519
- #: inc/cpcff_admin_int.inc.php:598
520
  msgid "Email field on the form"
521
  msgstr ""
522
 
523
- #: inc/cpcff_admin_int.inc.php:625
524
  msgid "Captcha Verification"
525
  msgstr ""
526
 
527
- #: inc/cpcff_admin_int.inc.php:629
528
  msgid "Use Captcha Verification?"
529
  msgstr ""
530
 
531
- #: inc/cpcff_admin_int.inc.php:640
532
  msgid "Width"
533
  msgstr ""
534
 
535
- #: inc/cpcff_admin_int.inc.php:642
536
  msgid "Height"
537
  msgstr ""
538
 
539
- #: inc/cpcff_admin_int.inc.php:644
540
  msgid "Chars"
541
  msgstr ""
542
 
543
- #: inc/cpcff_admin_int.inc.php:649
544
  msgid "Min font size"
545
  msgstr ""
546
 
547
- #: inc/cpcff_admin_int.inc.php:651
548
  msgid "Max font size"
549
  msgstr ""
550
 
551
- #: inc/cpcff_admin_int.inc.php:656
552
  msgid "security code"
553
  msgstr ""
554
 
555
- #: inc/cpcff_admin_int.inc.php:662
556
  msgid "Noise"
557
  msgstr ""
558
 
559
- #: inc/cpcff_admin_int.inc.php:664
560
  msgid "Noise Length"
561
  msgstr ""
562
 
563
- #: inc/cpcff_admin_int.inc.php:669
564
  msgid "Background"
565
  msgstr ""
566
 
567
- #: inc/cpcff_admin_int.inc.php:676
568
  msgid "Font"
569
  msgstr ""
570
 
571
- #: inc/cpcff_admin_int_list.inc.php:53
572
  msgid "Default settings updated"
573
  msgstr ""
574
 
575
- #: inc/cpcff_admin_int_list.inc.php:68
576
  msgid "Item added"
577
  msgstr ""
578
 
579
- #: inc/cpcff_admin_int_list.inc.php:78
580
  msgid "Item updated"
581
  msgstr ""
582
 
583
- #: inc/cpcff_admin_int_list.inc.php:84
584
  msgid "Item deleted"
585
  msgstr ""
586
 
587
- #: inc/cpcff_admin_int_list.inc.php:88
588
  msgid "Item duplicated/cloned"
589
  msgstr ""
590
 
591
- #: inc/cpcff_admin_int_list.inc.php:89
592
  msgid "Duplicate/Clone Error, the form cannot be cloned"
593
  msgstr ""
594
 
595
- #: inc/cpcff_admin_int_list.inc.php:139
596
  msgid "Troubleshoot settings updated"
597
  msgstr ""
598
 
599
- #: inc/cpcff_admin_int_list.inc.php:202
600
  msgid "Are you sure you want to delete this item?"
601
  msgstr ""
602
 
603
- #: inc/cpcff_admin_int_list.inc.php:210
604
  msgid "Are you sure you want to update these settings?"
605
  msgstr ""
606
 
607
- #: inc/cpcff_admin_int_list.inc.php:235
608
  msgid ""
609
  "Are you sure you want to modify existing forms?\\nWe recommend modifying the "
610
  "forms one by one."
611
  msgstr ""
612
 
613
- #: inc/cpcff_admin_int_list.inc.php:244
614
  msgid "Forms and Settings"
615
  msgstr ""
616
 
@@ -618,27 +630,27 @@ msgstr ""
618
  msgid "Marketplace"
619
  msgstr ""
620
 
621
- #: inc/cpcff_admin_int_list.inc.php:263
622
  msgid "Form Categories"
623
  msgstr ""
624
 
625
- #: inc/cpcff_admin_int_list.inc.php:265
626
  msgid "All forms"
627
  msgstr ""
628
 
629
- #: inc/cpcff_admin_int_list.inc.php:277
630
  msgid "Form List / Items List"
631
  msgstr ""
632
 
633
- #: inc/cpcff_admin_int_list.inc.php:281
634
  msgid "in"
635
  msgstr ""
636
 
637
- #: inc/cpcff_admin_int_list.inc.php:281
638
  msgid "category"
639
  msgstr ""
640
 
641
- #: inc/cpcff_admin_int_list.inc.php:288
642
  msgid "ID"
643
  msgstr ""
644
 
@@ -654,23 +666,23 @@ msgstr ""
654
  msgid "Category/Shortcode"
655
  msgstr ""
656
 
657
- #: inc/cpcff_admin_int_list.inc.php:304 inc/cpcff_admin_int_list.inc.php:363
658
  msgid "Update"
659
  msgstr ""
660
 
661
- #: inc/cpcff_admin_int_list.inc.php:305 inc/cpcff_main.inc.php:222
662
  msgid "Settings"
663
  msgstr ""
664
 
665
- #: inc/cpcff_admin_int_list.inc.php:306
666
  msgid "Messages"
667
  msgstr ""
668
 
669
- #: inc/cpcff_admin_int_list.inc.php:307
670
  msgid "Clone"
671
  msgstr ""
672
 
673
- #: inc/cpcff_admin_int_list.inc.php:308
674
  msgid "Delete"
675
  msgstr ""
676
 
@@ -686,7 +698,7 @@ msgstr ""
686
  msgid "Item Name"
687
  msgstr ""
688
 
689
- #: inc/cpcff_admin_int_list.inc.php:326
690
  msgid "Category"
691
  msgstr ""
692
 
@@ -694,15 +706,19 @@ msgstr ""
694
  msgid "Create Form"
695
  msgstr ""
696
 
697
- #: inc/cpcff_admin_int_list.inc.php:340
 
 
 
 
698
  msgid "Default Settings"
699
  msgstr ""
700
 
701
- #: inc/cpcff_admin_int_list.inc.php:342
702
  msgid "Applies the default settings to new forms."
703
  msgstr ""
704
 
705
- #: inc/cpcff_admin_int_list.inc.php:344
706
  msgid "Default Template"
707
  msgstr ""
708
 
@@ -733,48 +749,48 @@ msgstr ""
733
  msgid "Script load method"
734
  msgstr ""
735
 
736
- #: inc/cpcff_admin_int_list.inc.php:380
737
  msgid "Classic (Recommended)"
738
  msgstr ""
739
 
740
- #: inc/cpcff_admin_int_list.inc.php:381
741
  msgid "Direct"
742
  msgstr ""
743
 
744
- #: inc/cpcff_admin_int_list.inc.php:383
745
  msgid ""
746
  "* Change the script load method if the form doesn't appear in the public "
747
  "website."
748
  msgstr ""
749
 
750
- #: inc/cpcff_admin_int_list.inc.php:385
751
  msgid "Character encoding"
752
  msgstr ""
753
 
754
- #: inc/cpcff_admin_int_list.inc.php:387
755
  msgid "Keep current charset (Recommended)"
756
  msgstr ""
757
 
758
- #: inc/cpcff_admin_int_list.inc.php:388
759
  msgid "try this first"
760
  msgstr ""
761
 
762
- #: inc/cpcff_admin_int_list.inc.php:389
763
  msgid "Only from MySQL 5.5"
764
  msgstr ""
765
 
766
- #: inc/cpcff_admin_int_list.inc.php:392
767
  msgid ""
768
  "* Update the charset if you are getting problems displaying special/non-"
769
  "latin characters. After updated you need to edit the special characters "
770
  "again."
771
  msgstr ""
772
 
773
- #: inc/cpcff_admin_int_list.inc.php:400
774
  msgid "There is active an optimization plugin in WordPress"
775
  msgstr ""
776
 
777
- #: inc/cpcff_admin_int_list.inc.php:401
778
  msgid ""
779
  "* Tick the checkbox if there is an optimization plugin active on the "
780
  "website, and the forms are not visible."
@@ -812,22 +828,22 @@ msgstr ""
812
  msgid "Calculated Fields Form Marketplace"
813
  msgstr ""
814
 
815
- #: inc/cpcff_admin_int_list.inc.php:436 inc/cpcff_main.inc.php:223
816
  msgid "Upgrade"
817
  msgstr ""
818
 
819
- #: inc/cpcff_amp.inc.php:155
820
  msgid "Click to expand"
821
  msgstr ""
822
 
823
- #: inc/cpcff_compatibility.inc.php:20
824
  msgid ""
825
  "There is active the <b>Breeze - WordPress Cache Plugin</b> plugin. If the "
826
  "forms are not visible, please tick the <i>\"There is active an optimization "
827
  "plugin in WordPress\"</i> and Purge the Breeze cache."
828
  msgstr ""
829
 
830
- #: inc/cpcff_compatibility.inc.php:26
831
  msgid ""
832
  "There is active the <b>Fast Velocity Minify</b> plugin. If the forms are not "
833
  "visible, please try disabling the <i>\"Disable minification on JS files\"</"
@@ -835,13 +851,13 @@ msgid ""
835
  "Velocity Minify</b> settings."
836
  msgstr ""
837
 
838
- #: inc/cpcff_compatibility.inc.php:32
839
  msgid ""
840
  "There is active the <b>W3 Total Cache</b> plugin. If the forms are not "
841
  "visible, please tick the checkbox."
842
  msgstr ""
843
 
844
- #: inc/cpcff_compatibility.inc.php:38
845
  msgid ""
846
  "There is active the <b>Autoptimize</b> plugin. If the forms are not visible, "
847
  "please try disabling the <i>\"Force JavaScript in &lt;head&gt;\"</i> option "
@@ -849,14 +865,14 @@ msgid ""
849
  "\"Exclude scripts from Autoptimize\"</i> one."
850
  msgstr ""
851
 
852
- #: inc/cpcff_compatibility.inc.php:44
853
  msgid ""
854
  "There is active the <b>LiteSpeed Cache</b> plugin. If the forms are not "
855
  "visible, please try disabling the <i>\"JS Combine\"</i> option in the "
856
  "<b>Optimize</b> tab of <b>LiteSpeed Cache</b> settings."
857
  msgstr ""
858
 
859
- #: inc/cpcff_compatibility.inc.php:50
860
  msgid ""
861
  "There is active the <b>WP Rocket</b> plugin. If the forms are not visible, "
862
  "please try disabling the <i>\"Combine JavaScript files\"</i> option in the "
@@ -864,7 +880,7 @@ msgid ""
864
  "clear the website cache."
865
  msgstr ""
866
 
867
- #: inc/cpcff_compatibility.inc.php:56
868
  msgid ""
869
  "There is active the <b>SG Optimizer</b> plugin. If the forms are not "
870
  "visible, please try disabling the options: <i>\"Minify the HTML Output\"</i> "
@@ -872,7 +888,7 @@ msgid ""
872
  "and remember to purge the website cache."
873
  msgstr ""
874
 
875
- #: inc/cpcff_compatibility.inc.php:62
876
  msgid ""
877
  "There is active the <b>Hummingbird</b> plugin. If the forms are not visible, "
878
  "check the <i>\"Hummingbird &gt; Asset Optimization\"</i> options. Make sure "
@@ -881,53 +897,55 @@ msgid ""
881
  "settings."
882
  msgstr ""
883
 
884
- #: inc/cpcff_main.inc.php:221
885
  msgid "Request custom changes"
886
  msgstr ""
887
 
888
- #: inc/cpcff_main.inc.php:241
889
  msgid "Insert Calculated Fields Form"
890
  msgstr ""
891
 
892
- #: inc/cpcff_main.inc.php:241
893
  msgid "Create a JavaScript var from POST, GET, SESSION, or COOKIE var"
894
  msgstr ""
895
 
896
- #: inc/cpcff_page_builders.inc.php:99
897
- #: pagebuilders/elementor/elementor.pb.php:59
898
  msgid "Select a form"
899
  msgstr ""
900
 
901
- #: inc/cpcff_page_builders.inc.php:100
902
  msgid "Forms"
903
  msgstr ""
904
 
905
- #: inc/cpcff_page_builders.inc.php:101
906
- #: pagebuilders/beaverbuilder/cff/cff.inc.php:38
907
- #: pagebuilders/elementor/elementor.pb.php:70
908
  msgid "Additional attributes"
909
  msgstr ""
910
 
911
- #: inc/cpcff_page_builders.inc.php:102
912
- #: pagebuilders/beaverbuilder/cff/cff.inc.php:43
913
- #: pagebuilders/elementor/elementor.pb.php:85
914
- #: pagebuilders/siteorigin/siteorigin-cpcff/fields/cff-button.class.php:12
915
  msgid "Edit form"
916
  msgstr ""
917
 
918
- #: pagebuilders/beaverbuilder/cff/cff.inc.php:21
919
  msgid "Select the form and enter the additional attributes"
920
  msgstr ""
921
 
922
- #: pagebuilders/beaverbuilder/cff/cff.inc.php:24
923
  msgid "Form information"
924
  msgstr ""
925
 
926
- #: pagebuilders/beaverbuilder/cff/cff.inc.php:28
 
927
  msgid "Select form"
928
  msgstr ""
929
 
930
- #: pagebuilders/beaverbuilder/cff/cff.inc.php:34
 
931
  msgid "Class name"
932
  msgstr ""
933
 
@@ -952,7 +970,7 @@ msgid "Enter the default value"
952
  msgstr ""
953
 
954
  #: pagebuilders/beaverbuilder/cffvar/cffvar.inc.php:24
955
- #: pagebuilders/siteorigin/siteorigin-cpcff-variable/siteorigin-cpcff-variable.php:29
956
  msgid "Generate variable from"
957
  msgstr ""
958
 
@@ -984,57 +1002,61 @@ msgstr ""
984
  msgid "Create javascript variable"
985
  msgstr ""
986
 
987
- #: pagebuilders/elementor/elementor.pb.php:180
 
 
 
 
988
  msgid "Variable Shortcode"
989
  msgstr ""
990
 
991
- #: pagebuilders/elementor/elementor.pb.php:187
992
  msgid "Variable shortcode"
993
  msgstr ""
994
 
995
- #: pagebuilders/elementor/elementor.pb.php:192
996
  msgid "I need help [+]"
997
  msgstr ""
998
 
999
- #: pagebuilders/siteorigin/siteorigin-cpcff-variable/siteorigin-cpcff-variable.php:14
1000
  msgid "Calculated Fields Form, Variable Shortcode"
1001
  msgstr ""
1002
 
1003
- #: pagebuilders/siteorigin/siteorigin-cpcff-variable/siteorigin-cpcff-variable.php:16
1004
  msgid ""
1005
  "Shortcode to generate a javascript variable from the url parameters (GET or "
1006
  "POST), session variables, cookies, or define it directly"
1007
  msgstr ""
1008
 
1009
- #: pagebuilders/siteorigin/siteorigin-cpcff-variable/siteorigin-cpcff-variable.php:24
1010
  msgid "Variable name"
1011
  msgstr ""
1012
 
1013
- #: pagebuilders/siteorigin/siteorigin-cpcff-variable/siteorigin-cpcff-variable.php:32
1014
  msgid "Any source"
1015
  msgstr ""
1016
 
1017
- #: pagebuilders/siteorigin/siteorigin-cpcff-variable/siteorigin-cpcff-variable.php:33
1018
  msgid "GET parameter"
1019
  msgstr ""
1020
 
1021
- #: pagebuilders/siteorigin/siteorigin-cpcff-variable/siteorigin-cpcff-variable.php:34
1022
  msgid "POST parameter"
1023
  msgstr ""
1024
 
1025
- #: pagebuilders/siteorigin/siteorigin-cpcff-variable/siteorigin-cpcff-variable.php:35
1026
  msgid "Session variable"
1027
  msgstr ""
1028
 
1029
- #: pagebuilders/siteorigin/siteorigin-cpcff-variable/siteorigin-cpcff-variable.php:36
1030
  msgid "Cookie"
1031
  msgstr ""
1032
 
1033
- #: pagebuilders/siteorigin/siteorigin-cpcff-variable/siteorigin-cpcff-variable.php:41
1034
  msgid "Default value (used when variables are generated from a source)"
1035
  msgstr ""
1036
 
1037
- #: pagebuilders/siteorigin/siteorigin-cpcff-variable/siteorigin-cpcff-variable.php:46
1038
  msgid "Value (value of the variable when it is generated directly)"
1039
  msgstr ""
1040
 
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: \n"
4
+ "POT-Creation-Date: 2022-09-12 12:19+0200\n"
5
+ "PO-Revision-Date: 2022-09-12 12:19+0200\n"
6
  "Last-Translator: CodePeople\n"
7
  "Language-Team: \n"
8
  "Language: en_US\n"
12
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
13
  "X-Generator: Poedit 3.1.1\n"
14
  "X-Poedit-Basepath: ..\n"
15
+ "X-Poedit-KeywordsList: __;_e;esc_attr__;esc_attr_e;esc_html__;esc_html_e\n"
16
  "X-Poedit-SearchPath-0: .\n"
17
 
18
+ #: cp_calculatedfieldsf_free.php:78
19
  msgid "Form Preview"
20
  msgstr ""
21
 
22
+ #: cp_calculatedfieldsf_free.php:119
23
  msgid ""
24
  "<div class=\"error-text\">The data cannot be stored in database because has "
25
  "occurred an error with the database structure. Please, go to the plugins "
28
  "please <a href=\"https://cff.dwbooster.com/contact-us\">contact us</a></div>"
29
  msgstr ""
30
 
31
+ #: cp_calculatedfieldsf_free.php:130
32
  msgid ""
33
  "<div class=\"error-text\">The data cannot be stored in database because has "
34
  "occurred an error with the form structure. Please, try to save the data "
41
  msgid "Settings saved"
42
  msgstr ""
43
 
44
+ #: inc/cpcff_admin_int.inc.php:51 inc/cpcff_admin_int_list.inc.php:148
45
+ #: inc/cpcff_page_builders.inc.php:164
46
  #: pagebuilders/beaverbuilder/cff/cff/cff.php:9
47
  #: pagebuilders/beaverbuilder/cff/cff/cff.php:11
48
  #: pagebuilders/beaverbuilder/cff/cff/cff.php:12
49
  #: pagebuilders/beaverbuilder/cffvar/cffvar/cffvar.php:11
50
  #: pagebuilders/beaverbuilder/cffvar/cffvar/cffvar.php:12
51
+ #: pagebuilders/divi/cff.pb.php:9 pagebuilders/elementor/elementor.pb.php:36
52
  msgid "Calculated Fields Form"
53
  msgstr ""
54
 
55
+ #: inc/cpcff_admin_int.inc.php:51 pagebuilders/divi/cff.pb.php:13
56
  msgid "Form"
57
  msgstr ""
58
 
64
  msgid "Back to items list..."
65
  msgstr ""
66
 
67
+ #: inc/cpcff_admin_int.inc.php:70 inc/cpcff_admin_int.inc.php:230
68
  msgid "Form Settings"
69
  msgstr ""
70
 
90
  msgid "Select a revision"
91
  msgstr ""
92
 
93
+ #: inc/cpcff_admin_int.inc.php:108 inc/cpcff_admin_int.inc.php:250
94
+ #: inc/cpcff_admin_int.inc.php:672
95
  msgid "Preview"
96
  msgstr ""
97
 
98
+ #: inc/cpcff_admin_int.inc.php:108
99
  msgid "Saves the form's structure only, and opens a preview windows"
100
  msgstr ""
101
 
102
+ #: inc/cpcff_admin_int.inc.php:109
103
  msgid "Fields List"
104
  msgstr ""
105
 
106
+ #: inc/cpcff_admin_int.inc.php:119
107
  msgid ""
108
  "If the form is not loading in the public website, go to the settings page of "
109
  "the plugin through the menu option: \"Settings/Calculated Fields Form\", "
111
  "press the \"Update\" button."
112
  msgstr ""
113
 
114
+ #: inc/cpcff_admin_int.inc.php:119
115
  msgid ""
116
  "If you need also the form to be sent to the server side for processing (for "
117
  "example to deliver emails) then the <a href=\"https://cff.dwbooster.com/"
119
  "required."
120
  msgstr ""
121
 
122
+ #: inc/cpcff_admin_int.inc.php:136
123
  msgid ""
124
  "The action will load the revision selected, the data are not stored will be "
125
  "lose. Do you want continue?"
126
  msgstr ""
127
 
128
+ #: inc/cpcff_admin_int.inc.php:193
129
  msgid ""
130
  "These features aren't available in this version. Do you want to open the "
131
  "plugin's page to check other versions?"
132
  msgstr ""
133
 
134
+ #: inc/cpcff_admin_int.inc.php:228
135
  msgid "Add a Field"
136
  msgstr ""
137
 
138
+ #: inc/cpcff_admin_int.inc.php:229
139
  msgid "Field Settings"
140
  msgstr ""
141
 
142
+ #: inc/cpcff_admin_int.inc.php:249 inc/cpcff_admin_int.inc.php:379
143
+ #: inc/cpcff_admin_int.inc.php:720
144
  msgid "Save Changes"
145
  msgstr ""
146
 
147
+ #: inc/cpcff_admin_int.inc.php:257
148
  msgid "Generate revisions in the form preview as well"
149
  msgstr ""
150
 
151
+ #: inc/cpcff_admin_int.inc.php:262
152
  msgid "Texts definition"
153
  msgstr ""
154
 
155
+ #: inc/cpcff_admin_int.inc.php:263
156
  msgid "Error texts"
157
  msgstr ""
158
 
159
+ #: inc/cpcff_admin_int.inc.php:264
160
  msgid "General payment settings"
161
  msgstr ""
162
 
163
+ #: inc/cpcff_admin_int.inc.php:265
164
  msgid "PayPal integration"
165
  msgstr ""
166
 
167
+ #: inc/cpcff_admin_int.inc.php:266
168
  msgid "Notification email"
169
  msgstr ""
170
 
171
+ #: inc/cpcff_admin_int.inc.php:267
172
  msgid "Email copy to user"
173
  msgstr ""
174
 
175
+ #: inc/cpcff_admin_int.inc.php:268
176
  msgid "Captcha settings"
177
  msgstr ""
178
 
179
+ #: inc/cpcff_admin_int.inc.php:271
180
  msgid "Define Texts"
181
  msgstr ""
182
 
183
+ #: inc/cpcff_admin_int.inc.php:275
184
  msgid "Previous button label (text)"
185
  msgstr ""
186
 
188
  msgid "Next button label (text)"
189
  msgstr ""
190
 
191
+ #: inc/cpcff_admin_int.inc.php:286
192
  msgid ""
193
  "- The styles can be applied into any of the CSS files of your theme or into "
194
  "the CSS file <em>\"calculated-fields-form\\css\\stylepublic.css\"</em>."
195
  msgstr ""
196
 
197
+ #: inc/cpcff_admin_int.inc.php:287
198
  msgid ""
199
  "- For general CSS styles modifications to the form and samples <a href="
200
  "\"https://cff.dwbooster.com/faq#q82\" target=\"_blank\">check this FAQ</a>."
201
  msgstr ""
202
 
203
+ #: inc/cpcff_admin_int.inc.php:303 inc/cpcff_admin_int.inc.php:364
204
+ #: inc/cpcff_admin_int.inc.php:451 inc/cpcff_admin_int.inc.php:537
205
+ #: inc/cpcff_admin_int.inc.php:590 inc/cpcff_admin_int.inc.php:636
206
+ #: inc/cpcff_admin_int.inc.php:709
207
  msgid "Up to form structure"
208
  msgstr ""
209
 
210
+ #: inc/cpcff_admin_int.inc.php:308
211
  msgid "Validation Settings"
212
  msgstr ""
213
 
214
+ #: inc/cpcff_admin_int.inc.php:312
215
  msgid "\"is required\" text"
216
  msgstr ""
217
 
218
+ #: inc/cpcff_admin_int.inc.php:316
219
  msgid "\"is email\" text"
220
  msgstr ""
221
 
222
+ #: inc/cpcff_admin_int.inc.php:320
223
  msgid "\"is valid captcha\" text"
224
  msgstr ""
225
 
226
+ #: inc/cpcff_admin_int.inc.php:325
227
  msgid "\"is valid date (mm/dd/yyyy)\" text"
228
  msgstr ""
229
 
230
+ #: inc/cpcff_admin_int.inc.php:329
231
  msgid "\"is valid date (dd/mm/yyyy)\" text"
232
  msgstr ""
233
 
234
+ #: inc/cpcff_admin_int.inc.php:333
235
  msgid "\"is number\" text"
236
  msgstr ""
237
 
238
+ #: inc/cpcff_admin_int.inc.php:337
239
  msgid "\"only digits\" text"
240
  msgstr ""
241
 
242
+ #: inc/cpcff_admin_int.inc.php:341
243
  msgid "\"under maximum\" text"
244
  msgstr ""
245
 
246
+ #: inc/cpcff_admin_int.inc.php:345
247
  msgid "\"over minimum\" text"
248
  msgstr ""
249
 
250
+ #: inc/cpcff_admin_int.inc.php:369
251
  msgid "Note"
252
  msgstr ""
253
 
254
+ #: inc/cpcff_admin_int.inc.php:371
255
  msgid ""
256
  "To display the form in a post/page, enter your shortcode in the post/page "
257
  "content:"
258
  msgstr ""
259
 
260
+ #: inc/cpcff_admin_int.inc.php:373
261
  msgid ""
262
  "The CFF plugin implements widgets and blocks to allow inserting the form "
263
  "visually with the most popular page builders such as Gutenberg Editor, "
265
  "Divi, and for the other page builders insert the shortcode directly."
266
  msgstr ""
267
 
268
+ #: inc/cpcff_admin_int.inc.php:382 inc/cpcff_admin_int.inc.php:723
269
  #: inc/cpcff_admin_int_list.inc.php:436
270
  msgid "Request Custom Modifications"
271
  msgstr ""
272
 
273
+ #: inc/cpcff_admin_int.inc.php:382 inc/cpcff_admin_int.inc.php:723
274
+ #: inc/cpcff_admin_int_list.inc.php:436 inc/cpcff_main.inc.php:218
275
  msgid "Help"
276
  msgstr ""
277
 
278
+ #: inc/cpcff_admin_int.inc.php:389
279
  msgid ""
280
  "The following features are available in the commercial version of the <a "
281
  "href=\"https://cff.dwbooster.com/download\" target=\"_blank\" style=\"text-"
282
  "decoration:none;\">\"Calculated Fields Form\"</a>"
283
  msgstr ""
284
 
285
+ #: inc/cpcff_admin_int.inc.php:390
286
  msgid "Pay only ONCE, use it FOREVER"
287
  msgstr ""
288
 
289
+ #: inc/cpcff_admin_int.inc.php:399
290
  msgid "Form Processing and Payment Settings"
291
  msgstr ""
292
 
293
+ #: inc/cpcff_admin_int.inc.php:403
294
  msgid "Payment Settings"
295
  msgstr ""
296
 
297
+ #: inc/cpcff_admin_int.inc.php:408
298
  msgid "Request cost"
299
  msgstr ""
300
 
301
+ #: inc/cpcff_admin_int.inc.php:413
302
  msgid "Currency"
303
  msgstr ""
304
 
305
+ #: inc/cpcff_admin_int.inc.php:415
306
+ msgid "United States dollar"
307
+ msgstr ""
308
+
309
+ #: inc/cpcff_admin_int.inc.php:415
310
+ msgid "Pound sterling"
311
+ msgstr ""
312
+
313
+ #: inc/cpcff_admin_int.inc.php:415
314
+ msgid "PayPal Currency Codes"
315
+ msgstr ""
316
+
317
+ #: inc/cpcff_admin_int.inc.php:420
318
  msgid "Base amount"
319
  msgstr ""
320
 
321
+ #: inc/cpcff_admin_int.inc.php:421
322
  msgid ""
323
  "Minimum amount to charge. If the final price is lesser than this number, the "
324
  "base amount will be applied."
325
  msgstr ""
326
 
327
+ #: inc/cpcff_admin_int.inc.php:426
328
  msgid "Paypal product name"
329
  msgstr ""
330
 
331
+ #: inc/cpcff_admin_int.inc.php:431
332
  msgid "Discount Codes"
333
  msgstr ""
334
 
335
+ #: inc/cpcff_admin_int.inc.php:433
336
  msgid "This feature isn't available in this version."
337
  msgstr ""
338
 
339
+ #: inc/cpcff_admin_int.inc.php:436
340
  msgid "Add new discount code"
341
  msgstr ""
342
 
343
+ #: inc/cpcff_admin_int.inc.php:438
344
  msgid "Code"
345
  msgstr ""
346
 
347
+ #: inc/cpcff_admin_int.inc.php:439
348
  msgid "Discount"
349
  msgstr ""
350
 
351
+ #: inc/cpcff_admin_int.inc.php:440
352
  msgid "Percent"
353
  msgstr ""
354
 
355
+ #: inc/cpcff_admin_int.inc.php:441
356
  msgid "Fixed Value"
357
  msgstr ""
358
 
359
+ #: inc/cpcff_admin_int.inc.php:444
360
  msgid "Valid until"
361
  msgstr ""
362
 
363
+ #: inc/cpcff_admin_int.inc.php:445
364
  msgid "Add"
365
  msgstr ""
366
 
367
+ #: inc/cpcff_admin_int.inc.php:447
368
  msgid "Note: Expiration date based in server time. Server time now is"
369
  msgstr ""
370
 
371
+ #: inc/cpcff_admin_int.inc.php:456
372
  msgid "Paypal Payment Configuration"
373
  msgstr ""
374
 
375
+ #: inc/cpcff_admin_int.inc.php:461
376
  msgid "Enable Paypal Payments?"
377
  msgstr ""
378
 
379
+ #: inc/cpcff_admin_int.inc.php:463 inc/cpcff_admin_int.inc.php:565
380
+ #: inc/cpcff_admin_int.inc.php:607 inc/cpcff_admin_int.inc.php:652
381
  msgid "No"
382
  msgstr ""
383
 
384
+ #: inc/cpcff_admin_int.inc.php:465
385
  msgid ""
386
  "Note: If \"Optional\" is selected, a radiobutton will appear in the form to "
387
  "select if the payment will be made with PayPal or not."
388
  msgstr ""
389
 
390
+ #: inc/cpcff_admin_int.inc.php:467
391
  msgid "Label for the \"<strong>Pay with PayPal</strong>\" option"
392
  msgstr ""
393
 
394
+ #: inc/cpcff_admin_int.inc.php:473
395
  msgid "Paypal Mode"
396
  msgstr ""
397
 
398
+ #: inc/cpcff_admin_int.inc.php:476
399
  msgid "Production - real payments processed"
400
  msgstr ""
401
 
402
+ #: inc/cpcff_admin_int.inc.php:478
403
  msgid "SandBox - PayPal testing sandbox area"
404
  msgstr ""
405
 
406
+ #: inc/cpcff_admin_int.inc.php:484
407
  msgid "Paypal email"
408
  msgstr ""
409
 
410
+ #: inc/cpcff_admin_int.inc.php:489
411
  msgid "A $0 amount to pay means"
412
  msgstr ""
413
 
414
+ #: inc/cpcff_admin_int.inc.php:492
415
  msgid "Let the user enter any amount at PayPal (ex: for a donation)"
416
  msgstr ""
417
 
427
  msgid "Payment frequency"
428
  msgstr ""
429
 
430
+ #: inc/cpcff_admin_int.inc.php:510
431
  msgid "One time payment (default option, user is billed only once)"
432
  msgstr ""
433
 
434
+ #: inc/cpcff_admin_int.inc.php:512
435
  msgid "Bill the user every 1 month"
436
  msgstr ""
437
 
438
+ #: inc/cpcff_admin_int.inc.php:514
439
  msgid "Bill the user every 3 months"
440
  msgstr ""
441
 
442
+ #: inc/cpcff_admin_int.inc.php:516
443
  msgid "Bill the user every 6 months"
444
  msgstr ""
445
 
446
+ #: inc/cpcff_admin_int.inc.php:518
447
  msgid "Bill the user every 12 months"
448
  msgstr ""
449
 
450
+ #: inc/cpcff_admin_int.inc.php:523
451
  msgid "Paypal prompt buyers for shipping address"
452
  msgstr ""
453
 
454
+ #: inc/cpcff_admin_int.inc.php:528
455
  msgid "Do not prompt for an address"
456
  msgstr ""
457
 
458
+ #: inc/cpcff_admin_int.inc.php:530
459
  msgid "Prompt for an address, but do not require one"
460
  msgstr ""
461
 
462
+ #: inc/cpcff_admin_int.inc.php:532
463
  msgid "Prompt for an address and require one"
464
  msgstr ""
465
 
466
+ #: inc/cpcff_admin_int.inc.php:542
467
  msgid "Form Processing / Email Settings"
468
  msgstr ""
469
 
470
+ #: inc/cpcff_admin_int.inc.php:546
471
  msgid "\"From\" email"
472
  msgstr ""
473
 
474
+ #: inc/cpcff_admin_int.inc.php:547
475
  msgid ""
476
  "This email is required if the \"From fixed email address\" option is "
477
  "selected, or it is enabled the email copy to the user."
478
  msgstr ""
479
 
480
+ #: inc/cpcff_admin_int.inc.php:550
481
  msgid "Destination emails (comma separated)"
482
  msgstr ""
483
 
484
+ #: inc/cpcff_admin_int.inc.php:554 inc/cpcff_admin_int.inc.php:616
485
  msgid "Email subject"
486
  msgstr ""
487
 
488
+ #: inc/cpcff_admin_int.inc.php:558
489
  msgid "Include additional information?"
490
  msgstr ""
491
 
492
+ #: inc/cpcff_admin_int.inc.php:563 inc/cpcff_admin_int.inc.php:605
493
+ #: inc/cpcff_admin_int.inc.php:650
494
  msgid "Yes"
495
  msgstr ""
496
 
497
+ #: inc/cpcff_admin_int.inc.php:566
498
  msgid ""
499
  "If the \"No\" option is selected the plugin won't capture the IP address of "
500
  "users."
501
  msgstr ""
502
 
503
+ #: inc/cpcff_admin_int.inc.php:570
504
  msgid "Thank you page (after sending the message)"
505
  msgstr ""
506
 
507
+ #: inc/cpcff_admin_int.inc.php:574 inc/cpcff_admin_int.inc.php:620
508
  msgid "Email format?"
509
  msgstr ""
510
 
511
+ #: inc/cpcff_admin_int.inc.php:579 inc/cpcff_admin_int.inc.php:625
512
  msgid "Plain Text (default)"
513
  msgstr ""
514
 
515
+ #: inc/cpcff_admin_int.inc.php:581 inc/cpcff_admin_int.inc.php:627
516
  msgid "HTML (use html in the textarea below)"
517
  msgstr ""
518
 
519
+ #: inc/cpcff_admin_int.inc.php:586 inc/cpcff_admin_int.inc.php:632
520
  msgid "Message"
521
  msgstr ""
522
 
523
+ #: inc/cpcff_admin_int.inc.php:596
524
  msgid "Email Copy to User"
525
  msgstr ""
526
 
527
+ #: inc/cpcff_admin_int.inc.php:600
528
  msgid "Send confirmation/thank you message to user?"
529
  msgstr ""
530
 
531
+ #: inc/cpcff_admin_int.inc.php:612
532
  msgid "Email field on the form"
533
  msgstr ""
534
 
535
+ #: inc/cpcff_admin_int.inc.php:641
536
  msgid "Captcha Verification"
537
  msgstr ""
538
 
539
+ #: inc/cpcff_admin_int.inc.php:645
540
  msgid "Use Captcha Verification?"
541
  msgstr ""
542
 
543
+ #: inc/cpcff_admin_int.inc.php:658
544
  msgid "Width"
545
  msgstr ""
546
 
547
+ #: inc/cpcff_admin_int.inc.php:660
548
  msgid "Height"
549
  msgstr ""
550
 
551
+ #: inc/cpcff_admin_int.inc.php:662
552
  msgid "Chars"
553
  msgstr ""
554
 
555
+ #: inc/cpcff_admin_int.inc.php:667
556
  msgid "Min font size"
557
  msgstr ""
558
 
559
+ #: inc/cpcff_admin_int.inc.php:669
560
  msgid "Max font size"
561
  msgstr ""
562
 
563
+ #: inc/cpcff_admin_int.inc.php:674
564
  msgid "security code"
565
  msgstr ""
566
 
567
+ #: inc/cpcff_admin_int.inc.php:680
568
  msgid "Noise"
569
  msgstr ""
570
 
571
+ #: inc/cpcff_admin_int.inc.php:682
572
  msgid "Noise Length"
573
  msgstr ""
574
 
575
+ #: inc/cpcff_admin_int.inc.php:687
576
  msgid "Background"
577
  msgstr ""
578
 
579
+ #: inc/cpcff_admin_int.inc.php:694
580
  msgid "Font"
581
  msgstr ""
582
 
583
+ #: inc/cpcff_admin_int_list.inc.php:48
584
  msgid "Default settings updated"
585
  msgstr ""
586
 
587
+ #: inc/cpcff_admin_int_list.inc.php:65
588
  msgid "Item added"
589
  msgstr ""
590
 
591
+ #: inc/cpcff_admin_int_list.inc.php:72
592
  msgid "Item updated"
593
  msgstr ""
594
 
595
+ #: inc/cpcff_admin_int_list.inc.php:76
596
  msgid "Item deleted"
597
  msgstr ""
598
 
599
+ #: inc/cpcff_admin_int_list.inc.php:80
600
  msgid "Item duplicated/cloned"
601
  msgstr ""
602
 
603
+ #: inc/cpcff_admin_int_list.inc.php:82
604
  msgid "Duplicate/Clone Error, the form cannot be cloned"
605
  msgstr ""
606
 
607
+ #: inc/cpcff_admin_int_list.inc.php:127
608
  msgid "Troubleshoot settings updated"
609
  msgstr ""
610
 
611
+ #: inc/cpcff_admin_int_list.inc.php:200
612
  msgid "Are you sure you want to delete this item?"
613
  msgstr ""
614
 
615
+ #: inc/cpcff_admin_int_list.inc.php:208
616
  msgid "Are you sure you want to update these settings?"
617
  msgstr ""
618
 
619
+ #: inc/cpcff_admin_int_list.inc.php:233
620
  msgid ""
621
  "Are you sure you want to modify existing forms?\\nWe recommend modifying the "
622
  "forms one by one."
623
  msgstr ""
624
 
625
+ #: inc/cpcff_admin_int_list.inc.php:243
626
  msgid "Forms and Settings"
627
  msgstr ""
628
 
630
  msgid "Marketplace"
631
  msgstr ""
632
 
633
+ #: inc/cpcff_admin_int_list.inc.php:262
634
  msgid "Form Categories"
635
  msgstr ""
636
 
637
+ #: inc/cpcff_admin_int_list.inc.php:264
638
  msgid "All forms"
639
  msgstr ""
640
 
641
+ #: inc/cpcff_admin_int_list.inc.php:276
642
  msgid "Form List / Items List"
643
  msgstr ""
644
 
645
+ #: inc/cpcff_admin_int_list.inc.php:279
646
  msgid "in"
647
  msgstr ""
648
 
649
+ #: inc/cpcff_admin_int_list.inc.php:279
650
  msgid "category"
651
  msgstr ""
652
 
653
+ #: inc/cpcff_admin_int_list.inc.php:287
654
  msgid "ID"
655
  msgstr ""
656
 
666
  msgid "Category/Shortcode"
667
  msgstr ""
668
 
669
+ #: inc/cpcff_admin_int_list.inc.php:303 inc/cpcff_admin_int_list.inc.php:363
670
  msgid "Update"
671
  msgstr ""
672
 
673
+ #: inc/cpcff_admin_int_list.inc.php:304 inc/cpcff_main.inc.php:216
674
  msgid "Settings"
675
  msgstr ""
676
 
677
+ #: inc/cpcff_admin_int_list.inc.php:305
678
  msgid "Messages"
679
  msgstr ""
680
 
681
+ #: inc/cpcff_admin_int_list.inc.php:306
682
  msgid "Clone"
683
  msgstr ""
684
 
685
+ #: inc/cpcff_admin_int_list.inc.php:307
686
  msgid "Delete"
687
  msgstr ""
688
 
698
  msgid "Item Name"
699
  msgstr ""
700
 
701
+ #: inc/cpcff_admin_int_list.inc.php:327
702
  msgid "Category"
703
  msgstr ""
704
 
706
  msgid "Create Form"
707
  msgstr ""
708
 
709
+ #: inc/cpcff_admin_int_list.inc.php:334
710
+ msgid "From Template"
711
+ msgstr ""
712
+
713
+ #: inc/cpcff_admin_int_list.inc.php:341
714
  msgid "Default Settings"
715
  msgstr ""
716
 
717
+ #: inc/cpcff_admin_int_list.inc.php:343
718
  msgid "Applies the default settings to new forms."
719
  msgstr ""
720
 
721
+ #: inc/cpcff_admin_int_list.inc.php:345
722
  msgid "Default Template"
723
  msgstr ""
724
 
749
  msgid "Script load method"
750
  msgstr ""
751
 
752
+ #: inc/cpcff_admin_int_list.inc.php:381
753
  msgid "Classic (Recommended)"
754
  msgstr ""
755
 
756
+ #: inc/cpcff_admin_int_list.inc.php:383
757
  msgid "Direct"
758
  msgstr ""
759
 
760
+ #: inc/cpcff_admin_int_list.inc.php:385
761
  msgid ""
762
  "* Change the script load method if the form doesn't appear in the public "
763
  "website."
764
  msgstr ""
765
 
766
+ #: inc/cpcff_admin_int_list.inc.php:387
767
  msgid "Character encoding"
768
  msgstr ""
769
 
770
+ #: inc/cpcff_admin_int_list.inc.php:389
771
  msgid "Keep current charset (Recommended)"
772
  msgstr ""
773
 
774
+ #: inc/cpcff_admin_int_list.inc.php:390
775
  msgid "try this first"
776
  msgstr ""
777
 
778
+ #: inc/cpcff_admin_int_list.inc.php:391
779
  msgid "Only from MySQL 5.5"
780
  msgstr ""
781
 
782
+ #: inc/cpcff_admin_int_list.inc.php:394
783
  msgid ""
784
  "* Update the charset if you are getting problems displaying special/non-"
785
  "latin characters. After updated you need to edit the special characters "
786
  "again."
787
  msgstr ""
788
 
789
+ #: inc/cpcff_admin_int_list.inc.php:401
790
  msgid "There is active an optimization plugin in WordPress"
791
  msgstr ""
792
 
793
+ #: inc/cpcff_admin_int_list.inc.php:402
794
  msgid ""
795
  "* Tick the checkbox if there is an optimization plugin active on the "
796
  "website, and the forms are not visible."
828
  msgid "Calculated Fields Form Marketplace"
829
  msgstr ""
830
 
831
+ #: inc/cpcff_admin_int_list.inc.php:436 inc/cpcff_main.inc.php:217
832
  msgid "Upgrade"
833
  msgstr ""
834
 
835
+ #: inc/cpcff_amp.inc.php:171
836
  msgid "Click to expand"
837
  msgstr ""
838
 
839
+ #: inc/cpcff_compatibility.inc.php:18
840
  msgid ""
841
  "There is active the <b>Breeze - WordPress Cache Plugin</b> plugin. If the "
842
  "forms are not visible, please tick the <i>\"There is active an optimization "
843
  "plugin in WordPress\"</i> and Purge the Breeze cache."
844
  msgstr ""
845
 
846
+ #: inc/cpcff_compatibility.inc.php:24
847
  msgid ""
848
  "There is active the <b>Fast Velocity Minify</b> plugin. If the forms are not "
849
  "visible, please try disabling the <i>\"Disable minification on JS files\"</"
851
  "Velocity Minify</b> settings."
852
  msgstr ""
853
 
854
+ #: inc/cpcff_compatibility.inc.php:30
855
  msgid ""
856
  "There is active the <b>W3 Total Cache</b> plugin. If the forms are not "
857
  "visible, please tick the checkbox."
858
  msgstr ""
859
 
860
+ #: inc/cpcff_compatibility.inc.php:36
861
  msgid ""
862
  "There is active the <b>Autoptimize</b> plugin. If the forms are not visible, "
863
  "please try disabling the <i>\"Force JavaScript in &lt;head&gt;\"</i> option "
865
  "\"Exclude scripts from Autoptimize\"</i> one."
866
  msgstr ""
867
 
868
+ #: inc/cpcff_compatibility.inc.php:42
869
  msgid ""
870
  "There is active the <b>LiteSpeed Cache</b> plugin. If the forms are not "
871
  "visible, please try disabling the <i>\"JS Combine\"</i> option in the "
872
  "<b>Optimize</b> tab of <b>LiteSpeed Cache</b> settings."
873
  msgstr ""
874
 
875
+ #: inc/cpcff_compatibility.inc.php:48
876
  msgid ""
877
  "There is active the <b>WP Rocket</b> plugin. If the forms are not visible, "
878
  "please try disabling the <i>\"Combine JavaScript files\"</i> option in the "
880
  "clear the website cache."
881
  msgstr ""
882
 
883
+ #: inc/cpcff_compatibility.inc.php:54
884
  msgid ""
885
  "There is active the <b>SG Optimizer</b> plugin. If the forms are not "
886
  "visible, please try disabling the options: <i>\"Minify the HTML Output\"</i> "
888
  "and remember to purge the website cache."
889
  msgstr ""
890
 
891
+ #: inc/cpcff_compatibility.inc.php:60
892
  msgid ""
893
  "There is active the <b>Hummingbird</b> plugin. If the forms are not visible, "
894
  "check the <i>\"Hummingbird &gt; Asset Optimization\"</i> options. Make sure "
897
  "settings."
898
  msgstr ""
899
 
900
+ #: inc/cpcff_main.inc.php:215
901
  msgid "Request custom changes"
902
  msgstr ""
903
 
904
+ #: inc/cpcff_main.inc.php:234
905
  msgid "Insert Calculated Fields Form"
906
  msgstr ""
907
 
908
+ #: inc/cpcff_main.inc.php:234
909
  msgid "Create a JavaScript var from POST, GET, SESSION, or COOKIE var"
910
  msgstr ""
911
 
912
+ #: inc/cpcff_page_builders.inc.php:89
913
+ #: pagebuilders/elementor/elementor.pb.php:54
914
  msgid "Select a form"
915
  msgstr ""
916
 
917
+ #: inc/cpcff_page_builders.inc.php:90
918
  msgid "Forms"
919
  msgstr ""
920
 
921
+ #: inc/cpcff_page_builders.inc.php:91
922
+ #: pagebuilders/beaverbuilder/cff/cff.inc.php:39
923
+ #: pagebuilders/divi/cff.pb.php:49 pagebuilders/elementor/elementor.pb.php:65
924
  msgid "Additional attributes"
925
  msgstr ""
926
 
927
+ #: inc/cpcff_page_builders.inc.php:92
928
+ #: pagebuilders/beaverbuilder/cff/cff.inc.php:44
929
+ #: pagebuilders/elementor/elementor.pb.php:79
930
+ #: pagebuilders/siteorigin/siteorigin-cpcff/fields/cff-button.class.php:11
931
  msgid "Edit form"
932
  msgstr ""
933
 
934
+ #: pagebuilders/beaverbuilder/cff/cff.inc.php:22
935
  msgid "Select the form and enter the additional attributes"
936
  msgstr ""
937
 
938
+ #: pagebuilders/beaverbuilder/cff/cff.inc.php:25
939
  msgid "Form information"
940
  msgstr ""
941
 
942
+ #: pagebuilders/beaverbuilder/cff/cff.inc.php:29
943
+ #: pagebuilders/divi/cff.pb.php:34
944
  msgid "Select form"
945
  msgstr ""
946
 
947
+ #: pagebuilders/beaverbuilder/cff/cff.inc.php:35
948
+ #: pagebuilders/divi/cff.pb.php:43
949
  msgid "Class name"
950
  msgstr ""
951
 
970
  msgstr ""
971
 
972
  #: pagebuilders/beaverbuilder/cffvar/cffvar.inc.php:24
973
+ #: pagebuilders/siteorigin/siteorigin-cpcff-variable/siteorigin-cpcff-variable.php:28
974
  msgid "Generate variable from"
975
  msgstr ""
976
 
1002
  msgid "Create javascript variable"
1003
  msgstr ""
1004
 
1005
+ #: pagebuilders/divi/cff.pb.php:39
1006
+ msgid "Select the form."
1007
+ msgstr ""
1008
+
1009
+ #: pagebuilders/elementor/elementor.pb.php:168
1010
  msgid "Variable Shortcode"
1011
  msgstr ""
1012
 
1013
+ #: pagebuilders/elementor/elementor.pb.php:175
1014
  msgid "Variable shortcode"
1015
  msgstr ""
1016
 
1017
+ #: pagebuilders/elementor/elementor.pb.php:180
1018
  msgid "I need help [+]"
1019
  msgstr ""
1020
 
1021
+ #: pagebuilders/siteorigin/siteorigin-cpcff-variable/siteorigin-cpcff-variable.php:13
1022
  msgid "Calculated Fields Form, Variable Shortcode"
1023
  msgstr ""
1024
 
1025
+ #: pagebuilders/siteorigin/siteorigin-cpcff-variable/siteorigin-cpcff-variable.php:15
1026
  msgid ""
1027
  "Shortcode to generate a javascript variable from the url parameters (GET or "
1028
  "POST), session variables, cookies, or define it directly"
1029
  msgstr ""
1030
 
1031
+ #: pagebuilders/siteorigin/siteorigin-cpcff-variable/siteorigin-cpcff-variable.php:23
1032
  msgid "Variable name"
1033
  msgstr ""
1034
 
1035
+ #: pagebuilders/siteorigin/siteorigin-cpcff-variable/siteorigin-cpcff-variable.php:31
1036
  msgid "Any source"
1037
  msgstr ""
1038
 
1039
+ #: pagebuilders/siteorigin/siteorigin-cpcff-variable/siteorigin-cpcff-variable.php:32
1040
  msgid "GET parameter"
1041
  msgstr ""
1042
 
1043
+ #: pagebuilders/siteorigin/siteorigin-cpcff-variable/siteorigin-cpcff-variable.php:33
1044
  msgid "POST parameter"
1045
  msgstr ""
1046
 
1047
+ #: pagebuilders/siteorigin/siteorigin-cpcff-variable/siteorigin-cpcff-variable.php:34
1048
  msgid "Session variable"
1049
  msgstr ""
1050
 
1051
+ #: pagebuilders/siteorigin/siteorigin-cpcff-variable/siteorigin-cpcff-variable.php:35
1052
  msgid "Cookie"
1053
  msgstr ""
1054
 
1055
+ #: pagebuilders/siteorigin/siteorigin-cpcff-variable/siteorigin-cpcff-variable.php:40
1056
  msgid "Default value (used when variables are generated from a source)"
1057
  msgstr ""
1058
 
1059
+ #: pagebuilders/siteorigin/siteorigin-cpcff-variable/siteorigin-cpcff-variable.php:45
1060
  msgid "Value (value of the variable when it is generated directly)"
1061
  msgstr ""
1062
 
pagebuilders/beaverbuilder/cff/cff.inc.php CHANGED
@@ -1,50 +1,51 @@
1
- <?php
2
- require_once CP_CALCULATEDFIELDSF_BASE_PATH.'/pagebuilders/beaverbuilder/cff/cff/cff.php';
3
-
4
- // Get the forms list
5
- global $wpdb;
6
- $options = array();
7
- $default = '';
8
-
9
- $rows = $wpdb->get_results( "SELECT id, form_name FROM ".$wpdb->prefix.CP_CALCULATEDFIELDSF_FORMS_TABLE );
10
- $url = CPCFF_AUXILIARY::editor_url();
11
- foreach ($rows as $item)
12
- {
13
- $options[$item->id] = $item->form_name;
14
- if(empty($default)) $default = $item->id;
15
- }
16
-
17
- FLBuilder::register_module(
18
- 'CFFBeaver',
19
- array(
20
- 'cff-form-tab' => array(
21
- 'title' => __('Select the form and enter the additional attributes', 'calculated-fields-form'),
22
- 'sections' => array(
23
- 'cff-form-section' => array(
24
- 'title' => __('Form information', 'calculated-fields-form'),
25
- 'fields' => array(
26
- 'form_id' => array(
27
- 'type' => 'select',
28
- 'label' => __('Select form', 'calculated-fields-form'),
29
- 'options' => $options,
30
- 'default' => $default,
31
- ),
32
- 'class_name' => array(
33
- 'type' => 'text',
34
- 'label' => __('Class name', 'calculated-fields-form')
35
- ),
36
- 'attributes' => array(
37
- 'type' => 'text',
38
- 'label' => __('Additional attributes', 'calculated-fields-form')
39
- ),
40
- 'form_editor' => array(
41
- 'type' => 'raw',
42
- 'preview' => 'none',
43
- 'content' => '<button style="float:right;" class="fl-builder-button fl-builder-button-small" title="'.esc_attr(__('Edit form', 'calculated-fields-form')).'" onclick="window.open(\''.esc_attr($url).'\'+document.getElementsByName(\'form_id\')[0].value);">'.esc_attr(__('Edit form', 'calculated-fields-form')).'</button>',
44
- )
45
- )
46
- )
47
- )
48
- )
49
- )
50
- );
 
1
+ <?php
2
+ require_once CP_CALCULATEDFIELDSF_BASE_PATH . '/pagebuilders/beaverbuilder/cff/cff/cff.php';
3
+
4
+ // Get the forms list
5
+ global $wpdb;
6
+ $options = array();
7
+ $default = '';
8
+
9
+ $rows = $wpdb->get_results( 'SELECT id, form_name FROM ' . $wpdb->prefix . CP_CALCULATEDFIELDSF_FORMS_TABLE ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
10
+ $url = CPCFF_AUXILIARY::editor_url();
11
+ foreach ( $rows as $item ) {
12
+ $options[ $item->id ] = $item->form_name;
13
+ if ( empty( $default ) ) {
14
+ $default = $item->id;
15
+ }
16
+ }
17
+
18
+ FLBuilder::register_module(
19
+ 'CFFBeaver',
20
+ array(
21
+ 'cff-form-tab' => array(
22
+ 'title' => __( 'Select the form and enter the additional attributes', 'calculated-fields-form' ),
23
+ 'sections' => array(
24
+ 'cff-form-section' => array(
25
+ 'title' => __( 'Form information', 'calculated-fields-form' ),
26
+ 'fields' => array(
27
+ 'form_id' => array(
28
+ 'type' => 'select',
29
+ 'label' => __( 'Select form', 'calculated-fields-form' ),
30
+ 'options' => $options,
31
+ 'default' => $default,
32
+ ),
33
+ 'class_name' => array(
34
+ 'type' => 'text',
35
+ 'label' => __( 'Class name', 'calculated-fields-form' ),
36
+ ),
37
+ 'attributes' => array(
38
+ 'type' => 'text',
39
+ 'label' => __( 'Additional attributes', 'calculated-fields-form' ),
40
+ ),
41
+ 'form_editor' => array(
42
+ 'type' => 'raw',
43
+ 'preview' => 'none',
44
+ 'content' => '<button style="float:right;" class="fl-builder-button fl-builder-button-small" title="' . esc_attr( __( 'Edit form', 'calculated-fields-form' ) ) . '" onclick="window.open(\'' . esc_attr( $url ) . '\'+document.getElementsByName(\'form_id\')[0].value);">' . esc_attr( __( 'Edit form', 'calculated-fields-form' ) ) . '</button>',
45
+ ),
46
+ ),
47
+ ),
48
+ ),
49
+ ),
50
+ )
51
+ );
pagebuilders/beaverbuilder/cff/cff/cff.php CHANGED
@@ -1,20 +1,21 @@
1
- <?php
2
- class CFFBeaver extends FLBuilderModule {
3
- public function __construct()
4
- {
5
- $modules_dir = dirname(__FILE__).'/';
6
- $modules_url = plugins_url( '/', __FILE__ ).'/';
7
-
8
- parent::__construct(array(
9
- 'name' => __( 'Calculated Fields Form', 'calculated-fields-form' ),
10
- 'description' => __( 'Inserts a form', 'fl-builder' ),
11
- 'group' => __( 'Calculated Fields Form', 'calculated-fields-form' ),
12
- 'category' => __( 'Calculated Fields Form', 'calculated-fields-form' ),
13
- 'dir' => $modules_dir,
14
- 'url' => $modules_url,
15
- 'partial_refresh' => true
16
- ));
17
-
18
- $this->add_js('cff-beaver-form', $this->url . 'js/settings.js', array('jquery'));
19
- }
20
- }
 
1
+ <?php
2
+ class CFFBeaver extends FLBuilderModule {
3
+ public function __construct() {
4
+ $modules_dir = dirname( __FILE__ ) . '/';
5
+ $modules_url = plugins_url( '/', __FILE__ ) . '/';
6
+
7
+ parent::__construct(
8
+ array(
9
+ 'name' => __( 'Calculated Fields Form', 'calculated-fields-form' ),
10
+ 'description' => __( 'Inserts a form', 'fl-builder' ),
11
+ 'group' => __( 'Calculated Fields Form', 'calculated-fields-form' ),
12
+ 'category' => __( 'Calculated Fields Form', 'calculated-fields-form' ),
13
+ 'dir' => $modules_dir,
14
+ 'url' => $modules_url,
15
+ 'partial_refresh' => true,
16
+ )
17
+ );
18
+
19
+ $this->add_js( 'cff-beaver-form', $this->url . 'js/settings.js', array( 'jquery' ) );
20
+ }
21
+ }
pagebuilders/beaverbuilder/cff/cff/includes/frontend.php CHANGED
@@ -1,15 +1,18 @@
1
- <?php
2
- $form = @intval($settings->form_id);
3
- if(!empty($form))
4
- {
5
- $output = '[CP_CALCULATED_FIELDS id="'.$form.'"';
6
-
7
- $class_name = sanitize_text_field($settings->class_name);
8
- if(!empty($class_name)) $output .= ' class="'.esc_attr($class_name).'"';
9
-
10
- $attributes = sanitize_text_field($settings->attributes);
11
- if(!empty($attributes)) $output .= ' '.$attributes;
12
-
13
- $output .= ']';
14
- echo $output;
15
- }
 
 
 
1
+ <?php
2
+ $form = @intval( $settings->form_id );
3
+ if ( ! empty( $form ) ) {
4
+ $output = '[CP_CALCULATED_FIELDS id="' . $form . '"';
5
+
6
+ $class_name = sanitize_text_field( $settings->class_name );
7
+ if ( ! empty( $class_name ) ) {
8
+ $output .= ' class="' . esc_attr( $class_name ) . '"';
9
+ }
10
+
11
+ $attributes = sanitize_text_field( $settings->attributes );
12
+ if ( ! empty( $attributes ) ) {
13
+ $output .= ' ' . $attributes;
14
+ }
15
+
16
+ $output .= ']';
17
+ echo $output; // phpcs:ignore WordPress.Security.EscapeOutput
18
+ }
pagebuilders/beaverbuilder/cffvar/cffvar.inc.php CHANGED
@@ -1,38 +1,38 @@
1
- <?php
2
- require_once CP_CALCULATEDFIELDSF_BASE_PATH.'/pagebuilders/beaverbuilder/cffvar/cffvar/cffvar.php';
3
-
4
- FLBuilder::register_module(
5
- 'CFFVarBeaver',
6
- array(
7
- 'cff-var-tab' => array(
8
- 'title' => __('Generate variable', 'calculated-fields-form'),
9
- 'sections' => array(
10
- 'cff-var-section' => array(
11
- 'title' => __('Variable attributes', 'calculated-fields-form'),
12
- 'fields' => array(
13
- 'var_name' => array(
14
- 'type' => 'text',
15
- 'label' => __('Enter the variable name', 'calculated-fields-form'),
16
- 'required' => true,
17
- ),
18
- 'default_value' => array(
19
- 'type' => 'text',
20
- 'label' => __('Enter the default value', 'calculated-fields-form')
21
- ),
22
- 'from' => array(
23
- 'type' => 'select',
24
- 'label' => __('Generate variable from', 'calculated-fields-form'),
25
- 'options' => array(
26
- 'directly' => __('Directly', 'calculated-fields-form'),
27
- 'get' => __('GET parameters', 'calculated-fields-form'),
28
- 'post' => __('POST parameters', 'calculated-fields-form'),
29
- 'session' => __('SESSION variables', 'calculated-fields-form'),
30
- 'cookies' => __('COOKIES variables', 'calculated-fields-form'),
31
- )
32
- ),
33
- )
34
- )
35
- )
36
- )
37
- )
38
- );
1
+ <?php
2
+ require_once CP_CALCULATEDFIELDSF_BASE_PATH . '/pagebuilders/beaverbuilder/cffvar/cffvar/cffvar.php';
3
+
4
+ FLBuilder::register_module(
5
+ 'CFFVarBeaver',
6
+ array(
7
+ 'cff-var-tab' => array(
8
+ 'title' => __( 'Generate variable', 'calculated-fields-form' ),
9
+ 'sections' => array(
10
+ 'cff-var-section' => array(
11
+ 'title' => __( 'Variable attributes', 'calculated-fields-form' ),
12
+ 'fields' => array(
13
+ 'var_name' => array(
14
+ 'type' => 'text',
15
+ 'label' => __( 'Enter the variable name', 'calculated-fields-form' ),
16
+ 'required' => true,
17
+ ),
18
+ 'default_value' => array(
19
+ 'type' => 'text',
20
+ 'label' => __( 'Enter the default value', 'calculated-fields-form' ),
21
+ ),
22
+ 'from' => array(
23
+ 'type' => 'select',
24
+ 'label' => __( 'Generate variable from', 'calculated-fields-form' ),
25
+ 'options' => array(
26
+ 'directly' => __( 'Directly', 'calculated-fields-form' ),
27
+ 'get' => __( 'GET parameters', 'calculated-fields-form' ),
28
+ 'post' => __( 'POST parameters', 'calculated-fields-form' ),
29
+ 'session' => __( 'SESSION variables', 'calculated-fields-form' ),
30
+ 'cookies' => __( 'COOKIES variables', 'calculated-fields-form' ),
31
+ ),
32
+ ),
33
+ ),
34
+ ),
35
+ ),
36
+ ),
37
+ )
38
+ );
pagebuilders/beaverbuilder/cffvar/cffvar/cffvar.php CHANGED
@@ -1,20 +1,21 @@
1
- <?php
2
- class CFFVarBeaver extends FLBuilderModule {
3
- public function __construct()
4
- {
5
- $modules_dir = dirname(__FILE__).'/';
6
- $modules_url = plugins_url( '/', __FILE__ ).'/';
7
-
8
- parent::__construct(array(
9
- 'name' => __( 'Create variable', 'calculated-fields-form' ),
10
- 'description' => __( 'Create javascript variable', 'fl-builder' ),
11
- 'group' => __( 'Calculated Fields Form', 'calculated-fields-form' ),
12
- 'category' => __( 'Calculated Fields Form', 'calculated-fields-form' ),
13
- 'dir' => $modules_dir,
14
- 'url' => $modules_url,
15
- 'partial_refresh' => true,
16
- ));
17
-
18
- $this->add_css('cff-var', $this->url . 'css/cffvar.css');
19
- }
20
- }
 
1
+ <?php
2
+ class CFFVarBeaver extends FLBuilderModule {
3
+ public function __construct() {
4
+ $modules_dir = dirname( __FILE__ ) . '/';
5
+ $modules_url = plugins_url( '/', __FILE__ ) . '/';
6
+
7
+ parent::__construct(
8
+ array(
9
+ 'name' => __( 'Create variable', 'calculated-fields-form' ),
10
+ 'description' => __( 'Create javascript variable', 'fl-builder' ),
11
+ 'group' => __( 'Calculated Fields Form', 'calculated-fields-form' ),
12
+ 'category' => __( 'Calculated Fields Form', 'calculated-fields-form' ),
13
+ 'dir' => $modules_dir,
14
+ 'url' => $modules_url,
15
+ 'partial_refresh' => true,
16
+ )
17
+ );
18
+
19
+ $this->add_css( 'cff-var', $this->url . 'css/cffvar.css' );
20
+ }
21
+ }
pagebuilders/beaverbuilder/cffvar/cffvar/includes/frontend.php CHANGED
@@ -1,17 +1,17 @@
1
- <?php
2
- $var_name = sanitize_text_field($settings->var_name);
3
- $default_value = sanitize_text_field($settings->default_value);
4
- $from = sanitize_text_field($settings->from);
5
-
6
- if(!empty($var_name))
7
- {
8
- $output = '[CP_CALCULATED_FIELDS_VAR name="'.esc_attr($var_name).'"';
9
-
10
- if(!empty($from) && $from !== 'directly')
11
- $output .= ' from="'.esc_attr($from).'" default_value="'.esc_attr($default_value).'"';
12
- elseif($from === 'directly')
13
- $output .= ' value="'.esc_attr($default_value).'"';
14
-
15
- $output .= ']';
16
- echo $output;
17
- }
1
+ <?php
2
+ $var_name = sanitize_text_field( $settings->var_name );
3
+ $default_value = sanitize_text_field( $settings->default_value );
4
+ $from = sanitize_text_field( $settings->from );
5
+
6
+ if ( ! empty( $var_name ) ) {
7
+ $output = '[CP_CALCULATED_FIELDS_VAR name="' . esc_attr( $var_name ) . '"';
8
+
9
+ if ( ! empty( $from ) && 'directly' !== $from ) {
10
+ $output .= ' from="' . esc_attr( $from ) . '" default_value="' . esc_attr( $default_value ) . '"';
11
+ } elseif ( 'directly' === $from ) {
12
+ $output .= ' value="' . esc_attr( $default_value ) . '"';
13
+ }
14
+
15
+ $output .= ']';
16
+ echo $output; // phpcs:ignore WordPress.Security.EscapeOutput
17
+ }
pagebuilders/divi/cff.pb.php CHANGED
@@ -1,78 +1,79 @@
1
- <?php
2
- class CFF_DIVI extends ET_Builder_Module
3
- {
4
-
5
- public $slug = 'cff_divi';
6
- public $vb_support = 'on';
7
-
8
- public function init()
9
- {
10
- $this->name = esc_html__('Calculated Fields Form', 'calculated-fields-form');
11
- $this->settings_modal_toggles = array(
12
- 'general' => array(
13
- 'toggles' => array(
14
- 'main_content' => esc_html__( 'Form', 'calculated-fields-form' ),
15
- ),
16
- ),
17
- );
18
- }
19
-
20
- public function get_fields()
21
- {
22
- global $wpdb;
23
- $options = array();
24
- $default = '';
25
-
26
- $rows = $wpdb->get_results( "SELECT id, form_name FROM ".$wpdb->prefix.CP_CALCULATEDFIELDSF_FORMS_TABLE );
27
- foreach ($rows as $item)
28
- {
29
- $options[$item->id] = $item->form_name;
30
- if(empty($default)) $default = $item->id;
31
- }
32
-
33
- return array(
34
- 'cff_form_id' => array(
35
- 'label' => esc_html__( 'Select form', 'calculated-fields-form' ),
36
- 'type' => 'select',
37
- 'options' => $options,
38
- 'default' => $default,
39
- 'option_category' => 'basic_option',
40
- 'description' => esc_html__( 'Select the form.', 'calculated-fields-form' ),
41
- 'toggle_slug' => 'main_content',
42
- ),
43
- 'cff_class_name' => array(
44
- 'label' => esc_html__( 'Class name', 'calculated-fields-form' ),
45
- 'type' => 'text',
46
- 'option_category' => 'basic_option',
47
- 'toggle_slug' => 'main_content',
48
- ),
49
- 'cff_attributes' => array(
50
- 'label' => esc_html__( 'Additional attributes', 'calculated-fields-form' ),
51
- 'type' => 'text',
52
- 'option_category' => 'basic_option',
53
- 'description' => 'attr1="value attr1" attr1="value attr1"',
54
- 'toggle_slug' => 'main_content',
55
- ),
56
- );
57
- }
58
-
59
- public function render($unprocessed_props, $content = null, $render_slug = '')
60
- {
61
- $output = '';
62
- $form = @intval($this->props['cff_form_id']);
63
- if(!empty($form))
64
- {
65
- $output = '[CP_CALCULATED_FIELDS id="'.$form.'"';
66
- $class_name = sanitize_text_field($this->props['cff_class_name']);
67
- if(!empty($class_name)) $output .= ' class="'.esc_attr($class_name).'"';
68
-
69
- $attributes = sanitize_text_field($this->props['cff_attributes']);
70
- if(!empty($attributes)) $output .= ' '.$attributes;
71
-
72
- $output .= ']';
73
- }
74
- return do_shortcode($output);
75
- }
76
- }
77
-
78
- new CFF_DIVI;
 
1
+ <?php
2
+ class CFF_DIVI extends ET_Builder_Module {
3
+
4
+
5
+ public $slug = 'cff_divi';
6
+ public $vb_support = 'on';
7
+
8
+ public function init() {
9
+ $this->name = esc_html__( 'Calculated Fields Form', 'calculated-fields-form' );
10
+ $this->settings_modal_toggles = array(
11
+ 'general' => array(
12
+ 'toggles' => array(
13
+ 'main_content' => esc_html__( 'Form', 'calculated-fields-form' ),
14
+ ),
15
+ ),
16
+ );
17
+ }
18
+
19
+ public function get_fields() {
20
+ global $wpdb;
21
+ $options = array();
22
+ $default = '';
23
+
24
+ $rows = $wpdb->get_results( 'SELECT id, form_name FROM ' . $wpdb->prefix . CP_CALCULATEDFIELDSF_FORMS_TABLE ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
25
+ foreach ( $rows as $item ) {
26
+ $options[ $item->id ] = $item->form_name;
27
+ if ( empty( $default ) ) {
28
+ $default = $item->id;
29
+ }
30
+ }
31
+
32
+ return array(
33
+ 'cff_form_id' => array(
34
+ 'label' => esc_html__( 'Select form', 'calculated-fields-form' ),
35
+ 'type' => 'select',
36
+ 'options' => $options,
37
+ 'default' => $default,
38
+ 'option_category' => 'basic_option',
39
+ 'description' => esc_html__( 'Select the form.', 'calculated-fields-form' ),
40
+ 'toggle_slug' => 'main_content',
41
+ ),
42
+ 'cff_class_name' => array(
43
+ 'label' => esc_html__( 'Class name', 'calculated-fields-form' ),
44
+ 'type' => 'text',
45
+ 'option_category' => 'basic_option',
46
+ 'toggle_slug' => 'main_content',
47
+ ),
48
+ 'cff_attributes' => array(
49
+ 'label' => esc_html__( 'Additional attributes', 'calculated-fields-form' ),
50
+ 'type' => 'text',
51
+ 'option_category' => 'basic_option',
52
+ 'description' => 'attr1="value attr1" attr1="value attr1"',
53
+ 'toggle_slug' => 'main_content',
54
+ ),
55
+ );
56
+ }
57
+
58
+ public function render( $unprocessed_props, $content = null, $render_slug = '' ) {
59
+ $output = '';
60
+ $form = @intval( $this->props['cff_form_id'] );
61
+ if ( ! empty( $form ) ) {
62
+ $output = '[CP_CALCULATED_FIELDS id="' . $form . '"';
63
+ $class_name = sanitize_text_field( $this->props['cff_class_name'] );
64
+ if ( ! empty( $class_name ) ) {
65
+ $output .= ' class="' . esc_attr( $class_name ) . '"';
66
+ }
67
+
68
+ $attributes = sanitize_text_field( $this->props['cff_attributes'] );
69
+ if ( ! empty( $attributes ) ) {
70
+ $output .= ' ' . $attributes;
71
+ }
72
+
73
+ $output .= ']';
74
+ }
75
+ return do_shortcode( $output );
76
+ }
77
+ }
78
+
79
+ new CFF_DIVI();
pagebuilders/elementor/elementor.pb.php CHANGED
@@ -1,210 +1,197 @@
1
- <?php
2
- namespace Elementor;
3
-
4
- if ( ! defined( 'ABSPATH' ) ) {
5
- exit; // Exit if accessed directly.
6
- }
7
-
8
- class Elementor_CFF_Widget extends Widget_Base
9
- {
10
- public function get_name()
11
- {
12
- return 'calculated-fields-form';
13
- } // End get_name
14
-
15
- public function get_title()
16
- {
17
- return 'Calculated Fields Form';
18
- } // End get_title
19
-
20
- public function get_icon()
21
- {
22
- return 'eicon-apps';
23
- } // End get_icon
24
-
25
- public function get_categories()
26
- {
27
- return array( 'calculated-fields-form-cat' );
28
- } // End get_categories
29
-
30
- public function is_reload_preview_required()
31
- {
32
- return true;
33
- } // End is_reload_preview_required
34
-
35
- protected function register_controls()
36
- {
37
- global $wpdb;
38
-
39
- $this->start_controls_section(
40
- 'cff_section',
41
- array(
42
- 'label' => __( 'Calculated Fields Form', 'calculated-fields-form' )
43
- )
44
- );
45
-
46
- $options = array();
47
- $default = '';
48
-
49
- $rows = $wpdb->get_results( "SELECT id, form_name FROM ".$wpdb->prefix.CP_CALCULATEDFIELDSF_FORMS_TABLE );
50
- foreach ($rows as $item)
51
- {
52
- $options[$item->id] = $item->form_name;
53
- if(empty($default)) $default = $item->id;
54
- }
55
-
56
- $this->add_control(
57
- 'form',
58
- array(
59
- 'label' => __('Select a form', 'calculated-fields-form'),
60
- 'type' => Controls_Manager::SELECT,
61
- 'classes' => 'cff-widefat',
62
- 'options' => $options,
63
- 'default' => $default
64
- )
65
- );
66
-
67
- $this->add_control(
68
- 'attrs',
69
- array(
70
- 'label' => __('Additional attributes', 'calculated-fields-form'),
71
- 'type' => Controls_Manager::TEXT,
72
- 'classes' => 'cff-widefat',
73
- 'input_type' => 'text',
74
- 'placeholder' => 'attr="value"'
75
- )
76
- );
77
-
78
- if(current_user_can( 'manage_options'))
79
- {
80
- $this->add_control(
81
- 'open-editor',
82
- array(
83
- 'type' => Controls_Manager::BUTTON,
84
- 'separator' => 'before',
85
- 'text' => __('Edit form', 'calculated-fields-form'),
86
- 'classes' => 'cff-edit-form-btn',
87
- 'button_type' => 'success',
88
- 'event' => 'cff_open_form_editor'
89
- )
90
- );
91
- }
92
-
93
- $this->end_controls_section();
94
- } // End register_controls
95
-
96
- private function _get_shortcode()
97
- {
98
- $settings = $this->get_settings_for_display();
99
- $attrs = sanitize_text_field($settings['attrs']);
100
- if(!empty($attrs)) $attrs = ' '.$attrs;
101
- return '[CP_CALCULATED_FIELDS id="'.@intval($settings['form']).'"'.$attrs.']';
102
- } // End _get_shortcode
103
-
104
- protected function render()
105
- {
106
- $shortcode = $this->_get_shortcode();
107
- if(
108
- isset($_REQUEST['action']) &&
109
- (
110
- $_REQUEST['action'] == 'elementor' ||
111
- $_REQUEST['action'] == 'elementor_ajax'
112
- )
113
- )
114
- {
115
- $atts = preg_replace(array('/\[\s*cp_calculated_fields\s*/i', '/\s*\]$/'),'', $shortcode);
116
- $atts = shortcode_parse_atts($atts);
117
- $url = \CPCFF_AUXILIARY::site_url();
118
- $url .= ((strpos($url, '?') === false) ? '?' : '&').'cff-editor-preview=1&cff-amp-redirected=1';
119
- foreach($atts as $i => $v)
120
- {
121
- if(is_numeric($i)) continue;
122
- if($i == 'id') $url .= '&cff-amp-form';
123
- else $url .= '&'.urlencode(sanitize_text_field($i));
124
- $url .= '='.urlencode(sanitize_text_field($v));
125
- }
126
-
127
- ?>
128
- <div class="cff-iframe-container" style="position:relative;">
129
- <div class="cff-iframe-overlay" style="position:absolute;top:0;right:0;bottom:0;left:0;"></div>
130
- <iframe height="0" width="100%" src="<?php print $url; ?>">
131
- </div>
132
- <?php
133
- }
134
- else
135
- {
136
- print do_shortcode(shortcode_unautop($shortcode));
137
- }
138
-
139
- } // End render
140
-
141
- public function render_plain_content()
142
- {
143
- echo $this->_get_shortcode();
144
- } // End render_plain_content
145
-
146
- } // End ClassElementor_CFF_Widget
147
-
148
- class Elementor_CFFV_Widget extends Widget_Shortcode
149
- {
150
- public function get_name()
151
- {
152
- return 'calculated-fields-form-variable';
153
- } // End get_name
154
-
155
- public function get_title()
156
- {
157
- return 'Define Variable';
158
- } // End get_title
159
-
160
- public function get_icon()
161
- {
162
- return 'eicon-shortcode';
163
- } // End get_icon
164
-
165
- public function get_categories()
166
- {
167
- return array( 'calculated-fields-form-cat' );
168
- } // End get_categories
169
-
170
- public function is_reload_preview_required()
171
- {
172
- return true;
173
- } // End is_reload_preview_required
174
-
175
- protected function register_controls()
176
- {
177
- $this->start_controls_section(
178
- 'section_shortcode',
179
- array(
180
- 'label' => __( 'Variable Shortcode', 'calculated-fields-form' ),
181
- )
182
- );
183
-
184
- $this->add_control(
185
- 'shortcode',
186
- array(
187
- 'label' => __( 'Variable shortcode', 'calculated-fields-form' ),
188
- 'type' => Controls_Manager::TEXT,
189
- 'classes' => 'cff-widefat',
190
- 'input_type' => 'text',
191
- 'default' => '[CP_CALCULATED_FIELDS_VAR name="varname"]',
192
- 'description' => '<a href="https://cff.dwbooster.com/documentation#javascript-variables" target="_blank">'.__( 'I need help [+]', 'calculated-fields-form' ).'</a>'
193
- )
194
- );
195
-
196
- $this->end_controls_section();
197
- } // End register_controls
198
-
199
- protected function render()
200
- {
201
- $cff_main = \CPCFF_MAIN::instance();
202
- add_shortcode( 'CP_CALCULATED_FIELDS_VAR', array($cff_main,'create_variable_shortcode') );
203
- parent::render();
204
- } // End render
205
-
206
- } // End ClassElementor_CFFV_Widget
207
-
208
- // Register the widgets
209
- Plugin::instance()->widgets_manager->register_widget_type( new Elementor_CFF_Widget );
210
- Plugin::instance()->widgets_manager->register_widget_type( new Elementor_CFFV_Widget );
1
+ <?php
2
+ namespace Elementor;
3
+
4
+ if ( ! defined( 'ABSPATH' ) ) {
5
+ exit; // Exit if accessed directly.
6
+ }
7
+
8
+ class Elementor_CFF_Widget extends Widget_Base {
9
+
10
+ public function get_name() {
11
+ return 'calculated-fields-form';
12
+ } // End get_name
13
+
14
+ public function get_title() {
15
+ return 'Calculated Fields Form';
16
+ } // End get_title
17
+
18
+ public function get_icon() {
19
+ return 'eicon-apps';
20
+ } // End get_icon
21
+
22
+ public function get_categories() {
23
+ return array( 'calculated-fields-form-cat' );
24
+ } // End get_categories
25
+
26
+ public function is_reload_preview_required() {
27
+ return true;
28
+ } // End is_reload_preview_required
29
+
30
+ protected function register_controls() {
31
+ global $wpdb;
32
+
33
+ $this->start_controls_section(
34
+ 'cff_section',
35
+ array(
36
+ 'label' => __( 'Calculated Fields Form', 'calculated-fields-form' ),
37
+ )
38
+ );
39
+
40
+ $options = array();
41
+ $default = '';
42
+
43
+ $rows = $wpdb->get_results( 'SELECT id, form_name FROM ' . $wpdb->prefix . CP_CALCULATEDFIELDSF_FORMS_TABLE ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
44
+ foreach ( $rows as $item ) {
45
+ $options[ $item->id ] = $item->form_name;
46
+ if ( empty( $default ) ) {
47
+ $default = $item->id;
48
+ }
49
+ }
50
+
51
+ $this->add_control(
52
+ 'form',
53
+ array(
54
+ 'label' => __( 'Select a form', 'calculated-fields-form' ),
55
+ 'type' => Controls_Manager::SELECT,
56
+ 'classes' => 'cff-widefat',
57
+ 'options' => $options,
58
+ 'default' => $default,
59
+ )
60
+ );
61
+
62
+ $this->add_control(
63
+ 'attrs',
64
+ array(
65
+ 'label' => __( 'Additional attributes', 'calculated-fields-form' ),
66
+ 'type' => Controls_Manager::TEXT,
67
+ 'classes' => 'cff-widefat',
68
+ 'input_type' => 'text',
69
+ 'placeholder' => 'attr="value"',
70
+ )
71
+ );
72
+
73
+ if ( current_user_can( 'manage_options' ) ) {
74
+ $this->add_control(
75
+ 'open-editor',
76
+ array(
77
+ 'type' => Controls_Manager::BUTTON,
78
+ 'separator' => 'before',
79
+ 'text' => __( 'Edit form', 'calculated-fields-form' ),
80
+ 'classes' => 'cff-edit-form-btn',
81
+ 'button_type' => 'success',
82
+ 'event' => 'cff_open_form_editor',
83
+ )
84
+ );
85
+ }
86
+
87
+ $this->end_controls_section();
88
+ } // End register_controls
89
+
90
+ private function _get_shortcode() {
91
+ $settings = $this->get_settings_for_display();
92
+ $attrs = sanitize_text_field( $settings['attrs'] );
93
+ if ( ! empty( $attrs ) ) {
94
+ $attrs = ' ' . $attrs;
95
+ }
96
+ return '[CP_CALCULATED_FIELDS id="' . @intval( $settings['form'] ) . '"' . $attrs . ']';
97
+ } // End _get_shortcode
98
+
99
+ protected function render() {
100
+ $shortcode = $this->_get_shortcode();
101
+ if (
102
+ isset( $_REQUEST['action'] ) &&
103
+ (
104
+ 'elementor' == $_REQUEST['action'] ||
105
+ 'elementor_ajax' == $_REQUEST['action']
106
+ )
107
+ ) {
108
+ $atts = preg_replace( array( '/\[\s*cp_calculated_fields\s*/i', '/\s*\]$/' ), '', $shortcode );
109
+ $atts = shortcode_parse_atts( $atts );
110
+ $url = \CPCFF_AUXILIARY::site_url();
111
+ $url .= ( ( strpos( $url, '?' ) === false ) ? '?' : '&' ) . 'cff-editor-preview=1&cff-amp-redirected=1';
112
+ foreach ( $atts as $i => $v ) {
113
+ if ( is_numeric( $i ) ) {
114
+ continue;
115
+ }
116
+ if ( 'id' == $i ) {
117
+ $url .= '&cff-amp-form';
118
+ } else {
119
+ $url .= '&' . urlencode( sanitize_text_field( $i ) );
120
+ }
121
+ $url .= '=' . urlencode( sanitize_text_field( $v ) );
122
+ }
123
+
124
+ ?>
125
+ <div class="cff-iframe-container" style="position:relative;">
126
+ <div class="cff-iframe-overlay" style="position:absolute;top:0;right:0;bottom:0;left:0;"></div>
127
+ <iframe height="0" width="100%" src="<?php print esc_attr( $url ); ?>">
128
+ </div>
129
+ <?php
130
+ } else {
131
+ print do_shortcode( shortcode_unautop( $shortcode ) );
132
+ }
133
+
134
+ } // End render
135
+
136
+ public function render_plain_content() {
137
+ echo esc_html( $this->_get_shortcode() );
138
+ } // End render_plain_content
139
+
140
+ } // End ClassElementor_CFF_Widget
141
+
142
+ class Elementor_CFFV_Widget extends Widget_Shortcode {
143
+
144
+ public function get_name() {
145
+ return 'calculated-fields-form-variable';
146
+ } // End get_name
147
+
148
+ public function get_title() {
149
+ return 'Define Variable';
150
+ } // End get_title
151
+
152
+ public function get_icon() {
153
+ return 'eicon-shortcode';
154
+ } // End get_icon
155
+
156
+ public function get_categories() {
157
+ return array( 'calculated-fields-form-cat' );
158
+ } // End get_categories
159
+
160
+ public function is_reload_preview_required() {
161
+ return true;
162
+ } // End is_reload_preview_required
163
+
164
+ protected function register_controls() {
165
+ $this->start_controls_section(
166
+ 'section_shortcode',
167
+ array(
168
+ 'label' => __( 'Variable Shortcode', 'calculated-fields-form' ),
169
+ )
170
+ );
171
+
172
+ $this->add_control(
173
+ 'shortcode',
174
+ array(
175
+ 'label' => __( 'Variable shortcode', 'calculated-fields-form' ),
176
+ 'type' => Controls_Manager::TEXT,
177
+ 'classes' => 'cff-widefat',
178
+ 'input_type' => 'text',
179
+ 'default' => '[CP_CALCULATED_FIELDS_VAR name="varname"]',
180
+ 'description' => '<a href="https://cff.dwbooster.com/documentation#javascript-variables" target="_blank">' . __( 'I need help [+]', 'calculated-fields-form' ) . '</a>',
181
+ )
182
+ );
183
+
184
+ $this->end_controls_section();
185
+ } // End register_controls
186
+
187
+ protected function render() {
188
+ $cff_main = \CPCFF_MAIN::instance();
189
+ add_shortcode( 'CP_CALCULATED_FIELDS_VAR', array( $cff_main, 'create_variable_shortcode' ) );
190
+ parent::render();
191
+ } // End render
192
+
193
+ } // End ClassElementor_CFFV_Widget
194
+
195
+ // Register the widgets
196
+ Plugin::instance()->widgets_manager->register_widget_type( new Elementor_CFF_Widget() );
197
+ Plugin::instance()->widgets_manager->register_widget_type( new Elementor_CFFV_Widget() );
 
 
 
 
 
 
 
 
 
 
 
 
 
pagebuilders/elementor/elementor_category.pb.php CHANGED
@@ -1,16 +1,16 @@
1
- <?php
2
- namespace Elementor;
3
-
4
- if ( ! defined( 'ABSPATH' ) ) {
5
- exit; // Exit if accessed directly.
6
- }
7
-
8
- // Register the categories
9
- Plugin::$instance->elements_manager->add_category(
10
- 'calculated-fields-form-cat',
11
- array(
12
- 'title'=>'Calculated Fields Form',
13
- 'icon' => 'fa fa-plug'
14
- ),
15
- 2 // position
16
- );
1
+ <?php
2
+ namespace Elementor;
3
+
4
+ if ( ! defined( 'ABSPATH' ) ) {
5
+ exit; // Exit if accessed directly.
6
+ }
7
+
8
+ // Register the categories
9
+ Plugin::$instance->elements_manager->add_category(
10
+ 'calculated-fields-form-cat',
11
+ array(
12
+ 'title' => 'Calculated Fields Form',
13
+ 'icon' => 'fa fa-plug',
14
+ ),
15
+ 2 // position
16
+ );
pagebuilders/siteorigin/siteorigin-cpcff-variable/siteorigin-cpcff-variable.php CHANGED
@@ -1,67 +1,64 @@
1
- <?php
2
- /*
3
- Widget Name: Calculated Fields Form Variable Shortcode
4
- Description: Insert a javascript generator shortcode on page.
5
- Documentation: https://cff.dwbooster.com/documentation#javascript-variables
6
- */
7
-
8
- class SiteOrigin_CFF_Variable_Shortcode extends SiteOrigin_Widget
9
- {
10
- function __construct()
11
- {
12
- parent::__construct(
13
- 'siteorigin-cff-variable-shortcode',
14
- __('Calculated Fields Form, Variable Shortcode', 'calculated-fields-form'),
15
- array(
16
- 'description' => __('Shortcode to generate a javascript variable from the url parameters (GET or POST), session variables, cookies, or define it directly', 'calculated-fields-form'),
17
- 'panels_groups' => array('calculated-fields-form'),
18
- 'help' => 'https://cff.dwbooster.com/documentation#javascript-variables',
19
- ),
20
- array(),
21
- array(
22
- 'name' => array(
23
- 'type' => 'text',
24
- 'label' => __( 'Variable name', 'calculated-fields-form' ),
25
- 'default' => '',
26
- ),
27
- 'from' => array(
28
- 'type' => 'select',
29
- 'label' => __('Generate variable from', 'calculated-fields-form' ),
30
- 'default' => '',
31
- 'options' => array(
32
- '' => __( 'Any source', 'calculated-fields-form' ),
33
- 'from="get"' => __( 'GET parameter', 'calculated-fields-form' ),
34
- 'from="post"' => __( 'POST parameter', 'calculated-fields-form' ),
35
- 'from="session"' => __( 'Session variable', 'calculated-fields-form' ),
36
- 'from="cookie"' => __( 'Cookie', 'calculated-fields-form' ),
37
- )
38
- ),
39
- 'default_value' => array(
40
- 'type' => 'text',
41
- 'label' => __( 'Default value (used when variables are generated from a source)', 'calculated-fields-form' ),
42
- 'default' => '',
43
- ),
44
- 'value' => array(
45
- 'type' => 'text',
46
- 'label' => __( 'Value (value of the variable when it is generated directly)', 'calculated-fields-form' ),
47
- 'default' => '',
48
- ),
49
- ),
50
- plugin_dir_path(__FILE__)
51
- );
52
- } // End __construct
53
-
54
- function get_template_name($instance)
55
- {
56
- return 'siteorigin-cff-variable-shortcode';
57
- } // End get_template_name
58
-
59
- function get_style_name($instance)
60
- {
61
- return '';
62
- } // End get_style_name
63
-
64
- } // End Class SiteOrigin_CFF_Variable_Shortcode
65
-
66
- // Registering the widget
67
- siteorigin_widget_register('siteorigin-cff-variable-shortcode', __FILE__, 'SiteOrigin_CFF_Variable_Shortcode');
1
+ <?php
2
+ /*
3
+ Widget Name: Calculated Fields Form Variable Shortcode
4
+ Description: Insert a javascript generator shortcode on page.
5
+ Documentation: https://cff.dwbooster.com/documentation#javascript-variables
6
+ */
7
+
8
+ class SiteOrigin_CFF_Variable_Shortcode extends SiteOrigin_Widget {
9
+
10
+ public function __construct() {
11
+ parent::__construct(
12
+ 'siteorigin-cff-variable-shortcode',
13
+ __( 'Calculated Fields Form, Variable Shortcode', 'calculated-fields-form' ),
14
+ array(
15
+ 'description' => __( 'Shortcode to generate a javascript variable from the url parameters (GET or POST), session variables, cookies, or define it directly', 'calculated-fields-form' ),
16
+ 'panels_groups' => array( 'calculated-fields-form' ),
17
+ 'help' => 'https://cff.dwbooster.com/documentation#javascript-variables',
18
+ ),
19
+ array(),
20
+ array(
21
+ 'name' => array(
22
+ 'type' => 'text',
23
+ 'label' => __( 'Variable name', 'calculated-fields-form' ),
24
+ 'default' => '',
25
+ ),
26
+ 'from' => array(
27
+ 'type' => 'select',
28
+ 'label' => __( 'Generate variable from', 'calculated-fields-form' ),
29
+ 'default' => '',
30
+ 'options' => array(
31
+ '' => __( 'Any source', 'calculated-fields-form' ),
32
+ 'from="get"' => __( 'GET parameter', 'calculated-fields-form' ),
33
+ 'from="post"' => __( 'POST parameter', 'calculated-fields-form' ),
34
+ 'from="session"' => __( 'Session variable', 'calculated-fields-form' ),
35
+ 'from="cookie"' => __( 'Cookie', 'calculated-fields-form' ),
36
+ ),
37
+ ),
38
+ 'default_value' => array(
39
+ 'type' => 'text',
40
+ 'label' => __( 'Default value (used when variables are generated from a source)', 'calculated-fields-form' ),
41
+ 'default' => '',
42
+ ),
43
+ 'value' => array(
44
+ 'type' => 'text',
45
+ 'label' => __( 'Value (value of the variable when it is generated directly)', 'calculated-fields-form' ),
46
+ 'default' => '',
47
+ ),
48
+ ),
49
+ plugin_dir_path( __FILE__ )
50
+ );
51
+ } // End __construct
52
+
53
+ public function get_template_name( $instance ) {
54
+ return 'siteorigin-cff-variable-shortcode';
55
+ } // End get_template_name
56
+
57
+ public function get_style_name( $instance ) {
58
+ return '';
59
+ } // End get_style_name
60
+
61
+ } // End Class SiteOrigin_CFF_Variable_Shortcode
62
+
63
+ // Registering the widget
64
+ siteorigin_widget_register( 'siteorigin-cff-variable-shortcode', __FILE__, 'SiteOrigin_CFF_Variable_Shortcode' );
 
 
 
pagebuilders/siteorigin/siteorigin-cpcff-variable/tpl/siteorigin-cff-variable-shortcode.php CHANGED
@@ -1,15 +1,20 @@
1
- <?php
2
- $name = sanitize_text_field($instance['name']);
3
- $from = sanitize_text_field($instance['from']);
4
- $default_value = sanitize_text_field($instance['default_value']);
5
- $value = sanitize_text_field($instance['value']);
6
- $shortcode = '';
7
- if(!empty($name))
8
- {
9
- $shortcode .= '[CP_CALCULATED_FIELDS_VAR name="'.esc_attr($name).'"';
10
- if(!empty($from)) $shortcode .= ' '.$from;
11
- if(!empty($default_value)) $shortcode .= ' default_value="'.esc_attr($default_value).'"';
12
- if(!empty($value)) $shortcode .= ' value="'.esc_attr($value).'"';
13
- $shortcode .= ']';
14
- }
15
- print $shortcode;
 
 
 
 
 
1
+ <?php
2
+ $name = sanitize_text_field( $instance['name'] );
3
+ $from = sanitize_text_field( $instance['from'] );
4
+ $default_value = sanitize_text_field( $instance['default_value'] );
5
+ $value = sanitize_text_field( $instance['value'] );
6
+ $shortcode = '';
7
+ if ( ! empty( $name ) ) {
8
+ $shortcode .= '[CP_CALCULATED_FIELDS_VAR name="' . esc_attr( $name ) . '"';
9
+ if ( ! empty( $from ) ) {
10
+ $shortcode .= ' ' . $from;
11
+ }
12
+ if ( ! empty( $default_value ) ) {
13
+ $shortcode .= ' default_value="' . esc_attr( $default_value ) . '"';
14
+ }
15
+ if ( ! empty( $value ) ) {
16
+ $shortcode .= ' value="' . esc_attr( $value ) . '"';
17
+ }
18
+ $shortcode .= ']';
19
+ }
20
+ print $shortcode; // phpcs:ignore WordPress.Security.EscapeOutput
pagebuilders/siteorigin/siteorigin-cpcff/fields/cff-button.class.php CHANGED
@@ -5,17 +5,16 @@
5
  class SiteOrigin_Widget_Field_CFF_Button extends SiteOrigin_Widget_Field_Base {
6
 
7
  protected function render_field( $value, $instance ) {
8
- if ( current_user_can( 'manage_options' ) )
9
- {
10
  $url = CPCFF_AUXILIARY::editor_url();
11
  ?>
12
- <input type="button" name="cff-button-edit-form" class="button-primary" value="<?php echo esc_attr( __('Edit form', 'calculated-fields-form') ); ?>" />
13
  <script>
14
  if(typeof jQuery != 'undefined')
15
  {
16
  jQuery(document).on('click', '[name="cff-button-edit-form"]', function(){
17
  window.open(
18
- '<?php print $url; ?>'+jQuery('select[id*="widget-siteorigin-cff-shortcode"]:visible').val(),
19
  '_blank'
20
  );
21
  });
@@ -25,9 +24,9 @@ class SiteOrigin_Widget_Field_CFF_Button extends SiteOrigin_Widget_Field_Base {
25
  }
26
  }
27
 
28
- protected function sanitize_field_input($value, $instance) {}
29
  protected function add_label_classes( $label_classes ) {}
30
- protected function render_field_label($value, $instance) {}
31
  protected function render_before_field( $value, $instance ) {}
32
  protected function render_after_field( $value, $instance ) {}
33
  }
5
  class SiteOrigin_Widget_Field_CFF_Button extends SiteOrigin_Widget_Field_Base {
6
 
7
  protected function render_field( $value, $instance ) {
8
+ if ( current_user_can( 'manage_options' ) ) {
 
9
  $url = CPCFF_AUXILIARY::editor_url();
10
  ?>
11
+ <input type="button" name="cff-button-edit-form" class="button-primary" value="<?php echo esc_attr( __( 'Edit form', 'calculated-fields-form' ) ); ?>" />
12
  <script>
13
  if(typeof jQuery != 'undefined')
14
  {
15
  jQuery(document).on('click', '[name="cff-button-edit-form"]', function(){
16
  window.open(
17
+ '<?php print esc_url( $url ); ?>'+jQuery('select[id*="widget-siteorigin-cff-shortcode"]:visible').val(),
18
  '_blank'
19
  );
20
  });
24
  }
25
  }
26
 
27
+ protected function sanitize_field_input( $value, $instance ) {}
28
  protected function add_label_classes( $label_classes ) {}
29
+ protected function render_field_label( $value, $instance ) {}
30
  protected function render_before_field( $value, $instance ) {}
31
  protected function render_after_field( $value, $instance ) {}
32
  }
pagebuilders/siteorigin/siteorigin-cpcff/siteorigin-cpcff.php CHANGED
@@ -1,75 +1,72 @@
1
- <?php
2
- /*
3
- Widget Name: Calculated Fields Form Shortcode
4
- Description: Insert a form on page.
5
- Documentation: https://cff.dwbooster.com/documentation#insertion-page
6
- */
7
-
8
- class SiteOrigin_CFF_Shortcode extends SiteOrigin_Widget
9
- {
10
- function __construct()
11
- {
12
- global $wpdb;
13
- $options = array();
14
- $default = '';
15
- $forms = $wpdb->get_results( "SELECT id, form_name FROM ".$wpdb->prefix.CP_CALCULATEDFIELDSF_FORMS_TABLE. " ORDER BY id ASC" );
16
- foreach($forms as $form)
17
- {
18
- if(empty($default)) $default = $form->id;
19
- $options[$form->id] = esc_html('('.$form->id.') '.$form->form_name);
20
- }
21
-
22
- parent::__construct(
23
- 'siteorigin-cff-shortcode',
24
- __('Calculated Fields Form Shortcode', 'calculated-fields-form'),
25
- array(
26
- 'description' => __('Includes the shortcode for inserting a form', 'calculated-fields-form'),
27
- 'panels_groups' => array('calculated-fields-form'),
28
- 'help' => 'https://cff.dwbooster.com/documentation#insertion-page',
29
- ),
30
- array(),
31
- array(
32
- 'form' => array(
33
- 'type' => 'select',
34
- 'label' => __( 'Form to include', 'calculated-fields-form' ),
35
- 'default' => $default,
36
- 'options' => $options
37
- ),
38
- 'class_name' => array(
39
- 'type' => 'text',
40
- 'label' => __('Enter a class name to be assigned to the form (optional)', 'calculated-fields-form')
41
- ),
42
- 'attrs' => array(
43
- 'type' => 'text',
44
- 'label' => __('Pass additional attributes to the form. Ex: attr_name="attr_value" (optional)', 'calculated-fields-form')
45
- ),
46
- 'btn' => array(
47
- 'type' => 'CFF_Button'
48
- ),
49
- ),
50
- plugin_dir_path(__FILE__)
51
- );
52
-
53
- add_filter( 'siteorigin_widgets_field_class_paths', array( $this, 'add_location_field_path' ) );
54
- } // End __construct
55
-
56
- function add_location_field_path($class_paths)
57
- {
58
- $class_paths[] = plugin_dir_path( __FILE__ ) . 'fields/';
59
- return $class_paths;
60
- } // End add_location_field_path
61
-
62
- function get_template_name($instance)
63
- {
64
- return 'siteorigin-cff-shortcode';
65
- } // End get_template_name
66
-
67
- function get_style_name($instance)
68
- {
69
- return '';
70
- } // End get_style_name
71
-
72
- } // End Class SiteOrigin_CFF_Shortcode
73
-
74
- // Registering the widget
75
- siteorigin_widget_register('siteorigin-cff-shortcode', __FILE__, 'SiteOrigin_CFF_Shortcode');
1
+ <?php
2
+ /*
3
+ Widget Name: Calculated Fields Form Shortcode
4
+ Description: Insert a form on page.
5
+ Documentation: https://cff.dwbooster.com/documentation#insertion-page
6
+ */
7
+
8
+ class SiteOrigin_CFF_Shortcode extends SiteOrigin_Widget {
9
+
10
+ public function __construct() {
11
+ global $wpdb;
12
+ $options = array();
13
+ $default = '';
14
+ $forms = $wpdb->get_results( 'SELECT id, form_name FROM ' . $wpdb->prefix . CP_CALCULATEDFIELDSF_FORMS_TABLE . ' ORDER BY id ASC' ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
15
+ foreach ( $forms as $form ) {
16
+ if ( empty( $default ) ) {
17
+ $default = $form->id;
18
+ }
19
+ $options[ $form->id ] = esc_html( '(' . $form->id . ') ' . $form->form_name );
20
+ }
21
+
22
+ parent::__construct(
23
+ 'siteorigin-cff-shortcode',
24
+ __( 'Calculated Fields Form Shortcode', 'calculated-fields-form' ),
25
+ array(
26
+ 'description' => __( 'Includes the shortcode for inserting a form', 'calculated-fields-form' ),
27
+ 'panels_groups' => array( 'calculated-fields-form' ),
28
+ 'help' => 'https://cff.dwbooster.com/documentation#insertion-page',
29
+ ),
30
+ array(),
31
+ array(
32
+ 'form' => array(
33
+ 'type' => 'select',
34
+ 'label' => __( 'Form to include', 'calculated-fields-form' ),
35
+ 'default' => $default,
36
+ 'options' => $options,
37
+ ),
38
+ 'class_name' => array(
39
+ 'type' => 'text',
40
+ 'label' => __( 'Enter a class name to be assigned to the form (optional)', 'calculated-fields-form' ),
41
+ ),
42
+ 'attrs' => array(
43
+ 'type' => 'text',
44
+ 'label' => __( 'Pass additional attributes to the form. Ex: attr_name="attr_value" (optional)', 'calculated-fields-form' ),
45
+ ),
46
+ 'btn' => array(
47
+ 'type' => 'CFF_Button',
48
+ ),
49
+ ),
50
+ plugin_dir_path( __FILE__ )
51
+ );
52
+
53
+ add_filter( 'siteorigin_widgets_field_class_paths', array( $this, 'add_location_field_path' ) );
54
+ } // End __construct
55
+
56
+ public function add_location_field_path( $class_paths ) {
57
+ $class_paths[] = plugin_dir_path( __FILE__ ) . 'fields/';
58
+ return $class_paths;
59
+ } // End add_location_field_path
60
+
61
+ public function get_template_name( $instance ) {
62
+ return 'siteorigin-cff-shortcode';
63
+ } // End get_template_name
64
+
65
+ public function get_style_name( $instance ) {
66
+ return '';
67
+ } // End get_style_name
68
+
69
+ } // End Class SiteOrigin_CFF_Shortcode
70
+
71
+ // Registering the widget
72
+ siteorigin_widget_register( 'siteorigin-cff-shortcode', __FILE__, 'SiteOrigin_CFF_Shortcode' );
 
 
 
pagebuilders/siteorigin/siteorigin-cpcff/tpl/siteorigin-cff-shortcode.php CHANGED
@@ -1,13 +1,16 @@
1
- <?php
2
- $form = trim($instance['form']);
3
- $class_name = sanitize_text_field($instance['class_name']);
4
- $attrs = sanitize_text_field($instance['attrs']);
5
- $shortcode = '';
6
- if(@intval($form))
7
- {
8
- $shortcode .= '[CP_CALCULATED_FIELDS id="'.esc_attr($form).'"';
9
- if(!empty($class_name)) $shortcode .= ' class="'.esc_attr($class_name).'"';
10
- if(!empty($attrs)) $shortcode .= ' '.$attrs;
11
- $shortcode .= ']';
12
- }
13
- print $shortcode;
 
 
 
1
+ <?php
2
+ $form = trim( $instance['form'] );
3
+ $class_name = sanitize_text_field( $instance['class_name'] );
4
+ $attrs = sanitize_text_field( $instance['attrs'] );
5
+ $shortcode = '';
6
+ if ( @intval( $form ) ) {
7
+ $shortcode .= '[CP_CALCULATED_FIELDS id="' . esc_attr( $form ) . '"';
8
+ if ( ! empty( $class_name ) ) {
9
+ $shortcode .= ' class="' . esc_attr( $class_name ) . '"';
10
+ }
11
+ if ( ! empty( $attrs ) ) {
12
+ $shortcode .= ' ' . $attrs;
13
+ }
14
+ $shortcode .= ']';
15
+ }
16
+ print $shortcode; // phpcs:ignore WordPress.Security.EscapeOutput
vendors/forms.js CHANGED
@@ -39,6 +39,21 @@ cff_forms_templates = {
39
  "category": "Basic Operations",
40
  "description": "An order form that allows you to add new products or delete existing ones.",
41
  "id": 20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  }, {
43
  "title": "Simple Accommodation Booking",
44
  "category": "Dates Operations",
39
  "category": "Basic Operations",
40
  "description": "An order form that allows you to add new products or delete existing ones.",
41
  "id": 20
42
+ }, {
43
+ "title": "Print Form Button",
44
+ "category": "Basic Operations",
45
+ "description": "The print form button allows you to print only the form, excluding the rest of the page. Assigning the class name cff-no-print to the fields allows you to exclude them from the printed form.",
46
+ "id": 26
47
+ }, {
48
+ "title": "Decimal Places",
49
+ "category": "Basic Operations",
50
+ "description": "Determine the number of decimal places in the result of the equation using the PREC operation.",
51
+ "id": 27
52
+ }, {
53
+ "title": "Recording User Audio and Video",
54
+ "category": "Basic Operations",
55
+ "description": "Allows you to record an audio or video of the user that you can use as proof of acceptance of a contract or terms of service.",
56
+ "id": 28
57
  }, {
58
  "title": "Simple Accommodation Booking",
59
  "category": "Dates Operations",