diff --git a/README.txt b/README.txt index 0bfb52a..dcf2d08 100644 --- a/README.txt +++ b/README.txt @@ -1,92 +1,92 @@ -=== Contact Form 8 === -Contributors: takayukister -Donate link: http://pledgie.com/campaigns/3117 -Tags: contact, contact form, email, ajax, captcha, akismet -Requires at least: 2.7 -Tested up to: 2.9-rare -Stable tag: 2.0.1 - -License: GPL? - -A fork of Contact Form 7, Contact Form 8 improves things like checkboxes (labels!). - -== Description == - -Just another contact form plugin. Simple but flexible. - -Contact Form 7 can manage multiple contact forms, plus you can customize the form and the mail contents flexibly with simple markup. The form supports Ajax-powered submitting, CAPTCHA, Akismet spam filtering and so on. - -**Note: Contact Form 7's CAPTCHA module has been separated as [Really Simple CAPTCHA](http://wordpress.org/extend/plugins/really-simple-captcha/) plugin. Now you need to install it if you use CAPTCHA. If you don't, you can use as in the past.** - -Since being published in August 2007, Contact Form 7 has been translated into a number of languages. Our thanks and appreciation must go to the following for their contributions: - -* Albanian (sq) - [Olgi Zenullari](http://www.olgizenullari.com/) -* Arabic (ar) - [Tarek Chaaban](http://www.chaaban.info/) and Muhammed Lardi -* Bangla (bn_BD) - [SM Mehdi Akram](http://www.shamokaldarpon.com/) -* Bosnian (bs) - [Vedran](http://www.seorabbit.com/) -* Brazilian Portuguese (pt_BR) - [Leonardo Pinheiro](http://www.eletrikabarbarella.com.br/) (updated by [Henrique Vianna](http://henriquevianna.com/)) -* Bulgarian (bg_BG) - [Iliyan Darganov](http://www.darganov.com/) -* Catalan (ca_ES) - [Jordi Sancho](http://www.qasolutions.net/blog) -* Chinese, Simplified (zh_CN) - [Soz](http://www.webtoolol.com/) -* Chinese, Traditional (zh_TW) - [James Wu](http://jameswublog.com) -* Croatian (hr) - [tolingo Translation Services](http://www.tolingo.com) -* Czech (cs_CZ) - Korry -* Danish (da_DK) - [Jens Griebel](http://www.kompas-it.dk/) (updated by [Georg S. Adamsen](http://wordpress.blogos.dk/)) -* Dutch (nl_NL) - [Chris Devriese](http://www.100it.be/) (updated by [Martin Hein](http://www.split-a-pixel.nl/)) -* Estonian (et) - [Peeter Rahuvarm](http://www.kraabus.ee) -* Finnish (fi) - [Miika Turunen](http://www.webwork.fi/) -* French (fr_FR) - [Jillij](http://www.jillij.com/) (updated by [Maître Mô](http://maitremo.fr/)) -* Georgian (ka_GE) - [Nodar Davituri](http://omedia.ge/) -* German (de_DE) - [Marcel Spitau](http://blog.spitau.de) (updated by [Ivan Graf](http://blog.bildergallery.com/)) -* Greek (el) - [Nick Mouratidis](http://www.kepik.gr/) (updated by [Pr. friedlich](http://friedlich.wordpress.com/)) -* Hebrew (he_IL) - [Yaron Ofer](http://www.gadgetguru.co.il/) -* Hindi (hi_IN) - [Tarun Joshi](http://www.readers-cafe.net/) -* Hungarian (hu_HU) - [Andras Hirschler](http://hia.itblog.hu/) -* Indonesian (id_ID) - [Hendry Lee](http://blogbuildingu.com/) -* Italian (it_IT) - [Bruno](http://www.brunosalzano.com) (updated by [Gianni Diurno](http://gidibao.net/)) -* Japanese (ja) - [Takayuki Miyoshi](http://ideasilo.wordpress.com) (plugin author) -* Korean (ko_KR) - Seong Eun Lee (updated by [Jong-In Kim](http://incommunity.codex.kr/wordpress/)) -* Latvian (lv) - [Sandis Veinbergs](http://www.kleofass.lv/) -* Norwegian (nb_NO) - Kjetil M. Bergem -* Persian (Farsi; fa_IR) - [Mohammad Musavi](http://www.musavis.com/) -* Polish (pl_PL) - [Zbigniew Czernik](http://zibik.jogger.pl/) -* Portuguese (pt_PT) - [Hugo Baeta](http://hugobaeta.com) -* Russian (ru_RU) - [Dmitry Volotovich](http://www.volnov.com) -* Romanian (ro_RO) - [Stas Sushkov](http://stas.nerd.ro/) -* Serbian (sr_RS) - [Vedran](http://www.seorabbit.com/) -* Slovak (sk) - [Patrik Bóna](http://www.mrhead.sk/) -* Slovene (sl_SI) - [Mihael Simonič](http://smihael.bplaced.net) -* Spanish (es_ES) - [Jordi Sancho](http://www.qasolutions.net/blog) -(updated by [Vladimir Prieto](http://vladimir.prie.to/), [Federico Mikaelian](http://www.fedemika.com.ar/) and [Matias Baldanza](http://matiasbaldanza.com/)) -* Swedish (sv_SE) - [Fredrik Jonsson](http://www.fredda-o-ac.se/) (updated by [the Swedish community](http://wp-support.se/)) -* Turkish (tr_TR) - [Roman Neumuller](http://katpatuka.wordpress.com) (updated by [Hasan Yılmaz](http://hedefturkce.com/)) -* Ukrainian (uk_UA) - [Andrey Kovba](http://myserver.com.ua/) -* Vietnamese (vi) - Thanh Hải, Hà - -If you have created your own language pack, or have an update of an existing one, you can send [gettext .po and .mo files](http://codex.wordpress.org/Translating_WordPress) to me so that I can bundle it into Contact Form 7. - -== Installation == - -1. Upload the entire `contact-form-7` folder to the `/wp-content/plugins/` directory. -1. Activate the plugin through the 'Plugins' menu in WordPress. - -You will find 'Contact' menu in your WordPress admin panel. - -For basic usage, you can also have a look at the [plugin homepage](http://ideasilo.wordpress.com/2007/04/30/contact-form-7/) and [FAQ](http://ideasilo.wordpress.com/2008/03/29/contact-form-7-faq/). - -== Frequently Asked Questions == - -Please see [FAQ](http://ideasilo.wordpress.com/2008/03/29/contact-form-7-faq/). - -If you have any further questions, -please submit them [to the support forum](http://wordpress.org/tags/contact-form-7#postform). - -Attention: [Check your site before reporting trouble, please!](http://ideasilo.wordpress.com/2009/01/20/check-your-site-before-reporting-trouble-please/) - -== Screenshots == - -1. screenshot-1.png - -== Changelog == - -[See change logs in author's blog.](http://ideasilo.wordpress.com/tag/contact-form-7/) +=== Contact Form 8 === +Contributors: takayukister +Donate link: http://pledgie.com/campaigns/3117 +Tags: contact, contact form, email, ajax, captcha, akismet +Requires at least: 2.7 +Tested up to: 2.9-rare +Stable tag: 2.0.1 + +License: GPL? + +A fork of Contact Form 7, Contact Form 8 improves things like checkboxes (labels!). + +== Description == + +Just another contact form plugin. Simple but flexible. + +Contact Form 7 can manage multiple contact forms, plus you can customize the form and the mail contents flexibly with simple markup. The form supports Ajax-powered submitting, CAPTCHA, Akismet spam filtering and so on. + +**Note: Contact Form 7's CAPTCHA module has been separated as [Really Simple CAPTCHA](http://wordpress.org/extend/plugins/really-simple-captcha/) plugin. Now you need to install it if you use CAPTCHA. If you don't, you can use as in the past.** + +Since being published in August 2007, Contact Form 7 has been translated into a number of languages. Our thanks and appreciation must go to the following for their contributions: + +* Albanian (sq) - [Olgi Zenullari](http://www.olgizenullari.com/) +* Arabic (ar) - [Tarek Chaaban](http://www.chaaban.info/) and Muhammed Lardi +* Bangla (bn_BD) - [SM Mehdi Akram](http://www.shamokaldarpon.com/) +* Bosnian (bs) - [Vedran](http://www.seorabbit.com/) +* Brazilian Portuguese (pt_BR) - [Leonardo Pinheiro](http://www.eletrikabarbarella.com.br/) (updated by [Henrique Vianna](http://henriquevianna.com/)) +* Bulgarian (bg_BG) - [Iliyan Darganov](http://www.darganov.com/) +* Catalan (ca_ES) - [Jordi Sancho](http://www.qasolutions.net/blog) +* Chinese, Simplified (zh_CN) - [Soz](http://www.webtoolol.com/) +* Chinese, Traditional (zh_TW) - [James Wu](http://jameswublog.com) +* Croatian (hr) - [tolingo Translation Services](http://www.tolingo.com) +* Czech (cs_CZ) - Korry +* Danish (da_DK) - [Jens Griebel](http://www.kompas-it.dk/) (updated by [Georg S. Adamsen](http://wordpress.blogos.dk/)) +* Dutch (nl_NL) - [Chris Devriese](http://www.100it.be/) (updated by [Martin Hein](http://www.split-a-pixel.nl/)) +* Estonian (et) - [Peeter Rahuvarm](http://www.kraabus.ee) +* Finnish (fi) - [Miika Turunen](http://www.webwork.fi/) +* French (fr_FR) - [Jillij](http://www.jillij.com/) (updated by [Maître Mô](http://maitremo.fr/)) +* Georgian (ka_GE) - [Nodar Davituri](http://omedia.ge/) +* German (de_DE) - [Marcel Spitau](http://blog.spitau.de) (updated by [Ivan Graf](http://blog.bildergallery.com/)) +* Greek (el) - [Nick Mouratidis](http://www.kepik.gr/) (updated by [Pr. friedlich](http://friedlich.wordpress.com/)) +* Hebrew (he_IL) - [Yaron Ofer](http://www.gadgetguru.co.il/) +* Hindi (hi_IN) - [Tarun Joshi](http://www.readers-cafe.net/) +* Hungarian (hu_HU) - [Andras Hirschler](http://hia.itblog.hu/) +* Indonesian (id_ID) - [Hendry Lee](http://blogbuildingu.com/) +* Italian (it_IT) - [Bruno](http://www.brunosalzano.com) (updated by [Gianni Diurno](http://gidibao.net/)) +* Japanese (ja) - [Takayuki Miyoshi](http://ideasilo.wordpress.com) (plugin author) +* Korean (ko_KR) - Seong Eun Lee (updated by [Jong-In Kim](http://incommunity.codex.kr/wordpress/)) +* Latvian (lv) - [Sandis Veinbergs](http://www.kleofass.lv/) +* Norwegian (nb_NO) - Kjetil M. Bergem +* Persian (Farsi; fa_IR) - [Mohammad Musavi](http://www.musavis.com/) +* Polish (pl_PL) - [Zbigniew Czernik](http://zibik.jogger.pl/) +* Portuguese (pt_PT) - [Hugo Baeta](http://hugobaeta.com) +* Russian (ru_RU) - [Dmitry Volotovich](http://www.volnov.com) +* Romanian (ro_RO) - [Stas Sushkov](http://stas.nerd.ro/) +* Serbian (sr_RS) - [Vedran](http://www.seorabbit.com/) +* Slovak (sk) - [Patrik Bóna](http://www.mrhead.sk/) +* Slovene (sl_SI) - [Mihael Simonič](http://smihael.bplaced.net) +* Spanish (es_ES) - [Jordi Sancho](http://www.qasolutions.net/blog) +(updated by [Vladimir Prieto](http://vladimir.prie.to/), [Federico Mikaelian](http://www.fedemika.com.ar/) and [Matias Baldanza](http://matiasbaldanza.com/)) +* Swedish (sv_SE) - [Fredrik Jonsson](http://www.fredda-o-ac.se/) (updated by [the Swedish community](http://wp-support.se/)) +* Turkish (tr_TR) - [Roman Neumuller](http://katpatuka.wordpress.com) (updated by [Hasan Yılmaz](http://hedefturkce.com/)) +* Ukrainian (uk_UA) - [Andrey Kovba](http://myserver.com.ua/) +* Vietnamese (vi) - Thanh Hải, Hà + +If you have created your own language pack, or have an update of an existing one, you can send [gettext .po and .mo files](http://codex.wordpress.org/Translating_WordPress) to me so that I can bundle it into Contact Form 7. + +== Installation == + +1. Upload the entire `contact-form-7` folder to the `/wp-content/plugins/` directory. +1. Activate the plugin through the 'Plugins' menu in WordPress. + +You will find 'Contact' menu in your WordPress admin panel. + +For basic usage, you can also have a look at the [plugin homepage](http://ideasilo.wordpress.com/2007/04/30/contact-form-7/) and [FAQ](http://ideasilo.wordpress.com/2008/03/29/contact-form-7-faq/). + +== Frequently Asked Questions == + +Please see [FAQ](http://ideasilo.wordpress.com/2008/03/29/contact-form-7-faq/). + +If you have any further questions, +please submit them [to the support forum](http://wordpress.org/tags/contact-form-7#postform). + +Attention: [Check your site before reporting trouble, please!](http://ideasilo.wordpress.com/2009/01/20/check-your-site-before-reporting-trouble-please/) + +== Screenshots == + +1. screenshot-1.png + +== Changelog == + +[See change logs in author's blog.](http://ideasilo.wordpress.com/tag/contact-form-7/) diff --git a/admin/admin-panel.php b/admin/admin-panel.php index 51602ea..7bb1ff5 100644 --- a/admin/admin-panel.php +++ b/admin/admin-panel.php @@ -1,339 +1,339 @@ - 1 ) ); - $create_table_link_url = wp_nonce_url( $create_table_link_url, 'wpcf7-create-table' ); - $message = sprintf( - __( 'The database table for Contact Form 7 does not exist. You must create the table for it to work.', 'wpcf7' ), - $create_table_link_url ); - } else { - $message = __( "The database table for Contact Form 7 does not exist.", 'wpcf7' ); - } -?> -
- -

-
-

-
-
-
- - - -

- - - - -

- - - - -
- - - - -
- - - - - - - - - -
-
- /> - - -

-
- - -

- - - -
- -
- - - - - -
-
- - - - - - - - - - - - - - - -
-
-
-
-
- - - - - - - - - - -
- -
-
- -
- -
-
- -
- -
-
- -
- -
- -
-
- -
- -
-
- -
- -
- -
- mail['use_html'] ) ? ' checked="checked"' : ''; ?> /> - -
- -
- -
-
- -
- -
- - - - - - - - - - - - - - -
- mail_2['active'] ) ? ' checked="checked"' : ''; ?> /> - -
- -
-
- -
- -
-
- -
- -
-
- -
- -
- -
-
- -
- -
-
- -
- -
- -
- mail_2['use_html'] ) ? ' checked="checked"' : ''; ?> /> - -
- -
- -
-
- -
- -
- - - - - - - - - -
-
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- - - - - - - - - -
-
- -
-
- - - - - - - -
-
- -
-
- - - -
- - -
+ 1 ) ); + $create_table_link_url = wp_nonce_url( $create_table_link_url, 'wpcf7-create-table' ); + $message = sprintf( + __( 'The database table for Contact Form 7 does not exist. You must create the table for it to work.', 'wpcf7' ), + $create_table_link_url ); + } else { + $message = __( "The database table for Contact Form 7 does not exist.", 'wpcf7' ); + } +?> +
+ +

