PluginProbe
Contact Forms by Cimatti / 1.5.2
Contact Forms by Cimatti v1.5.2
2.3.6 2.3.5 2.3.0 2.2.32 2.2.4 2.2.0 2.1.2 2.1.1 trunk 1.0 1.1 1.2 1.2.1 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 All 62 releases
contact-forms / contact-forms.php

contact-forms.php in Contact Forms by Cimatti 1.5.2, at contact-forms.php

738 lines 19.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: WordPress Contact Forms by Cimatti
4 Description: Quickly create and publish forms in your WordPress powered website.
5 Version: 1.5.2
6 Plugin URI: https://www.cimatti.it/wordpress/contact-forms/
7 Author: Cimatti Consulting
8 Author URI: https://www.cimatti.it
9 Text Domain: contact-forms
10 Domain Path: /languages
11 */
12
13 /*
14 WordPress Contact Forms by Cimatti
15 Copyright (c) 2011-2022 Andrea Cimatti
16
17 This program is free software; you can redistribute it and/or
18 modify it under the terms of the GNU General Public License
19 as published by the Free Software Foundation; either version 2
20 of the License, or (at your option) any later version.
21
22 This program is distributed in the hope that it will be useful,
23 but WITHOUT ANY WARRANTY; without even the implied warranty of
24 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 GNU General Public License for more details.
26
27 You should have received a copy of the GNU General Public License
28 along with this program; if not, write to the Free Software
29 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30
31
32 The full copy of the GNU General Public License is available here: http://www.gnu.org/licenses/gpl.txt
33
34 */
35
36 define('ACCUA_FORMS_DB_VERSION', '9');
37 define('ACCUA_FORMS_CSS_VERSION', '48');
38 define('ACCUA_FORMS_JS_VERSION', '6');
39 define('ACCUA_FORMS_DIR_URL', plugin_dir_url( __FILE__ ));
40 define('ACCUA_FORMS_DIR', dirname( __FILE__ ));
41
42 require_once('accua-form-api.php');
43 require_once('accua-forms.php');
44 require_once('accua-shortcode-button.php');
45
46 function accua_forms_dashboard_page_head(){
47 $screen = get_current_screen();
48 $screen->add_help_tab( array(
49 'id' => 'accua_help_tab',
50 'title' => __('Contact Forms Dashboard'),
51 'content' => '<p>' . __( 'Marketing tools for WordPress', 'contact-forms') . '</p>',
52 ) );
53
54 //wp_enqueue_script('accua', plugins_url('/flot/jquery.flot.js', __FILE__ ), array( 'jquery' ));
55 wp_enqueue_script('accua_chart_js', plugins_url('/chartjs/Chart.min.js', __FILE__ ), array( 'jquery' ), ACCUA_FORMS_JS_VERSION);
56 //wp_enqueue_style('accua_flot', plugins_url('/flot/layout.css', __FILE__ ));
57 wp_enqueue_style('accua', plugins_url('accua.css', __FILE__ ), array(), ACCUA_FORMS_CSS_VERSION);
58
59 /* Tentativo x drag and drop
60 $page_hook_id = fx_smb_setings_page_id();
61 /* Load the JavaScript needed for the settings screen. * /
62 add_action( 'admin_enqueue_scripts', 'fx_smb_enqueue_scripts' );
63 add_action( "admin_footer-{$page_hook_id}", 'fx_smb_footer_scripts' );
64
65 /* Set number of column available. * /
66 add_filter( 'screen_layout_columns', 'fx_smb_screen_layout_column', 10, 2 );
67 */
68 }
69
70 /* COSA CARINA PER AGGIUNGERE WIDGET NELLA DASHBOARD DI WP
71 todo: posso scegliere la sua posizione di default?
72 */
73 add_action( 'wp_dashboard_setup', 'accua_contact_forms_dashboard_add_widgets' );
74 function accua_contact_forms_dashboard_add_widgets() {
75 wp_add_dashboard_widget( 'accua_contact_forms_dashboard_widget_news', __( 'Contact Forms', 'contact-forms' ), 'accua_contact_forms_dashboard_widget_news_handler' );
76 }
77
78 function accua_contact_forms_dashboard_widget_news_handler() {
79 global $wpdb; ?>
80 <table>
81 <tr class="first">
82 <?php $forms_data = get_option('accua_forms_saved_forms', array());
83 $active_forms = count($forms_data); ?>
84 <td class="first b"><?php echo $active_forms; ?></td><td class="t"><?php _e('Active forms', 'contact-forms'); ?></td>
85 </tr>
86 <tr class="first">
87 <?php $pages = $wpdb->get_var("SELECT COUNT(DISTINCT afs_uri) FROM `{$wpdb->prefix}accua_forms_submissions`"); ?>
88 <td class="first b"><?php echo $pages; ?></td><td class="t"><?php _e('Pages', 'contact-forms'); ?></td>
89 </tr>
90 <tr class="first">
91 <?php $active_submissions = $wpdb->get_var("SELECT COUNT(*) FROM `{$wpdb->prefix}accua_forms_submissions` WHERE afs_status >= 0"); ?>
92 <td class="first b"><?php echo $active_submissions; ?></td><td class="t"><?php _e('Submissions', 'contact-forms'); ?></td>
93 </tr>
94 <tr class="first">
95 <?php $emails = $wpdb->get_var("SELECT COUNT(DISTINCT afsv_value) FROM `{$wpdb->prefix}accua_forms_submissions_values` WHERE afsv_type LIKE 'autoreply_email'"); ?>
96 <td class="first b"><?php echo $emails; ?></td><td class="t"><?php _e('Distinct Emails', 'contact-forms'); ?></td>
97 </tr>
98 </table>
99 <br />
100 <span id="accua-forms-version"><a href="https://www.cimatti.it/wordpress/contact-forms/"><?php
101 $plugin_data = get_plugin_data( __FILE__ );
102 _e('Version', 'contact-forms'); echo " ".$plugin_data['Version']; ?></a> | <a href="admin.php?page=accua_forms" title="Contact Forms Dashboard"><?php _e('Dashboard', 'contact-forms'); ?></a>
103 </span>
104
105 <?php
106 }
107
108 /* Tentativo x drag and drop
109 function accuacf_index(){
110 echo 'bu';
111
112 }
113 function fx_smb_setings_page_id(){
114 return 'toplevel_page_fx_smb';
115 }
116
117 function fx_smb_enqueue_scripts( $hook_suffix ){
118 $page_hook_id = fx_smb_setings_page_id();
119 if ( $hook_suffix == $page_hook_id ){
120 wp_enqueue_script( 'common' );
121 wp_enqueue_script( 'wp-lists' );
122 wp_enqueue_script( 'postbox' );
123 }
124 }
125
126 function fx_smb_footer_scripts(){
127 $page_hook_id = fx_smb_setings_page_id();
128 ?>
129 <script type="text/javascript">
130 //<![CDATA[
131 jQuery(document).ready( function($) {
132 // toggle
133 $('.if-js-closed').removeClass('if-js-closed').addClass('closed');
134 postboxes.add_postbox_toggles( '<?php echo $page_hook_id; ?>' );
135 });
136 //]]>
137 </script>
138 <?php
139 }
140 function fx_smb_screen_layout_column( $columns, $screen ){
141 $page_hook_id = fx_smb_setings_page_id();
142 if ( $screen == $page_hook_id )
143 $columns[$page_hook_id] = 2;
144 return $columns;
145 }*/
146
147 function accua_forms_dashboard_page(){
148 require_once ACCUA_FORMS_DIR.'/accua-forms-dashboard.php';
149 return _accua_forms_dashboard_page();
150 }
151
152
153 register_activation_hook(__FILE__, 'accua_forms_install');
154 function accua_forms_install(){
155 load_plugin_textdomain( 'contact-forms', false, ACCUA_FORM_API_PLUGIN_TEXTDOMAIN_PATH);
156 $modified = false;
157 $keys = get_option('accua_form_api_keys', array());
158 if (!isset($keys['hash'])) {
159 $modified = true;
160 $keys['hash'] = wp_generate_password(64,true,true);
161 }
162 if (!isset($keys['aes'])) {
163 $modified = true;
164 $keys['aes'] = wp_generate_password(64,true,true);
165 }
166 if ($modified) {
167 update_option('accua_form_api_keys', $keys);
168 }
169
170 global $wpdb;
171
172 require_once(ABSPATH.'wp-admin/upgrade-functions.php');
173
174 $charset_collate = '';
175 if ( ! empty($wpdb->charset) )
176 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
177 if ( ! empty($wpdb->collate) )
178 $charset_collate .= " COLLATE $wpdb->collate";
179
180 $old_db_version = (int) get_option('accua_forms_db_version', 0);
181
182 if ($old_db_version < 3) {
183 @ $wpdb->query("ALTER TABLE `{$wpdb->prefix}accua_forms_submissions` DROP INDEX uri");
184 @ $wpdb->query("ALTER TABLE `{$wpdb->prefix}accua_forms_submissions` DROP INDEX referrer");
185 }
186
187 $sql = "CREATE TABLE `{$wpdb->prefix}accua_forms_submissions` (
188 afs_id BIGINT(20) NOT NULL AUTO_INCREMENT,
189 afs_form_id VARCHAR(77) NOT NULL DEFAULT '',
190 afs_post_id BIGINT(20) NOT NULL DEFAULT 0,
191 afs_ip VARCHAR(255) NOT NULL DEFAULT '',
192 afs_uri TEXT NOT NULL DEFAULT '',
193 afs_referrer TEXT NOT NULL DEFAULT '',
194 afs_lang VARCHAR(60) NOT NULL DEFAULT '',
195 afs_created TIMESTAMP NOT NULL DEFAULT 0,
196 afs_submitted TIMESTAMP NOT NULL DEFAULT 0,
197 afs_status TINYINT(1) NOT NULL DEFAULT 0,
198 afs_stats TEXT NOT NULL DEFAULT '',
199 PRIMARY KEY (afs_id),
200 KEY form (afs_form_id, afs_status),
201 KEY uri (afs_uri(190)),
202 KEY pid (afs_post_id),
203 KEY referrer (afs_referrer(190)),
204 KEY status (afs_status, afs_id),
205 KEY submitted (afs_submitted)
206 ) $charset_collate;";
207 dbDelta($sql);
208
209 $sql = "CREATE TABLE `{$wpdb->prefix}accua_forms_submissions_values` (
210 afsv_sub_id BIGINT(20) NOT NULL,
211 afsv_field_id VARCHAR(77) NOT NULL,
212 afsv_type varchar(255) NOT NULL DEFAULT '',
213 afsv_value TEXT NOT NULL DEFAULT '',
214 PRIMARY KEY (afsv_sub_id, afsv_field_id),
215 KEY value_index (afsv_field_id(77), afsv_value(114))
216 ) $charset_collate;";
217 dbDelta($sql);
218
219 /* creazione tabella per le note dell'utente
220 sono relative a una compilazione
221 possono esserci più note per ogni compilazione in date diverse
222
223 todo: chiedere ad andrea se cambiare la tabella delle note, perchè così (anche se non è sbagliato), senza un'id autoincrementativo c'è rischio che due utenti in contemporanea scrivano sulla stessa compilazione e si generi un errore
224 */
225 $sql = "CREATE TABLE `{$wpdb->prefix}accua_forms_submissions_notes` (
226 afsn_sub_id BIGINT(20) NOT NULL,
227 afsn_date TIMESTAMP NOT NULL DEFAULT 0,
228 afsn_text TEXT NOT NULL DEFAULT '',
229 afsn_user VARCHAR(100) NOT NULL DEFAULT '',
230 PRIMARY KEY (afsn_sub_id, afsn_date),
231 KEY afsn_sub_id (afsn_sub_id)
232 ) $charset_collate;";
233 dbDelta($sql);
234
235
236 $avail_fields = get_option('accua_forms_avail_fields', array());
237
238 if (!is_array($avail_fields)) {
239 $avail_fields = array();
240 }
241
242 if (empty($avail_fields) || ($old_db_version === 0)) {
243 $avail_fields += array(
244 'first_name' => array(
245 'id' => 'first_name',
246 'name' => 'First Name',
247 'type' => 'textfield',
248 'description' => '',
249 'default_value' => '',
250 'allowed_values' => '',
251 ),
252 'last_name' => array(
253 'id' => 'last_name',
254 'name' => 'Last Name',
255 'type' => 'textfield',
256 'description' => '',
257 'default_value' => '',
258 'allowed_values' => '',
259 ),
260 'email' => array(
261 'id' => 'email',
262 'name' => 'Email',
263 'type' => 'autoreply_email',
264 'description' => '',
265 'default_value' => '',
266 'allowed_values' => '',
267 ),
268 'address' => array(
269 'id' => 'address',
270 'name' => 'Address',
271 'type' => 'textfield',
272 'description' => '',
273 'default_value' => '',
274 'allowed_values' => '',
275 ),
276 'city' => array(
277 'id' => 'city',
278 'name' => 'City',
279 'type' => 'textfield',
280 'description' => '',
281 'default_value' => '',
282 'allowed_values' => '',
283 ),
284 'state_province' => array(
285 'id' => 'state_province',
286 'name' => 'State/Province',
287 'type' => 'textfield',
288 'description' => '',
289 'default_value' => '',
290 'allowed_values' => '',
291 ),
292 'country' => array(
293 'id' => 'country',
294 'name' => 'Country',
295 'type' => 'select',
296 'description' => '',
297 'default_value' => '-',
298 'allowed_values' => "-|Select...
299 Afghanistan
300 �
301 land Islands
302 Albania
303 Algeria
304 American Samoa
305 Andorra
306 Angola
307 Anguilla
308 Antarctica
309 Antigua And Barbuda
310 Argentina
311 Armenia
312 Aruba
313 Australia
314 Austria
315 Azerbaijan
316 Bahamas
317 Bahrain
318 Bangladesh
319 Barbados
320 Belarus
321 Belgium
322 Belize
323 Benin
324 Bermuda
325 Bhutan
326 Bolivia
327 Bosnia And Herzegovina
328 Botswana
329 Bouvet Island
330 Brazil
331 British Indian Ocean Territory
332 Brunei Darussalam
333 Bulgaria
334 Burkina Faso
335 Burundi
336 Cambodia
337 Cameroon
338 Canada
339 Cape Verde
340 Cayman Islands
341 Central African Republic
342 Chad
343 Chile
344 China
345 Christmas Island
346 Cocos (Keeling) Islands
347 Colombia
348 Comoros
349 Congo
350 Congo, The Democratic Republic Of The
351 Cook Islands
352 Costa Rica
353 Côte D'Ivoire
354 Croatia
355 Cuba
356 Cyprus
357 Czech Republic
358 Denmark
359 Djibouti
360 Dominica
361 Dominican Republic
362 Ecuador
363 Egypt
364 El Salvador
365 Equatorial Guinea
366 Eritrea
367 Estonia
368 Ethiopia
369 Falkland Islands (Malvinas)
370 Faroe Islands
371 Fiji
372 Finland
373 France
374 French Guiana
375 French Polynesia
376 French Southern Territories
377 Gabon
378 Gambia
379 Georgia
380 Germany
381 Ghana
382 Gibraltar
383 Greece
384 Greenland
385 Grenada
386 Guadeloupe
387 Guam
388 Guatemala
389 Guernsey
390 Guinea
391 Guinea-Bissau
392 Guyana
393 Haiti
394 Heard Island And Mcdonald Islands
395 Holy See (Vatican City State)
396 Honduras
397 Hong Kong
398 Hungary
399 Iceland
400 India
401 Indonesia
402 Iran, Islamic Republic Of
403 Iraq
404 Ireland
405 Isle Of Man
406 Israel
407 Italy
408 Jamaica
409 Japan
410 Jersey
411 Jordan
412 Kazakhstan
413 Kenya
414 Kiribati
415 Korea, Democratic People'S Republic Of
416 Korea, Republic Of
417 Kuwait
418 Kyrgyzstan
419 Lao People'S Democratic Republic
420 Latvia
421 Lebanon
422 Lesotho
423 Liberia
424 Libyan Arab Jamahiriya
425 Liechtenstein
426 Lithuania
427 Luxembourg
428 Macao
429 Macedonia, The Former Yugoslav Republic Of
430 Madagascar
431 Malawi
432 Malaysia
433 Maldives
434 Mali
435 Malta
436 Marshall Islands
437 Martinique
438 Mauritania
439 Mauritius
440 Mayotte
441 Mexico
442 Micronesia, Federated States Of
443 Moldova, Republic Of
444 Monaco
445 Mongolia
446 Montenegro
447 Montserrat
448 Morocco
449 Mozambique
450 Myanmar
451 Namibia
452 Nauru
453 Nepal
454 Netherlands
455 Netherlands Antilles
456 New Caledonia
457 New Zealand
458 Nicaragua
459 Niger
460 Nigeria
461 Niue
462 Norfolk Island
463 Northern Mariana Islands
464 Norway
465 Oman
466 Pakistan
467 Palau
468 Palestinian Territory, Occupied
469 Panama
470 Papua New Guinea
471 Paraguay
472 Peru
473 Philippines
474 Pitcairn
475 Poland
476 Portugal
477 Puerto Rico
478 Qatar
479 Réunion
480 Romania
481 Russian Federation
482 Rwanda
483 Saint Barthélemy
484 Saint Helena
485 Saint Kitts And Nevis
486 Saint Lucia
487 Saint Martin
488 Saint Pierre And Miquelon
489 Saint Vincent And The Grenadines
490 Samoa
491 San Marino
492 Sao Tome And Principe
493 Saudi Arabia
494 Senegal
495 Serbia
496 Seychelles
497 Sierra Leone
498 Singapore
499 Slovakia
500 Slovenia
501 Solomon Islands
502 Somalia
503 South Africa
504 South Georgia And The South Sandwich Islands
505 Spain
506 Sri Lanka
507 Sudan
508 Suriname
509 Svalbard And Jan Mayen
510 Swaziland
511 Sweden
512 Switzerland
513 Syrian Arab Republic
514 Taiwan, Province Of China
515 Tajikistan
516 Tanzania, United Republic Of
517 Thailand
518 Timor-Leste
519 Togo
520 Tokelau
521 Tonga
522 Trinidad And Tobago
523 Tunisia
524 Turkey
525 Turkmenistan
526 Turks And Caicos Islands
527 Tuvalu
528 Uganda
529 Ukraine
530 United Arab Emirates
531 United Kingdom
532 United States
533 United States Minor Outlying Islands
534 Uruguay
535 Uzbekistan
536 Vanuatu
537 Venezuela, Bolivarian Republic Of
538 Viet Nam
539 Virgin Islands, British
540 Virgin Islands, U.S.
541 Wallis And Futuna
542 Western Sahara
543 Yemen
544 Zambia
545 Zimbabwe",
546 ),
547 'message' => array(
548 'id' => 'message',
549 'name' => 'Message',
550 'type' => 'textarea',
551 'description' => '',
552 'default_value' => '',
553 'allowed_values' => '',
554 ),
555 'captcha' => array(
556 'id' => 'captcha',
557 'name' => 'Captcha',
558 'type' => 'captcha',
559 'description' => '',
560 'default_value' => '',
561 'allowed_values' => '',
562 ),
563 );
564 update_option('accua_forms_avail_fields', $avail_fields);
565 }
566
567 $form_data = get_option('accua_forms_default_form_data',array());
568 if (!is_array($form_data)) {
569 $form_data = array();
570 }
571
572 $form_data += array(
573 'success_message' => '<div style="padding: 10px; background-color: #fbf8b2; border: 1px solid #f7c84b;">
574 <h2>Thank you {first_name} {last_name},</h2>
575 We have received your contact request. Check your inbox for the confirmation message.
576
577 <strong>Can\'t find the email?</strong>
578
579 It doesn\'t happen often but your mailbox could apply strict spam rules that block our email from reaching your inbox. Try checking your spam folder.
580
581 Also check that the email you entered in the form (<strong>{email}</strong>) is correct. If it is not exact you can submit the form again.
582
583 For other possible problems you may have encountered do not hesitate to contact us
584
585 </div>',
586 'error_message' => '<div style="padding: 10px; background-color: #fbf8b2; border: 1px solid #f7c84b;">
587 <h2>Oops! Something went wrong.</h2>
588 Internet is an awfully complex place and even though we take every precaution to make sure things run smoothly every once in a while things can go wrong that are not under our control.
589
590 Please try filling in the form again.
591
592 For other possible problems you may have encountered do not hesitate to contact us
593
594 </div>',
595 'emails_from_name' => '',
596 'emails_from' => '',
597 'admin_emails_to' => get_option('admin_email', ''),
598 'emails_bcc' => '',
599 'admin_emails_subject' => 'A contact from your site',
600 'admin_emails_message' => '<table style="font-family: \'Lucida Sans\',\'Lucida Grande\', Verdana, Arial, Sans-Serif !important; background: #fff; margin-top: 10px; border: 1px solid #DDDDDD; max-width: 700px;" cellspacing="0" cellpadding="0" align="center">
601 <tbody>
602 <tr>
603 <td>
604 <table style="max-width:700px;" border="0" cellspacing="0" cellpadding="0" align="center">
605 <tbody>
606 <tr>
607 <td>
608 <table style="padding: 10px; background-color: #fbf8b2; border: 1px solid #f7c84b; max-width:700px;" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#FFFFFF">
609 <tbody>
610 <tr valign="top">
611 <td style="max-width:22px;"></td>
612 <td style="font-family: \'Lucida Sans\',\'Lucida Grande\', Verdana, Arial, Sans-Serif !important; padding: 15px 0px; max-width: 645px;">
613 <table>
614 <tbody>
615 <tr>
616 <td>On {__submitted_day_month_year} at {__submitted_hour} the following form was filled in.
617
618 <hr />
619
620 <strong>Page where the form was filled in</strong>
621 <a href="{__url}">{__url}</a></td>
622 </tr>
623 <tr>
624 <td id="submitted_html">{__submitted_html}</td>
625 </tr>
626 <tr>
627 <td>[form_if {__referrer} [<strong>Referrer</strong> - where did the contact come from <em>before reaching the page</em>: {__referrer}]]</td>
628 </tr>
629 <tr>
630 <td><strong>Contact IP</strong> {__ip}
631 <hr />
632 </td>
633 </tr>
634 <tr>
635 <td>[form_if {__autoreply} [The contact received in his email <a href="mailto:{email}">{email}</a> the following confirmation message:
636 <table>
637 <tbody>
638 <tr>
639 <td>{__confirmation_emails_message}</td>
640 </tr>
641 </tbody>
642 </table> ]]
643 </td>
644 </tr>
645 </tbody>
646 </table>
647 </td>
648 <td style="max-width:23px"></td>
649 </tr>
650 </tbody>
651 </table>
652 </td>
653 </tr>
654 </tbody>
655 </table>
656 </td>
657 </tr>
658 </tbody>
659 </table>',
660 'confirmation_emails_subject' => 'Your message',
661 'confirmation_emails_message' => '<h2>Thank you {first_name} {last_name},</h2>
662 Thank Your for your contact request.
663
664 We will contact you as soon as possible.
665
666 Sincerely,
667
668 The Website Team
669
670 <hr />',
671
672 'layout' => 'sidebyside',
673 'style_margin' => '',
674 'style_border_color' => '',
675 'style_border_width' => '',
676 'style_border_radius' => '',
677 'style_background_color' => '',
678 'style_padding' => '',
679 'style_color' => '',
680 'style_font_size' => '',
681 'style_field_spacing' => '',
682 'style_field_border_color' => '',
683 'style_field_border_width' => '',
684 'style_field_border_radius' => '',
685 'style_field_background_color' => '',
686 'style_field_padding' => '',
687 'style_field_color' => '',
688 'style_submit_border_color' => '',
689 'style_submit_border_width' => '',
690 'style_submit_border_radius' => '',
691 'style_submit_background_color' => '',
692 'style_submit_padding' => '',
693 'style_submit_color' => '',
694 'style_submit_font_size' => '',
695 );
696
697 update_option('accua_forms_default_form_data', $form_data);
698 update_option('accua_forms_db_version', ACCUA_FORMS_DB_VERSION);
699 }
700
701 add_action('plugins_loaded', 'accua_forms_check_db_version_and_update', 9);
702 function accua_forms_check_db_version_and_update() {
703 $db_version = get_option('accua_forms_db_version', '');
704 if (ACCUA_FORMS_DB_VERSION != $db_version) {
705 accua_forms_install();
706 }
707 }
708
709 add_filter( 'robots_txt', 'accua_forms_robots_txt', 10, 2);
710 function accua_forms_robots_txt($output, $public) {
711 if ($public) {
712 $site_url = parse_url( site_url() );
713 $path = ( !empty( $site_url['path'] ) ) ? $site_url['path'] : '';
714 $output .= "\nUser-agent: *\n";
715 $output .= "Allow: $path/wp-admin/js/\n";
716 $output .= "Allow: $path/wp-admin/css/\n";
717 }
718 return $output;
719 }
720
721 function _accua_forms_json_encode($item) {
722 static $version = NULL;
723 if ($version === NULL) {
724 $version = version_compare(PHP_VERSION, '5.3.0', '>=');
725 }
726 if ($version) {
727 return json_encode($item, JSON_HEX_TAG|JSON_HEX_APOS|JSON_HEX_QUOT|JSON_HEX_AMP);
728 } else {
729 return strtr(json_encode($item),
730 array(
731 '&' => '\\u0026',
732 '<' => '\\u003C',
733 '>' => '\\u003E',
734 ));
735 }
736 }
737
738