+
+

+
+
+
+ + + +

+ + + + +

+ + + + +
+ + + + +
+ + + + + + + + + +
+
+ /> + + +

+
+ + +

+ + + +
+ +
+ + + + + +
+
+ + + + + + + + + + + + + + + +
+
+
+
+
+ + + + + + + + + + +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+ +
+ mail['use_html'] ) ? ' checked="checked"' : ''; ?> /> + +
+ +
+ +
+
+ +
+ +
+ + + + + + + + + + + + + + +
+ mail_2['active'] ) ? ' checked="checked"' : ''; ?> /> + +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+ +
+ mail_2['use_html'] ) ? ' checked="checked"' : ''; ?> /> + +
+ +
+ +
+
+ +
+ +
+ + + + + + + + + +
+
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ + + + + + + + + +
+
+ +
+
+ + + + + + + +
+
+ +
+
+ + + +
+ + +
diff --git a/admin/admin-stylesheet-rtl.css b/admin/admin-stylesheet-rtl.css index 831d02b..764c648 100644 --- a/admin/admin-stylesheet-rtl.css +++ b/admin/admin-stylesheet-rtl.css @@ -1,22 +1,22 @@ -ul.subsubsub li.addnew { - margin-left: 0; - margin-right: 0.5em; -} -div.save-contact-form { - direction: rtl; -} -div.actions-link { - right: auto; - left: 0; -} -span#message-fields-toggle-switch { - margin-left: 0; - margin-right: 1em; -} -div.tg-pane table caption { - text-align: right; -} -div.tg-dropdown { - left: auto; - right: 0; +ul.subsubsub li.addnew { + margin-left: 0; + margin-right: 0.5em; +} +div.save-contact-form { + direction: rtl; +} +div.actions-link { + right: auto; + left: 0; +} +span#message-fields-toggle-switch { + margin-left: 0; + margin-right: 1em; +} +div.tg-pane table caption { + text-align: right; +} +div.tg-dropdown { + left: auto; + right: 0; } \ No newline at end of file diff --git a/admin/admin-stylesheet.css b/admin/admin-stylesheet.css index 300ab5d..b966413 100644 --- a/admin/admin-stylesheet.css +++ b/admin/admin-stylesheet.css @@ -1,170 +1,170 @@ -div.wpcf7 div.donation { - border-width: 1px; - border-style: solid; - padding: 0 0.6em; - margin: 5px 0 15px; - -moz-border-radius: 3px; - -khtml-border-radius: 3px; - -webkit-border-radius: 3px; - border-radius: 3px; - background-color: #ffffe0; - border-color: #e6db55; - text-align: center; -} - -div.wpcf7 div.donation p { - margin: 0.5em 0; - line-height: 1; - padding: 2px; -} - -div.wpcf7 div.donation p img { - vertical-align: text-bottom; -} - -div.wpcf7 div.donation p em { - padding-left: 1em; - color: #555; - font-weight: bold; -} - -div.wpcf7 ul.subsubsub { - white-space: normal; -} -ul.subsubsub li.addnew { - margin-left: 0.5em; -} -ul.subsubsub li.addnew a { - color: #e6255b; -} -ul.subsubsub li.addnew a:hover, -ul.subsubsub li.addnew a:active { - color: #999; -} -div.save-contact-form { - padding: 1.4em 0 0 0; - text-align: right; -} -div.actions-link { - position: absolute; - top: 0; - right: 0; - margin: 0; - padding: 0; -} -div.actions-link input { - padding: 0; - margin: 0; - border: none; - background-color: #fff; - font-size: 11px; - cursor: pointer; -} -div.actions-link input.copy { - color: #006505; -} -div.actions-link input.delete { - color: #bc0b0b; -} -input#wpcf7-title { - color: #555; - background-color: #fff; - border: none; - font: bold 20px serif; -} -p.tagcode { - color: #333; - margin: 2ex 0 1ex 1em; -} -input#contact-form-anchor-text { - color: #fff; - background: #8a796d; - border: none; - width: 96%; - -moz-border-radius: 6px; - -khtml-border-radius: 6px; - -webkit-border-radius: 6px; - border-radius: 6px; -} -span#message-fields-toggle-switch, span#additional-settings-fields-toggle-switch { - margin-left: 1em; - font-weight: normal; - font-size: smaller; - color: #2583ad; - cursor: pointer; -} -div.pseudo-hr { - border-bottom: 1px solid #fff; - margin: 0.7em 0; -} -input, textarea { - border: 1px solid #dfdfdf; -} -input.wide { - width: 100%; -} -textarea { - width: 100%; -} -label.disabled { - color: #777; -} -div.tag-generator { - position: relative; - background: #fff; - padding: 5px 0 5px 1px; -} -div.tg-pane { - border: 1px dashed #999; - background: #f1f1f1; - margin: 1ex 0 0 0; - padding: 10px; - -moz-border-radius: 6px; - -khtml-border-radius: 6px; - -webkit-border-radius: 6px; - border-radius: 6px; -} -div.tg-pane table { - width: 100%; - margin: 0 0 0.7em 0; -} -div.tg-pane table caption { - text-align: left; - padding: 0 0 0.2em 0; - font-weight: bolder; - color: #777; -} -div.tg-pane table code { - background-color: inherit; -} -div.tg-pane table td { - vertical-align: top; - width: 50%; -} -div.tg-pane input.tag { - border: none; - color: #fff; - background-color: #8a796d; - -moz-border-radius: 6px; - -khtml-border-radius: 6px; - -webkit-border-radius: 6px; - border-radius: 6px; -} -div.tg-dropdown { - position: absolute; - top: 26px; - left: 0; - z-index: 10; - border: 1px solid #ddd; -} -span.tg-closebutton { - color: #777; - font: bold 18px monospace; - padding: 1px 4px; - cursor: pointer; -} -div.tg-panetitle { - font: bold 132% sans-serif; - margin: 0 0 10px; - color: #777; -} +div.wpcf7 div.donation { + border-width: 1px; + border-style: solid; + padding: 0 0.6em; + margin: 5px 0 15px; + -moz-border-radius: 3px; + -khtml-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; + background-color: #ffffe0; + border-color: #e6db55; + text-align: center; +} + +div.wpcf7 div.donation p { + margin: 0.5em 0; + line-height: 1; + padding: 2px; +} + +div.wpcf7 div.donation p img { + vertical-align: text-bottom; +} + +div.wpcf7 div.donation p em { + padding-left: 1em; + color: #555; + font-weight: bold; +} + +div.wpcf7 ul.subsubsub { + white-space: normal; +} +ul.subsubsub li.addnew { + margin-left: 0.5em; +} +ul.subsubsub li.addnew a { + color: #e6255b; +} +ul.subsubsub li.addnew a:hover, +ul.subsubsub li.addnew a:active { + color: #999; +} +div.save-contact-form { + padding: 1.4em 0 0 0; + text-align: right; +} +div.actions-link { + position: absolute; + top: 0; + right: 0; + margin: 0; + padding: 0; +} +div.actions-link input { + padding: 0; + margin: 0; + border: none; + background-color: #fff; + font-size: 11px; + cursor: pointer; +} +div.actions-link input.copy { + color: #006505; +} +div.actions-link input.delete { + color: #bc0b0b; +} +input#wpcf7-title { + color: #555; + background-color: #fff; + border: none; + font: bold 20px serif; +} +p.tagcode { + color: #333; + margin: 2ex 0 1ex 1em; +} +input#contact-form-anchor-text { + color: #fff; + background: #8a796d; + border: none; + width: 96%; + -moz-border-radius: 6px; + -khtml-border-radius: 6px; + -webkit-border-radius: 6px; + border-radius: 6px; +} +span#message-fields-toggle-switch, span#additional-settings-fields-toggle-switch { + margin-left: 1em; + font-weight: normal; + font-size: smaller; + color: #2583ad; + cursor: pointer; +} +div.pseudo-hr { + border-bottom: 1px solid #fff; + margin: 0.7em 0; +} +input, textarea { + border: 1px solid #dfdfdf; +} +input.wide { + width: 100%; +} +textarea { + width: 100%; +} +label.disabled { + color: #777; +} +div.tag-generator { + position: relative; + background: #fff; + padding: 5px 0 5px 1px; +} +div.tg-pane { + border: 1px dashed #999; + background: #f1f1f1; + margin: 1ex 0 0 0; + padding: 10px; + -moz-border-radius: 6px; + -khtml-border-radius: 6px; + -webkit-border-radius: 6px; + border-radius: 6px; +} +div.tg-pane table { + width: 100%; + margin: 0 0 0.7em 0; +} +div.tg-pane table caption { + text-align: left; + padding: 0 0 0.2em 0; + font-weight: bolder; + color: #777; +} +div.tg-pane table code { + background-color: inherit; +} +div.tg-pane table td { + vertical-align: top; + width: 50%; +} +div.tg-pane input.tag { + border: none; + color: #fff; + background-color: #8a796d; + -moz-border-radius: 6px; + -khtml-border-radius: 6px; + -webkit-border-radius: 6px; + border-radius: 6px; +} +div.tg-dropdown { + position: absolute; + top: 26px; + left: 0; + z-index: 10; + border: 1px solid #ddd; +} +span.tg-closebutton { + color: #777; + font: bold 18px monospace; + padding: 1px 4px; + cursor: pointer; +} +div.tg-panetitle { + font: bold 132% sans-serif; + margin: 0 0 10px; + color: #777; +} diff --git a/admin/admin.php b/admin/admin.php index 215e452..5aa193d 100644 --- a/admin/admin.php +++ b/admin/admin.php @@ -1,383 +1,383 @@ -initial = true; - } - - $title = trim( $_POST['wpcf7-title'] ); - $form = trim( $_POST['wpcf7-form'] ); - $mail = array( - 'subject' => trim( $_POST['wpcf7-mail-subject'] ), - 'sender' => trim( $_POST['wpcf7-mail-sender'] ), - 'body' => trim( $_POST['wpcf7-mail-body'] ), - 'recipient' => trim( $_POST['wpcf7-mail-recipient'] ), - 'additional_headers' => trim( $_POST['wpcf7-mail-additional-headers'] ), - 'attachments' => trim( $_POST['wpcf7-mail-attachments'] ), - 'use_html' => ( 1 == $_POST['wpcf7-mail-use-html'] ) ? true : false - ); - $mail_2 = array( - 'active' => ( 1 == $_POST['wpcf7-mail-2-active'] ) ? true : false, - 'subject' => trim( $_POST['wpcf7-mail-2-subject'] ), - 'sender' => trim( $_POST['wpcf7-mail-2-sender'] ), - 'body' => trim( $_POST['wpcf7-mail-2-body'] ), - 'recipient' => trim( $_POST['wpcf7-mail-2-recipient'] ), - 'additional_headers' => trim( $_POST['wpcf7-mail-2-additional-headers'] ), - 'attachments' => trim( $_POST['wpcf7-mail-2-attachments'] ), - 'use_html' => ( 1 == $_POST['wpcf7-mail-2-use-html'] ) ? true : false - ); - $messages = array( - 'mail_sent_ok' => trim( $_POST['wpcf7-message-mail-sent-ok'] ), - 'mail_sent_ng' => trim( $_POST['wpcf7-message-mail-sent-ng'] ), - 'akismet_says_spam' => trim( $_POST['wpcf7-message-akismet-says-spam'] ), - 'validation_error' => trim( $_POST['wpcf7-message-validation-error'] ), - 'accept_terms' => trim( $_POST['wpcf7-message-accept-terms'] ), - 'invalid_email' => trim( $_POST['wpcf7-message-invalid-email'] ), - 'invalid_required' => trim( $_POST['wpcf7-message-invalid-required'] ), - 'quiz_answer_not_correct' => trim( $_POST['wpcf7-message-quiz-answer-not-correct'] ), - 'captcha_not_match' => trim( $_POST['wpcf7-message-captcha-not-match'] ), - 'upload_failed' => trim( $_POST['wpcf7-message-upload-failed'] ), - 'upload_file_type_invalid' => trim( $_POST['wpcf7-message-upload-file-type-invalid'] ), - 'upload_file_too_large' => trim( $_POST['wpcf7-message-upload-file-too-large'] ) - ); - $additional_settings = trim( $_POST['wpcf7-additional-settings'] ); - - $query = array(); - $query['message'] = ( $contact_form->initial ) ? 'created' : 'saved'; - - $contact_form->title = $title; - $contact_form->form = $form; - $contact_form->mail = $mail; - $contact_form->mail_2 = $mail_2; - $contact_form->messages = $messages; - $contact_form->additional_settings = $additional_settings; - - $contact_form->save(); - - $query['contactform'] = $contact_form->id; - $redirect_to = wpcf7_admin_url( 'admin.php', $query ); - wp_redirect( $redirect_to ); - exit(); - } elseif ( isset( $_POST['wpcf7-copy'] ) && wpcf7_admin_has_edit_cap() ) { - $id = $_POST['wpcf7-id']; - check_admin_referer( 'wpcf7-copy_' . $id ); - - $query = array(); - - if ( $contact_form = wpcf7_contact_form( $id ) ) { - $new_contact_form = $contact_form->copy(); - $new_contact_form->save(); - - $query['contactform'] = $new_contact_form->id; - $query['message'] = 'created'; - } else { - $query['contactform'] = $contact_form->id; - } - - $redirect_to = wpcf7_admin_url( 'admin.php', $query ); - wp_redirect( $redirect_to ); - exit(); - } elseif ( isset( $_POST['wpcf7-delete'] ) && wpcf7_admin_has_edit_cap() ) { - $id = $_POST['wpcf7-id']; - check_admin_referer( 'wpcf7-delete_' . $id ); - - if ( $contact_form = wpcf7_contact_form( $id ) ) - $contact_form->delete(); - - $redirect_to = wpcf7_admin_url( 'admin.php', array( 'message' => 'deleted' ) ); - wp_redirect( $redirect_to ); - exit(); - } elseif ( isset( $_GET['wpcf7-create-table'] ) ) { - check_admin_referer( 'wpcf7-create-table' ); - - $query = array(); - - if ( ! wpcf7_table_exists() && current_user_can( 'activate_plugins' ) ) { - wpcf7_install(); - if ( wpcf7_table_exists() ) { - $query['message'] = 'table_created'; - } else { - $query['message'] = 'table_not_created'; - } - } - - wp_redirect( wpcf7_admin_url( 'admin.php', $query ) ); - exit(); - } - - add_menu_page( __( 'Contact Form 7', 'wpcf7' ), __( 'Contact', 'wpcf7' ), - WPCF7_ADMIN_READ_CAPABILITY, __FILE__, 'wpcf7_admin_management_page' ); - - add_submenu_page( __FILE__, __( 'Edit Contact Forms', 'wpcf7' ), __( 'Edit', 'wpcf7' ), - WPCF7_ADMIN_READ_CAPABILITY, __FILE__, 'wpcf7_admin_management_page' ); -} - -add_action( 'admin_menu', 'wpcf7_admin_add_pages' ); - -function wpcf7_admin_head() { - global $plugin_page; - - if ( isset( $plugin_page ) && $plugin_page == plugin_basename( __FILE__ ) ) { - - $admin_stylesheet_url = wpcf7_plugin_url( 'admin/admin-stylesheet.css' ); - echo ''; - - if ( 'rtl' == get_bloginfo( 'text_direction' ) ) { - $admin_stylesheet_rtl_url = wpcf7_plugin_url( 'admin/admin-stylesheet-rtl.css' ); - echo ''; - } - -?> - - __( 'optional', 'wpcf7' ), - 'generateTag' => __( 'Generate Tag', 'wpcf7' ), - 'textField' => __( 'Text field', 'wpcf7' ), - 'emailField' => __( 'Email field', 'wpcf7' ), - 'textArea' => __( 'Text area', 'wpcf7' ), - 'menu' => __( 'Drop-down menu', 'wpcf7' ), - 'checkboxes' => __( 'Checkboxes', 'wpcf7' ), - 'radioButtons' => __( 'Radio buttons', 'wpcf7' ), - 'acceptance' => __( 'Acceptance', 'wpcf7' ), - 'isAcceptanceDefaultOn' => __( "Make this checkbox checked by default?", 'wpcf7' ), - 'isAcceptanceInvert' => __( "Make this checkbox work inversely?", 'wpcf7' ), - 'isAcceptanceInvertMeans' => __( "* That means visitor who accepts the term unchecks it.", 'wpcf7' ), - 'captcha' => __( 'CAPTCHA', 'wpcf7' ), - 'quiz' => __( 'Quiz', 'wpcf7' ), - 'quizzes' => __( 'Quizzes', 'wpcf7' ), - 'quizFormatDesc' => __( "* quiz|answer (e.g. 1+1=?|2)", 'wpcf7' ), - 'fileUpload' => __( 'File upload', 'wpcf7' ), - 'bytes' => __( 'bytes', 'wpcf7' ), - 'submit' => __( 'Submit button', 'wpcf7' ), - 'tagName' => __( 'Name', 'wpcf7' ), - 'isRequiredField' => __( 'Required field?', 'wpcf7' ), - 'allowsMultipleSelections' => __( 'Allow multiple selections?', 'wpcf7' ), - 'insertFirstBlankOption' => __( 'Insert a blank item as the first option?', 'wpcf7' ), - 'makeCheckboxesExclusive' => __( 'Make checkboxes exclusive?', 'wpcf7' ), - 'menuChoices' => __( 'Choices', 'wpcf7' ), - 'label' => __( 'Label', 'wpcf7' ), - 'defaultValue' => __( 'Default value', 'wpcf7' ), - 'akismet' => __( 'Akismet', 'wpcf7' ), - 'akismetAuthor' => __( "This field requires author's name", 'wpcf7' ), - 'akismetAuthorUrl' => __( "This field requires author's URL", 'wpcf7' ), - 'akismetAuthorEmail' => __( "This field requires author's email address", 'wpcf7' ), - 'generatedTag' => __( "Copy this code and paste it into the form left.", 'wpcf7' ), - 'fgColor' => __( "Foreground color", 'wpcf7' ), - 'bgColor' => __( "Background color", 'wpcf7' ), - 'imageSize' => __( "Image size", 'wpcf7' ), - 'imageSizeSmall' => __( "Small", 'wpcf7' ), - 'imageSizeMedium' => __( "Medium", 'wpcf7' ), - 'imageSizeLarge' => __( "Large", 'wpcf7' ), - 'imageSettings' => __( "Image settings", 'wpcf7' ), - 'inputFieldSettings' => __( "Input field settings", 'wpcf7' ), - 'tagForImage' => __( "For image", 'wpcf7' ), - 'tagForInputField' => __( "For input field", 'wpcf7' ), - 'oneChoicePerLine' => __( "* One choice per line.", 'wpcf7' ), - 'show' => __( "Show", 'wpcf7' ), - 'hide' => __( "Hide", 'wpcf7' ), - 'fileSizeLimit' => __( "File size limit", 'wpcf7' ), - 'acceptableFileTypes' => __( "Acceptable file types", 'wpcf7' ), - 'needReallySimpleCaptcha' => __( "Note: To use CAPTCHA, you need Really Simple CAPTCHA plugin installed.", 'wpcf7' ) - ) ); -} - -add_action( 'wp_print_scripts', 'wpcf7_admin_load_js' ); - -function wpcf7_admin_management_page() { - global $wp_version; - - switch ( $_GET['message'] ) { - case 'created': - $updated_message = __( "Contact form created.", 'wpcf7' ); - break; - case 'saved': - $updated_message = __( "Contact form saved.", 'wpcf7' ); - break; - case 'deleted': - $updated_message = __( "Contact form deleted.", 'wpcf7' ); - break; - case 'table_created': - $updated_message = __( "Database table created.", 'wpcf7' ); - break; - case 'table_not_created': - $updated_message = __( "Failed to create database table.", 'wpcf7' ); - break; - } - - $contact_forms = wpcf7_contact_forms(); - - $id = $_POST['wpcf7-id']; - - if ( 'new' == $_GET['contactform'] ) { - $unsaved = true; - $current = -1; - $cf = wpcf7_contact_form_default_pack(); - } elseif ( $cf = wpcf7_contact_form( $_GET['contactform'] ) ) { - $current = (int) $_GET['contactform']; - } else { - $first = reset( $contact_forms ); // Returns first item - $current = $first->id; - $cf = wpcf7_contact_form( $current ); - } - - require_once WPCF7_PLUGIN_DIR . '/admin/admin-panel.php'; -} - -/* Install and default settings */ - -function wpcf7_install() { - global $wpdb; - - if ( wpcf7_table_exists() ) - return; // Exists already - - $table_name = wpcf7_table_name(); - - $charset_collate = ''; - if ( $wpdb->has_cap( 'collation' ) ) { - if ( ! empty( $wpdb->charset ) ) - $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; - if ( ! empty( $wpdb->collate ) ) - $charset_collate .= " COLLATE $wpdb->collate"; - } - - $wpdb->query( "CREATE TABLE IF NOT EXISTS $table_name ( - cf7_unit_id bigint(20) unsigned NOT NULL auto_increment, - title varchar(200) NOT NULL default '', - form text NOT NULL, - mail text NOT NULL, - mail_2 text NOT NULL, - messages text NOT NULL, - additional_settings text NOT NULL, - PRIMARY KEY (cf7_unit_id)) $charset_collate;" ); - - if ( ! wpcf7_table_exists() ) - return false; // Failed to create - - $legacy_data = get_option( 'wpcf7' ); - if ( is_array( $legacy_data ) ) { - foreach ( $legacy_data['contact_forms'] as $key => $value ) { - $wpdb->insert( $table_name, array( - 'cf7_unit_id' => $key, - 'title' => $value['title'], - 'form' => maybe_serialize( $value['form'] ), - 'mail' => maybe_serialize( $value['mail'] ), - 'mail_2' => maybe_serialize( $value['mail_2'] ), - 'messages' => maybe_serialize( $value['messages'] ), - 'additional_settings' => maybe_serialize( $value['additional_settings'] ) - ), array( '%d', '%s', '%s', '%s', '%s', '%s', '%s' ) ); - } - - // delete_option( 'wpcf7' ); // Comment out for downgrading case for a while - } else { - wpcf7_load_plugin_textdomain(); - - $wpdb->insert( $table_name, array( - 'title' => __( 'Contact form', 'wpcf7' ) . ' 1', - 'form' => maybe_serialize( wpcf7_default_form_template() ), - 'mail' => maybe_serialize( wpcf7_default_mail_template() ), - 'mail_2' => maybe_serialize ( wpcf7_default_mail_2_template() ), - 'messages' => maybe_serialize( wpcf7_default_messages_template() ) ) ); - } -} - -add_action( 'activate_' . WPCF7_PLUGIN_BASENAME, 'wpcf7_install' ); - -/* Misc */ - -function wpcf7_admin_url( $file, $query = array() ) { - $file = trim( $file, ' /' ); - if ( 'admin/' != substr( $file, 0, 6 ) ) - $file = 'admin/' . $file; - - $path = 'admin.php'; - $path .= '?page=' . WPCF7_PLUGIN_NAME . '/' . $file; - - if ( $query = build_query( $query ) ) - $path .= '&' . $query; - - $url = admin_url( $path ); - - return $url; -} - -function wpcf7_plugin_action_links( $links, $file ) { - if ( $file != WPCF7_PLUGIN_BASENAME ) - return $links; - - $url = wpcf7_admin_url( 'admin.php' ); - - $settings_link = '' . esc_html( __( 'Settings', 'wpcf7' ) ) . ''; - - array_unshift( $links, $settings_link ); - - return $links; -} - -add_filter( 'plugin_action_links', 'wpcf7_plugin_action_links', 10, 2 ); - -function wpcf7_donation_link() { - if ( ! WPCF7_SHOW_DONATION_LINK ) - return; - - if ( 'new' == $_GET['contactform'] || ! empty($_GET['message']) ) - return; - - $num = mt_rand(0, 99); - if ($num >= 10) // 90% - return; - - $texts = array( - __( "Contact Form 7 needs your support. Please donate today.", 'wpcf7' ), - __( "Is this plugin useful for you? If you like it, please help the developer.", 'wpcf7' ), - __( "Your contribution is needed for making this plugin better.", 'wpcf7' ), - __( "Developing a plugin and providing user support is really hard work. Please help.", 'wpcf7' ) ); - - $text = $texts[array_rand( $texts )]; - -?> -
-

-Click here to lend your support to: Support Contact Form 7 and make a donation at www.pledgie.com ! - -

-
-initial = true; + } + + $title = trim( $_POST['wpcf7-title'] ); + $form = trim( $_POST['wpcf7-form'] ); + $mail = array( + 'subject' => trim( $_POST['wpcf7-mail-subject'] ), + 'sender' => trim( $_POST['wpcf7-mail-sender'] ), + 'body' => trim( $_POST['wpcf7-mail-body'] ), + 'recipient' => trim( $_POST['wpcf7-mail-recipient'] ), + 'additional_headers' => trim( $_POST['wpcf7-mail-additional-headers'] ), + 'attachments' => trim( $_POST['wpcf7-mail-attachments'] ), + 'use_html' => ( 1 == $_POST['wpcf7-mail-use-html'] ) ? true : false + ); + $mail_2 = array( + 'active' => ( 1 == $_POST['wpcf7-mail-2-active'] ) ? true : false, + 'subject' => trim( $_POST['wpcf7-mail-2-subject'] ), + 'sender' => trim( $_POST['wpcf7-mail-2-sender'] ), + 'body' => trim( $_POST['wpcf7-mail-2-body'] ), + 'recipient' => trim( $_POST['wpcf7-mail-2-recipient'] ), + 'additional_headers' => trim( $_POST['wpcf7-mail-2-additional-headers'] ), + 'attachments' => trim( $_POST['wpcf7-mail-2-attachments'] ), + 'use_html' => ( 1 == $_POST['wpcf7-mail-2-use-html'] ) ? true : false + ); + $messages = array( + 'mail_sent_ok' => trim( $_POST['wpcf7-message-mail-sent-ok'] ), + 'mail_sent_ng' => trim( $_POST['wpcf7-message-mail-sent-ng'] ), + 'akismet_says_spam' => trim( $_POST['wpcf7-message-akismet-says-spam'] ), + 'validation_error' => trim( $_POST['wpcf7-message-validation-error'] ), + 'accept_terms' => trim( $_POST['wpcf7-message-accept-terms'] ), + 'invalid_email' => trim( $_POST['wpcf7-message-invalid-email'] ), + 'invalid_required' => trim( $_POST['wpcf7-message-invalid-required'] ), + 'quiz_answer_not_correct' => trim( $_POST['wpcf7-message-quiz-answer-not-correct'] ), + 'captcha_not_match' => trim( $_POST['wpcf7-message-captcha-not-match'] ), + 'upload_failed' => trim( $_POST['wpcf7-message-upload-failed'] ), + 'upload_file_type_invalid' => trim( $_POST['wpcf7-message-upload-file-type-invalid'] ), + 'upload_file_too_large' => trim( $_POST['wpcf7-message-upload-file-too-large'] ) + ); + $additional_settings = trim( $_POST['wpcf7-additional-settings'] ); + + $query = array(); + $query['message'] = ( $contact_form->initial ) ? 'created' : 'saved'; + + $contact_form->title = $title; + $contact_form->form = $form; + $contact_form->mail = $mail; + $contact_form->mail_2 = $mail_2; + $contact_form->messages = $messages; + $contact_form->additional_settings = $additional_settings; + + $contact_form->save(); + + $query['contactform'] = $contact_form->id; + $redirect_to = wpcf7_admin_url( 'admin.php', $query ); + wp_redirect( $redirect_to ); + exit(); + } elseif ( isset( $_POST['wpcf7-copy'] ) && wpcf7_admin_has_edit_cap() ) { + $id = $_POST['wpcf7-id']; + check_admin_referer( 'wpcf7-copy_' . $id ); + + $query = array(); + + if ( $contact_form = wpcf7_contact_form( $id ) ) { + $new_contact_form = $contact_form->copy(); + $new_contact_form->save(); + + $query['contactform'] = $new_contact_form->id; + $query['message'] = 'created'; + } else { + $query['contactform'] = $contact_form->id; + } + + $redirect_to = wpcf7_admin_url( 'admin.php', $query ); + wp_redirect( $redirect_to ); + exit(); + } elseif ( isset( $_POST['wpcf7-delete'] ) && wpcf7_admin_has_edit_cap() ) { + $id = $_POST['wpcf7-id']; + check_admin_referer( 'wpcf7-delete_' . $id ); + + if ( $contact_form = wpcf7_contact_form( $id ) ) + $contact_form->delete(); + + $redirect_to = wpcf7_admin_url( 'admin.php', array( 'message' => 'deleted' ) ); + wp_redirect( $redirect_to ); + exit(); + } elseif ( isset( $_GET['wpcf7-create-table'] ) ) { + check_admin_referer( 'wpcf7-create-table' ); + + $query = array(); + + if ( ! wpcf7_table_exists() && current_user_can( 'activate_plugins' ) ) { + wpcf7_install(); + if ( wpcf7_table_exists() ) { + $query['message'] = 'table_created'; + } else { + $query['message'] = 'table_not_created'; + } + } + + wp_redirect( wpcf7_admin_url( 'admin.php', $query ) ); + exit(); + } + + add_menu_page( __( 'Contact Form 7', 'wpcf7' ), __( 'Contact', 'wpcf7' ), + WPCF8_ADMIN_READ_CAPABILITY, __FILE__, 'wpcf7_admin_management_page' ); + + add_submenu_page( __FILE__, __( 'Edit Contact Forms', 'wpcf7' ), __( 'Edit', 'wpcf7' ), + WPCF8_ADMIN_READ_CAPABILITY, __FILE__, 'wpcf7_admin_management_page' ); +} + +add_action( 'admin_menu', 'wpcf7_admin_add_pages' ); + +function wpcf7_admin_head() { + global $plugin_page; + + if ( isset( $plugin_page ) && $plugin_page == plugin_basename( __FILE__ ) ) { + + $admin_stylesheet_url = wpcf7_plugin_url( 'admin/admin-stylesheet.css' ); + echo ''; + + if ( 'rtl' == get_bloginfo( 'text_direction' ) ) { + $admin_stylesheet_rtl_url = wpcf7_plugin_url( 'admin/admin-stylesheet-rtl.css' ); + echo ''; + } + +?> + + __( 'optional', 'wpcf7' ), + 'generateTag' => __( 'Generate Tag', 'wpcf7' ), + 'textField' => __( 'Text field', 'wpcf7' ), + 'emailField' => __( 'Email field', 'wpcf7' ), + 'textArea' => __( 'Text area', 'wpcf7' ), + 'menu' => __( 'Drop-down menu', 'wpcf7' ), + 'checkboxes' => __( 'Checkboxes', 'wpcf7' ), + 'radioButtons' => __( 'Radio buttons', 'wpcf7' ), + 'acceptance' => __( 'Acceptance', 'wpcf7' ), + 'isAcceptanceDefaultOn' => __( "Make this checkbox checked by default?", 'wpcf7' ), + 'isAcceptanceInvert' => __( "Make this checkbox work inversely?", 'wpcf7' ), + 'isAcceptanceInvertMeans' => __( "* That means visitor who accepts the term unchecks it.", 'wpcf7' ), + 'captcha' => __( 'CAPTCHA', 'wpcf7' ), + 'quiz' => __( 'Quiz', 'wpcf7' ), + 'quizzes' => __( 'Quizzes', 'wpcf7' ), + 'quizFormatDesc' => __( "* quiz|answer (e.g. 1+1=?|2)", 'wpcf7' ), + 'fileUpload' => __( 'File upload', 'wpcf7' ), + 'bytes' => __( 'bytes', 'wpcf7' ), + 'submit' => __( 'Submit button', 'wpcf7' ), + 'tagName' => __( 'Name', 'wpcf7' ), + 'isRequiredField' => __( 'Required field?', 'wpcf7' ), + 'allowsMultipleSelections' => __( 'Allow multiple selections?', 'wpcf7' ), + 'insertFirstBlankOption' => __( 'Insert a blank item as the first option?', 'wpcf7' ), + 'makeCheckboxesExclusive' => __( 'Make checkboxes exclusive?', 'wpcf7' ), + 'menuChoices' => __( 'Choices', 'wpcf7' ), + 'label' => __( 'Label', 'wpcf7' ), + 'defaultValue' => __( 'Default value', 'wpcf7' ), + 'akismet' => __( 'Akismet', 'wpcf7' ), + 'akismetAuthor' => __( "This field requires author's name", 'wpcf7' ), + 'akismetAuthorUrl' => __( "This field requires author's URL", 'wpcf7' ), + 'akismetAuthorEmail' => __( "This field requires author's email address", 'wpcf7' ), + 'generatedTag' => __( "Copy this code and paste it into the form left.", 'wpcf7' ), + 'fgColor' => __( "Foreground color", 'wpcf7' ), + 'bgColor' => __( "Background color", 'wpcf7' ), + 'imageSize' => __( "Image size", 'wpcf7' ), + 'imageSizeSmall' => __( "Small", 'wpcf7' ), + 'imageSizeMedium' => __( "Medium", 'wpcf7' ), + 'imageSizeLarge' => __( "Large", 'wpcf7' ), + 'imageSettings' => __( "Image settings", 'wpcf7' ), + 'inputFieldSettings' => __( "Input field settings", 'wpcf7' ), + 'tagForImage' => __( "For image", 'wpcf7' ), + 'tagForInputField' => __( "For input field", 'wpcf7' ), + 'oneChoicePerLine' => __( "* One choice per line.", 'wpcf7' ), + 'show' => __( "Show", 'wpcf7' ), + 'hide' => __( "Hide", 'wpcf7' ), + 'fileSizeLimit' => __( "File size limit", 'wpcf7' ), + 'acceptableFileTypes' => __( "Acceptable file types", 'wpcf7' ), + 'needReallySimpleCaptcha' => __( "Note: To use CAPTCHA, you need Really Simple CAPTCHA plugin installed.", 'wpcf7' ) + ) ); +} + +add_action( 'wp_print_scripts', 'wpcf7_admin_load_js' ); + +function wpcf7_admin_management_page() { + global $wp_version; + + switch ( $_GET['message'] ) { + case 'created': + $updated_message = __( "Contact form created.", 'wpcf7' ); + break; + case 'saved': + $updated_message = __( "Contact form saved.", 'wpcf7' ); + break; + case 'deleted': + $updated_message = __( "Contact form deleted.", 'wpcf7' ); + break; + case 'table_created': + $updated_message = __( "Database table created.", 'wpcf7' ); + break; + case 'table_not_created': + $updated_message = __( "Failed to create database table.", 'wpcf7' ); + break; + } + + $contact_forms = wpcf7_contact_forms(); + + $id = $_POST['wpcf7-id']; + + if ( 'new' == $_GET['contactform'] ) { + $unsaved = true; + $current = -1; + $cf = wpcf7_contact_form_default_pack(); + } elseif ( $cf = wpcf7_contact_form( $_GET['contactform'] ) ) { + $current = (int) $_GET['contactform']; + } else { + $first = reset( $contact_forms ); // Returns first item + $current = $first->id; + $cf = wpcf7_contact_form( $current ); + } + + require_once WPCF8_PLUGIN_DIR . '/admin/admin-panel.php'; +} + +/* Install and default settings */ + +function wpcf7_install() { + global $wpdb; + + if ( wpcf7_table_exists() ) + return; // Exists already + + $table_name = wpcf7_table_name(); + + $charset_collate = ''; + if ( $wpdb->has_cap( 'collation' ) ) { + if ( ! empty( $wpdb->charset ) ) + $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; + if ( ! empty( $wpdb->collate ) ) + $charset_collate .= " COLLATE $wpdb->collate"; + } + + $wpdb->query( "CREATE TABLE IF NOT EXISTS $table_name ( + cf7_unit_id bigint(20) unsigned NOT NULL auto_increment, + title varchar(200) NOT NULL default '', + form text NOT NULL, + mail text NOT NULL, + mail_2 text NOT NULL, + messages text NOT NULL, + additional_settings text NOT NULL, + PRIMARY KEY (cf7_unit_id)) $charset_collate;" ); + + if ( ! wpcf7_table_exists() ) + return false; // Failed to create + + $legacy_data = get_option( 'wpcf7' ); + if ( is_array( $legacy_data ) ) { + foreach ( $legacy_data['contact_forms'] as $key => $value ) { + $wpdb->insert( $table_name, array( + 'cf7_unit_id' => $key, + 'title' => $value['title'], + 'form' => maybe_serialize( $value['form'] ), + 'mail' => maybe_serialize( $value['mail'] ), + 'mail_2' => maybe_serialize( $value['mail_2'] ), + 'messages' => maybe_serialize( $value['messages'] ), + 'additional_settings' => maybe_serialize( $value['additional_settings'] ) + ), array( '%d', '%s', '%s', '%s', '%s', '%s', '%s' ) ); + } + + // delete_option( 'wpcf7' ); // Comment out for downgrading case for a while + } else { + wpcf7_load_plugin_textdomain(); + + $wpdb->insert( $table_name, array( + 'title' => __( 'Contact form', 'wpcf7' ) . ' 1', + 'form' => maybe_serialize( wpcf7_default_form_template() ), + 'mail' => maybe_serialize( wpcf7_default_mail_template() ), + 'mail_2' => maybe_serialize ( wpcf7_default_mail_2_template() ), + 'messages' => maybe_serialize( wpcf7_default_messages_template() ) ) ); + } +} + +add_action( 'activate_' . WPCF8_PLUGIN_BASENAME, 'wpcf7_install' ); + +/* Misc */ + +function wpcf7_admin_url( $file, $query = array() ) { + $file = trim( $file, ' /' ); + if ( 'admin/' != substr( $file, 0, 6 ) ) + $file = 'admin/' . $file; + + $path = 'admin.php'; + $path .= '?page=' . WPCF8_PLUGIN_NAME . '/' . $file; + + if ( $query = build_query( $query ) ) + $path .= '&' . $query; + + $url = admin_url( $path ); + + return $url; +} + +function wpcf7_plugin_action_links( $links, $file ) { + if ( $file != WPCF8_PLUGIN_BASENAME ) + return $links; + + $url = wpcf7_admin_url( 'admin.php' ); + + $settings_link = '' . esc_html( __( 'Settings', 'wpcf7' ) ) . ''; + + array_unshift( $links, $settings_link ); + + return $links; +} + +add_filter( 'plugin_action_links', 'wpcf7_plugin_action_links', 10, 2 ); + +function wpcf7_donation_link() { + if ( ! WPCF8_SHOW_DONATION_LINK ) + return; + + if ( 'new' == $_GET['contactform'] || ! empty($_GET['message']) ) + return; + + $num = mt_rand(0, 99); + if ($num >= 10) // 90% + return; + + $texts = array( + __( "Contact Form 7 needs your support. Please donate today.", 'wpcf7' ), + __( "Is this plugin useful for you? If you like it, please help the developer.", 'wpcf7' ), + __( "Your contribution is needed for making this plugin better.", 'wpcf7' ), + __( "Developing a plugin and providing user support is really hard work. Please help.", 'wpcf7' ) ); + + $text = $texts[array_rand( $texts )]; + +?> +
+

+Click here to lend your support to: Support Contact Form 7 and make a donation at www.pledgie.com ! + +

+
+ \ No newline at end of file diff --git a/includes/classes.php b/includes/classes.php index a051007..93e00cb 100644 --- a/includes/classes.php +++ b/includes/classes.php @@ -1,545 +1,545 @@ -unit_tag == $_POST['_wpcf7_unit_tag'] ) - return true; - - return false; - } - - /* Generating Form HTML */ - - function form_html() { - $form = '
'; - - $url = parse_url( $_SERVER['REQUEST_URI'] ); - $url = $url['path'] . ( empty( $url['query'] ) ? '' : '?' . $url['query'] ) . '#' . $this->unit_tag; - - $enctype = apply_filters( 'wpcf7_form_enctype', '' ); - - $form .= '
'; - $form .= '
'; - $form .= ''; - $form .= ''; - $form .= ''; - $form .= '
'; - $form .= $this->form_elements(); - - if ( ! $this->responses_count ) - $form .= $this->form_response_output(); - - $form .= '
'; - - $form .= '
'; - - return $form; - } - - function form_response_output() { - $class = 'wpcf7-response-output'; - - if ( $this->is_posted() ) { // Post response output for non-AJAX - if ( isset( $_POST['_wpcf7_mail_sent'] ) && $_POST['_wpcf7_mail_sent']['id'] == $this->id ) { - if ( $_POST['_wpcf7_mail_sent']['ok'] ) { - $class .= ' wpcf7-mail-sent-ok'; - $content = $_POST['_wpcf7_mail_sent']['message']; - } else { - $class .= ' wpcf7-mail-sent-ng'; - if ( $_POST['_wpcf7_mail_sent']['spam'] ) - $class .= ' wpcf7-spam-blocked'; - $content = $_POST['_wpcf7_mail_sent']['message']; - } - } elseif ( isset( $_POST['_wpcf7_validation_errors'] ) && $_POST['_wpcf7_validation_errors']['id'] == $this->id ) { - $class .= ' wpcf7-validation-errors'; - $content = $this->message( 'validation_error' ); - } - } else { - $class .= ' wpcf7-display-none'; - } - - $class = ' class="' . $class . '"'; - - return '' . $content . ''; - } - - function validation_error( $name ) { - if ( $this->is_posted() && $ve = $_POST['_wpcf7_validation_errors']['messages'][$name] ) - return '' . esc_html( $ve ) . ''; - - return ''; - } - - /* Form Elements */ - - function form_do_shortcode() { - global $wpcf7_shortcode_manager; - - $form = $this->form; - - $form = $wpcf7_shortcode_manager->do_shortcode( $form ); - $this->scanned_form_tags = $wpcf7_shortcode_manager->scanned_tags; - - if ( WPCF7_AUTOP ) - $form = wpcf7_autop( $form ); - - return $form; - } - - function form_scan_shortcode( $cond = null ) { - global $wpcf7_shortcode_manager; - - if ( ! empty( $this->scanned_form_tags ) ) { - $scanned = $this->scanned_form_tags; - } else { - $scanned = $wpcf7_shortcode_manager->scan_shortcode( $this->form ); - $this->scanned_form_tags = $scanned; - } - - if ( empty( $scanned ) ) - return null; - - if ( ! is_array( $cond ) || empty( $cond ) ) - return $scanned; - - for ( $i = 0, $size = count( $scanned ); $i < $size; $i++ ) { - - if ( is_string( $cond['type'] ) && ! empty( $cond['type'] ) ) { - if ( $scanned[$i]['type'] != $cond['type'] ) { - unset( $scanned[$i] ); - continue; - } - } elseif ( is_array( $cond['type'] ) ) { - if ( ! in_array( $scanned[$i]['type'], $cond['type'] ) ) { - unset( $scanned[$i] ); - continue; - } - } - - if ( is_string( $cond['name'] ) && ! empty( $cond['name'] ) ) { - if ( $scanned[$i]['name'] != $cond['name'] ) { - unset ( $scanned[$i] ); - continue; - } - } elseif ( is_array( $cond['name'] ) ) { - if ( ! in_array( $scanned[$i]['name'], $cond['name'] ) ) { - unset( $scanned[$i] ); - continue; - } - } - } - - return array_values( $scanned ); - } - - function form_elements() { - $form = $this->form_do_shortcode(); - - // Response output - $response_regex = '%\[\s*response\s*\]%'; - $form = preg_replace_callback( $response_regex, - array( &$this, 'response_replace_callback' ), $form ); - - return $form; - } - - function response_replace_callback( $matches ) { - $this->responses_count += 1; - return $this->form_response_output(); - } - - /* Validate */ - - function validate() { - $fes = $this->form_scan_shortcode(); - - $result = array( 'valid' => true, 'reason' => array() ); - - foreach ( $fes as $fe ) { - $type = $fe['type']; - $name = $fe['name']; - - if ( empty( $name ) ) - continue; - - $result = apply_filters( 'wpcf7_validate_' . $type, $result, $fe ); - } - - return $result; - } - - /* Acceptance */ - - function accepted() { - $accepted = true; - - return apply_filters( 'wpcf7_acceptance', $accepted ); - } - - /* Akismet */ - - function akismet() { - global $akismet_api_host, $akismet_api_port; - - if ( ! function_exists( 'akismet_http_post' ) || - ! ( get_option( 'wordpress_api_key' ) || $wpcom_api_key ) ) - return false; - - $akismet_ready = false; - $author = $author_email = $author_url = $content = ''; - $fes = $this->form_scan_shortcode(); - - foreach ( $fes as $fe ) { - if ( ! is_array( $fe['options'] ) ) continue; - - if ( preg_grep( '%^akismet:author$%', $fe['options'] ) && '' == $author ) { - $author = $_POST[$fe['name']]; - $akismet_ready = true; - } - - if ( preg_grep( '%^akismet:author_email$%', $fe['options'] ) && '' == $author_email ) { - $author_email = $_POST[$fe['name']]; - $akismet_ready = true; - } - - if ( preg_grep( '%^akismet:author_url$%', $fe['options'] ) && '' == $author_url ) { - $author_url = $_POST[$fe['name']]; - $akismet_ready = true; - } - - if ( '' != $content ) - $content .= "\n\n"; - - $content .= $_POST[$fe['name']]; - } - - if ( ! $akismet_ready ) - return false; - - $c['blog'] = get_option( 'home' ); - $c['user_ip'] = preg_replace( '/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR'] ); - $c['user_agent'] = $_SERVER['HTTP_USER_AGENT']; - $c['referrer'] = $_SERVER['HTTP_REFERER']; - $c['comment_type'] = 'contactform7'; - if ( $permalink = get_permalink() ) - $c['permalink'] = $permalink; - if ( '' != $author ) - $c['comment_author'] = $author; - if ( '' != $author_email ) - $c['comment_author_email'] = $author_email; - if ( '' != $author_url ) - $c['comment_author_url'] = $author_url; - if ( '' != $content ) - $c['comment_content'] = $content; - - $ignore = array( 'HTTP_COOKIE' ); - - foreach ( $_SERVER as $key => $value ) - if ( ! in_array( $key, (array) $ignore ) ) - $c["$key"] = $value; - - $query_string = ''; - foreach ( $c as $key => $data ) - $query_string .= $key . '=' . urlencode( stripslashes( $data ) ) . '&'; - - $response = akismet_http_post( $query_string, $akismet_api_host, - '/1.1/comment-check', $akismet_api_port ); - if ( 'true' == $response[1] ) - return true; - else - return false; - } - - /* Mail */ - - function mail() { - $fes = $this->form_scan_shortcode(); - - foreach ( $fes as $fe ) { - $name = $fe['name']; - $pipes = $fe['pipes']; - - if ( empty( $name ) ) - continue; - - $value = $_POST[$name]; - - if ( WPCF7_USE_PIPE && is_a( $pipes, 'WPCF7_Pipes' ) && ! $pipes->zero() ) { - if ( is_array( $value) ) { - $new_value = array(); - foreach ( $value as $v ) { - $new_value[] = $pipes->do_pipe( $v ); - } - $value = $new_value; - } else { - $value = $pipes->do_pipe( $value ); - } - } - - $this->posted_data[$name] = $value; - } - - if ( $this->compose_and_send_mail( $this->mail ) ) { - if ( $this->mail_2['active'] ) - $this->compose_and_send_mail( $this->mail_2 ); - - return true; - } - - return false; - } - - function compose_and_send_mail( $mail_template ) { - $regex = '/\[\s*([a-zA-Z][0-9a-zA-Z:._-]*)\s*\]/'; - $callback = array( &$this, 'mail_callback' ); - - $mail_subject = preg_replace_callback( $regex, $callback, $mail_template['subject'] ); - $mail_sender = preg_replace_callback( $regex, $callback, $mail_template['sender'] ); - $mail_body = preg_replace_callback( $regex, $callback, $mail_template['body'] ); - $mail_recipient = preg_replace_callback( $regex, $callback, $mail_template['recipient'] ); - - $mail_headers = "From: $mail_sender\n"; - - if ( $mail_template['use_html'] ) - $mail_headers .= "Content-Type: text/html\n"; - - $mail_additional_headers = preg_replace_callback( $regex, $callback, - $mail_template['additional_headers'] ); - $mail_headers .= trim( $mail_additional_headers ) . "\n"; - - if ( $this->uploaded_files ) { - $for_this_mail = array(); - foreach ( $this->uploaded_files as $name => $path ) { - if ( false === strpos( $mail_template['attachments'], "[${name}]" ) ) - continue; - $for_this_mail[] = $path; - } - - return @wp_mail( $mail_recipient, $mail_subject, $mail_body, $mail_headers, - $for_this_mail ); - } else { - return @wp_mail( $mail_recipient, $mail_subject, $mail_body, $mail_headers ); - } - } - - function mail_callback( $matches ) { - if ( isset( $this->posted_data[$matches[1]] ) ) { - $submitted = $this->posted_data[$matches[1]]; - - if ( is_array( $submitted ) ) - $submitted = join( ', ', $submitted ); - - return stripslashes( $submitted ); - - } else { - // Special [wpcf7.remote_ip] tag - if ( 'wpcf7.remote_ip' == $matches[1] ) - return preg_replace( '/[^0-9a-f.:, ]/', '', $_SERVER['REMOTE_ADDR'] ); - - return $matches[0]; - } - } - - /* Message */ - - function message( $status ) { - $messages = $this->messages; - $message = ''; - - if ( ! is_array( $messages ) || ! isset( $messages[$status] ) ) - $message = wpcf7_default_message( $status ); - else - $message = $messages[$status]; - - return apply_filters( 'wpcf7_display_message', $message ); - } - - /* Additional settings */ - - function additional_setting( $name, $max = 1 ) { - $tmp_settings = (array) explode( "\n", $this->additional_settings ); - - $count = 0; - $values = array(); - - foreach ( $tmp_settings as $setting ) { - if ( preg_match('/^([a-zA-Z0-9_]+)\s*:(.*)$/', $setting, $matches ) ) { - if ( $matches[1] != $name ) - continue; - - if ( ! $max || $count < (int) $max ) { - $values[] = trim( $matches[2] ); - $count += 1; - } - } - } - - return $values; - } - - /* Upgrade */ - - function upgrade() { - if ( ! isset( $this->mail['recipient'] ) ) - $this->mail['recipient'] = get_option( 'admin_email' ); - - - if ( ! is_array( $this->messages ) ) - $this->messages = array(); - - $messages = array( - 'mail_sent_ok', 'mail_sent_ng', 'akismet_says_spam', 'validation_error', 'accept_terms', - 'invalid_email', 'invalid_required', 'captcha_not_match', 'upload_failed', 'upload_file_type_invalid', - 'upload_file_too_large', 'quiz_answer_not_correct' ); - - foreach ($messages as $message) { - if ( ! isset( $this->messages[$message] ) ) - $this->messages[$message] = wpcf7_default_message( $message ); - } - } - - /* Save */ - - function save() { - global $wpdb; - - $table_name = wpcf7_table_name(); - - if ( $this->initial ) { - $result = $wpdb->insert( $table_name, array( - 'title' => $this->title, - 'form' => maybe_serialize( $this->form ), - 'mail' => maybe_serialize( $this->mail ), - 'mail_2' => maybe_serialize ( $this->mail_2 ), - 'messages' => maybe_serialize( $this->messages ), - 'additional_settings' => maybe_serialize( $this->additional_settings ) ) ); - - if ( $result ) { - $this->initial = false; - $this->id = $wpdb->insert_id; - - do_action_ref_array( 'wpcf7_after_create', array( &$this ) ); - } else { - return false; // Failed to save - } - - } else { // Update - if ( ! (int) $this->id ) - return false; // Missing ID - - $result = $wpdb->update( $table_name, array( - 'title' => $this->title, - 'form' => maybe_serialize( $this->form ), - 'mail' => maybe_serialize( $this->mail ), - 'mail_2' => maybe_serialize ( $this->mail_2 ), - 'messages' => maybe_serialize( $this->messages ), - 'additional_settings' => maybe_serialize( $this->additional_settings ) - ), array( 'cf7_unit_id' => absint( $this->id) ) ); - - if ( false !== $result ) { - do_action_ref_array( 'wpcf7_after_update', array( &$this ) ); - } else { - return false; // Failed to save - } - } - - do_action_ref_array( 'wpcf7_after_save', array( &$this ) ); - return true; // Succeeded to save - } - - function copy() { - $new = new WPCF7_ContactForm(); - $new->initial = true; - - $new->title = $this->title . '_copy'; - $new->form = $this->form; - $new->mail = $this->mail; - $new->mail_2 = $this->mail_2; - $new->messages = $this->messages; - $new->additional_settings = $this->additional_settings; - - return $new; - } - - function delete() { - global $wpdb; - - if ( $this->initial ) - return; - - $table_name = wpcf7_table_name(); - - $query = $wpdb->prepare( - "DELETE FROM $table_name WHERE cf7_unit_id = %d LIMIT 1", - absint( $this->id ) ); - - $wpdb->query( $query ); - - $this->initial = true; - $this->id = null; - } -} - -function wpcf7_contact_form( $id ) { - global $wpdb; - - $table_name = wpcf7_table_name(); - - $id = (int) $id; - - $query = $wpdb->prepare( "SELECT * FROM $table_name WHERE cf7_unit_id = %d", $id ); - - if ( ! $row = $wpdb->get_row( $query ) ) - return false; // No data - - $contact_form = new WPCF7_ContactForm(); - $contact_form->id = $row->cf7_unit_id; - $contact_form->title = stripslashes_deep( $row->title ); - $contact_form->form = stripslashes_deep( maybe_unserialize( $row->form ) ); - $contact_form->mail = stripslashes_deep( maybe_unserialize( $row->mail ) ); - $contact_form->mail_2 = stripslashes_deep( maybe_unserialize( $row->mail_2 ) ); - $contact_form->messages = stripslashes_deep( maybe_unserialize( $row->messages ) ); - $contact_form->additional_settings = stripslashes_deep( maybe_unserialize( $row->additional_settings ) ); - - $contact_form->upgrade(); - - return $contact_form; -} - -function wpcf7_contact_form_default_pack() { - $contact_form = new WPCF7_ContactForm(); - $contact_form->initial = true; - - $contact_form->title = __( 'Untitled', 'wpcf7' ); - $contact_form->form = wpcf7_default_form_template(); - $contact_form->mail = wpcf7_default_mail_template(); - $contact_form->mail_2 = wpcf7_default_mail_2_template(); - $contact_form->messages = wpcf7_default_messages_template(); - - return $contact_form; -} - +unit_tag == $_POST['_wpcf7_unit_tag'] ) + return true; + + return false; + } + + /* Generating Form HTML */ + + function form_html() { + $form = '
'; + + $url = parse_url( $_SERVER['REQUEST_URI'] ); + $url = $url['path'] . ( empty( $url['query'] ) ? '' : '?' . $url['query'] ) . '#' . $this->unit_tag; + + $enctype = apply_filters( 'wpcf7_form_enctype', '' ); + + $form .= '
'; + $form .= '
'; + $form .= ''; + $form .= ''; + $form .= ''; + $form .= '
'; + $form .= $this->form_elements(); + + if ( ! $this->responses_count ) + $form .= $this->form_response_output(); + + $form .= '
'; + + $form .= '
'; + + return $form; + } + + function form_response_output() { + $class = 'wpcf7-response-output'; + + if ( $this->is_posted() ) { // Post response output for non-AJAX + if ( isset( $_POST['_wpcf7_mail_sent'] ) && $_POST['_wpcf7_mail_sent']['id'] == $this->id ) { + if ( $_POST['_wpcf7_mail_sent']['ok'] ) { + $class .= ' wpcf7-mail-sent-ok'; + $content = $_POST['_wpcf7_mail_sent']['message']; + } else { + $class .= ' wpcf7-mail-sent-ng'; + if ( $_POST['_wpcf7_mail_sent']['spam'] ) + $class .= ' wpcf7-spam-blocked'; + $content = $_POST['_wpcf7_mail_sent']['message']; + } + } elseif ( isset( $_POST['_wpcf7_validation_errors'] ) && $_POST['_wpcf7_validation_errors']['id'] == $this->id ) { + $class .= ' wpcf7-validation-errors'; + $content = $this->message( 'validation_error' ); + } + } else { + $class .= ' wpcf7-display-none'; + } + + $class = ' class="' . $class . '"'; + + return '' . $content . ''; + } + + function validation_error( $name ) { + if ( $this->is_posted() && $ve = $_POST['_wpcf7_validation_errors']['messages'][$name] ) + return '' . esc_html( $ve ) . ''; + + return ''; + } + + /* Form Elements */ + + function form_do_shortcode() { + global $wpcf7_shortcode_manager; + + $form = $this->form; + + $form = $wpcf7_shortcode_manager->do_shortcode( $form ); + $this->scanned_form_tags = $wpcf7_shortcode_manager->scanned_tags; + + if ( WPCF8_AUTOP ) + $form = wpcf7_autop( $form ); + + return $form; + } + + function form_scan_shortcode( $cond = null ) { + global $wpcf7_shortcode_manager; + + if ( ! empty( $this->scanned_form_tags ) ) { + $scanned = $this->scanned_form_tags; + } else { + $scanned = $wpcf7_shortcode_manager->scan_shortcode( $this->form ); + $this->scanned_form_tags = $scanned; + } + + if ( empty( $scanned ) ) + return null; + + if ( ! is_array( $cond ) || empty( $cond ) ) + return $scanned; + + for ( $i = 0, $size = count( $scanned ); $i < $size; $i++ ) { + + if ( is_string( $cond['type'] ) && ! empty( $cond['type'] ) ) { + if ( $scanned[$i]['type'] != $cond['type'] ) { + unset( $scanned[$i] ); + continue; + } + } elseif ( is_array( $cond['type'] ) ) { + if ( ! in_array( $scanned[$i]['type'], $cond['type'] ) ) { + unset( $scanned[$i] ); + continue; + } + } + + if ( is_string( $cond['name'] ) && ! empty( $cond['name'] ) ) { + if ( $scanned[$i]['name'] != $cond['name'] ) { + unset ( $scanned[$i] ); + continue; + } + } elseif ( is_array( $cond['name'] ) ) { + if ( ! in_array( $scanned[$i]['name'], $cond['name'] ) ) { + unset( $scanned[$i] ); + continue; + } + } + } + + return array_values( $scanned ); + } + + function form_elements() { + $form = $this->form_do_shortcode(); + + // Response output + $response_regex = '%\[\s*response\s*\]%'; + $form = preg_replace_callback( $response_regex, + array( &$this, 'response_replace_callback' ), $form ); + + return $form; + } + + function response_replace_callback( $matches ) { + $this->responses_count += 1; + return $this->form_response_output(); + } + + /* Validate */ + + function validate() { + $fes = $this->form_scan_shortcode(); + + $result = array( 'valid' => true, 'reason' => array() ); + + foreach ( $fes as $fe ) { + $type = $fe['type']; + $name = $fe['name']; + + if ( empty( $name ) ) + continue; + + $result = apply_filters( 'wpcf7_validate_' . $type, $result, $fe ); + } + + return $result; + } + + /* Acceptance */ + + function accepted() { + $accepted = true; + + return apply_filters( 'wpcf7_acceptance', $accepted ); + } + + /* Akismet */ + + function akismet() { + global $akismet_api_host, $akismet_api_port; + + if ( ! function_exists( 'akismet_http_post' ) || + ! ( get_option( 'wordpress_api_key' ) || $wpcom_api_key ) ) + return false; + + $akismet_ready = false; + $author = $author_email = $author_url = $content = ''; + $fes = $this->form_scan_shortcode(); + + foreach ( $fes as $fe ) { + if ( ! is_array( $fe['options'] ) ) continue; + + if ( preg_grep( '%^akismet:author$%', $fe['options'] ) && '' == $author ) { + $author = $_POST[$fe['name']]; + $akismet_ready = true; + } + + if ( preg_grep( '%^akismet:author_email$%', $fe['options'] ) && '' == $author_email ) { + $author_email = $_POST[$fe['name']]; + $akismet_ready = true; + } + + if ( preg_grep( '%^akismet:author_url$%', $fe['options'] ) && '' == $author_url ) { + $author_url = $_POST[$fe['name']]; + $akismet_ready = true; + } + + if ( '' != $content ) + $content .= "\n\n"; + + $content .= $_POST[$fe['name']]; + } + + if ( ! $akismet_ready ) + return false; + + $c['blog'] = get_option( 'home' ); + $c['user_ip'] = preg_replace( '/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR'] ); + $c['user_agent'] = $_SERVER['HTTP_USER_AGENT']; + $c['referrer'] = $_SERVER['HTTP_REFERER']; + $c['comment_type'] = 'contactform7'; + if ( $permalink = get_permalink() ) + $c['permalink'] = $permalink; + if ( '' != $author ) + $c['comment_author'] = $author; + if ( '' != $author_email ) + $c['comment_author_email'] = $author_email; + if ( '' != $author_url ) + $c['comment_author_url'] = $author_url; + if ( '' != $content ) + $c['comment_content'] = $content; + + $ignore = array( 'HTTP_COOKIE' ); + + foreach ( $_SERVER as $key => $value ) + if ( ! in_array( $key, (array) $ignore ) ) + $c["$key"] = $value; + + $query_string = ''; + foreach ( $c as $key => $data ) + $query_string .= $key . '=' . urlencode( stripslashes( $data ) ) . '&'; + + $response = akismet_http_post( $query_string, $akismet_api_host, + '/1.1/comment-check', $akismet_api_port ); + if ( 'true' == $response[1] ) + return true; + else + return false; + } + + /* Mail */ + + function mail() { + $fes = $this->form_scan_shortcode(); + + foreach ( $fes as $fe ) { + $name = $fe['name']; + $pipes = $fe['pipes']; + + if ( empty( $name ) ) + continue; + + $value = $_POST[$name]; + + if ( WPCF8_USE_PIPE && is_a( $pipes, 'WPCF8_Pipes' ) && ! $pipes->zero() ) { + if ( is_array( $value) ) { + $new_value = array(); + foreach ( $value as $v ) { + $new_value[] = $pipes->do_pipe( $v ); + } + $value = $new_value; + } else { + $value = $pipes->do_pipe( $value ); + } + } + + $this->posted_data[$name] = $value; + } + + if ( $this->compose_and_send_mail( $this->mail ) ) { + if ( $this->mail_2['active'] ) + $this->compose_and_send_mail( $this->mail_2 ); + + return true; + } + + return false; + } + + function compose_and_send_mail( $mail_template ) { + $regex = '/\[\s*([a-zA-Z][0-9a-zA-Z:._-]*)\s*\]/'; + $callback = array( &$this, 'mail_callback' ); + + $mail_subject = preg_replace_callback( $regex, $callback, $mail_template['subject'] ); + $mail_sender = preg_replace_callback( $regex, $callback, $mail_template['sender'] ); + $mail_body = preg_replace_callback( $regex, $callback, $mail_template['body'] ); + $mail_recipient = preg_replace_callback( $regex, $callback, $mail_template['recipient'] ); + + $mail_headers = "From: $mail_sender\n"; + + if ( $mail_template['use_html'] ) + $mail_headers .= "Content-Type: text/html\n"; + + $mail_additional_headers = preg_replace_callback( $regex, $callback, + $mail_template['additional_headers'] ); + $mail_headers .= trim( $mail_additional_headers ) . "\n"; + + if ( $this->uploaded_files ) { + $for_this_mail = array(); + foreach ( $this->uploaded_files as $name => $path ) { + if ( false === strpos( $mail_template['attachments'], "[${name}]" ) ) + continue; + $for_this_mail[] = $path; + } + + return @wp_mail( $mail_recipient, $mail_subject, $mail_body, $mail_headers, + $for_this_mail ); + } else { + return @wp_mail( $mail_recipient, $mail_subject, $mail_body, $mail_headers ); + } + } + + function mail_callback( $matches ) { + if ( isset( $this->posted_data[$matches[1]] ) ) { + $submitted = $this->posted_data[$matches[1]]; + + if ( is_array( $submitted ) ) + $submitted = join( ', ', $submitted ); + + return stripslashes( $submitted ); + + } else { + // Special [wpcf7.remote_ip] tag + if ( 'wpcf7.remote_ip' == $matches[1] ) + return preg_replace( '/[^0-9a-f.:, ]/', '', $_SERVER['REMOTE_ADDR'] ); + + return $matches[0]; + } + } + + /* Message */ + + function message( $status ) { + $messages = $this->messages; + $message = ''; + + if ( ! is_array( $messages ) || ! isset( $messages[$status] ) ) + $message = wpcf7_default_message( $status ); + else + $message = $messages[$status]; + + return apply_filters( 'wpcf7_display_message', $message ); + } + + /* Additional settings */ + + function additional_setting( $name, $max = 1 ) { + $tmp_settings = (array) explode( "\n", $this->additional_settings ); + + $count = 0; + $values = array(); + + foreach ( $tmp_settings as $setting ) { + if ( preg_match('/^([a-zA-Z0-9_]+)\s*:(.*)$/', $setting, $matches ) ) { + if ( $matches[1] != $name ) + continue; + + if ( ! $max || $count < (int) $max ) { + $values[] = trim( $matches[2] ); + $count += 1; + } + } + } + + return $values; + } + + /* Upgrade */ + + function upgrade() { + if ( ! isset( $this->mail['recipient'] ) ) + $this->mail['recipient'] = get_option( 'admin_email' ); + + + if ( ! is_array( $this->messages ) ) + $this->messages = array(); + + $messages = array( + 'mail_sent_ok', 'mail_sent_ng', 'akismet_says_spam', 'validation_error', 'accept_terms', + 'invalid_email', 'invalid_required', 'captcha_not_match', 'upload_failed', 'upload_file_type_invalid', + 'upload_file_too_large', 'quiz_answer_not_correct' ); + + foreach ($messages as $message) { + if ( ! isset( $this->messages[$message] ) ) + $this->messages[$message] = wpcf7_default_message( $message ); + } + } + + /* Save */ + + function save() { + global $wpdb; + + $table_name = wpcf7_table_name(); + + if ( $this->initial ) { + $result = $wpdb->insert( $table_name, array( + 'title' => $this->title, + 'form' => maybe_serialize( $this->form ), + 'mail' => maybe_serialize( $this->mail ), + 'mail_2' => maybe_serialize ( $this->mail_2 ), + 'messages' => maybe_serialize( $this->messages ), + 'additional_settings' => maybe_serialize( $this->additional_settings ) ) ); + + if ( $result ) { + $this->initial = false; + $this->id = $wpdb->insert_id; + + do_action_ref_array( 'wpcf7_after_create', array( &$this ) ); + } else { + return false; // Failed to save + } + + } else { // Update + if ( ! (int) $this->id ) + return false; // Missing ID + + $result = $wpdb->update( $table_name, array( + 'title' => $this->title, + 'form' => maybe_serialize( $this->form ), + 'mail' => maybe_serialize( $this->mail ), + 'mail_2' => maybe_serialize ( $this->mail_2 ), + 'messages' => maybe_serialize( $this->messages ), + 'additional_settings' => maybe_serialize( $this->additional_settings ) + ), array( 'cf7_unit_id' => absint( $this->id) ) ); + + if ( false !== $result ) { + do_action_ref_array( 'wpcf7_after_update', array( &$this ) ); + } else { + return false; // Failed to save + } + } + + do_action_ref_array( 'wpcf7_after_save', array( &$this ) ); + return true; // Succeeded to save + } + + function copy() { + $new = new WPCF8_ContactForm(); + $new->initial = true; + + $new->title = $this->title . '_copy'; + $new->form = $this->form; + $new->mail = $this->mail; + $new->mail_2 = $this->mail_2; + $new->messages = $this->messages; + $new->additional_settings = $this->additional_settings; + + return $new; + } + + function delete() { + global $wpdb; + + if ( $this->initial ) + return; + + $table_name = wpcf7_table_name(); + + $query = $wpdb->prepare( + "DELETE FROM $table_name WHERE cf7_unit_id = %d LIMIT 1", + absint( $this->id ) ); + + $wpdb->query( $query ); + + $this->initial = true; + $this->id = null; + } +} + +function wpcf7_contact_form( $id ) { + global $wpdb; + + $table_name = wpcf7_table_name(); + + $id = (int) $id; + + $query = $wpdb->prepare( "SELECT * FROM $table_name WHERE cf7_unit_id = %d", $id ); + + if ( ! $row = $wpdb->get_row( $query ) ) + return false; // No data + + $contact_form = new WPCF8_ContactForm(); + $contact_form->id = $row->cf7_unit_id; + $contact_form->title = stripslashes_deep( $row->title ); + $contact_form->form = stripslashes_deep( maybe_unserialize( $row->form ) ); + $contact_form->mail = stripslashes_deep( maybe_unserialize( $row->mail ) ); + $contact_form->mail_2 = stripslashes_deep( maybe_unserialize( $row->mail_2 ) ); + $contact_form->messages = stripslashes_deep( maybe_unserialize( $row->messages ) ); + $contact_form->additional_settings = stripslashes_deep( maybe_unserialize( $row->additional_settings ) ); + + $contact_form->upgrade(); + + return $contact_form; +} + +function wpcf7_contact_form_default_pack() { + $contact_form = new WPCF8_ContactForm(); + $contact_form->initial = true; + + $contact_form->title = __( 'Untitled', 'wpcf7' ); + $contact_form->form = wpcf7_default_form_template(); + $contact_form->mail = wpcf7_default_mail_template(); + $contact_form->mail_2 = wpcf7_default_mail_2_template(); + $contact_form->messages = wpcf7_default_messages_template(); + + return $contact_form; +} + ?> \ No newline at end of file diff --git a/includes/formatting.php b/includes/formatting.php index 5dcca54..aac6dd2 100644 --- a/includes/formatting.php +++ b/includes/formatting.php @@ -1,81 +1,81 @@ -\s*
|', "\n\n", $pee ); - // Space things out a little - /* wpcf7: removed select and input */ - $allblocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|form|map|area|blockquote|address|math|style|p|h[1-6]|hr)'; - $pee = preg_replace( '!(<' . $allblocks . '[^>]*>)!', "\n$1", $pee ); - $pee = preg_replace( '!()!', "$1\n\n", $pee ); - $pee = str_replace( array( "\r\n", "\r" ), "\n", $pee ); // cross-platform newlines - if ( strpos( $pee, ']*)>\s*|', "", $pee ); // no pee inside object/embed - $pee = preg_replace( '|\s*\s*|', '', $pee ); - } - $pee = preg_replace( "/\n\n+/", "\n\n", $pee ); // take care of duplicates - // make paragraphs, including one at the end - $pees = preg_split( '/\n\s*\n/', $pee, -1, PREG_SPLIT_NO_EMPTY ); - $pee = ''; - foreach ( $pees as $tinkle ) - $pee .= '

' . trim( $tinkle, "\n" ) . "

\n"; - $pee = preg_replace( '|

\s*

|', '', $pee ); // under certain strange conditions it could create a P of entirely whitespace - $pee = preg_replace( '!

([^<]+)!', "

$1

", $pee ); - $pee = preg_replace( '!

\s*(]*>)\s*

!', "$1", $pee ); // don't pee all over a tag - $pee = preg_replace( "|

(|", "$1", $pee ); // problem with nested lists - $pee = preg_replace( '|

]*)>|i', "

", $pee ); - $pee = str_replace( '

', '

', $pee ); - $pee = preg_replace( '!

\s*(]*>)!', "$1", $pee ); - $pee = preg_replace( '!(]*>)\s*

!', "$1", $pee ); - if ( $br ) { - /* wpcf7: add textarea */ - $pee = preg_replace_callback( '/<(script|style|textarea).*?<\/\\1>/s', create_function( '$matches', 'return str_replace("\n", "", $matches[0]);' ), $pee ); - $pee = preg_replace( '|(?)\s*\n|', "
\n", $pee ); // optionally make line breaks - $pee = str_replace( '', "\n", $pee ); - } - $pee = preg_replace( '!(]*>)\s*
!', "$1", $pee ); - $pee = preg_replace( '!
(\s*]*>)!', '$1', $pee ); - if ( strpos( $pee, ']*>)(.*?)!is', 'clean_pre', $pee ); - $pee = preg_replace( "|\n

$|", '

', $pee ); - /* wpcf7: replaced to wpcf7_get_shortcode_regex ( -> comment out) */ - // don't auto-p wrap shortcodes that stand alone - // $pee = preg_replace( '/

\s*?(' . wpcf7_get_shortcode_regex() . ')\s*<\/p>/s', '$1', $pee ); - - return $pee; -} - -function wpcf7_strip_quote( $text ) { - $text = trim( $text ); - if ( preg_match( '/^"(.*)"$/', $text, $matches ) ) - $text = $matches[1]; - elseif ( preg_match( "/^'(.*)'$/", $text, $matches ) ) - $text = $matches[1]; - return $text; -} - -function wpcf7_strip_quote_deep( $arr ) { - if ( is_string( $arr ) ) - return wpcf7_strip_quote( $arr ); - - if ( is_array( $arr ) ) { - $result = array(); - foreach ( $arr as $key => $text ) { - $result[$key] = wpcf7_strip_quote( $text ); - } - return $result; - } -} - -function wpcf7_canonicalize( $text ) { - if ( function_exists( 'mb_convert_kana' ) && 'UTF-8' == get_option( 'blog_charset' ) ) - $text = mb_convert_kana( $text, 'asKV', 'UTF-8' ); - - $text = strtolower( $text ); - $text = trim( $text ); - return $text; -} - +\s*
|', "\n\n", $pee ); + // Space things out a little + /* wpcf7: removed select and input */ + $allblocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|form|map|area|blockquote|address|math|style|p|h[1-6]|hr)'; + $pee = preg_replace( '!(<' . $allblocks . '[^>]*>)!', "\n$1", $pee ); + $pee = preg_replace( '!()!', "$1\n\n", $pee ); + $pee = str_replace( array( "\r\n", "\r" ), "\n", $pee ); // cross-platform newlines + if ( strpos( $pee, ']*)>\s*|', "", $pee ); // no pee inside object/embed + $pee = preg_replace( '|\s*\s*|', '', $pee ); + } + $pee = preg_replace( "/\n\n+/", "\n\n", $pee ); // take care of duplicates + // make paragraphs, including one at the end + $pees = preg_split( '/\n\s*\n/', $pee, -1, PREG_SPLIT_NO_EMPTY ); + $pee = ''; + foreach ( $pees as $tinkle ) + $pee .= '

' . trim( $tinkle, "\n" ) . "

\n"; + $pee = preg_replace( '|

\s*

|', '', $pee ); // under certain strange conditions it could create a P of entirely whitespace + $pee = preg_replace( '!

([^<]+)!', "

$1

", $pee ); + $pee = preg_replace( '!

\s*(]*>)\s*

!', "$1", $pee ); // don't pee all over a tag + $pee = preg_replace( "|

(|", "$1", $pee ); // problem with nested lists + $pee = preg_replace( '|

]*)>|i', "

", $pee ); + $pee = str_replace( '

', '

', $pee ); + $pee = preg_replace( '!

\s*(]*>)!', "$1", $pee ); + $pee = preg_replace( '!(]*>)\s*

!', "$1", $pee ); + if ( $br ) { + /* wpcf7: add textarea */ + $pee = preg_replace_callback( '/<(script|style|textarea).*?<\/\\1>/s', create_function( '$matches', 'return str_replace("\n", "", $matches[0]);' ), $pee ); + $pee = preg_replace( '|(?)\s*\n|', "
\n", $pee ); // optionally make line breaks + $pee = str_replace( '', "\n", $pee ); + } + $pee = preg_replace( '!(]*>)\s*
!', "$1", $pee ); + $pee = preg_replace( '!
(\s*]*>)!', '$1', $pee ); + if ( strpos( $pee, ']*>)(.*?)!is', 'clean_pre', $pee ); + $pee = preg_replace( "|\n

$|", '

', $pee ); + /* wpcf7: replaced to wpcf7_get_shortcode_regex ( -> comment out) */ + // don't auto-p wrap shortcodes that stand alone + // $pee = preg_replace( '/

\s*?(' . wpcf7_get_shortcode_regex() . ')\s*<\/p>/s', '$1', $pee ); + + return $pee; +} + +function wpcf7_strip_quote( $text ) { + $text = trim( $text ); + if ( preg_match( '/^"(.*)"$/', $text, $matches ) ) + $text = $matches[1]; + elseif ( preg_match( "/^'(.*)'$/", $text, $matches ) ) + $text = $matches[1]; + return $text; +} + +function wpcf7_strip_quote_deep( $arr ) { + if ( is_string( $arr ) ) + return wpcf7_strip_quote( $arr ); + + if ( is_array( $arr ) ) { + $result = array(); + foreach ( $arr as $key => $text ) { + $result[$key] = wpcf7_strip_quote( $text ); + } + return $result; + } +} + +function wpcf7_canonicalize( $text ) { + if ( function_exists( 'mb_convert_kana' ) && 'UTF-8' == get_option( 'blog_charset' ) ) + $text = mb_convert_kana( $text, 'asKV', 'UTF-8' ); + + $text = strtolower( $text ); + $text = trim( $text ); + return $text; +} + ?> \ No newline at end of file diff --git a/includes/functions.php b/includes/functions.php index c102e5d..8384a32 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -1,173 +1,173 @@ -' . __( 'Your Name', 'wpcf7' ) . ' ' . __( '(required)', 'wpcf7' ) . '
' . "\n"; - $template .= ' [text* your-name]

' . "\n\n"; - $template .= '

' . __( 'Your Email', 'wpcf7' ) . ' ' . __( '(required)', 'wpcf7' ) . '
' . "\n"; - $template .= ' [email* your-email]

' . "\n\n"; - $template .= '

' . __( 'Subject', 'wpcf7' ) . '
' . "\n"; - $template .= ' [text your-subject]

' . "\n\n"; - $template .= '

' . __( 'Your Message', 'wpcf7' ) . '
' . "\n"; - $template .= ' [textarea your-message]

' . "\n\n"; - $template .= '

[submit "' . __( 'Send', 'wpcf7' ) . '"]

'; - return $template; -} - -function wpcf7_default_mail_template() { - $subject = '[your-subject]'; - $sender = '[your-name] <[your-email]>'; - $body = '[your-message]'; - $recipient = get_option( 'admin_email' ); - return compact( 'subject', 'sender', 'body', 'recipient' ); -} - -function wpcf7_default_mail_2_template() { - $active = false; - $subject = '[your-subject]'; - $sender = '[your-name] <[your-email]>'; - $body = '[your-message]'; - $recipient = '[your-email]'; - return compact( 'active', 'subject', 'sender', 'body', 'recipient' ); -} - -function wpcf7_default_messages_template() { - $mail_sent_ok = wpcf7_default_message( 'mail_sent_ok' ); - $mail_sent_ng = wpcf7_default_message( 'mail_sent_ng' ); - $akismet_says_spam = wpcf7_default_message( 'akismet_says_spam' ); - $validation_error = wpcf7_default_message( 'validation_error' ); - $accept_terms = wpcf7_default_message( 'accept_terms' ); - $invalid_email = wpcf7_default_message( 'invalid_email' ); - $invalid_required = wpcf7_default_message( 'invalid_required' ); - $quiz_answer_not_correct = wpcf7_default_message( 'quiz_answer_not_correct' ); - $captcha_not_match = wpcf7_default_message( 'captcha_not_match' ); - $upload_failed = wpcf7_default_message( 'upload_failed' ); - $upload_file_type_invalid = wpcf7_default_message( 'upload_file_type_invalid' ); - $upload_file_too_large = wpcf7_default_message( 'upload_file_too_large' ); - - return compact( 'mail_sent_ok', 'mail_sent_ng', 'akismet_says_spam', - 'validation_error', 'accept_terms', 'invalid_email', 'invalid_required', 'quiz_answer_not_correct', - 'captcha_not_match', 'upload_failed', 'upload_file_type_invalid', 'upload_file_too_large' ); -} - -function wpcf7_upload_dir( $type = false ) { - $siteurl = get_option( 'siteurl' ); - $upload_path = trim( get_option( 'upload_path' ) ); - if ( empty( $upload_path ) ) - $dir = WP_CONTENT_DIR . '/uploads'; - else - $dir = $upload_path; - - $dir = path_join( ABSPATH, $dir ); - - if ( ! $url = get_option( 'upload_url_path' ) ) { - if ( empty( $upload_path ) || $upload_path == $dir ) - $url = WP_CONTENT_URL . '/uploads'; - else - $url = trailingslashit( $siteurl ) . $upload_path; - } - - if ( defined( 'UPLOADS' ) ) { - $dir = ABSPATH . UPLOADS; - $url = trailingslashit( $siteurl ) . UPLOADS; - } - - if ( 'dir' == $type ) - return $dir; - if ( 'url' == $type ) - return $url; - return array( 'dir' => $dir, 'url' => $url ); -} - -function wpcf7_captcha_tmp_dir() { - if ( defined( 'WPCF7_CAPTCHA_TMP_DIR' ) ) - return WPCF7_CAPTCHA_TMP_DIR; - else - return wpcf7_upload_dir( 'dir' ) . '/wpcf7_captcha'; -} - -function wpcf7_captcha_tmp_url() { - if ( defined( 'WPCF7_CAPTCHA_TMP_URL' ) ) - return WPCF7_CAPTCHA_TMP_URL; - else - return wpcf7_upload_dir( 'url' ) . '/wpcf7_captcha'; -} - -function wpcf7_upload_tmp_dir() { - if ( defined( 'WPCF7_UPLOADS_TMP_DIR' ) ) - return WPCF7_UPLOADS_TMP_DIR; - else - return wpcf7_upload_dir( 'dir' ) . '/wpcf7_uploads'; -} - -function wpcf7_json( $items ) { - if ( is_array( $items ) ) { - if ( empty( $items ) ) - return 'null'; - - $keys = array_keys( $items ); - $all_int = true; - foreach ( $keys as $key ) { - if ( ! is_int( $key ) ) { - $all_int = false; - break; - } - } - - if ( $all_int ) { - $children = array(); - foreach ( $items as $item ) { - $children[] = wpcf7_json( $item ); - } - return '[' . join( ', ', $children ) . ']'; - } else { // Object - $children = array(); - foreach ( $items as $key => $item ) { - $key = esc_js( (string) $key ); - if ( preg_match( '/[^a-zA-Z]/', $key ) ) - $key = '"' . $key . '"'; - - $children[] = $key . ': ' . wpcf7_json( $item ); - } - return '{ ' . join( ', ', $children ) . ' }'; - } - } elseif ( is_numeric( $items ) ) { - return (string) $items; - } elseif ( is_bool( $items ) ) { - return $items ? '1' : '0'; - } elseif ( is_null( $items ) ) { - return 'null'; - } else { - return '"' . esc_js( (string) $items ) . '"'; - } -} - +' . __( 'Your Name', 'wpcf7' ) . ' ' . __( '(required)', 'wpcf7' ) . '
' . "\n"; + $template .= ' [text* your-name]

' . "\n\n"; + $template .= '

' . __( 'Your Email', 'wpcf7' ) . ' ' . __( '(required)', 'wpcf7' ) . '
' . "\n"; + $template .= ' [email* your-email]

' . "\n\n"; + $template .= '

' . __( 'Subject', 'wpcf7' ) . '
' . "\n"; + $template .= ' [text your-subject]

' . "\n\n"; + $template .= '

' . __( 'Your Message', 'wpcf7' ) . '
' . "\n"; + $template .= ' [textarea your-message]

' . "\n\n"; + $template .= '

[submit "' . __( 'Send', 'wpcf7' ) . '"]

'; + return $template; +} + +function wpcf7_default_mail_template() { + $subject = '[your-subject]'; + $sender = '[your-name] <[your-email]>'; + $body = '[your-message]'; + $recipient = get_option( 'admin_email' ); + return compact( 'subject', 'sender', 'body', 'recipient' ); +} + +function wpcf7_default_mail_2_template() { + $active = false; + $subject = '[your-subject]'; + $sender = '[your-name] <[your-email]>'; + $body = '[your-message]'; + $recipient = '[your-email]'; + return compact( 'active', 'subject', 'sender', 'body', 'recipient' ); +} + +function wpcf7_default_messages_template() { + $mail_sent_ok = wpcf7_default_message( 'mail_sent_ok' ); + $mail_sent_ng = wpcf7_default_message( 'mail_sent_ng' ); + $akismet_says_spam = wpcf7_default_message( 'akismet_says_spam' ); + $validation_error = wpcf7_default_message( 'validation_error' ); + $accept_terms = wpcf7_default_message( 'accept_terms' ); + $invalid_email = wpcf7_default_message( 'invalid_email' ); + $invalid_required = wpcf7_default_message( 'invalid_required' ); + $quiz_answer_not_correct = wpcf7_default_message( 'quiz_answer_not_correct' ); + $captcha_not_match = wpcf7_default_message( 'captcha_not_match' ); + $upload_failed = wpcf7_default_message( 'upload_failed' ); + $upload_file_type_invalid = wpcf7_default_message( 'upload_file_type_invalid' ); + $upload_file_too_large = wpcf7_default_message( 'upload_file_too_large' ); + + return compact( 'mail_sent_ok', 'mail_sent_ng', 'akismet_says_spam', + 'validation_error', 'accept_terms', 'invalid_email', 'invalid_required', 'quiz_answer_not_correct', + 'captcha_not_match', 'upload_failed', 'upload_file_type_invalid', 'upload_file_too_large' ); +} + +function wpcf7_upload_dir( $type = false ) { + $siteurl = get_option( 'siteurl' ); + $upload_path = trim( get_option( 'upload_path' ) ); + if ( empty( $upload_path ) ) + $dir = WP_CONTENT_DIR . '/uploads'; + else + $dir = $upload_path; + + $dir = path_join( ABSPATH, $dir ); + + if ( ! $url = get_option( 'upload_url_path' ) ) { + if ( empty( $upload_path ) || $upload_path == $dir ) + $url = WP_CONTENT_URL . '/uploads'; + else + $url = trailingslashit( $siteurl ) . $upload_path; + } + + if ( defined( 'UPLOADS' ) ) { + $dir = ABSPATH . UPLOADS; + $url = trailingslashit( $siteurl ) . UPLOADS; + } + + if ( 'dir' == $type ) + return $dir; + if ( 'url' == $type ) + return $url; + return array( 'dir' => $dir, 'url' => $url ); +} + +function wpcf7_captcha_tmp_dir() { + if ( defined( 'WPCF8_CAPTCHA_TMP_DIR' ) ) + return WPCF8_CAPTCHA_TMP_DIR; + else + return wpcf7_upload_dir( 'dir' ) . '/wpcf7_captcha'; +} + +function wpcf7_captcha_tmp_url() { + if ( defined( 'WPCF8_CAPTCHA_TMP_URL' ) ) + return WPCF8_CAPTCHA_TMP_URL; + else + return wpcf7_upload_dir( 'url' ) . '/wpcf7_captcha'; +} + +function wpcf7_upload_tmp_dir() { + if ( defined( 'WPCF8_UPLOADS_TMP_DIR' ) ) + return WPCF8_UPLOADS_TMP_DIR; + else + return wpcf7_upload_dir( 'dir' ) . '/wpcf7_uploads'; +} + +function wpcf7_json( $items ) { + if ( is_array( $items ) ) { + if ( empty( $items ) ) + return 'null'; + + $keys = array_keys( $items ); + $all_int = true; + foreach ( $keys as $key ) { + if ( ! is_int( $key ) ) { + $all_int = false; + break; + } + } + + if ( $all_int ) { + $children = array(); + foreach ( $items as $item ) { + $children[] = wpcf7_json( $item ); + } + return '[' . join( ', ', $children ) . ']'; + } else { // Object + $children = array(); + foreach ( $items as $key => $item ) { + $key = esc_js( (string) $key ); + if ( preg_match( '/[^a-zA-Z]/', $key ) ) + $key = '"' . $key . '"'; + + $children[] = $key . ': ' . wpcf7_json( $item ); + } + return '{ ' . join( ', ', $children ) . ' }'; + } + } elseif ( is_numeric( $items ) ) { + return (string) $items; + } elseif ( is_bool( $items ) ) { + return $items ? '1' : '0'; + } elseif ( is_null( $items ) ) { + return 'null'; + } else { + return '"' . esc_js( (string) $items ) . '"'; + } +} + ?> \ No newline at end of file diff --git a/includes/pipe.php b/includes/pipe.php index bd88ed9..c63e4dd 100644 --- a/includes/pipe.php +++ b/includes/pipe.php @@ -1,67 +1,67 @@ -before = $this->after = $text; - } else { - $this->before = substr( $text, 0, $pipe_pos ); - $this->after = substr( $text, $pipe_pos + 1 ); - } - } -} - -class WPCF7_Pipes { - - var $pipes = array(); - - function WPCF7_Pipes( $texts ) { - if ( ! is_array( $texts ) ) - return; - - foreach ( $texts as $text ) { - $this->add_pipe( $text ); - } - } - - function add_pipe( $text ) { - $pipe = new WPCF7_Pipe( $text ); - $this->pipes[] = $pipe; - } - - function do_pipe( $before ) { - foreach ( $this->pipes as $pipe ) { - if ( $pipe->before == $before ) - return $pipe->after; - } - return $before; - } - - function collect_befores() { - $befores = array(); - - foreach ( $this->pipes as $pipe ) { - $befores[] = $pipe->before; - } - - return $befores; - } - - function zero() { - return empty( $this->pipes ); - } - - function random_pipe() { - if ( $this->zero() ) - return null; - - return $this->pipes[array_rand( $this->pipes )]; - } -} - +before = $this->after = $text; + } else { + $this->before = substr( $text, 0, $pipe_pos ); + $this->after = substr( $text, $pipe_pos + 1 ); + } + } +} + +class WPCF8_Pipes { + + var $pipes = array(); + + function WPCF8_Pipes( $texts ) { + if ( ! is_array( $texts ) ) + return; + + foreach ( $texts as $text ) { + $this->add_pipe( $text ); + } + } + + function add_pipe( $text ) { + $pipe = new WPCF8_Pipe( $text ); + $this->pipes[] = $pipe; + } + + function do_pipe( $before ) { + foreach ( $this->pipes as $pipe ) { + if ( $pipe->before == $before ) + return $pipe->after; + } + return $before; + } + + function collect_befores() { + $befores = array(); + + foreach ( $this->pipes as $pipe ) { + $befores[] = $pipe->before; + } + + return $befores; + } + + function zero() { + return empty( $this->pipes ); + } + + function random_pipe() { + if ( $this->zero() ) + return null; + + return $this->pipes[array_rand( $this->pipes )]; + } +} + ?> \ No newline at end of file diff --git a/includes/shortcodes.php b/includes/shortcodes.php index d18e955..4820b49 100644 --- a/includes/shortcodes.php +++ b/includes/shortcodes.php @@ -1,6 +1,6 @@ collect_befores(); $scanned_tag['pipes'] = $pipes; } else { @@ -117,7 +117,7 @@ function shortcode_parse_atts( $text ) { } -$wpcf7_shortcode_manager = new WPCF7_ShortcodeManager(); +$wpcf7_shortcode_manager = new WPCF8_ShortcodeManager(); function wpcf7_add_shortcode( $tag, $func, $has_name = false ) { global $wpcf7_shortcode_manager; diff --git a/languages/wpcf7-el.mo b/languages/wpcf7-el.mo old mode 100755 new mode 100644 diff --git a/languages/wpcf7-el.po b/languages/wpcf7-el.po old mode 100755 new mode 100644 diff --git a/modules/acceptance.php b/modules/acceptance.php index 9c17e34..f981e17 100644 --- a/modules/acceptance.php +++ b/modules/acceptance.php @@ -45,7 +45,7 @@ function wpcf7_acceptance_shortcode_handler( $tag ) { $default_on = (bool) preg_grep( '/^default:on$/i', $options ); - if ( WPCF7_LOAD_JS ) + if ( WPCF8_LOAD_JS ) $onclick = ' onclick="wpcf7ToggleSubmit(this.form);"'; $checked = $default_on ? ' checked="checked"' : ''; diff --git a/modules/captcha.php b/modules/captcha.php index b869f4f..9b39926 100644 --- a/modules/captcha.php +++ b/modules/captcha.php @@ -20,7 +20,7 @@ function wpcf7_captcha_shortcode_handler( $tag ) { return ''; $validation_error = ''; - if ( is_a( $wpcf7_contact_form, 'WPCF7_ContactForm' ) ) + if ( is_a( $wpcf7_contact_form, 'WPCF8_ContactForm' ) ) $validation_error = $wpcf7_contact_form->validation_error( $name ); $atts = ''; @@ -52,7 +52,7 @@ function wpcf7_captcha_shortcode_handler( $tag ) { $atts .= ' class="' . trim( $class_att ) . '"'; // Value. - if ( is_a( $wpcf7_contact_form, 'WPCF7_ContactForm' ) && $wpcf7_contact_form->is_posted() ) + if ( is_a( $wpcf7_contact_form, 'WPCF8_ContactForm' ) && $wpcf7_contact_form->is_posted() ) $value = ''; else $value = $values[0]; @@ -134,7 +134,7 @@ function wpcf7_captcha_validation_filter( $result, $tag ) { function wpcf7_captcha_ajax_echo_filter( $items ) { global $wpcf7_contact_form; - if ( ! is_a( $wpcf7_contact_form, 'WPCF7_ContactForm' ) ) + if ( ! is_a( $wpcf7_contact_form, 'WPCF8_ContactForm' ) ) return $items; if ( ! is_array( $items ) ) diff --git a/modules/checkbox.php b/modules/checkbox.php index d8ecc7b..e27e1f0 100644 --- a/modules/checkbox.php +++ b/modules/checkbox.php @@ -66,12 +66,12 @@ function wpcf7_checkbox_shortcode_handler( $tag ) { $html = ''; - if ( preg_match( '/^checkbox[*]?$/', $type ) && ! $multiple && WPCF7_LOAD_JS ) + if ( preg_match( '/^checkbox[*]?$/', $type ) && ! $multiple && WPCF8_LOAD_JS ) $onclick = ' onclick="wpcf7ExclusiveCheckbox(this);"'; $input_type = rtrim( $type, '*' ); - $posted = is_a( $wpcf7_contact_form, 'WPCF7_ContactForm' ) && $wpcf7_contact_form->is_posted(); + $posted = is_a( $wpcf7_contact_form, 'WPCF8_ContactForm' ) && $wpcf7_contact_form->is_posted(); //Array to store HTML of items until it can be glued together with //
s between checkbox items @@ -116,12 +116,12 @@ function wpcf7_checkbox_shortcode_handler( $tag ) { // $item = '' . $item . ''; $items[] = $item; } - $html .= implode("\n ",$items); + $html .= implode("\n",$items); $html = '' . $html . ''; $validation_error = ''; - if ( is_a( $wpcf7_contact_form, 'WPCF7_ContactForm' ) ) + if ( is_a( $wpcf7_contact_form, 'WPCF8_ContactForm' ) ) $validation_error = $wpcf7_contact_form->validation_error( $name ); $html = '' . $html . $validation_error . ''; diff --git a/modules/file.php b/modules/file.php index 58f1199..0fc3204 100644 --- a/modules/file.php +++ b/modules/file.php @@ -43,7 +43,7 @@ function wpcf7_file_shortcode_handler( $tag ) { $html = ''; $validation_error = ''; - if ( is_a( $wpcf7_contact_form, 'WPCF7_ContactForm' ) ) + if ( is_a( $wpcf7_contact_form, 'WPCF8_ContactForm' ) ) $validation_error = $wpcf7_contact_form->validation_error( $name ); $html = '' . $html . $validation_error . ''; diff --git a/modules/icl.php b/modules/icl.php index 7242263..14ec693 100644 --- a/modules/icl.php +++ b/modules/icl.php @@ -90,7 +90,7 @@ function icl_wpcf7_form_tag_filter( $tag ) { /* Message dispaly filter */ function icl_wpcf7_display_message_filter( $message ) { - $shortcode_manager = new WPCF7_ShortcodeManager(); + $shortcode_manager = new WPCF8_ShortcodeManager(); $shortcode_manager->add_shortcode( 'icl', 'icl_wpcf7_shortcode_handler', true ); return $shortcode_manager->do_shortcode( $message ); @@ -147,7 +147,7 @@ function icl_wpcf7_collect_strings( &$contact_form ) { $messages = (array) $contact_form->messages; - $shortcode_manager = new WPCF7_ShortcodeManager(); + $shortcode_manager = new WPCF8_ShortcodeManager(); $shortcode_manager->add_shortcode( 'icl', create_function( '$tag', 'return null;' ), true ); foreach ( $messages as $message ) { diff --git a/modules/quiz.php b/modules/quiz.php index c8d9124..8b407fc 100644 --- a/modules/quiz.php +++ b/modules/quiz.php @@ -52,7 +52,7 @@ function wpcf7_quiz_shortcode_handler( $tag ) { if ( $maxlength_att ) $atts .= ' maxlength="' . $maxlength_att . '"'; - if ( is_a( $pipes, 'WPCF7_Pipes' ) && ! $pipes->zero() ) { + if ( is_a( $pipes, 'WPCF8_Pipes' ) && ! $pipes->zero() ) { $pipe = $pipes->random_pipe(); $question = $pipe->before; $answer = $pipe->after; @@ -69,7 +69,7 @@ function wpcf7_quiz_shortcode_handler( $tag ) { $html .= ''; $validation_error = ''; - if ( is_a( $wpcf7_contact_form, 'WPCF7_ContactForm' ) ) + if ( is_a( $wpcf7_contact_form, 'WPCF8_ContactForm' ) ) $validation_error = $wpcf7_contact_form->validation_error( $name ); $html = '' . $html . $validation_error . ''; @@ -107,7 +107,7 @@ function wpcf7_quiz_validation_filter( $result, $tag ) { function wpcf7_quiz_ajax_echo_filter( $items ) { global $wpcf7_contact_form; - if ( ! is_a( $wpcf7_contact_form, 'WPCF7_ContactForm' ) ) + if ( ! is_a( $wpcf7_contact_form, 'WPCF8_ContactForm' ) ) return $items; if ( ! is_array( $items ) ) @@ -128,7 +128,7 @@ function wpcf7_quiz_ajax_echo_filter( $items ) { if ( empty( $name ) ) continue; - if ( is_a( $pipes, 'WPCF7_Pipes' ) && ! $pipes->zero() ) { + if ( is_a( $pipes, 'WPCF8_Pipes' ) && ! $pipes->zero() ) { $pipe = $pipes->random_pipe(); $question = $pipe->before; $answer = $pipe->after; diff --git a/modules/select.php b/modules/select.php index ae1f082..6a11417 100644 --- a/modules/select.php +++ b/modules/select.php @@ -55,7 +55,7 @@ function wpcf7_select_shortcode_handler( $tag ) { $html = ''; - $posted = is_a( $wpcf7_contact_form, 'WPCF7_ContactForm' ) && $wpcf7_contact_form->is_posted(); + $posted = is_a( $wpcf7_contact_form, 'WPCF8_ContactForm' ) && $wpcf7_contact_form->is_posted(); foreach ( $values as $key => $value ) { $selected = false; @@ -86,7 +86,7 @@ function wpcf7_select_shortcode_handler( $tag ) { $html = ''; $validation_error = ''; - if ( is_a( $wpcf7_contact_form, 'WPCF7_ContactForm' ) ) + if ( is_a( $wpcf7_contact_form, 'WPCF8_ContactForm' ) ) $validation_error = $wpcf7_contact_form->validation_error( $name ); $html = '' . $html . $validation_error . ''; diff --git a/modules/text.php b/modules/text.php index ff7b14d..5148843 100644 --- a/modules/text.php +++ b/modules/text.php @@ -59,7 +59,7 @@ function wpcf7_text_shortcode_handler( $tag ) { $atts .= ' maxlength="' . $maxlength_att . '"'; // Value - if ( is_a( $wpcf7_contact_form, 'WPCF7_ContactForm' ) && $wpcf7_contact_form->is_posted() ) { + if ( is_a( $wpcf7_contact_form, 'WPCF8_ContactForm' ) && $wpcf7_contact_form->is_posted() ) { if ( isset( $_POST['_wpcf7_mail_sent'] ) && $_POST['_wpcf7_mail_sent']['ok'] ) $value = ''; else @@ -71,7 +71,7 @@ function wpcf7_text_shortcode_handler( $tag ) { $html = ''; $validation_error = ''; - if ( is_a( $wpcf7_contact_form, 'WPCF7_ContactForm' ) ) + if ( is_a( $wpcf7_contact_form, 'WPCF8_ContactForm' ) ) $validation_error = $wpcf7_contact_form->validation_error( $name ); $html = '' . $html . $validation_error . ''; diff --git a/modules/textarea.php b/modules/textarea.php index 12b18df..e3266c1 100644 --- a/modules/textarea.php +++ b/modules/textarea.php @@ -59,7 +59,7 @@ function wpcf7_textarea_shortcode_handler( $tag ) { $atts .= ' rows="10"'; // default size // Value - if ( is_a( $wpcf7_contact_form, 'WPCF7_ContactForm' ) && $wpcf7_contact_form->is_posted() ) { + if ( is_a( $wpcf7_contact_form, 'WPCF8_ContactForm' ) && $wpcf7_contact_form->is_posted() ) { if ( isset( $_POST['_wpcf7_mail_sent'] ) && $_POST['_wpcf7_mail_sent']['ok'] ) $value = ''; else @@ -74,7 +74,7 @@ function wpcf7_textarea_shortcode_handler( $tag ) { $html = ''; $validation_error = ''; - if ( is_a( $wpcf7_contact_form, 'WPCF7_ContactForm' ) ) + if ( is_a( $wpcf7_contact_form, 'WPCF8_ContactForm' ) ) $validation_error = $wpcf7_contact_form->validation_error( $name ); $html = '' . $html . $validation_error . ''; diff --git a/stylesheet-rtl.css b/stylesheet-rtl.css index 0c28be7..b41afbd 100644 --- a/stylesheet-rtl.css +++ b/stylesheet-rtl.css @@ -1,12 +1,12 @@ -span.wpcf7-not-valid-tip { - left: auto; - right: 20%; - direction: rtl; -} -span.wpcf7-not-valid-tip-no-ajax { - direction: rtl; -} -span.wpcf7-list-item { - margin-left: 0; - margin-right: 0.5em; -} +span.wpcf7-not-valid-tip { + left: auto; + right: 20%; + direction: rtl; +} +span.wpcf7-not-valid-tip-no-ajax { + direction: rtl; +} +span.wpcf7-list-item { + margin-left: 0; + margin-right: 0.5em; +} diff --git a/stylesheet.css b/stylesheet.css index 9165786..93cc615 100644 --- a/stylesheet.css +++ b/stylesheet.css @@ -1,55 +1,55 @@ -div.wpcf7 { - margin: 0; - padding: 0; -} - -div.wpcf7-response-output { - margin: 2em 0.5em 1em; - padding: 0.2em 1em; -} - -div.wpcf7-mail-sent-ok { - border: 2px solid #398f14; -} - -div.wpcf7-mail-sent-ng { - border: 2px solid #ff0000; -} - -div.wpcf7-spam-blocked { - border: 2px solid #ffa500; -} - -div.wpcf7-validation-errors { - border: 2px solid #f7e700; -} - -span.wpcf7-form-control-wrap { - position: relative; -} - -span.wpcf7-not-valid-tip { - position: absolute; - top: 20%; - left: 20%; - z-index: 100; - background: #fff; - border: 1px solid #ff0000; - font-size: 10pt; - width: 280px; - padding: 2px; -} - -span.wpcf7-not-valid-tip-no-ajax { - color: #f00; - font-size: 10pt; - display: block; -} - -span.wpcf7-list-item { - margin-left: 0.5em; -} - -.wpcf7-display-none { - display: none; -} +div.wpcf7 { + margin: 0; + padding: 0; +} + +div.wpcf7-response-output { + margin: 2em 0.5em 1em; + padding: 0.2em 1em; +} + +div.wpcf7-mail-sent-ok { + border: 2px solid #398f14; +} + +div.wpcf7-mail-sent-ng { + border: 2px solid #ff0000; +} + +div.wpcf7-spam-blocked { + border: 2px solid #ffa500; +} + +div.wpcf7-validation-errors { + border: 2px solid #f7e700; +} + +span.wpcf7-form-control-wrap { + position: relative; +} + +span.wpcf7-not-valid-tip { + position: absolute; + top: 20%; + left: 20%; + z-index: 100; + background: #fff; + border: 1px solid #ff0000; + font-size: 10pt; + width: 280px; + padding: 2px; +} + +span.wpcf7-not-valid-tip-no-ajax { + color: #f00; + font-size: 10pt; + display: block; +} + +span.wpcf7-list-item { + margin-left: 0.5em; +} + +.wpcf7-display-none { + display: none; +}