first commit

This commit is contained in:
2026-03-05 13:07:40 +01:00
commit 64ba0721ee
25709 changed files with 4691006 additions and 0 deletions

View File

@@ -0,0 +1,72 @@
<?php
//require_once __DIR__.'/init.php';
class Wpcf7cfMailParser {
private $mail_body;
private $visible_groups;
private $hidden_groups;
private $repeaters;
private $posted_data;
function __construct($mail_body, $visible_groups, $hidden_groups, $repeaters, $posted_data) {
$this->mail_body = $mail_body;
$this->visible_groups = $visible_groups;
$this->hidden_groups = $hidden_groups;
$this->repeaters = $repeaters;
$this->posted_data = $posted_data;
}
public function getParsedMail() {
return preg_replace_callback(WPCF7CF_REGEX_MAIL_GROUP, array($this, 'hide_hidden_mail_fields_regex_callback'), $this->mail_body );
}
function hide_hidden_mail_fields_regex_callback ( $matches ) {
$name = $matches[1];
$name_parts = explode('__', $name);
$name_root = array_shift($name_parts);
$name_suffix = implode('__',$name_parts);
$content = $matches[2];
if ( in_array( $name, $this->hidden_groups ) ) {
// The tag name represents a hidden group, so replace everything from [tagname] to [/tagname] with nothing
return '';
} elseif ( in_array( $name, $this->visible_groups ) ) {
// The tag name represents a visible group, so remove the tags themselves, but return everything else
// ( instead of just returning the $content, return the preg_replaced content )
return preg_replace_callback(WPCF7CF_REGEX_MAIL_GROUP, array($this, 'hide_hidden_mail_fields_regex_callback'), $content );
} elseif ( $this->repeaters !== null && in_array( $name, $this->repeaters ) ) {
$original_name = explode('__',$name)[0];
$inner_template = $content;
ob_start();
$num_subs = $this->posted_data[$name.'_count'];
for ($i=1; $i<=$num_subs; $i++) {
$str = preg_replace(["/\[{$original_name}\:index[^\]]*?\]/"],$i,$inner_template);
//echo str_replace(']','__'.$i.']',$str);
echo preg_replace("/\[([^\s^\]]*?)([\s\]]+)([^\]]*?)/", "[$1__{$i}$2",$str);
}
$underscored_content = ob_get_clean();
return preg_replace_callback(WPCF7CF_REGEX_MAIL_GROUP, array($this, 'hide_hidden_mail_fields_regex_callback'), $underscored_content );
}else {
// The tag name doesn't represent a group that was used in the form. Leave it alone (return the entire match).
return $matches[0];
}
}
}

View File

@@ -0,0 +1,277 @@
#wpcf7cf-new-entry {
display: inline-block;
display: none;
}
#wpcf7cf-delete-button {
display: none;
}
#wpcf7cf-settings-text {
width: 100%;
height: 280px;
font-family: "Courier New", Courier, monospace;
}
#wpcf7cf-conditional-panel {
overflow-x: auto;
}
#wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .label, #wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .field, #wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .description {
padding: 10px;
display: inline-block;
vertical-align: middle;
width: 10%;
}
#wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .field {
width: 20%;
}
#wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .description {
width: 40%;
vertical-align: top;
}
#wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .option-line {
border-bottom: 1px solid #dddddd;
background-color: #f9f9f9;
padding: 0 10px;
}
#wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .option-line:nth-child(2n) {
background-color: #e9e9e9;
}
#wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .option-line input, #wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .option-line select {
width: 100%;
}
#wpcf7cf-conditional-panel .ui-autocomplete-term {
font-weight: bold;
}
#wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .option-line > .label.editable {
position: relative;
}
#wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .option-line > .label.editable input {
background-color: transparent;
border-width: 0;
outline: none;
box-shadow: none;
padding: 0;
}
#wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .option-line > .label.editable input:after {
content: "edit";
display: block;
width: 10px;
right: 0;
position: absolute;
}
#wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .option-line > .label.editable input:focus {
background: #fff;
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.07);
border: 1px solid #ddd;
padding: 2px;
}
#wpcf7cf-conditional-panel .wpcf7cf-admin-wrap .option-line > .label.editable input:focus:after {
content: "";
}
#wpcf7cf-conditional-panel .wpcf7cf-and {
display: inline-block;
}
#wpcf7cf-conditional-panel .wpcf7cf-and-rules, #wpcf7cf-conditional-panel .wpcf7cf-if {
display: inline-block;
vertical-align: top;
}
#wpcf7cf-conditional-panel #wpcf7cf-entries input, #wpcf7cf-conditional-panel #wpcf7cf-entries select, #wpcf7cf-conditional-panel .and-button, #wpcf7cf-conditional-panel .delete-button, #wpcf7cf-conditional-panel #wpcf7cf-entries .if-txt, #wpcf7cf-conditional-panel #wpcf7cf-entries .label, #wpcf7cf-conditional-panel #wpcf7cf-add-button {
position: relative;
display: inline-block;
vertical-align: bottom;
margin: 2px;
padding: 3px;
background: #fefefe;
border: 1px solid #bababa;
box-shadow: none;
height: 22px;
line-height: 22px;
min-height: 22px;
box-sizing: content-box;
}
#wpcf7cf-conditional-panel #wpcf7cf-entries .label {
background-color: transparent;
border: none;
}
#wpcf7cf-conditional-panel .and-button, #wpcf7cf-conditional-panel .delete-button, #wpcf7cf-conditional-panel #wpcf7cf-add-button {
border: 1px solid #4ed521;
color: #007b04;
cursor: pointer;
font-size: 11px;
font-weight: bold;
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Safari */
-khtml-user-select: none; /* Konqueror HTML */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none; /* Non-prefixed version, currently */
background-color: rgba(75, 169, 61, 0.11);
}
#wpcf7cf-conditional-panel #wpcf7cf-add-button {
margin-top: 10px;
text-align: center;
padding-left: 20px;
padding-right: 20px;
}
#wpcf7cf-conditional-panel .and-button:hover {
background-color: rgba(75, 169, 61, 0.2);
}
#wpcf7cf-conditional-panel .delete-button {
border: 1px solid #bababa;
color: #858585;
background-color: transparent;
margin-left: 42px;
}
#wpcf7cf-conditional-panel .delete-button:hover {
background-color: rgba(133, 133, 133, 0.11);
}
#wpcf7cf-conditional-panel .and-button {
display: none;
width: 30px;
text-align: center;
}
#wpcf7cf-conditional-panel .wpcf7cf-and-rule:first-child .and-button {
display: inline-block;
vertical-align: top;
height: 22px;
position: absolute;
line-height: 22px;
right: 53px;
top: 0;
}
#wpcf7cf-conditional-panel .wpcf7cf-and-rule {
margin-bottom: 4px;
height: 30px;
}
#wpcf7cf-conditional-panel .wpcf7cf-and-rule .if-txt, #wpcf7cf-conditional-panel .wpcf7cf-if > .label {
cursor: n-resize;
}
#wpcf7cf-conditional-panel .wpcf7cf-and-rule .if-txt:before {
content: "and";
position: absolute;
width: 30px;
text-align: right;
left: -34px;
}
#wpcf7cf-conditional-panel .wpcf7cf-and-rule:first-child .if-txt:before {
display: none;
}
#wpcf7cf-conditional-panel .wpcf7cf-inner-container {
min-width: 800px;
}
#wpcf7cf-conditional-panel .entry {
box-sizing: border-box;
display: flex;
}
#wpcf7cf-conditional-panel .entry .wpcf7cf-if {
width: 189px;
}
#wpcf7cf-conditional-panel .then-field-select {
width: 130px;
}
#wpcf7cf-conditional-panel .entry .wpcf7cf-and-rules {
flex: 1;
position: relative;
}
#wpcf7cf-conditional-panel .wpcf7cf-and-rule {
display: flex;
}
#wpcf7cf-conditional-panel .if-txt {
width: 14px;
text-align: center;
}
#wpcf7cf-conditional-panel .operator {
/*width:140px;*/
}
#wpcf7cf-conditional-panel .if-value {
flex: 1;
margin-right: 3px !important;
}
.wpcf7cf-list li {
list-style: disc;
margin-left: 20px;
}
/* The switch - the box around the slider */
.wpcf7cf-switch {
position: absolute;
display: block;
top: 20px;
right: 20px;
}
.wpcf7cf-switch .label {
margin-right: 4px;
display: inline-block;
vertical-align: top;
}
.wpcf7cf-switch .switch {
position: relative;
display: inline-block;
width: 30px;
height: 17px;
/* Hide default HTML checkbox */
/* The slider */
/* Rounded sliders */
}
.wpcf7cf-switch .switch input {
opacity: 0;
width: 0;
height: 0;
}
.wpcf7cf-switch .switch .slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: 0.4s;
transition: 0.4s;
}
.wpcf7cf-switch .switch .slider:before {
position: absolute;
content: "";
height: 13px;
width: 13px;
left: 2px;
bottom: 2px;
background-color: white;
-webkit-transition: 0.4s;
transition: 0.3s;
}
.wpcf7cf-switch .switch input:checked + .slider {
background-color: #1e8cbe;
}
.wpcf7cf-switch .switch input:focus + .slider {
box-shadow: 0 0 1px #1e8cbe;
}
.wpcf7cf-switch .switch input:checked + .slider:before {
-webkit-transform: translateX(13px);
-ms-transform: translateX(13px);
transform: translateX(13px);
}
.wpcf7cf-switch .switch .slider.round {
border-radius: 17px;
}
.wpcf7cf-switch .switch .slider.round:before {
border-radius: 50%;
}
#wpcf7cf-conditional-panel {
position: relative;
}
.wpcf7cf-notice {
background: #fff;
border: 1px solid #ccd0d4;
border-left-width: 4px;
border-left-color: #ffb900;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
margin: 5px 0 2px;
padding: 1px 12px;
}
/*# sourceMappingURL=admin-style.css.map */

View File

@@ -0,0 +1 @@
{"version":3,"sourceRoot":"","sources":["admin-style.scss"],"names":[],"mappings":"AAAA;EAAqB;EAAuB;;;AAC5C;EAAyB;;;AACzB;EAAyB;EAAa;EAAe;;;AAErD;EAqHI;;AAnHA;EACI;EACA;EACA;EACA;;AAEJ;EACI;;AAEJ;EACI;EACA;;AAIJ;EACI;EACA;EACA;;AAGJ;EACI;;AAGJ;EACI;;AAGJ;EACI;;AAGJ;EACI;;AAGJ;EACI;EACA;EACA;EACA;EACA;;AAGJ;EACI;EACA;EACA;EACA;EACA;;AAGJ;EACI;EACA;EACA;EACA;;AAGJ;EACI;;AAGJ;EACI;;AAGJ;EACI;EACA;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAGJ;EACI;EACA;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAGJ;EACI;EACA;EACA;EACA;;AAKJ;EACI;;AAGJ;EACI;EACA;EACA;EACA;;AAGJ;EACI;;AAIJ;EACI;EACA;EACA;;AAEJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;;AAGJ;EACI;EACA;;AAGJ;EACI;;AAKJ;EACI;EACA;EACA;EACA;EACA;;AAGJ;EACI;;AAGJ;EACI;;AAGJ;EACI;EACA;;AAGJ;EACI;;AAGJ;EACI;;AAIJ;EACI;EACA;;AAGJ;EACI;;AAEJ;EACI;EACA;;AAGJ;AACI;;AAGJ;EACI;EACA;;;AAIR;EACI;EACA;;;AAGJ;AAGA;EACI;EACA;EACA;EACA;;AAEA;EACI;EACA;EACA;;AAGJ;EACI;EACA;EACA;EACA;AAEA;AAOA;AAuCA;;AA7CA;EACI;EACA;EACA;;AAIJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAGJ;EACI;;AAGJ;EACI;;AAGJ;EACI;EACA;EACA;;AAIJ;EACI;;AAGJ;EACI;;;AAMZ;EACI;;;AAIJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA","file":"admin-style.css"}

View File

@@ -0,0 +1,316 @@
#wpcf7cf-new-entry { display: inline-block; display:none; }
#wpcf7cf-delete-button { display: none; }
#wpcf7cf-settings-text { width: 100%; height: 280px; font-family: "Courier New", Courier, monospace; }
#wpcf7cf-conditional-panel {
.wpcf7cf-admin-wrap .label, .wpcf7cf-admin-wrap .field, .wpcf7cf-admin-wrap .description {
padding: 10px;
display: inline-block;
vertical-align: middle;
width: 10%;
}
.wpcf7cf-admin-wrap .field {
width: 20%;
}
.wpcf7cf-admin-wrap .description {
width: 40%;
vertical-align: top;
}
.wpcf7cf-admin-wrap .option-line {
border-bottom: 1px solid #dddddd;
background-color: #f9f9f9;
padding: 0 10px;
}
.wpcf7cf-admin-wrap .option-line:nth-child(2n) {
background-color: #e9e9e9;
}
.wpcf7cf-admin-wrap .option-line input, .wpcf7cf-admin-wrap .option-line select {
width: 100%;
}
.ui-autocomplete-term {
font-weight: bold;
}
.wpcf7cf-admin-wrap .option-line > .label.editable {
position: relative;
}
.wpcf7cf-admin-wrap .option-line > .label.editable input {
background-color: transparent;
border-width: 0;
outline: none;
box-shadow: none;
padding: 0;
}
.wpcf7cf-admin-wrap .option-line > .label.editable input:after {
content: "edit";
display: block;
width: 10px;
right:0;
position: absolute;
}
.wpcf7cf-admin-wrap .option-line > .label.editable input:focus {
background: #fff;
box-shadow: inset 0 1px 2px rgba(0,0,0,.07) ;
border: 1px solid #ddd;
padding: 2px;
}
.wpcf7cf-admin-wrap .option-line > .label.editable input:focus:after {
content: "";
}
.wpcf7cf-and {
display: inline-block;
}
.wpcf7cf-and-rules, .wpcf7cf-if {
display: inline-block;
vertical-align: top;
}
#wpcf7cf-entries input, #wpcf7cf-entries select, .and-button, .delete-button, #wpcf7cf-entries .if-txt, #wpcf7cf-entries .label, #wpcf7cf-add-button {
position:relative;
display: inline-block;
vertical-align: bottom;
margin:2px;
padding: 3px;
background: #fefefe;
border: 1px solid #bababa;
box-shadow: none;
height: 22px;
line-height: 22px;
min-height: 22px;
box-sizing: content-box;
}
#wpcf7cf-entries .label {
background-color: transparent;
border: none;
}
.and-button, .delete-button, #wpcf7cf-add-button {
border: 1px solid #4ed521;
color: #007b04;
cursor: pointer;
font-size: 11px;
font-weight: bold;
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Safari */
-khtml-user-select: none; /* Konqueror HTML */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none; /* Non-prefixed version, currently */
background-color: rgba(75, 169, 61, 0.11);
}
#wpcf7cf-add-button {
margin-top: 10px;
text-align: center;
padding-left: 20px;
padding-right:20px;
}
overflow-x: auto;
.and-button:hover {
background-color: rgba(75, 169, 61, 0.2);
}
.delete-button {
border: 1px solid #bababa;
color: #858585;
background-color: transparent;
margin-left: 42px;
}
.delete-button:hover {
background-color: rgba(133, 133, 133, 0.11);
}
.and-button {
display:none;
width: 30px;
text-align: center;
}
.wpcf7cf-and-rule:first-child .and-button {
display: inline-block;
vertical-align: top;
height: 22px;
position: absolute;
line-height: 22px;
right: 53px;
top: 0;
}
.wpcf7cf-and-rule {
margin-bottom: 4px;
height: 30px;
}
.wpcf7cf-and-rule .if-txt, .wpcf7cf-if > .label {
cursor: n-resize;
}
.wpcf7cf-and-rule .if-txt:before {
content: 'and';
position: absolute;
width: 30px;
text-align: right;
left: -34px;
}
.wpcf7cf-and-rule:first-child .if-txt:before {
display:none;
}
.wpcf7cf-inner-container {
min-width: 800px;
}
.entry {
box-sizing: border-box;
display:flex;
}
.entry .wpcf7cf-if {
width: 189px;
}
.then-field-select {
width: 130px;
}
.entry .wpcf7cf-and-rules {
flex:1;
position:relative;
}
.wpcf7cf-and-rule {
display:flex;
}
.if-txt {
width: 14px;
text-align: center;
}
.operator {
/*width:140px;*/
}
.if-value {
flex:1;
margin-right:3px !important;
}
}
.wpcf7cf-list li {
list-style: disc;
margin-left: 20px;
}
/* The switch - the box around the slider */
.wpcf7cf-switch {
position: absolute;
display: block;
top: 20px;
right: 20px;
.label {
margin-right: 4px;
display: inline-block;
vertical-align: top;
}
.switch {
position: relative;
display: inline-block;
width: 30px;
height: 17px;
/* Hide default HTML checkbox */
input {
opacity: 0;
width: 0;
height: 0;
}
/* The slider */
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 13px;
width: 13px;
left: 2px;
bottom: 2px;
background-color: white;
-webkit-transition: .4s;
transition: .3s;
}
input:checked + .slider {
background-color: #1e8cbe;
}
input:focus + .slider {
box-shadow: 0 0 1px #1e8cbe;
}
input:checked + .slider:before {
-webkit-transform: translateX(13px);
-ms-transform: translateX(13px);
transform: translateX(13px);
}
/* Rounded sliders */
.slider.round {
border-radius: 17px;
}
.slider.round:before {
border-radius: 50%;
}
}
}
#wpcf7cf-conditional-panel {
position: relative;
//display: block !important;
}
.wpcf7cf-notice {
background: #fff;
border: 1px solid #ccd0d4;
border-left-width: 4px;
border-left-color: #ffb900;
box-shadow: 0 1px 1px rgba(0,0,0,.04);
margin: 5px 0 2px;
padding: 1px 12px;
}

View File

@@ -0,0 +1,251 @@
<?php
add_action( 'admin_enqueue_scripts', 'wpcf7cf_admin_enqueue_scripts', 11 ); // set priority so scripts and styles get loaded later.
function wpcf7cf_admin_enqueue_scripts( $hook_suffix ) {
wp_enqueue_script('cf7cf-scripts-admin-all-pages', wpcf7cf_plugin_url( 'js/scripts_admin_all_pages.js' ),array( 'jquery' ), WPCF7CF_VERSION,true);
if ( isset($_GET['page']) && ( $_GET['page'] == 'wpcf7' && isset($_GET['post']) || $_GET['page'] == 'wpcf7-new' ) ) {
//only load styles and scripts if this is a CF7 detail page.
wpcf7cf_admin_enqueue_form_edit_scripts($hook_suffix);
}
}
/* fix for std post editor used in Smart Grid */
add_action('cf7sg_enqueue_admin_editor_scripts', 'wpcf7cf_admin_enqueue_form_edit_scripts');
function wpcf7cf_admin_enqueue_form_edit_scripts($hook_suffix){
wp_enqueue_script('cf7cf-scripts-admin', wpcf7cf_plugin_url( 'js/scripts_admin.js' ),array('jquery-ui-autocomplete', 'jquery-ui-sortable'), WPCF7CF_VERSION,true);
wp_localize_script('cf7cf-scripts-admin', 'wpcf7cf_options_0', wpcf7cf_get_settings());
//wp_localize_script('cf7cf-scripts-admin', 'wpcf7cf_newEntryHTML', );
}
add_filter('wpcf7_editor_panels', 'add_conditional_panel');
function add_conditional_panel($panels) {
if ( current_user_can( 'wpcf7_edit_contact_forms' ) ) {
$panels['wpcf7cf-conditional-panel'] = array(
'title' => __( 'Conditional fields', 'cf7-conditional-fields' ),
'callback' => 'wpcf7cf_editor_panel_conditional'
);
}
return $panels;
}
function wpcf7cf_all_field_options($post, $selected = '-1') {
$all_fields = $post->scan_form_tags();
?>
<option value="-1" <?php echo $selected == '-1'?'selected':'' ?>><?php _e( '-- Select field --', 'cf7-conditional-fields' ); ?></option>
<?php
foreach ($all_fields as $tag) {
if ($tag['type'] == 'group' || $tag['name'] == '') continue;
?>
<option value="<?php echo $tag['name']; ?>" <?php echo $selected == $tag['name']?'selected':'' ?>><?php echo $tag['name']; ?></option>
<?php
}
}
function wpcf7cf_all_group_options($post, $selected = '-1') {
$all_groups = $post->scan_form_tags(array('type'=>'group'));
?>
<option value="-1" <?php echo $selected == '-1'?'selected':'' ?>><?php _e( '-- Select group --', 'cf7-conditional-fields' ); ?></option>
<?php
foreach ($all_groups as $tag) {
?>
<option value="<?php echo $tag['name']; ?>" <?php echo $selected == $tag['name']?'selected':'' ?>><?php echo $tag['name']; ?></option>
<?php
}
}
if (!function_exists('all_operator_options')) {
function all_operator_options($selected = 'equals') {
$all_options = array('equals', 'not equals');
$all_options = apply_filters('wpcf7cf_get_operators', $all_options);
foreach($all_options as $option) {
// backwards compat
$selected = $selected == '≤' ? 'less than or equals' : $selected;
$selected = $selected == '≥' ? 'greater than or equals' : $selected;
$selected = $selected == '>' ? 'greater than' : $selected;
$selected = $selected == '<' ? 'less than' : $selected;
?>
<option value="<?php echo htmlentities($option) ?>" <?php echo $selected == $option?'selected':'' ?>><?php echo htmlentities($option) ?></option>
<?php
}
}
}
function wpcf7cf_editor_panel_conditional($form) {
$settings = wpcf7cf_get_settings();
$is_text_only = $settings['conditions_ui'] === 'text_only';
// print_r($settings);
$form_id = isset($_GET['post']) ? $_GET['post'] : false;
if ($form_id !== false) {
$wpcf7cf_entries = CF7CF::getConditions($form_id);
$wpcf7cf_entries = array_values($wpcf7cf_entries);
} else {
$wpcf7cf_entries = [];
}
?>
<div class="wpcf7cf-inner-container">
<label class="wpcf7cf-switch" id="wpcf7cf-text-only-switch">
<span class="label"><?php _e( 'Text mode', 'cf7-conditional-fields' ); ?></span>
<span class="switch">
<input type="checkbox" id="wpcf7cf-text-only-checkbox" name="wpcf7cf-text-only-checkbox" value="text_only" <?php echo $is_text_only ? 'checked':''; ?>>
<span class="slider round"></span>
</span>
</label>
<h2><?php _e( 'Conditional fields', 'cf7-conditional-fields' ); ?></h2>
<div id="wpcf7cf-entries-ui" style="display:none">
<div id="wpcf7cf-entries">
</div>
<span id="wpcf7cf-add-button" title="<?php _e( 'add new rule', 'cf7-conditional-fields' ); ?>"><?php _e( '+ add new conditional rule', 'cf7-conditional-fields'); ?></span>
<div id="wpcf7cf-a-lot-of-conditions" class="wpcf7cf-notice notice-warning" style="display:none;">
<p>
<strong><?php _e( 'Wow, That\'s a lot of conditions!', 'cf7-conditional-fields' ); ?></strong><br>
<?php
// translators: 1. max recommended conditions
echo sprintf( __( 'You can only add up to %d conditions using this interface.', 'cf7-conditional-fields' ), WPCF7CF_MAX_RECOMMENDED_CONDITIONS ) . ' ';
// translators: 1,2: strong tags, 3. max recommended conditions
printf( __( 'Please switch to %1$sText mode%2$s if you want to add more than %3$d conditions.', 'cf7-conditional-fields' ), '<a href="#" class="wpcf7cf-switch-to-txt-link">', '</a>', WPCF7CF_MAX_RECOMMENDED_CONDITIONS ); ?>
</p>
</div>
</div>
<div id="wpcf7cf-text-entries">
<div id="wpcf7cf-settings-text-wrap">
<textarea id="wpcf7cf-settings-text" name="wpcf7cf-settings-text"><?php echo CF7CF::serializeConditions($wpcf7cf_entries) ?></textarea>
<br>
</div>
</div>
</div>
<?php
}
// Save conditions and summary field
add_action( 'wpcf7_after_save', function($contact_form) {
if ( ! isset( $_POST ) || empty( $_POST ) || ! isset( $_POST['wpcf7cf-settings-text'] ) ) {
return;
}
$post_id = $contact_form->id();
if ( ! $post_id ) {
return;
}
// we intentionally don't use sanitize_textarea_field here,
// because basically any character is a valid character.
// To arm agains SQL injections and other funky junky, the CF7CF::parse_conditions function is used.
$conditions_string = stripslashes($_POST['wpcf7cf-settings-text']);
$conditions = CF7CF::parse_conditions($conditions_string);
CF7CF::setConditions($post_id, $conditions);
if (isset($_POST['wpcf7cf-summary-template'])) {
WPCF7CF_Summary::saveSummaryTemplate($_POST['wpcf7cf-summary-template'],$post_id);
}
}, 8, 1 );
// duplicate conditions on duplicate form part 1.
add_filter('wpcf7_copy','wpcf7cf_copy', 10, 2);
function wpcf7cf_copy($new_form,$current_form) {
$id = $current_form->id();
$props = $new_form->get_properties();
$props['messages']['wpcf7cf_copied'] = $id;
$new_form->set_properties($props);
return $new_form;
}
// duplicate conditions on duplicate form part 2.
add_action('wpcf7_after_save','wpcf7cf_after_save',10,1);
function wpcf7cf_after_save($contact_form) {
$props = $contact_form->get_properties();
$original_id = isset($props['messages']['wpcf7cf_copied']) ? $props['messages']['wpcf7cf_copied'] : 0;
if ($original_id !== 0) {
$post_id = $contact_form->id();
unset($props['messages']['wpcf7cf_copied']);
$contact_form->set_properties($props);
CF7CF::setConditions($post_id, CF7CF::getConditions($original_id));
return;
}
}
function wpcf7cf_sanitize_options($options) {
//$options = array_values($options);
$sanitized_options = [];
foreach ($options as $option_entry) {
$sanitized_option = [];
$sanitized_option['then_field'] = sanitize_text_field($option_entry['then_field']);
foreach ($option_entry['and_rules'] as $and_rule) {
$sanitized_option['and_rules'][] = [
'if_field' => sanitize_text_field($and_rule['if_field']),
'operator' => $and_rule['operator'],
'if_value' => sanitize_text_field($and_rule['if_value']),
];
}
$sanitized_options[] = $sanitized_option;
}
return $sanitized_options;
}
add_action('admin_notices', function () {
$settings = wpcf7cf_get_settings();
$nid = 'install-cf7';
if (!defined('WPCF7_VERSION') && empty($settings['notice_dismissed_'.$nid]) && current_user_can('update_plugins') ) {
?>
<div class="wpcf7cf-admin-notice notice notice-warning is-dismissible" data-notice-id="<?php echo $nid ?>">
<p>
<strong>Conditional Fields for Contact Form 7</strong> depends on Contact Form 7. Please install <a target="_blank" href="https://downloads.wordpress.org/plugin/contact-form-7.<?php echo WPCF7CF_CF7_MAX_VERSION ?>.zip">Contact Form 7</a>.
</p>
</div>
<?php
return;
}
$nid = 'rollback-cf7-'.WPCF7CF_CF7_MAX_VERSION;
if ( version_compare( WPCF7CF_CF7_MAX_VERSION, WPCF7_VERSION, '<' ) && empty($settings['notice_dismissed_'.$nid]) && current_user_can('update_plugins') ) {
?>
<div class="wpcf7cf-admin-notice notice notice-warning is-dismissible" data-notice-id="<?php echo $nid ?>">
<p>
<strong>Conditional Fields for Contact Form 7</strong> is not yet tested with your current version of Contact Form 7.
<br>If you notice any problems with your forms, please roll back to Contact Form 7 <strong>version <?php echo WPCF7CF_CF7_MAX_VERSION ?></strong>.
<br>For a quick and safe rollback, we recommend <a href="https://wordpress.org/plugins/wp-rollback/" target="_blank">WP Rollback</a>.
</p>
</div>
<?php
}
$nid = 'update-cf7-'.WPCF7CF_CF7_MAX_VERSION;
if ( version_compare( WPCF7CF_CF7_MAX_VERSION, WPCF7_VERSION, '>' ) && empty($settings['notice_dismissed_'.$nid]) && current_user_can('update_plugins') ) {
?>
<div class="wpcf7cf-admin-notice notice notice-warning is-dismissible" data-notice-id="<?php echo $nid ?>">
<p>
<strong>Conditional Fields for Contact Form 7</strong> is fully compatible and tested with Contact Form 7 version <?php echo WPCF7CF_CF7_MAX_VERSION ?>.
<br>Compatibility with other versions of CF7 is not guaranteed, so please install <a target="_blank" href="https://downloads.wordpress.org/plugin/contact-form-7.<?php echo WPCF7CF_CF7_MAX_VERSION ?>.zip">CF7 version <?php echo WPCF7CF_CF7_MAX_VERSION ?></a>
</p>
</div>
<?php
}
});

View File

@@ -0,0 +1,547 @@
<?php
class CF7CF {
private $hidden_fields = array();
private $visible_groups = array();
private $hidden_groups = array();
private $repeaters = array();
function __construct() {
// Register shortcodes
add_action('wpcf7_init', array(__CLASS__, 'add_shortcodes'));
// Tag generator
add_action('admin_init', array(__CLASS__, 'tag_generator'), 590);
// compatibility with CF7 multi-step forms by Webhead LLC.
add_filter( 'wpcf7_posted_data', array($this,'cf7msm_merge_post_with_cookie'), 8, 1 );
// compatibility with CF7 Multi Step by NinjaTeam https://wordpress.org/plugins/cf7-multi-step/
add_action('wp_ajax_cf7mls_validation', array($this,'cf7mls_validation_callback'),9);
add_action('wp_ajax_nopriv_cf7mls_validation', array($this,'cf7mls_validation_callback'),9);
add_filter( 'wpcf7_validate', array($this, 'skip_validation_for_hidden_fields'), 2, 2 );
add_filter( 'wpcf7_validate_file*', array($this, 'skip_validation_for_hidden_file_field'), 30, 3);
add_filter( 'wpcf7_validate_multifile*', array($this, 'skip_validation_for_hidden_file_field'), 30, 3);
// If acceptance_as_validation is on, then Acceptance fields inside hidden groups should not trigger an error
add_filter( 'wpcf7_acceptance', function($accepted, $submission) {
$acceptance_as_validation = $submission->get_contact_form()->additional_setting('acceptance_as_validation');
return $accepted || (is_array($acceptance_as_validation) && in_array('on', $acceptance_as_validation));
}, 20, 2 );
// validation messages
add_action('wpcf7_config_validator_validate', array($this,'wpcf7cf_config_validator_validate'));
add_action("wpcf7_before_send_mail", [$this, 'hide_hidden_mail_fields'], 10, 3);
register_activation_hook(__FILE__, array($this, 'activate'));
if (is_admin()) {
require_once dirname(__FILE__) . '/admin.php';
}
}
/**
* Suppress invalid mailbox syntax errors on fields that contain existing conditional
*/
function wpcf7cf_config_validator_validate(WPCF7_ConfigValidator $wpcf7_config_validator) {
// TODO: For now we kill every syntax error once a [groupname] tag is detected.
// Ideally, this function should check each string inside the group for invalid syntax.
// TODO 2: ajax validation not working yet, because $cf->scan_form_tags() does not seem to contain group tags if it's an ajax request. Need to investigate.
$cf = $wpcf7_config_validator->contact_form();
$all_group_tags = $cf->scan_form_tags();
foreach ($wpcf7_config_validator->collect_error_messages() as $err_type => $err) {
// print_r($err_type);
$parts = explode('.',$err_type);
$property = $parts[0];
if ($property == 'form') continue; // the 'form' field can be safely validated by CF7. No need to suppress it.
$sub_prop = $parts[1];
$prop_val = $cf->prop($property)[$sub_prop];
// TODO 2: Dirty hack. Because of TODO 2 we are just going to kill the error message if we detect the string '[/'
// Start removing here.
if (strpos($prop_val, '[/') !== false) {
if ( defined( 'WPCF7_ConfigValidator::error_invalid_mailbox_syntax' ) ) {
// Pre CF7 v5.8
$wpcf7_config_validator->remove_error($err_type, WPCF7_ConfigValidator::error_invalid_mailbox_syntax);
} else {
// CF7 v5.8+
$wpcf7_config_validator->remove_error($err_type, 'invalid_mail_header');
}
continue;
}
}
return new WPCF7_ConfigValidator($wpcf7_config_validator->contact_form());
}
function activate() {
//add options with add_option and stuff
}
public static function add_shortcodes() {
if (function_exists('wpcf7_add_form_tag'))
wpcf7_add_form_tag('group', array(__CLASS__, 'shortcode_handler'), true);
else if (function_exists('wpcf7_add_shortcode')) {
wpcf7_add_shortcode('group', array(__CLASS__, 'shortcode_handler'), true);
} else {
throw new Exception('functions wpcf7_add_form_tag and wpcf7_add_shortcode not found.');
}
}
// TODO: check if we can remove this function. Doesn't seem to be called.
function group_shortcode_handler( $atts, $content = "" ) {
return $content;
}
// TODO: check if we can remove this function. Doesn't seem to be called.
public static function shortcode_handler($tag) {
//$tag = new WPCF7_Shortcode($tag);
$tag = new WPCF7_FormTag($tag);
//ob_start();
//print_r($tag);
//return print_r($tag, true);
return $tag->content;
}
public static function tag_generator() {
if (! function_exists( 'wpcf7_add_tag_generator'))
return;
wpcf7_add_tag_generator('group',
__('Conditional Fields Group', 'cf7-conditional-fields'),
'wpcf7-tg-pane-group',
array(__CLASS__, 'tg_pane')
);
do_action('wpcf7cf_tag_generator');
}
static function tg_pane( $contact_form, $args = '' ) {
$args = wp_parse_args( $args, array() );
$type = 'group';
$description = __( "Generate a group tag to group form elements that can be shown conditionally.", 'cf7-conditional-fields' );
include 'tg_pane_group.php';
}
/**
* Remove validation requirements for fields that are hidden at the time of form submission.
* Required/invalid fields should never trigger validation errors if they are inside a hidden group during submission.
* Called using add_filter( 'wpcf7_validate', array($this, 'skip_validation_for_hidden_fields'), 2, 2 );
* where the priority of 2 causes this to kill any validations with a priority higher than 2
*
* NOTE: CF7 is weirdly designed when it comes to validating a form with files.
* Only the non-file fields are considered during the wpcf7_validate filter.
* When validation passes for all fields (except the file fields), the files fields are validated individually.
* ( see skip_validation_for_hidden_file_field )
*
* @param $result
* @param $tag
*
* @return mixed
*/
function skip_validation_for_hidden_fields($result, $tags, $args = []) {
if(isset($_POST)) {
$this->set_hidden_fields_arrays($_POST);
}
$invalid_fields = $result->get_invalid_fields();
$return_result = new WPCF7_Validation();
if (count($this->hidden_fields) == 0 || !is_array($invalid_fields) || count($invalid_fields) == 0) {
$return_result = $result;
} else {
foreach ($invalid_fields as $invalid_field_key => $invalid_field_data) {
if (!in_array($invalid_field_key, $this->hidden_fields)) {
foreach ($tags as $tag) {
if ($tag['name'] === $invalid_field_key) {
$return_result->invalidate($tag, $invalid_field_data['reason']);
}
}
}
}
}
return apply_filters('wpcf7cf_validate', $return_result, $tags);
}
/**
* Does the same thing as skip_validation_for_hidden_fields, but CF7 will check files again later
* via the wpcf7_unship_uploaded_files function
* so we need to skip validation a second time for individual file fields
*/
function skip_validation_for_hidden_file_field($result, $tag, $args=[]) {
if (!count($result->get_invalid_fields())) {
return $result;
}
if(isset($_POST)) {
$this->set_hidden_fields_arrays($_POST);
}
$invalid_field_keys = array_keys($result->get_invalid_fields());
// if the current file is the only invalid tag in the result AND if the file is hidden: return a valid (blank) object
if (isset($this->hidden_fields) && is_array($this->hidden_fields) && in_array($tag->name, $this->hidden_fields) && count($invalid_field_keys) == 1) {
return new WPCF7_Validation();
}
// if the current file is not hidden, we'll just return the result (keep it invalid).
// (Note that this might also return the hidden files as invalid, but that shouldn't matter because the form is invalid, and the notification will be inside a hidden group)
return $result;
}
function cf7msm_merge_post_with_cookie($posted_data) {
if (!function_exists('cf7msm_get') || !key_exists('cf7msm_posted_data',$_COOKIE)) return $posted_data;
if (!$posted_data) {
$posted_data = WPCF7_Submission::get_instance()->get_posted_data();
}
// this will temporarily set the hidden fields data to the posted_data.
// later this function will be called again with the updated posted_data
$this->set_hidden_fields_arrays($_POST);
// get cookie data
$cookie_data = cf7msm_get('cf7msm_posted_data');
$cookie_data_hidden_group_fields = json_decode(stripslashes($cookie_data['_wpcf7cf_hidden_group_fields']));
$cookie_data_hidden_groups = json_decode(stripslashes($cookie_data['_wpcf7cf_hidden_groups']));
$cookie_data_visible_groups = json_decode(stripslashes($cookie_data['_wpcf7cf_visible_groups']));
// remove all the currently posted data from the cookie data (we don't wanna add it twice)
$cookie_data_hidden_group_fields = array_diff($cookie_data_hidden_group_fields, array_keys($posted_data));
$cookie_data_hidden_groups = array_diff((array) $cookie_data_hidden_groups, $this->hidden_groups, $this->visible_groups);
$cookie_data_visible_groups = array_diff((array) $cookie_data_visible_groups, $this->hidden_groups, $this->visible_groups);
// update current post data with cookie data
$posted_data['_wpcf7cf_hidden_group_fields'] = addslashes(json_encode(array_merge((array) $cookie_data_hidden_group_fields, $this->hidden_fields)));
$posted_data['_wpcf7cf_hidden_groups'] = addslashes(json_encode(array_merge((array) $cookie_data_hidden_groups, $this->hidden_groups)));
$posted_data['_wpcf7cf_visible_groups'] = addslashes(json_encode(array_merge((array) $cookie_data_visible_groups, $this->visible_groups)));
return $posted_data;
}
// compatibility with CF7 Multi Step by NinjaTeam https://wordpress.org/plugins/cf7-multi-step/
function cf7mls_validation_callback() {
$this->set_hidden_fields_arrays($_POST);
}
/**
* Finds the currently submitted form and set the hidden_fields variables accoringly
*
* @param bool|array $posted_data
*/
function set_hidden_fields_arrays($posted_data = false) {
if (!$posted_data) $posted_data = $_POST;
$hidden_fields = json_decode(stripslashes($posted_data['_wpcf7cf_hidden_group_fields']));
if (is_array($hidden_fields) && count($hidden_fields) > 0) {
foreach ($hidden_fields as $field) {
$this->hidden_fields[] = $field;
if (wpcf7cf_endswith($field, '[]')) {
$this->hidden_fields[] = substr($field,0,strlen($field)-2);
}
}
}
$this->hidden_groups = json_decode(stripslashes($posted_data['_wpcf7cf_hidden_groups']));
$this->visible_groups = json_decode(stripslashes($posted_data['_wpcf7cf_visible_groups']));
$this->repeaters = json_decode(stripslashes($posted_data['_wpcf7cf_repeaters']));
$this->steps = json_decode(stripslashes($posted_data['_wpcf7cf_steps']));
}
function hide_hidden_mail_fields($form,$abort,$submission) {
$props = $form->get_properties();
$mails = ['mail','mail_2','messages'];
foreach ($mails as $mail) {
if (!is_array($props[$mail])) { continue; }
foreach ($props[$mail] as $key=>$val) {
// remove unwanted whitespace between closing and opening groups from email
$count = 1;
while ($count) {
$val = preg_replace(WPCF7CF_REGEX_MAIL_UNWANTED_WHITESPACE, '$1$2', $val, -1, $count);
}
// remove hiddden groups from email
$parser = new Wpcf7cfMailParser($val, $this->visible_groups, $this->hidden_groups, $this->repeaters, $_POST);
$props[$mail][$key] = $parser->getParsedMail();
}
}
//$props['mail']['body'] = 'xxx';
$form->set_properties($props);
}
function hide_hidden_mail_fields_regex_callback ( $matches ) {
$name = $matches[1];
$content = $matches[2];
if ( in_array( $name, $this->hidden_groups ) ) {
// The tag name represents a hidden group, so replace everything from [tagname] to [/tagname] with nothing
return '';
} elseif ( in_array( $name, $this->visible_groups ) ) {
// The tag name represents a visible group, so remove the tags themselves, but return everything else
// instead of just returning the $content, return the preg_replaced content :)
return preg_replace_callback(WPCF7CF_REGEX_MAIL_GROUP, array($this, 'hide_hidden_mail_fields_regex_callback'), $content );
} else {
// The tag name doesn't represent a group that was used in the form. Leave it alone (return the entire match).
return $matches[0];
}
}
public static function parse_conditions($string, $format='array') {
// Parse stuff like "show [g1] if [field] equals 2" to Array
preg_match_all(WPCF7CF_REGEX_CONDITIONS, $string, $matches);
$conditions = [];
$prev_then_field = '';
foreach ($matches[0] as $i=>$line) {
$then_field = $matches[1][$i];
$if_field = $matches[2][$i];
$operator = $matches[3][$i];
$if_value = $matches[4][$i];
$index = count($conditions);
if ($then_field == '') {
$index = $index -1;
$then_field = $prev_then_field;
} else {
$conditions[$index]['then_field'] = $then_field;
}
$conditions[$index]['and_rules'][] = [
'if_field' => $if_field,
'operator' => $operator,
'if_value' => $if_value,
];
$prev_then_field = $then_field;
}
$conditions = array_values($conditions);
if ($format == 'array') {
return $conditions;
} else if ($format == 'json') {
return json_encode($conditions);
}
}
/**
* load the conditions from the form's post_meta
*
* @param string $form_id
* @return array
*/
public static function getConditions($form_id) {
// make sure conditions are an array.
$options = get_post_meta($form_id,'wpcf7cf_options',true);
return is_array($options) ? $options : array(); // the meta key 'wpcf7cf_options' is a bit misleading at this point, because it only holds the form's conditions, no other options/settings
}
/**
* load the conditions from the form's post_meta as plain text
*
* @param string $form_id
* @return void
*/
public static function getConditionsPlainText($form_id) {
return CF7CF::serializeConditions(CF7CF::getConditions($form_id));
}
public static function serializeConditions($array) {
$lines = [];
foreach ($array as $entry) {
$then_field = $entry['then_field'];
$and_rules = $entry['and_rules'];
$indent = strlen($then_field) + 4;
foreach ($and_rules as $i => $rule) {
$if_field = $rule['if_field'];
$operator = $rule['operator'];
$if_value = $rule['if_value'];
if ($i == 0) {
$lines[] = "show [$then_field] if [$if_field] $operator \"$if_value\"";
} else {
$lines[] = str_repeat(' ',$indent)."and if [$if_field] $operator \"$if_value\"";
}
}
}
return implode("\n", $lines);
}
/**
* save the conditions to the form's post_meta
*
* @param string $form_id
* @return void
*/
public static function setConditions($form_id, $conditions) {
return update_post_meta($form_id,'wpcf7cf_options',$conditions); // the meta key 'wpcf7cf_options' is a bit misleading at this point, because it only holds the form's conditions, no other options/settings
}
}
new CF7CF;
add_filter( 'wpcf7_contact_form_properties', 'wpcf7cf_properties', 10, 2 );
function wpcf7cf_properties($properties, $wpcf7form) {
// Before CF7 5.5.3, this function was called each time we call get_properties() on a contact form. Since CF7 5.5.3 this function is called only once in the WPCF7_ContactForm
if (!is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) { // TODO: kind of hacky. maybe find a better solution. Needed because otherwise the group tags will be replaced in the editor as well.
$form = $properties['form'];
$form_parts = preg_split('/(\[\/?group(?:\]|\s.*?\]))/',$form, -1,PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
ob_start();
$stack = array();
foreach ($form_parts as $form_part) {
if (substr($form_part,0,7) == '[group ') {
$tag_parts = explode(' ',rtrim($form_part,']'));
array_shift($tag_parts);
$tag_id = $tag_parts[0];
$tag_html_type = 'div';
$tag_html_data = array();
foreach ($tag_parts as $i => $tag_part) {
if ($i==0) continue;
$tag_part = explode(':',$tag_part);
if ($tag_part[0] == 'inline') $tag_html_type = 'span';
else if ($tag_part[0] == 'clear_on_hide') $tag_html_data[] = 'data-clear_on_hide';
else if ($tag_part[0] == 'disable_on_hide' && WPCF7CF_IS_PRO) $tag_html_data[] = 'data-disable_on_hide';
else if ($tag_part[0] == 'class') $tag_html_data[] = 'class="'.($tag_part[1]??'').'"';
}
array_push($stack,$tag_html_type);
echo '<'.$tag_html_type.' data-id="'.$tag_id.'" data-orig_data_id="'.$tag_id.'" '.implode(' ',$tag_html_data).' data-class="wpcf7cf_group">';
} else if ($form_part == '[/group]') {
echo '</'.array_pop($stack).'>';
} else {
echo $form_part;
}
}
$properties['form'] = ob_get_clean();
}
return $properties;
}
add_filter('wpcf7_form_hidden_fields', 'wpcf7cf_form_hidden_fields',10,1);
function wpcf7cf_form_hidden_fields($hidden_fields) {
$current_form = wpcf7_get_current_contact_form();
$current_form_id = $current_form->id();
$options = array(
'form_id' => $current_form_id,
'conditions' => CF7CF::getConditions($current_form_id),
'settings' => wpcf7cf_get_settings()
);
unset($options['settings']['license_key']); // don't show license key in the source code duh.
return array_merge($hidden_fields, array(
'_wpcf7cf_hidden_group_fields' => '[]',
'_wpcf7cf_hidden_groups' => '[]',
'_wpcf7cf_visible_groups' => '[]',
'_wpcf7cf_repeaters' => '[]',
'_wpcf7cf_steps' => '{}',
'_wpcf7cf_options' => ''.json_encode($options),
));
}
function wpcf7cf_endswith($string, $test) {
$strlen = strlen($string);
$testlen = strlen($test);
if ($testlen > $strlen) return false;
return substr_compare($string, $test, $strlen - $testlen, $testlen) === 0;
}
add_filter( 'wpcf7_form_tag_data_option', 'wpcf7cf_form_tag_data_option', 10, 3 );
function wpcf7cf_form_tag_data_option($output, $args, $nog) {
$data = array();
return $data;
}
/* Scripts & Styles */
function wpcf7cf_load_js() {
return apply_filters( 'wpcf7cf_load_js', WPCF7CF_LOAD_JS );
}
function wpcf7cf_load_css() {
return apply_filters( 'wpcf7cf_load_css', WPCF7CF_LOAD_CSS );
}
add_action( 'wp_enqueue_scripts', 'wpcf7cf_do_enqueue_scripts', 20, 0 );
function wpcf7cf_do_enqueue_scripts() {
if ( wpcf7cf_load_js() ) {
wpcf7cf_enqueue_scripts();
}
if ( wpcf7cf_load_css() ) {
wpcf7cf_enqueue_styles();
}
}
function wpcf7cf_enqueue_scripts() {
if (is_admin()) return;
wp_enqueue_script('wpcf7cf-scripts', plugins_url('js/scripts.js', __FILE__), array('jquery'), WPCF7CF_VERSION, true);
wp_localize_script('wpcf7cf-scripts', 'wpcf7cf_global_settings',
array(
'ajaxurl' => admin_url('admin-ajax.php'),
)
);
}
function wpcf7cf_enqueue_styles() {
if (is_admin()) return;
wp_enqueue_style('cf7cf-style', plugins_url('style.css', __FILE__), array(), WPCF7CF_VERSION);
}
// Make sure CF7 doesn't target any disabled fields for validation
// (HTML standard: "disabled fields don't get submitted", so no need to validate them)
add_filter( 'wpcf7_feedback_response', function($response, $result) {
foreach ($response['invalid_fields'] as $i => $inv) {
if (isset($response['invalid_fields'][$i]['into'])) {
$response['invalid_fields'][$i]['into'] .= ':not(.wpcf7cf-disabled)';
}
}
return $response;
}, 2, 10 );

View File

@@ -0,0 +1,48 @@
<?php
/**
* Plugin Name: Conditional Fields for Contact Form 7
* Plugin URI: http://bdwm.be/
* Description: Adds support for conditional fields to Contact Form 7. This plugin depends on Contact Form 7.
* Author: Jules Colle
* Version: 2.4.1
* Author URI: http://bdwm.be/
* Text Domain: cf7-conditional-fields
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
*/
/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
if ( function_exists( 'wpcf7cf_pro_deactivate_free_version_notice' ) ) {
add_action( 'admin_notices', 'wpcf7cf_pro_deactivate_free_version_notice' );
} else {
function wpcf7cf_pro_deactivate_free_version_notice() {
?>
<div class="notice notice-error is-dismissible">
<p><?php
// translators: 1. <a>, 2. </a>
printf( __( '<strong>Conditional Fields for Contact Form 7</strong> needs to %1$sdeactivate the free plugin%1$s', 'cf7-conditional-fields' ), '<a href="' . wp_nonce_url( 'plugins.php?action=deactivate&amp;plugin=cf7-conditional-fields%2Fcontact-form-7-conditional-fields.php&amp;plugin_status=all&amp;paged=1&amp;s=', 'deactivate-plugin_cf7-conditional-fields/contact-form-7-conditional-fields.php' ) . '">', '</a>' );
?></p>
</div>
<?php
}
require_once __DIR__.'/init.php';
}

View File

@@ -0,0 +1,56 @@
<?php
if (!defined('WPCF7CF_VERSION')) define( 'WPCF7CF_VERSION', '2.4.1' );
if (!defined('WPCF7CF_CF7_MIN_VERSION')) define( 'WPCF7CF_CF7_MIN_VERSION', '5.6' );
if (!defined('WPCF7CF_CF7_MAX_VERSION')) define( 'WPCF7CF_CF7_MAX_VERSION', '5.8.3' );
if (!defined('WPCF7CF_REQUIRED_WP_VERSION')) define( 'WPCF7CF_REQUIRED_WP_VERSION', '4.1' );
if (!defined('WPCF7CF_PLUGIN')) define( 'WPCF7CF_PLUGIN', __FILE__ );
if (!defined('WPCF7CF_PLUGIN_BASENAME')) define( 'WPCF7CF_PLUGIN_BASENAME', plugin_basename( WPCF7CF_PLUGIN ) );
if (!defined('WPCF7CF_PLUGIN_NAME')) define( 'WPCF7CF_PLUGIN_NAME', trim( dirname( WPCF7CF_PLUGIN_BASENAME ), '/' ) );
if (!defined('WPCF7CF_PLUGIN_DIR')) define( 'WPCF7CF_PLUGIN_DIR', untrailingslashit( dirname( WPCF7CF_PLUGIN ) ) );
if (!defined('WPCF7CF_LOAD_JS')) define('WPCF7CF_LOAD_JS', true);
if (!defined('WPCF7CF_LOAD_CSS')) define('WPCF7CF_LOAD_CSS', true);
if (!defined('WPCF7CF_REGEX_MAIL_GROUP')) define( 'WPCF7CF_REGEX_MAIL_GROUP', '@\[[\s]*([a-zA-Z_][0-9a-zA-Z:._-]*)[\s]*\](.*?)\[[\s]*/[\s]*\1[\s]*\]@s');
if (!defined('WPCF7CF_REGEX_MAIL_GROUP_INVERTED')) define( 'WPCF7CF_REGEX_MAIL_GROUP_INVERTED', '@\[![\s]*([a-zA-Z_][0-9a-zA-Z:._-]*)[\s]*\](.*?)\[![\s]*/[\s]*\1[\s]*\]@s');
if (!defined('WPCF7CF_REGEX_MAIL_UNWANTED_WHITESPACE')) define('WPCF7CF_REGEX_MAIL_UNWANTED_WHITESPACE', '@(\[/[^\]]*\])\s+?(\[)@s');
if (!defined('WPCF7CF_REGEX_CONDITIONS')) define( 'WPCF7CF_REGEX_CONDITIONS', '/(?:show \[([^\]]*?)\]|and) if \[([^\]]*?)\] (?:(equals \(regex\)|not equals \(regex\)|equals|not equals|greater than or equals|greater than|less than or equals|less than|is empty|not empty|function)(?: \"(.*)\")?)/m');
if (!defined('WPCF7CF_MAX_RECOMMENDED_CONDITIONS')) define( 'WPCF7CF_MAX_RECOMMENDED_CONDITIONS', 50 );
if(file_exists(WPCF7CF_PLUGIN_DIR.'/pro/pro-functions.php')) {
if (!defined('WPCF7CF_IS_PRO')) define( 'WPCF7CF_IS_PRO', true );
} else {
if (!defined('WPCF7CF_IS_PRO')) define( 'WPCF7CF_IS_PRO', false );
}
if(file_exists(WPCF7CF_PLUGIN_DIR.'/tests/init.php')) {
require_once WPCF7CF_PLUGIN_DIR.'/tests/init.php';
if (!defined('WPCF7CF_TESTMODE')) define( 'WPCF7CF_TESTMODE', true );
}
function wpcf7cf_plugin_path( $path = '' ) {
return path_join( WPCF7CF_PLUGIN_DIR, trim( $path, '/' ) );
}
function wpcf7cf_plugin_url( $path = '' ) {
$url = plugins_url( $path, WPCF7CF_PLUGIN );
if ( is_ssl() && 'http:' == substr( $url, 0, 5 ) ) {
$url = 'https:' . substr( $url, 5 );
}
return $url;
}
require_once WPCF7CF_PLUGIN_DIR.'/Wpcf7cfMailParser.php';
if (WPCF7CF_IS_PRO) {
require_once WPCF7CF_PLUGIN_DIR.'/pro/pro-functions.php';
}
require_once WPCF7CF_PLUGIN_DIR.'/cf7cf.php';
require_once WPCF7CF_PLUGIN_DIR.'/wpcf7cf-options.php';
if (WPCF7CF_IS_PRO) {
require_once WPCF7CF_PLUGIN_DIR.'/pro/update.php';
}

View File

@@ -0,0 +1,90 @@
// endsWith polyfill
if (!String.prototype.endsWith) {
String.prototype.endsWith = function(search, thisLength) {
if (thisLength === undefined || thisLength > this.length) {
thisLength = this.length;
}
return this.substring(thisLength - search.length, thisLength) === search;
};
}
// Object.values polyfill
if (!Object.values) Object.values = o=>Object.keys(o).map(k=>o[k]);
// Array.from polyfill
if (!Array.from) {
Array.from = (function () {
var toStr = Object.prototype.toString;
var isCallable = function (fn) {
return typeof fn === 'function' || toStr.call(fn) === '[object Function]';
};
var toInteger = function (value) {
var number = Number(value);
if (isNaN(number)) { return 0; }
if (number === 0 || !isFinite(number)) { return number; }
return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number));
};
var maxSafeInteger = Math.pow(2, 53) - 1;
var toLength = function (value) {
var len = toInteger(value);
return Math.min(Math.max(len, 0), maxSafeInteger);
};
// The length property of the from method is 1.
return function from(arrayLike/*, mapFn, thisArg */) {
// 1. Let C be the this value.
var C = this;
// 2. Let items be ToObject(arrayLike).
var items = Object(arrayLike);
// 3. ReturnIfAbrupt(items).
if (arrayLike == null) {
throw new TypeError("Array.from requires an array-like object - not null or undefined");
}
// 4. If mapfn is undefined, then let mapping be false.
var mapFn = arguments.length > 1 ? arguments[1] : void undefined;
var T;
if (typeof mapFn !== 'undefined') {
// 5. else
// 5. a If IsCallable(mapfn) is false, throw a TypeError exception.
if (!isCallable(mapFn)) {
throw new TypeError('Array.from: when provided, the second argument must be a function');
}
// 5. b. If thisArg was supplied, let T be thisArg; else let T be undefined.
if (arguments.length > 2) {
T = arguments[2];
}
}
// 10. Let lenValue be Get(items, "length").
// 11. Let len be ToLength(lenValue).
var len = toLength(items.length);
// 13. If IsConstructor(C) is true, then
// 13. a. Let A be the result of calling the [[Construct]] internal method of C with an argument list containing the single item len.
// 14. a. Else, Let A be ArrayCreate(len).
var A = isCallable(C) ? Object(new C(len)) : new Array(len);
// 16. Let k be 0.
var k = 0;
// 17. Repeat, while k < len… (also steps a - h)
var kValue;
while (k < len) {
kValue = items[k];
if (mapFn) {
A[k] = typeof T === 'undefined' ? mapFn(kValue, k) : mapFn.call(T, kValue, k);
} else {
A[k] = kValue;
}
k += 1;
}
// 18. Let putStatus be Put(A, "length", len, true).
A.length = len;
// 20. Return A.
return A;
};
}());
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,428 @@
/**
* These scripts are part of the Conditional Fields for Contact Form 7 plugin.
* Should only be loaded when editing a form in the WP backend.
*/
var wpcf7cf = {};
wpcf7cf.MAX_CONDITIONS = 50;
wpcf7cf.$newEntry = jQuery('#wpcf7cf-new-entry').eq(0);
wpcf7cf.$textView = jQuery('#wpcf7cf-settings-text').eq(0);
wpcf7cf.$textOnlyCheckbox = jQuery('#wpcf7cf-text-only-checkbox').eq(0);
wpcf7cf.$textOnlyLinks = jQuery('.wpcf7cf-switch-to-txt-link');
wpcf7cf.$entriesUi = jQuery('#wpcf7cf-entries-ui').eq(0);
wpcf7cf.$addButton = jQuery('#wpcf7cf-add-button').eq(0);
wpcf7cf.$maxReachedWarning = jQuery('#wpcf7cf-a-lot-of-conditions').eq(0);
wpcf7cf.$formEditorForm = jQuery('#wpcf7-admin-form-element').eq(0);
// Smart Grid compat https://wordpress.org/support/topic/rule-sets-only-saving-when-in-text-mode/
if(jQuery('#cf7sg-editor').length>0) wpcf7cf.$formEditorForm = jQuery('form#post').eq(0);
wpcf7cf.$if_values = jQuery('.if-value'); // gets updated now and then
wpcf7cf.regexCondition = /(?:show \[([^\]]*?)\]) if \[([^\]]*?)\] (?:(equals \(regex\)|not equals \(regex\)|equals|not equals|greater than or equals|greater than|less than or equals|less than|is empty|not empty|function)(?: \"(.*)\")?)/g;
wpcf7cf.regexConditionAnd = /and if \[([^\]]*?)\] (?:(equals \(regex\)|not equals \(regex\)|equals|not equals|greater than or equals|greater than|less than or equals|less than|is empty|not empty|function)(?: \"(.*)\")?)/g;
// HTML templates
wpcf7cf.template_for_condition_fields_with_one_and_rule = wpcf7cf.$newEntry.html();
wpcf7cf.template_for_and_rule = wpcf7cf.$newEntry.find('.wpcf7cf-and-rule')[0] ? wpcf7cf.$newEntry.find('.wpcf7cf-and-rule')[0].outerHTML : '';
// remove and-rules from dom
wpcf7cf.$newEntry.find('.wpcf7cf-and-rules').eq(0).html('');
wpcf7cf.template_for_condition_fields_without_and_rules = wpcf7cf.$newEntry.html();
wpcf7cf.transformConditionsFromStringToArrayOfObjects = function(str) {
if (!str) str = '';
var conditionsAsStrings = str.split(/\r?\n(?=show)/);
var conditionsAsObjects = [];
for (var i = 0; i<conditionsAsStrings.length; i++) {
var lines = conditionsAsStrings[i].split(/\r?\n/);
wpcf7cf.regexCondition.lastIndex = 0;
var line1Match = wpcf7cf.regexCondition.exec(lines[0]);
if (line1Match != null) {
var conditionObject = {
then_field:line1Match[1],
and_rules: [
{
if_field: line1Match[2],
operator: line1Match[3],
if_value: line1Match[4],
},
],
};
for(var and_i = 1; and_i < lines.length; and_i++) {
wpcf7cf.regexConditionAnd.lastIndex = 0;
lineMatch = wpcf7cf.regexConditionAnd.exec(lines[and_i]);
if (lineMatch != null) {
conditionObject.and_rules.push({
if_field: lineMatch[1],
operator: lineMatch[2],
if_value: lineMatch[3],
});
}
}
conditionsAsObjects.push(conditionObject);
}
}
return conditionsAsObjects;
}
wpcf7cf.getnumberOfTextEntries = function () {
const textConditions = wpcf7cf.transformConditionsFromStringToArrayOfObjects(wpcf7cf.$textView.val());
return textConditions.length;
}
wpcf7cf.getnumberOfFieldEntries = function () {
return wpcf7cf.$entriesUi.find('.entry').length;
}
wpcf7cf.transformConditionsFromArrayOfObjectsToString = function(conditions) {
return conditions.map(function(condition){
var indent = ' '.repeat(condition.then_field.length + 4);
return `show [${condition.then_field}] `+condition.and_rules.map(function(rule, i){
return ( i>0 ? indent+'and ':'' ) + `if [${rule.if_field}] ${rule.operator} "${rule.if_value}"`
}).join('\n');
}).join('\n');
}
/**
* Tranform an array of conditions (Objects) to HTML fields
* @param Array conditions
* @returns jQuery
*/
wpcf7cf.transformConditionsFromArrayOfObjectsToFieldElements = function(conditions) {
if ( wpcf7cf.MAX_CONDITIONS < conditions.length ) {
jQuery('#wpcf7cf-entries').html('');
wpcf7cf.maybeDisableAddButton();
return;
}
var entries = [];
for (var c_i = 0; c_i<conditions.length; c_i++) {
var condition = conditions[c_i];
var id=0;
// setup then_field
var $entry = jQuery( '<div class="entry">' + wpcf7cf.template_for_condition_fields_without_and_rules + '</div>' );
jQuery('.then-field-select', $entry).val(condition.then_field);
for (var a_i = 0; a_i < condition.and_rules.length; a_i++) {
var and_rule = condition.and_rules[a_i];
$rule = jQuery(wpcf7cf.template_for_and_rule);
jQuery('.if-field-select', $rule).val(and_rule.if_field);
jQuery('.operator', $rule).val(and_rule.operator);
jQuery('.if-value', $rule).val(and_rule.if_value);
jQuery('.wpcf7cf-and-rules', $entry).eq(0).append($rule);
}
entries.push($entry);
}
jQuery('#wpcf7cf-entries').html(entries);
update_entries();
}
wpcf7cf.maybeDisableAddButton = function() {
if (wpcf7cf.getnumberOfTextEntries() >= wpcf7cf.MAX_CONDITIONS && wpcf7cf.getnumberOfFieldEntries() == 0 ||
wpcf7cf.getnumberOfFieldEntries() >= wpcf7cf.MAX_CONDITIONS
) {
wpcf7cf.$addButton.hide();
wpcf7cf.$maxReachedWarning.show();
} else {
wpcf7cf.$addButton.show();
wpcf7cf.$maxReachedWarning.hide();
}
}
wpcf7cf.maybeDisableAddButton();
wpcf7cf.transformConditionsFromFieldsToArrayOfObjects = function($entries) {
if (!$entries) {
$entries = jQuery('#wpcf7cf-entries .entry');
}
var conditionsAsObjects = [];
$entries.each(function() {
var $entry = jQuery(this);
var then_field = $entry.find('.then-field-select').val() ?? '';
var conditionObject = {
then_field: then_field,
and_rules: [],
};
$entry.find('.wpcf7cf-and-rule').each(function(i) {
const $and_rule = jQuery(this);
conditionObject.and_rules.push({
operator : $and_rule.find('.operator').val() ?? '',
if_field : $and_rule.find('.if-field-select').val() ?? '',
if_value : $and_rule.find('.if-value').val() ?? '',
});
});
conditionsAsObjects.push(conditionObject);
});
return conditionsAsObjects;
}
wpcf7cf.copyTextToFields = function() {
var str = wpcf7cf.$textView.val();
var obj = wpcf7cf.transformConditionsFromStringToArrayOfObjects(str);
wpcf7cf.transformConditionsFromArrayOfObjectsToFieldElements(obj);
}
wpcf7cf.copyFieldsToText = function() {
var obj = wpcf7cf.transformConditionsFromFieldsToArrayOfObjects();
var str = wpcf7cf.transformConditionsFromArrayOfObjectsToString(obj);
wpcf7cf.$textView.val(str);
}
var regexes = [
{ label: wpcf7cf_options_0.regex_email_label, desc: wpcf7cf_options_0.regex_email },
{ label: wpcf7cf_options_0.regex_numeric_label, desc: wpcf7cf_options_0.regex_numeric },
{ label: wpcf7cf_options_0.regex_alphanumeric_label, desc: wpcf7cf_options_0.regex_alphanumeric },
{ label: wpcf7cf_options_0.regex_alphabetic_label, desc: wpcf7cf_options_0.regex_alphabetic },
{ label: wpcf7cf_options_0.regex_date_label, desc: wpcf7cf_options_0.regex_date },
{ label: wpcf7cf_options_0.regex_custom_1_label, desc: wpcf7cf_options_0.regex_custom_1 },
{ label: wpcf7cf_options_0.regex_custom_2_label, desc: wpcf7cf_options_0.regex_custom_2 },
{ label: wpcf7cf_options_0.regex_custom_3_label, desc: wpcf7cf_options_0.regex_custom_3 },
{ label: wpcf7cf_options_0.regex_custom_4_label, desc: wpcf7cf_options_0.regex_custom_4 },
{ label: wpcf7cf_options_0.regex_custom_5_label, desc: wpcf7cf_options_0.regex_custom_5 },
];
var i = regexes.length;
while (i--) {
if (null == regexes[i].label || null == regexes[i].desc || regexes[i].label == '' || regexes[i].desc == '') {
regexes.splice(i,1);
}
}
var termTemplate = "<span class='ui-autocomplete-term'>%s</span>";
jQuery('#wpcf7cf-entries').sortable();
var index = jQuery('#wpcf7cf-entries .entry').length;
var index_and = 0;
wpcf7cf.$addButton.click(function(){
add_condition_fields();
});
function add_condition_fields() {
$c = jQuery('<div class="entry">'+wpcf7cf.template_for_condition_fields_with_one_and_rule+'</div>')
$c.appendTo('#wpcf7cf-entries');
update_entries();
}
function update_entries() {
wpcf7cf.$if_values = jQuery('.if-value');
init_autocomplete();
wpcf7cf.$if_values.css({'visibility':'visible'});
wpcf7cf.$if_values.autocomplete( "disable" );
jQuery('#wpcf7cf-entries .wpcf7cf-and-rule').each(function() {
var $and_rule = jQuery(this);
var $operatorField = $and_rule.find('.operator').eq(0);
var operator = $operatorField.val() || 'equals';
if ($and_rule.find('.operator').eq(0).val() === 'is empty' || $and_rule.find('.operator').eq(0).val() === 'not empty') {
$and_rule.find('.if-value').eq(0).css({'visibility':'hidden'});
} else if (operator.endsWith('(regex)')) {
$and_rule.find('.if-value').eq(0).autocomplete( "enable" );
}
});
scale_and_button();
set_events();
wpcf7cf.maybeDisableAddButton();
}
function init_autocomplete() {
wpcf7cf.$if_values.autocomplete({
disabled: true,
source: function(request, response) {
var matcher = new RegExp(jQuery.ui.autocomplete.escapeRegex(request.term), "i");
response(jQuery.grep(regexes, function(value) {
return matcher.test(value.label || value.value || value) || matcher.test(value.desc);
}));
},
focus: function( event, ui ) {
jQuery( event.target ).val( ui.item.desc );
return false;
},
select: function( event, ui ) {
jQuery( event.target ).val( ui.item.desc );
return false;
},
open: function(e,ui) {
$el = jQuery(e.target);
var styledTerm = termTemplate.replace('%s', $el.val());
jQuery('.ui-autocomplete').find('em').each(function() {
var me = jQuery(this);
me.html( me.text().replace($el.val(), styledTerm) );
});
},
minLength: 0
}).each(function() {
jQuery(this).autocomplete( "instance" )._renderItem = function( ul, item ) {
return jQuery("<li>")
.append("<div><em>" + item.label + "</em><br><em>" + item.desc + "</em></div>")
.appendTo(ul);
}
});
wpcf7cf.$if_values.on('focus', function() {
jQuery(this).autocomplete("search");
});
}
function set_events() { // called at the end of update_entries
jQuery('.wpcf7cf-and-rules').sortable();
jQuery('.and-button').off('click').click(function() {
$this = jQuery(this);
$andblock = $this.closest('.wpcf7cf-and-rule');
$andblocks_container = $this.closest('.wpcf7cf-and-rules');
next_index = $andblocks_container.data('next-index');
$andblocks_container.data('next-index',next_index+1);
var and_i = next_index;
clone_html = $andblock.get(0).outerHTML.replace(/wpcf7cf_options\[([0-9]*)\]\[and_rules\]\[([0-9]*)\]/g, 'wpcf7cf_options[$1][and_rules]['+and_i+']');
$andblock.after(clone_html);
//update_settings_textarea();
update_entries();
return false;
});
jQuery('.delete-button').off('click').click(function(){
$and_rule = jQuery(this).closest('.wpcf7cf-and-rule');
if ($and_rule.siblings().length > 0) {
$and_rule.remove();
} else {
$and_rule[0].closest('.entry').remove();
}
//update_settings_textarea();
update_entries();
return false;
});
jQuery('.operator').off('change').change(function() {
update_entries();
return false;
});
}
function scale_and_button() {
jQuery('.wpcf7cf-and-rule:first-child .and-button').each(function(){
$and_button = jQuery(this);
num_and_rules = $and_button.closest('.wpcf7cf-and-rule').siblings().length+1;
var height = (34*num_and_rules-12)+'px';
$and_button.css({'height':height,'line-height':height});
});
}
// ------------------------------------
// TOOGGLE UI MODE
// ------------------------------------
function setUiMode(is_text_only) {
if (is_text_only) {
wpcf7cf.currentMode = 'text';
wpcf7cf.$entriesUi.hide();
wpcf7cf.$textView.show();
if (wpcf7cf.getnumberOfFieldEntries() > 0) {
wpcf7cf.copyFieldsToText();
}
} else {
wpcf7cf.currentMode = 'normal';
wpcf7cf.$entriesUi.show();
wpcf7cf.$textView.hide();
wpcf7cf.copyTextToFields();
}
}
wpcf7cf.$textOnlyLinks.on( 'click', function() {
wpcf7cf.$textOnlyCheckbox.prop('checked', true).trigger('change');
} )
wpcf7cf.$textOnlyCheckbox.on( 'change', function() {
setUiMode( wpcf7cf.$textOnlyCheckbox.is( ':checked' ) );
} );
setUiMode(wpcf7cf.$textOnlyCheckbox.is(':checked'));
wpcf7cf.$formEditorForm.on('submit', function() {
if (wpcf7cf.currentMode == 'normal' && wpcf7cf.getnumberOfFieldEntries() > 0) {
wpcf7cf.copyFieldsToText();
}
});
// ------------------------------------
// CF7 TAG GENERATOR OVERRIDE
// ------------------------------------
if (_wpcf7 == null) { var _wpcf7 = wpcf7}; // wpcf7 4.8 fix
var old_compose = _wpcf7.taggen.compose;
// ...before overwriting the jQuery extension point
_wpcf7.taggen.compose = function(tagType, $form)
{
jQuery('#tag-generator-panel-group-style-hidden').val(jQuery('#tag-generator-panel-group-style').val());
// original behavior - use function.apply to preserve context
var ret = old_compose.apply(this, arguments);
//tagType = arguments[0];
//$form = arguments[1];
// START: code here will be executed after the _wpcf7.taggen.update function
if (tagType== 'group') ret += "[/group]";
if (tagType== 'repeater') ret += "[/repeater]";
// END
if (tagType== 'togglebutton') {
$val1 = jQuery('#tag-generator-panel-togglebutton-value-1');
$val2 = jQuery('#tag-generator-panel-togglebutton-value-2');
var val1 = $val1.val();
var val2 = $val2.val();
if (val1 == "") val1 = $val1.data('default');
if (val2 == "") val2 = $val2.data('default');
str_val = ' "'+val1+'" "'+val2+'"';
ret = ret.replace(']', str_val+']');
}
return ret;
};

View File

@@ -0,0 +1,565 @@
/**
* These scripts are part of the Conditional Fields for Contact Form 7 plugin.
* Should only be loaded when editing a form in the WP backend.
*/
let wpcf7cf_formcode = null; // used to detect if the form code has changed
var regexes = [
{ label: wpcf7cf_options_0.regex_email_label, desc: wpcf7cf_options_0.regex_email },
{ label: wpcf7cf_options_0.regex_numeric_label, desc: wpcf7cf_options_0.regex_numeric },
{ label: wpcf7cf_options_0.regex_alphanumeric_label, desc: wpcf7cf_options_0.regex_alphanumeric },
{ label: wpcf7cf_options_0.regex_alphabetic_label, desc: wpcf7cf_options_0.regex_alphabetic },
{ label: wpcf7cf_options_0.regex_date_label, desc: wpcf7cf_options_0.regex_date },
{ label: wpcf7cf_options_0.regex_custom_1_label, desc: wpcf7cf_options_0.regex_custom_1 },
{ label: wpcf7cf_options_0.regex_custom_2_label, desc: wpcf7cf_options_0.regex_custom_2 },
{ label: wpcf7cf_options_0.regex_custom_3_label, desc: wpcf7cf_options_0.regex_custom_3 },
{ label: wpcf7cf_options_0.regex_custom_4_label, desc: wpcf7cf_options_0.regex_custom_4 },
{ label: wpcf7cf_options_0.regex_custom_5_label, desc: wpcf7cf_options_0.regex_custom_5 },
];
var i = regexes.length;
while (i--) {
if (null == regexes[i].label || null == regexes[i].desc || regexes[i].label == '' || regexes[i].desc == '') {
regexes.splice(i,1);
}
}
if (typeof(_wpcf7) != 'undefined' || typeof(wpcf7) != 'undefined') {
var wpcf7cf = {};
wpcf7cf.MAX_CONDITIONS = 50;
wpcf7cf.operators = [
'equals',
'not equals',
'equals (regex)',
'not equals (regex)',
'greater than',
'greater than or equals',
'less than',
'less than or equals',
'is empty',
'not empty',
'function',
];
wpcf7cf.$newEntry = jQuery(`<div class="entry">
<div class="wpcf7cf-if">
<span class="label">Show</span>
<select class="then-field-select"></select>
</div>
<div class="wpcf7cf-and-rules ui-sortable" data-next-index="1">
<div class="wpcf7cf-and-rule ui-sortable-handle">
<span class="rule-part if-txt label">if</span>
<select class="rule-part if-field-select"></select>
<select class="rule-part operator">${ wpcf7cf.operators.map(o => `<option value="${o}">${o}</option>`) }</select>
<input class="rule-part if-value" type="text" placeholder="value" value="" style="visibility: visible;">
<span class="and-button" style="height: 22px; line-height: 22px;">And</span>
<span title="delete rule" class="rule-part delete-button">remove</span>
</div>
</div>
</div>`);
wpcf7cf.$textView = jQuery('#wpcf7cf-settings-text').eq(0);
wpcf7cf.$textOnlyCheckbox = jQuery('#wpcf7cf-text-only-checkbox').eq(0);
wpcf7cf.$textOnlyLinks = jQuery('.wpcf7cf-switch-to-txt-link');
wpcf7cf.$entriesUi = jQuery('#wpcf7cf-entries-ui').eq(0);
wpcf7cf.$addButton = jQuery('#wpcf7cf-add-button').eq(0);
wpcf7cf.$maxReachedWarning = jQuery('#wpcf7cf-a-lot-of-conditions').eq(0);
wpcf7cf.$formEditorForm = jQuery('#wpcf7-admin-form-element').eq(0);
wpcf7cf.$formEditor = jQuery('#wpcf7-form').eq(0);
// Smart Grid compat https://wordpress.org/support/topic/rule-sets-only-saving-when-in-text-mode/
if(jQuery('#cf7sg-editor').length>0) wpcf7cf.$formEditorForm = jQuery('form#post').eq(0);
wpcf7cf.regexCondition = /(?:show \[([^\]]*?)\]) if \[([^\]]*?)\] (?:(equals \(regex\)|not equals \(regex\)|equals|not equals|greater than or equals|greater than|less than or equals|less than|is empty|not empty|function)(?: \"(.*)\")?)/g;
wpcf7cf.regexConditionAnd = /and if \[([^\]]*?)\] (?:(equals \(regex\)|not equals \(regex\)|equals|not equals|greater than or equals|greater than|less than or equals|less than|is empty|not empty|function)(?: \"(.*)\")?)/g;
wpcf7cf.transformConditionsFromStringToArrayOfObjects = function(str) {
if (!str) str = '';
var conditionsAsStrings = str.split(/\r?\n(?=show)/);
var conditionsAsObjects = [];
for (var i = 0; i<conditionsAsStrings.length; i++) {
var lines = conditionsAsStrings[i].split(/\r?\n/);
wpcf7cf.regexCondition.lastIndex = 0;
var line1Match = wpcf7cf.regexCondition.exec(lines[0]);
if (line1Match != null) {
var conditionObject = {
then_field:line1Match[1],
and_rules: [
{
if_field: line1Match[2],
operator: line1Match[3],
if_value: line1Match[4],
},
],
};
for(var and_i = 1; and_i < lines.length; and_i++) {
wpcf7cf.regexConditionAnd.lastIndex = 0;
lineMatch = wpcf7cf.regexConditionAnd.exec(lines[and_i]);
if (lineMatch != null) {
conditionObject.and_rules.push({
if_field: lineMatch[1],
operator: lineMatch[2],
if_value: lineMatch[3],
});
}
}
conditionsAsObjects.push(conditionObject);
}
}
return conditionsAsObjects;
}
wpcf7cf.getnumberOfTextEntries = function () {
const textConditions = wpcf7cf.transformConditionsFromStringToArrayOfObjects(wpcf7cf.$textView.val());
return textConditions.length;
}
wpcf7cf.getnumberOfFieldEntries = function () {
return wpcf7cf.$entriesUi.find('.entry').length;
}
wpcf7cf.transformConditionsFromArrayOfObjectsToString = function(conditions) {
return conditions.map(function(condition){
var indent = ' '.repeat(condition.then_field.length + 4);
return `show [${condition.then_field}] `+condition.and_rules.map(function(rule, i){
return ( i>0 ? indent+'and ':'' ) + `if [${rule.if_field}] ${rule.operator} "${rule.if_value}"`
}).join('\n');
}).join('\n');
}
/**
* Tranform an array of conditions (Objects) to HTML fields
* @param Array conditions
* @returns jQuery
*/
wpcf7cf.transformConditionsFromArrayOfObjectsToFieldElements = function(conditions) {
if ( wpcf7cf.MAX_CONDITIONS < conditions.length ) {
jQuery('#wpcf7cf-entries').html('');
wpcf7cf.maybeDisableAddButton();
return;
}
var entries = [];
for (var c_i = 0; c_i<conditions.length; c_i++) {
var condition = conditions[c_i];
var id=0;
// setup then_field
var $entry = jQuery(wpcf7cf.template_for_condition_fields_without_and_rules);
jQuery('.then-field-select', $entry).val(condition.then_field);
for (var a_i = 0; a_i < condition.and_rules.length; a_i++) {
var and_rule = condition.and_rules[a_i];
$rule = jQuery(wpcf7cf.template_for_and_rule);
jQuery('.if-field-select', $rule).val(and_rule.if_field);
jQuery('.operator', $rule).val(and_rule.operator);
jQuery('.if-value', $rule).val(and_rule.if_value);
jQuery('.wpcf7cf-and-rules', $entry).eq(0).append($rule);
}
entries.push($entry);
}
jQuery('#wpcf7cf-entries').html(entries);
updateDisplayOfEntries();
}
wpcf7cf.isMaxConditionsReached = function() {
return wpcf7cf.getnumberOfTextEntries() >= wpcf7cf.MAX_CONDITIONS && wpcf7cf.getnumberOfFieldEntries() == 0 ||
wpcf7cf.getnumberOfFieldEntries() >= wpcf7cf.MAX_CONDITIONS;
}
wpcf7cf.maybeDisableAddButton = function() {
if (wpcf7cf.isMaxConditionsReached()) {
wpcf7cf.$addButton.hide();
wpcf7cf.$maxReachedWarning.show();
} else {
wpcf7cf.$addButton.show();
wpcf7cf.$maxReachedWarning.hide();
}
}
wpcf7cf.transformConditionsFromFieldsToArrayOfObjects = function($entries) {
if (!$entries) {
$entries = jQuery('#wpcf7cf-entries .entry');
}
var conditionsAsObjects = [];
$entries.each(function() {
var $entry = jQuery(this);
var then_field = $entry.find('.then-field-select').val() ?? '';
var conditionObject = {
then_field: then_field,
and_rules: [],
};
$entry.find('.wpcf7cf-and-rule').each(function(i) {
const $and_rule = jQuery(this);
conditionObject.and_rules.push({
operator : $and_rule.find('.operator').val() ?? '',
if_field : $and_rule.find('.if-field-select').val() ?? '',
if_value : $and_rule.find('.if-value').val() ?? '',
});
});
conditionsAsObjects.push(conditionObject);
});
return conditionsAsObjects;
}
wpcf7cf.copyTextToFields = function() {
var str = wpcf7cf.$textView.val();
var obj = wpcf7cf.transformConditionsFromStringToArrayOfObjects(str);
wpcf7cf.transformConditionsFromArrayOfObjectsToFieldElements(obj);
wpcf7cf.setDefaultValues();
}
wpcf7cf.copyFieldsToText = function() {
var obj = wpcf7cf.transformConditionsFromFieldsToArrayOfObjects();
var str = wpcf7cf.transformConditionsFromArrayOfObjectsToString(obj);
wpcf7cf.$textView.val(str);
}
function add_condition_fields() {
$c = jQuery(wpcf7cf.template_for_condition_fields_with_one_and_rule)
$c.appendTo('#wpcf7cf-entries');
updateDisplayOfEntries();
}
/**
* Update visibility / autocomplete and some other visual properties based on the selected conditions.
*/
function updateDisplayOfEntries() {
wpcf7cf.$if_values = jQuery('.if-value');
init_autocomplete();
wpcf7cf.$if_values.css({'visibility':'visible'});
wpcf7cf.$if_values.autocomplete( "disable" );
jQuery('#wpcf7cf-entries .wpcf7cf-and-rule').each(function() {
var $and_rule = jQuery(this);
var $operatorField = $and_rule.find('.operator').eq(0);
var operator = $operatorField.val() || 'equals';
if ($and_rule.find('.operator').eq(0).val() === 'is empty' || $and_rule.find('.operator').eq(0).val() === 'not empty') {
$and_rule.find('.if-value').eq(0).css({'visibility':'hidden'});
} else if (operator.endsWith('(regex)')) {
$and_rule.find('.if-value').eq(0).autocomplete( "enable" );
}
});
scale_and_button();
set_events();
wpcf7cf.maybeDisableAddButton();
}
function init_autocomplete() {
wpcf7cf.$if_values.autocomplete({
disabled: true,
source: function(request, response) {
var matcher = new RegExp(jQuery.ui.autocomplete.escapeRegex(request.term), "i");
response(jQuery.grep(regexes, function(value) {
return matcher.test(value.label || value.value || value) || matcher.test(value.desc);
}));
},
focus: function( event, ui ) {
jQuery( event.target ).val( ui.item.desc );
return false;
},
select: function( event, ui ) {
jQuery( event.target ).val( ui.item.desc );
return false;
},
open: function(e,ui) {
$el = jQuery(e.target);
var styledTerm = `<span class='ui-autocomplete-term'>${$el.val()}</span>`;
jQuery('.ui-autocomplete').find('em').each(function() {
var me = jQuery(this);
me.html( me.text().replace($el.val(), styledTerm) );
});
},
minLength: 0
}).each(function() {
jQuery(this).autocomplete( "instance" )._renderItem = function( ul, item ) {
return jQuery("<li>")
.append("<div><em>" + item.label + "</em><br><em>" + item.desc + "</em></div>")
.appendTo(ul);
}
});
wpcf7cf.$if_values.on('focus', function() {
jQuery(this).autocomplete("search");
});
}
function set_events() { // called at the end of updateDisplayOfEntries
jQuery('.wpcf7cf-and-rules').sortable();
jQuery('.and-button').off('click').click(function() {
$this = jQuery(this);
$andblock = $this.closest('.wpcf7cf-and-rule');
$andblocks_container = $this.closest('.wpcf7cf-and-rules');
next_index = $andblocks_container.data('next-index');
$andblocks_container.data('next-index',next_index+1);
var and_i = next_index;
clone_html = $andblock.get(0).outerHTML.replace(/wpcf7cf_options\[([0-9]*)\]\[and_rules\]\[([0-9]*)\]/g, 'wpcf7cf_options[$1][and_rules]['+and_i+']');
$andblock.after(clone_html);
updateDisplayOfEntries();
wpcf7cf.copyFieldsToText();
return false;
});
jQuery('.delete-button').off('click').click(function(){
$and_rule = jQuery(this).closest('.wpcf7cf-and-rule');
if ($and_rule.siblings().length > 0) {
$and_rule.remove();
} else {
$and_rule[0].closest('.entry').remove();
}
updateDisplayOfEntries();
wpcf7cf.copyFieldsToText();
return false;
});
jQuery('.operator').on('change', (function() {
updateDisplayOfEntries();
wpcf7cf.copyFieldsToText();
return false;
}));
}
function scale_and_button() {
jQuery('.wpcf7cf-and-rule:first-child .and-button').each(function(){
$and_button = jQuery(this);
num_and_rules = $and_button.closest('.wpcf7cf-and-rule').siblings().length+1;
var height = (34*num_and_rules-12)+'px';
$and_button.css({'height':height,'line-height':height});
});
}
// ------------------------------------
// TOOGGLE UI MODE
// ------------------------------------
/**
* Make either Text-only view or field view visible.
*
* @param {boolean} is_text_only `true` to show text-only view. `false` for fields view
*/
wpcf7cf.setViewMode = function(is_text_only) {
if (is_text_only) {
wpcf7cf.currentMode = 'text';
wpcf7cf.$entriesUi.hide();
wpcf7cf.$textView.show();
if (wpcf7cf.getnumberOfFieldEntries() > 0) {
wpcf7cf.copyFieldsToText();
}
} else {
wpcf7cf.currentMode = 'normal';
wpcf7cf.$entriesUi.show();
wpcf7cf.$textView.hide();
wpcf7cf.copyTextToFields();
}
}
wpcf7cf.$textOnlyLinks.on( 'click', function() {
wpcf7cf.$textOnlyCheckbox.prop('checked', true).trigger('change');
return false;
} )
wpcf7cf.$textOnlyCheckbox.on('change', function() {
wpcf7cf.setViewMode(wpcf7cf.$textOnlyCheckbox.is(':checked'));
});
wpcf7cf.$formEditorForm.on('submit', function() {
if (wpcf7cf.currentMode == 'normal' && wpcf7cf.getnumberOfFieldEntries() > 0) {
wpcf7cf.copyFieldsToText();
}
});
wpcf7cf.$entriesUi.on('change', function(){
wpcf7cf.copyFieldsToText();
});
// ------------------------------------
// CF7 TAG GENERATOR OVERRIDE
// ------------------------------------
if (_wpcf7 == null) { var _wpcf7 = wpcf7}; // wpcf7 4.8 fix
var old_compose = _wpcf7.taggen.compose;
// ...before overwriting the jQuery extension point
_wpcf7.taggen.compose = function(tagType, $form)
{
jQuery('#tag-generator-panel-group-style-hidden').val(jQuery('#tag-generator-panel-group-style').val());
// original behavior - use function.apply to preserve context
var ret = old_compose.apply(this, arguments);
//tagType = arguments[0];
//$form = arguments[1];
// START: code here will be executed after the _wpcf7.taggen.update function
if (tagType== 'group') ret += "[/group]";
if (tagType== 'repeater') ret += "[/repeater]";
// END
if (tagType== 'togglebutton') {
$val1 = jQuery('#tag-generator-panel-togglebutton-value-1');
$val2 = jQuery('#tag-generator-panel-togglebutton-value-2');
var val1 = $val1.val();
var val2 = $val2.val();
if (val1 == "") val1 = $val1.data('default');
if (val2 == "") val2 = $val2.data('default');
str_val = ' "'+val1+'" "'+val2+'"';
ret = ret.replace(']', str_val+']');
}
return ret;
};
// console.log('huh');
// jQuery( window ).on( 'beforeunload', function( event ) {
// wpcf7cf.copyFieldsToText();
// if (wpcf7cf.$textView.val() === wpcf7cf.$textView[0].defaultValue) {
// // jQuery('#wpcf7cf-entries-ui').remove();
// jQuery("#wpcf7cf-entries-ui :input").prop("disabled", true);
// }
// });
function scanFormTags(formCode) {
const fields = [...formCode.matchAll(/\[(?!group|step|repeater|submit)[^\] ]+ ([^\] ]+)/g)].map(e=>e[1]);
const groups = [...formCode.matchAll(/\[group ([^\] ]+)/g)].map(e=>e[1]);
return [ fields, groups ];
}
function updateAvailableGroupsAndFields() {
const formCode = wpcf7cf.$formEditor.val();
const [ fields, groups ] = scanFormTags(formCode);
$temp = jQuery(wpcf7cf.template_for_condition_fields_with_one_and_rule);
$temp.find('.then-field-select').eq(0).html(createOptionsHTML(groups, 'group'));
$temp.find('.if-field-select').eq(0).html(createOptionsHTML(fields, 'field'));
// $temp.find('.operator').eq(0).html(createOptionsHTML(wpcf7cf.operators, null));
wpcf7cf.template_for_condition_fields_with_one_and_rule = $temp[0].outerHTML;
$temp.find('.wpcf7cf-and-rules').eq(0).html('');
wpcf7cf.template_for_condition_fields_without_and_rules = $temp[0].outerHTML;
$temp = jQuery(wpcf7cf.template_for_and_rule);
$temp.find('.if-field-select').eq(0).html(createOptionsHTML(fields, 'field'));
wpcf7cf.template_for_and_rule = $temp[0].outerHTML;
jQuery('.then-field-select').each(function(){
const $this = jQuery(this);
updateSelectWithValues($this, groups, 'group');
});
jQuery('.if-field-select').each(function(){
const $this = jQuery(this);
updateSelectWithValues($this, fields, 'field');
});
}
function updateSelectWithValues($select, values, type) {
$select.html(createOptionsHTML(values, type));
}
function createOptionsHTML(values, type) {
return (type?`<option value="-1">-- Select ${type} --</option>`:'')+values.map(value => `<option value="${value}">${value}</option>`).join('');
}
/**
* Set the default value of all fields to their current value.
* This prevents CF7 to show an unsaved-changes warning on these fields.
* (The single source of truth is the value in the text view.)
*/
wpcf7cf.setDefaultValues = function() {
jQuery('#wpcf7cf-entries select').each(function() {
const $select = jQuery(this);
let selectedIndex = $select.prop('selectedIndex');
if (selectedIndex == -1) {
selectedIndex = 0;
}
$select.find('option').removeAttr('selected');
$select.find(`option:eq(${selectedIndex})`).prop('selected', 'selected').attr('selected', 'selected');
})
jQuery('#wpcf7cf-entries .if-value').each(function(){
const $input = jQuery(this);
$input.attr('value',$input.val());
});
}
// update available groups and fields each time there is a change in the form code.
wpcf7cf.$formEditor.on('change focusout', function() {
if( !wpcf7cf_formcode || wpcf7cf_formcode !== this.value ) {
wpcf7cf_formcode = this.value;
updateAvailableGroupsAndFields();
if (!wpcf7cf.isMaxConditionsReached()) {
wpcf7cf.copyTextToFields();
wpcf7cf.copyFieldsToText();
}
}
});
wpcf7cf.$addButton.click(function(){
add_condition_fields();
wpcf7cf.copyFieldsToText();
});
jQuery(document).ready(function() {
wpcf7cf.$if_values = jQuery('.if-value'); // gets updated now and then
// init HTML templates (will be updated immediatly by updateAvailableGroupsAndFields())
wpcf7cf.template_for_condition_fields_with_one_and_rule = wpcf7cf.$newEntry[0].outerHTML;
wpcf7cf.template_for_and_rule = wpcf7cf.$newEntry.find('.wpcf7cf-and-rule')[0] ? wpcf7cf.$newEntry.find('.wpcf7cf-and-rule')[0].outerHTML : '';
updateAvailableGroupsAndFields();
wpcf7cf.copyTextToFields();
wpcf7cf.maybeDisableAddButton();
jQuery('#wpcf7cf-entries').sortable();
wpcf7cf.setViewMode(wpcf7cf.$textOnlyCheckbox.is(':checked'));
})
}

View File

@@ -0,0 +1,25 @@
// ------------------------------------
// DISMISS NOTICES
// ------------------------------------
jQuery(document).ready(function($) {
$('.notice-dismiss,.notice-dismiss-alt', '.wpcf7cf-admin-notice').click(function () {
wpcf7cf_dismiss_notice(
$(this).closest('.wpcf7cf-admin-notice').data('noticeId')
);
});
function wpcf7cf_dismiss_notice(noticeId) {
if (noticeId === '') {
$('input[name="wpcf7cf_options[notice_dismissed]"]').val('true');
}
$.post(ajaxurl, { action:'wpcf7cf_dismiss_notice', noticeId:noticeId }, function(response) {
// nothing to do. dismiss_notice option should be set to TRUE server side by now.
});
}
});

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,510 @@
/**
* These scripts are part of the Conditional Fields for Contact Form 7 plugin.
* Should only be loaded when editing a form in the WP backend.
*/
if (typeof(_wpcf7) != 'undefined' || typeof(wpcf7) != 'undefined') {
var wpcf7cf = {};
wpcf7cf.MAX_CONDITIONS = 50;
wpcf7cf.$newEntry = jQuery(`<div class="entry">
<div class="wpcf7cf-if">
<span class="label">Show</span>
<select class="then-field-select"></select>
</div>
<div class="wpcf7cf-and-rules ui-sortable" data-next-index="1">
<div class="wpcf7cf-and-rule ui-sortable-handle">
<span class="rule-part if-txt label">if</span>
<select class="rule-part if-field-select"></select>
<select class="rule-part operator">
<option value="equals" selected="">equals</option>
<option value="not equals">not equals</option>
<option value="equals (regex)">equals (regex)</option>
<option value="not equals (regex)">not equals (regex)</option>
<option value="greater than">greater than</option>
<option value="greater than or equals">greater than or equals</option>
<option value="less than">less than</option>
<option value="less than or equals">less than or equals</option>
<option value="is empty">is empty</option>
<option value="not empty">not empty</option>
<option value="function">function</option>
</select>
<input class="rule-part if-value" type="text" placeholder="value" value="" style="visibility: visible;">
<span class="and-button" style="height: 22px; line-height: 22px;">And</span>
<span title="delete rule" class="rule-part delete-button">remove</span>
</div>
</div>
</div>`);
wpcf7cf.$textView = jQuery('#wpcf7cf-settings-text').eq(0);
wpcf7cf.$textOnlyCheckbox = jQuery('#wpcf7cf-text-only-checkbox').eq(0);
wpcf7cf.$entriesUi = jQuery('#wpcf7cf-entries-ui').eq(0);
wpcf7cf.$addButton = jQuery('#wpcf7cf-add-button').eq(0);
wpcf7cf.$maxReachedWarning = jQuery('#wpcf7cf-a-lot-of-conditions').eq(0);
wpcf7cf.$formEditorForm = jQuery('#wpcf7-admin-form-element').eq(0);
wpcf7cf.$formEditor = jQuery('#wpcf7-form').eq(0);
// Smart Grid compat https://wordpress.org/support/topic/rule-sets-only-saving-when-in-text-mode/
if(jQuery('#cf7sg-editor').length>0) wpcf7cf.$formEditorForm = jQuery('form#post').eq(0);
wpcf7cf.regexCondition = /(?:show \[([^\]]*?)\]) if \[([^\]]*?)\] (?:(equals \(regex\)|not equals \(regex\)|equals|not equals|greater than or equals|greater than|less than or equals|less than|is empty|not empty|function)(?: \"(.*)\")?)/g;
wpcf7cf.regexConditionAnd = /and if \[([^\]]*?)\] (?:(equals \(regex\)|not equals \(regex\)|equals|not equals|greater than or equals|greater than|less than or equals|less than|is empty|not empty|function)(?: \"(.*)\")?)/g;
wpcf7cf.transformConditionsFromStringToArrayOfObjects = function(str) {
if (!str) str = '';
var conditionsAsStrings = str.split(/\r?\n(?=show)/);
var conditionsAsObjects = [];
for (var i = 0; i<conditionsAsStrings.length; i++) {
var lines = conditionsAsStrings[i].split(/\r?\n/);
wpcf7cf.regexCondition.lastIndex = 0;
var line1Match = wpcf7cf.regexCondition.exec(lines[0]);
if (line1Match != null) {
var conditionObject = {
then_field:line1Match[1],
and_rules: [
{
if_field: line1Match[2],
operator: line1Match[3],
if_value: line1Match[4],
},
],
};
for(var and_i = 1; and_i < lines.length; and_i++) {
wpcf7cf.regexConditionAnd.lastIndex = 0;
lineMatch = wpcf7cf.regexConditionAnd.exec(lines[and_i]);
if (lineMatch != null) {
conditionObject.and_rules.push({
if_field: lineMatch[1],
operator: lineMatch[2],
if_value: lineMatch[3],
});
}
}
conditionsAsObjects.push(conditionObject);
}
}
return conditionsAsObjects;
}
wpcf7cf.getnumberOfTextEntries = function () {
const textConditions = wpcf7cf.transformConditionsFromStringToArrayOfObjects(wpcf7cf.$textView.val());
return textConditions.length;
}
wpcf7cf.getnumberOfFieldEntries = function () {
return wpcf7cf.$entriesUi.find('.entry').length;
}
wpcf7cf.transformConditionsFromArrayOfObjectsToString = function(conditions) {
return conditions.map(function(condition){
var indent = ' '.repeat(condition.then_field.length + 4);
return `show [${condition.then_field}] `+condition.and_rules.map(function(rule, i){
return ( i>0 ? indent+'and ':'' ) + `if [${rule.if_field}] ${rule.operator} "${rule.if_value}"`
}).join('\n');
}).join('\n');
}
/**
* Tranform an array of conditions (Objects) to HTML fields
* @param Array conditions
* @returns jQuery
*/
wpcf7cf.transformConditionsFromArrayOfObjectsToFieldElements = function(conditions) {
if ( wpcf7cf.MAX_CONDITIONS < conditions.length ) {
jQuery('#wpcf7cf-entries').html('');
wpcf7cf.maybeDisableAddButton();
return;
}
var entries = [];
for (var c_i = 0; c_i<conditions.length; c_i++) {
var condition = conditions[c_i];
var id=0;
// setup then_field
var $entry = jQuery(wpcf7cf.template_for_condition_fields_without_and_rules);
jQuery('.then-field-select', $entry).val(condition.then_field).attr('value', condition.then_field );
for (var a_i = 0; a_i < condition.and_rules.length; a_i++) {
var and_rule = condition.and_rules[a_i];
$rule = jQuery(wpcf7cf.template_for_and_rule);
jQuery('.if-field-select', $rule).val(and_rule.if_field).attr('value', and_rule.if_field );
jQuery('.operator', $rule).val(and_rule.operator).attr('value', and_rule.operator );
jQuery('.if-value', $rule).val(and_rule.if_value).attr('value', and_rule.if_value );
jQuery('.wpcf7cf-and-rules', $entry).eq(0).append($rule);
}
entries.push($entry);
}
jQuery('#wpcf7cf-entries').html(entries);
update_entries();
}
wpcf7cf.maybeDisableAddButton = function() {
if (wpcf7cf.getnumberOfTextEntries() >= wpcf7cf.MAX_CONDITIONS && wpcf7cf.getnumberOfFieldEntries() == 0 ||
wpcf7cf.getnumberOfFieldEntries() >= wpcf7cf.MAX_CONDITIONS
) {
wpcf7cf.$addButton.hide();
wpcf7cf.$maxReachedWarning.show();
} else {
wpcf7cf.$addButton.show();
wpcf7cf.$maxReachedWarning.hide();
}
}
wpcf7cf.transformConditionsFromFieldsToArrayOfObjects = function($entries) {
if (!$entries) {
$entries = jQuery('#wpcf7cf-entries .entry');
}
var conditionsAsObjects = [];
$entries.each(function() {
var $entry = jQuery(this);
var then_field = $entry.find('.then-field-select').val() ?? '';
var conditionObject = {
then_field: then_field,
and_rules: [],
};
$entry.find('.wpcf7cf-and-rule').each(function(i) {
const $and_rule = jQuery(this);
conditionObject.and_rules.push({
operator : $and_rule.find('.operator').val() ?? '',
if_field : $and_rule.find('.if-field-select').val() ?? '',
if_value : $and_rule.find('.if-value').val() ?? '',
});
});
conditionsAsObjects.push(conditionObject);
});
return conditionsAsObjects;
}
wpcf7cf.copyTextToFields = function() {
var str = wpcf7cf.$textView.val();
var obj = wpcf7cf.transformConditionsFromStringToArrayOfObjects(str);
wpcf7cf.transformConditionsFromArrayOfObjectsToFieldElements(obj);
}
wpcf7cf.copyFieldsToText = function() {
var obj = wpcf7cf.transformConditionsFromFieldsToArrayOfObjects();
var str = wpcf7cf.transformConditionsFromArrayOfObjectsToString(obj);
wpcf7cf.$textView.val(str);
}
function add_condition_fields() {
$c = jQuery(wpcf7cf.template_for_condition_fields_with_one_and_rule)
$c.appendTo('#wpcf7cf-entries');
update_entries();
}
function update_entries() {
wpcf7cf.$if_values = jQuery('.if-value');
init_autocomplete();
wpcf7cf.$if_values.css({'visibility':'visible'});
wpcf7cf.$if_values.autocomplete( "disable" );
jQuery('#wpcf7cf-entries .wpcf7cf-and-rule').each(function() {
var $and_rule = jQuery(this);
var $operatorField = $and_rule.find('.operator').eq(0);
var operator = $operatorField.val() || 'equals';
if ($and_rule.find('.operator').eq(0).val() === 'is empty' || $and_rule.find('.operator').eq(0).val() === 'not empty') {
$and_rule.find('.if-value').eq(0).css({'visibility':'hidden'});
} else if (operator.endsWith('(regex)')) {
$and_rule.find('.if-value').eq(0).autocomplete( "enable" );
}
});
scale_and_button();
set_events();
wpcf7cf.maybeDisableAddButton();
}
function init_autocomplete() {
wpcf7cf.$if_values.autocomplete({
disabled: true,
source: function(request, response) {
var matcher = new RegExp(jQuery.ui.autocomplete.escapeRegex(request.term), "i");
response(jQuery.grep(regexes, function(value) {
return matcher.test(value.label || value.value || value) || matcher.test(value.desc);
}));
},
focus: function( event, ui ) {
jQuery( event.target ).val( ui.item.desc );
return false;
},
select: function( event, ui ) {
jQuery( event.target ).val( ui.item.desc );
return false;
},
open: function(e,ui) {
$el = jQuery(e.target);
var styledTerm = `<span class='ui-autocomplete-term'>${$el.val}</span>`;
jQuery('.ui-autocomplete').find('em').each(function() {
var me = jQuery(this);
me.html( me.text().replace($el.val(), styledTerm) );
});
},
minLength: 0
}).each(function() {
jQuery(this).autocomplete( "instance" )._renderItem = function( ul, item ) {
return jQuery("<li>")
.append("<div><em>" + item.label + "</em><br><em>" + item.desc + "</em></div>")
.appendTo(ul);
}
});
wpcf7cf.$if_values.on('focus', function() {
jQuery(this).autocomplete("search");
});
}
function set_events() { // called at the end of update_entries
jQuery('.wpcf7cf-and-rules').sortable();
jQuery('.and-button').off('click').click(function() {
$this = jQuery(this);
$andblock = $this.closest('.wpcf7cf-and-rule');
$andblocks_container = $this.closest('.wpcf7cf-and-rules');
next_index = $andblocks_container.data('next-index');
$andblocks_container.data('next-index',next_index+1);
var and_i = next_index;
clone_html = $andblock.get(0).outerHTML.replace(/wpcf7cf_options\[([0-9]*)\]\[and_rules\]\[([0-9]*)\]/g, 'wpcf7cf_options[$1][and_rules]['+and_i+']');
$andblock.after(clone_html);
//update_settings_textarea();
update_entries();
return false;
});
jQuery('.delete-button').off('click').click(function(){
$and_rule = jQuery(this).closest('.wpcf7cf-and-rule');
if ($and_rule.siblings().length > 0) {
$and_rule.remove();
} else {
$and_rule[0].closest('.entry').remove();
}
//update_settings_textarea();
update_entries();
return false;
});
jQuery('.operator').off('change').change(function() {
update_entries();
return false;
});
}
function scale_and_button() {
jQuery('.wpcf7cf-and-rule:first-child .and-button').each(function(){
$and_button = jQuery(this);
num_and_rules = $and_button.closest('.wpcf7cf-and-rule').siblings().length+1;
var height = (34*num_and_rules-12)+'px';
$and_button.css({'height':height,'line-height':height});
});
}
// ------------------------------------
// TOOGGLE UI MODE
// ------------------------------------
function setUiMode(is_text_only) {
if (is_text_only) {
wpcf7cf.currentMode = 'text';
wpcf7cf.$entriesUi.hide();
wpcf7cf.$textView.show();
if (wpcf7cf.getnumberOfFieldEntries() > 0) {
wpcf7cf.copyFieldsToText();
}
} else {
wpcf7cf.currentMode = 'normal';
wpcf7cf.$entriesUi.show();
wpcf7cf.$textView.hide();
wpcf7cf.copyTextToFields();
}
}
wpcf7cf.$textOnlyCheckbox.on('change', function() {
setUiMode(wpcf7cf.$textOnlyCheckbox.is(':checked'));
});
wpcf7cf.$formEditorForm.on('submit', function() {
if (wpcf7cf.currentMode == 'normal' && wpcf7cf.getnumberOfFieldEntries() > 0) {
wpcf7cf.copyFieldsToText();
}
});
// ------------------------------------
// CF7 TAG GENERATOR OVERRIDE
// ------------------------------------
if (_wpcf7 == null) { var _wpcf7 = wpcf7}; // wpcf7 4.8 fix
var old_compose = _wpcf7.taggen.compose;
// ...before overwriting the jQuery extension point
_wpcf7.taggen.compose = function(tagType, $form)
{
jQuery('#tag-generator-panel-group-style-hidden').val(jQuery('#tag-generator-panel-group-style').val());
// original behavior - use function.apply to preserve context
var ret = old_compose.apply(this, arguments);
//tagType = arguments[0];
//$form = arguments[1];
// START: code here will be executed after the _wpcf7.taggen.update function
if (tagType== 'group') ret += "[/group]";
if (tagType== 'repeater') ret += "[/repeater]";
// END
if (tagType== 'togglebutton') {
$val1 = jQuery('#tag-generator-panel-togglebutton-value-1');
$val2 = jQuery('#tag-generator-panel-togglebutton-value-2');
var val1 = $val1.val();
var val2 = $val2.val();
if (val1 == "") val1 = $val1.data('default');
if (val2 == "") val2 = $val2.data('default');
str_val = ' "'+val1+'" "'+val2+'"';
ret = ret.replace(']', str_val+']');
}
return ret;
};
// console.log('huh');
// jQuery( window ).on( 'beforeunload', function( event ) {
// wpcf7cf.copyFieldsToText();
// if (wpcf7cf.$textView.val() === wpcf7cf.$textView[0].defaultValue) {
// // jQuery('#wpcf7cf-entries-ui').remove();
// jQuery("#wpcf7cf-entries-ui :input").prop("disabled", true);
// }
// });
function scanFormTags(formCode) {
const fields = [...formCode.matchAll(/\[(?!group|step|repeater|submit)[^\] ]+ ([^\] ]+)/g)].map(e=>e[1]);
const groups = [...formCode.matchAll(/\[group ([^\] ]+)/g)].map(e=>e[1]);
return [ fields, groups ];
}
function updateAvailableGroupsAndFields() {
const formCode = wpcf7cf.$formEditor.val();
const [ fields, groups ] = scanFormTags(formCode);
jQuery('.then-field-select').each(function(){
const $this = jQuery(this);
updateSelectWithValues($this, groups, 'group');
});
jQuery('.if-field-select').each(function(){
const $this = jQuery(this);
updateSelectWithValues($this, fields, 'field');
});
$temp = jQuery(wpcf7cf.template_for_condition_fields_with_one_and_rule);
$temp.find('.then-field-select').eq(0).html(createOptionsHTML(groups, 'group'));
$temp.find('.if-field-select').eq(0).html(createOptionsHTML(fields, 'field'));
wpcf7cf.template_for_condition_fields_with_one_and_rule = $temp[0].outerHTML;
$temp.find('.wpcf7cf-and-rules').eq(0).html('');
wpcf7cf.template_for_condition_fields_without_and_rules = $temp[0].outerHTML;
$temp = jQuery(wpcf7cf.template_for_and_rule);
$temp.find('.if-field-select').eq(0).html(createOptionsHTML(fields, 'field'));
wpcf7cf.template_for_and_rule = $temp[0].outerHTML;
//wpcf7cf.template_for_and_rule = wpcf7cf.$newEntry.find('.wpcf7cf-and-rule')[0] ? wpcf7cf.$newEntry.find('.wpcf7cf-and-rule')[0].outerHTML : '';
}
function updateSelectWithValues($select, values, type) {
const originalValue = $select.val();
$select.html(createOptionsHTML(values, type, originalValue));
}
function createOptionsHTML(values, type, originalValue = '-1') {
return `<option value="-1" ${'-1' == originalValue ? 'selected' : ''}>-- Select ${type} --</option>`+values.map(value => `<option value="${value}" ${value == originalValue ? 'selected' : ''}>${value}</option>`).join('');
}
// update available groups and fields each time there is a change in the form code.
wpcf7cf.$formEditor.on('change', function() {
updateAvailableGroupsAndFields();
});
var regexes = [
{ label: wpcf7cf_options_0.regex_email_label, desc: wpcf7cf_options_0.regex_email },
{ label: wpcf7cf_options_0.regex_numeric_label, desc: wpcf7cf_options_0.regex_numeric },
{ label: wpcf7cf_options_0.regex_alphanumeric_label, desc: wpcf7cf_options_0.regex_alphanumeric },
{ label: wpcf7cf_options_0.regex_alphabetic_label, desc: wpcf7cf_options_0.regex_alphabetic },
{ label: wpcf7cf_options_0.regex_date_label, desc: wpcf7cf_options_0.regex_date },
{ label: wpcf7cf_options_0.regex_custom_1_label, desc: wpcf7cf_options_0.regex_custom_1 },
{ label: wpcf7cf_options_0.regex_custom_2_label, desc: wpcf7cf_options_0.regex_custom_2 },
{ label: wpcf7cf_options_0.regex_custom_3_label, desc: wpcf7cf_options_0.regex_custom_3 },
{ label: wpcf7cf_options_0.regex_custom_4_label, desc: wpcf7cf_options_0.regex_custom_4 },
{ label: wpcf7cf_options_0.regex_custom_5_label, desc: wpcf7cf_options_0.regex_custom_5 },
];
var i = regexes.length;
while (i--) {
if (null == regexes[i].label || null == regexes[i].desc || regexes[i].label == '' || regexes[i].desc == '') {
regexes.splice(i,1);
}
}
wpcf7cf.$addButton.click(function(){
add_condition_fields();
});
jQuery(document).on('ready', function() {
wpcf7cf.$if_values = jQuery('.if-value'); // gets updated now and then
// init HTML templates (will be updated immediatly by updateAvailableGroupsAndFields())
wpcf7cf.template_for_condition_fields_with_one_and_rule = wpcf7cf.$newEntry[0].outerHTML;
wpcf7cf.template_for_and_rule = wpcf7cf.$newEntry.find('.wpcf7cf-and-rule')[0] ? wpcf7cf.$newEntry.find('.wpcf7cf-and-rule')[0].outerHTML : '';
updateAvailableGroupsAndFields();
wpcf7cf.copyTextToFields();
wpcf7cf.maybeDisableAddButton();
jQuery('#wpcf7cf-entries').sortable();
setUiMode(wpcf7cf.$textOnlyCheckbox.is(':checked'));
})
}

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 116 KiB

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 118 KiB

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 120 KiB

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 114 KiB

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 120 KiB

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 117 KiB

View File

@@ -0,0 +1,292 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Global</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Global</h1>
<section>
<header>
<h2></h2>
</header>
<article>
<div class="container-overview">
<dl class="details">
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="repeaterAddSub"><span class="type-signature"></span>repeaterAddSub<span class="signature">($form, repeaterDataId)</span><span class="type-signature"></span></h4>
<div class="description">
<p>Append a new sub-entry to the repeater with the name <code>repeaterDataId</code> inside the form <code>$form</code></p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>$form</code></td>
<td class="type">
<span class="param-type">String</span>
|
<span class="param-type">JQuery</span>
</td>
<td class="description last"><p>JQuery object or css-selector representing the form</p></td>
</tr>
<tr>
<td class="name"><code>repeaterDataId</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last"><p><em>data-id</em> attribute of the repeater. Normally this is simply the name of the repeater. However, in case of a nested repeater you need to append the name with the correct suffix. For example <code>my-nested-repeater__1__3</code>. Hint (check the <code>data-id</code> attribute in the HTML code to find the correct suffix)</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="scripts_es6.js.html">scripts_es6.js</a>, <a href="scripts_es6.js.html#line1355">line 1355</a>
</li></ul></dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Namespaces</h3><ul><li><a href="wpcf7cf.html">wpcf7cf</a></li></ul><h3>Global</h3><ul><li><a href="global.html#repeaterAddSub">repeaterAddSub</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.5</a> on Mon Sep 07 2020 11:18:31 GMT+0200 (Central European Summer Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>

View File

@@ -0,0 +1,65 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Home</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Home</h1>
<h3> </h3>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Namespaces</h3><ul><li><a href="wpcf7cf.html">wpcf7cf</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Mon Nov 13 2023 02:00:25 GMT+0100 (GMT+01:00)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>

View File

@@ -0,0 +1,85 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Module: wpcf7cf</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Module: wpcf7cf</h1>
<section>
<header>
</header>
<article>
<div class="container-overview">
</div>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-wpcf7cf.html">wpcf7cf</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.5</a> on Mon Sep 07 2020 11:06:55 GMT+0200 (Central European Summer Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,25 @@
/*global document */
(() => {
const source = document.getElementsByClassName('prettyprint source linenums');
let i = 0;
let lineNumber = 0;
let lineId;
let lines;
let totalLines;
let anchorHash;
if (source && source[0]) {
anchorHash = document.location.hash.substring(1);
lines = source[0].getElementsByTagName('li');
totalLines = lines.length;
for (; i < totalLines; i++) {
lineNumber++;
lineId = `line${lineNumber}`;
lines[i].id = lineId;
if (lineId === anchorHash) {
lines[i].className += ' selected';
}
}
}
})();

View File

@@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@@ -0,0 +1,2 @@
PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\f\r ]+/,null," \t\r\n "]],[["str",/^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/,null],["str",/^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/,null],["lang-css-str",/^url\(([^"')]*)\)/i],["kwd",/^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],["com",
/^(?:<\!--|--\>)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#[\da-f]{3,6}/i],["pln",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],["pun",/^[^\s\w"']+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^"')]+/]]),["css-str"]);

View File

@@ -0,0 +1,28 @@
var q=null;window.PR_SHOULD_USE_CONTINUATION=!0;
(function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a=
[],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c<i;++c){var j=f[c];if(/\\[bdsw]/i.test(j))a.push(j);else{var j=m(j),d;c+2<i&&"-"===f[c+1]?(d=m(f[c+2]),c+=2):d=j;b.push([j,d]);d<65||j>122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;c<b.length;++c)i=b[c],i[0]<=j[1]+1?j[1]=Math.max(j[1],i[1]):f.push(j=i);b=["["];o&&b.push("^");b.push.apply(b,a);for(c=0;c<
f.length;++c)i=f[c],b.push(e(i[0])),i[1]>i[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c<b;++c){var j=f[c];j==="("?++i:"\\"===j.charAt(0)&&(j=+j.substring(1))&&j<=i&&(d[j]=-1)}for(c=1;c<d.length;++c)-1===d[c]&&(d[c]=++t);for(i=c=0;c<b;++c)j=f[c],j==="("?(++i,d[i]===void 0&&(f[c]="(?:")):"\\"===j.charAt(0)&&
(j=+j.substring(1))&&j<=i&&(f[c]="\\"+d[i]);for(i=c=0;c<b;++c)"^"===f[c]&&"^"!==f[c+1]&&(f[c]="");if(a.ignoreCase&&s)for(c=0;c<b;++c)j=f[c],a=j.charAt(0),j.length>=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p<d;++p){var g=a[p];if(g.ignoreCase)l=!0;else if(/[a-z]/i.test(g.source.replace(/\\u[\da-f]{4}|\\x[\da-f]{2}|\\[^UXux]/gi,""))){s=!0;l=!1;break}}for(var r=
{b:8,t:9,n:10,v:11,f:12,r:13},n=[],p=0,d=a.length;p<d;++p){g=a[p];if(g.global||g.multiline)throw Error(""+g);n.push("(?:"+y(g)+")")}return RegExp(n.join("|"),l?"gi":"g")}function M(a){function m(a){switch(a.nodeType){case 1:if(e.test(a.className))break;for(var g=a.firstChild;g;g=g.nextSibling)m(g);g=a.nodeName;if("BR"===g||"LI"===g)h[s]="\n",t[s<<1]=y++,t[s++<<1|1]=a;break;case 3:case 4:g=a.nodeValue,g.length&&(g=p?g.replace(/\r\n?/g,"\n"):g.replace(/[\t\n\r ]+/g," "),h[s]=g,t[s<<1]=y,y+=g.length,
t[s++<<1|1]=a)}}var e=/(?:^|\s)nocode(?:\s|$)/,h=[],y=0,t=[],s=0,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=document.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);m(a);return{a:h.join("").replace(/\n$/,""),c:t}}function B(a,m,e,h){m&&(a={a:m,d:a},e(a),h.push.apply(h,a.e))}function x(a,m){function e(a){for(var l=a.d,p=[l,"pln"],d=0,g=a.a.match(y)||[],r={},n=0,z=g.length;n<z;++n){var f=g[n],b=r[f],o=void 0,c;if(typeof b===
"string")c=!1;else{var i=h[f.charAt(0)];if(i)o=f.match(i[1]),b=i[0];else{for(c=0;c<t;++c)if(i=m[c],o=f.match(i[1])){b=i[0];break}o||(b="pln")}if((c=b.length>=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m),
l=[],p={},d=0,g=e.length;d<g;++d){var r=e[d],n=r[3];if(n)for(var k=n.length;--k>=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/,
q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/,
q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g,
"");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a),
a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e}
for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g<d.length;++g)e(d[g]);m===(m|0)&&d[0].setAttribute("value",
m);var r=s.createElement("OL");r.className="linenums";for(var n=Math.max(0,m-1|0)||0,g=0,z=d.length;g<z;++g)l=d[g],l.className="L"+(g+n)%10,l.firstChild||l.appendChild(s.createTextNode("\xa0")),r.appendChild(l);a.appendChild(r)}function k(a,m){for(var e=m.length;--e>=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*</.test(m)?"default-markup":"default-code";return A[a]}function E(a){var m=
a.g;try{var e=M(a.h),h=e.a;a.a=h;a.c=e.c;a.d=0;C(m,h)(a);var k=/\bMSIE\b/.test(navigator.userAgent),m=/\n/g,t=a.a,s=t.length,e=0,l=a.c,p=l.length,h=0,d=a.e,g=d.length,a=0;d[g]=s;var r,n;for(n=r=0;n<g;)d[n]!==d[n+2]?(d[r++]=d[n++],d[r++]=d[n++]):n+=2;g=r;for(n=r=0;n<g;){for(var z=d[n],f=d[n+1],b=n+2;b+2<=g&&d[b+1]===f;)b+=2;d[r++]=z;d[r++]=f;n=b}for(d.length=r;h<p;){var o=l[h+2]||s,c=d[a+2]||s,b=Math.min(o,c),i=l[h+1],j;if(i.nodeType!==1&&(j=t.substring(e,b))){k&&(j=j.replace(m,"\r"));i.nodeValue=
j;var u=i.ownerDocument,v=u.createElement("SPAN");v.className=d[a+1];var x=i.parentNode;x.replaceChild(v,i);v.appendChild(i);e<o&&(l[h+1]=i=u.createTextNode(t.substring(b,o)),x.insertBefore(i,v.nextSibling))}e=b;e>=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],
"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"],
H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],
J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+
I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^<?]+/],["dec",/^<!\w[^>]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),
["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css",
/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),
["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes",
hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p<h.length&&l.now()<e;p++){var n=h[p],k=n.className;if(k.indexOf("prettyprint")>=0){var k=k.match(g),f,b;if(b=
!k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p<h.length?setTimeout(m,
250):a&&a()}for(var e=[document.getElementsByTagName("pre"),document.getElementsByTagName("code"),document.getElementsByTagName("xmp")],h=[],k=0;k<e.length;++k)for(var t=0,s=e[k].length;t<s;++t)h.push(e[k][t]);var e=q,l=Date;l.now||(l={now:function(){return+new Date}});var p=0,d,g=/\blang(?:uage)?-([\w.]+)(?!\S)/;m()};window.PR={createSimpleLexer:x,registerLangHandler:k,sourceDecorator:u,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",
PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ"}})();

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,358 @@
@font-face {
font-family: 'Open Sans';
font-weight: normal;
font-style: normal;
src: url('../fonts/OpenSans-Regular-webfont.eot');
src:
local('Open Sans'),
local('OpenSans'),
url('../fonts/OpenSans-Regular-webfont.eot?#iefix') format('embedded-opentype'),
url('../fonts/OpenSans-Regular-webfont.woff') format('woff'),
url('../fonts/OpenSans-Regular-webfont.svg#open_sansregular') format('svg');
}
@font-face {
font-family: 'Open Sans Light';
font-weight: normal;
font-style: normal;
src: url('../fonts/OpenSans-Light-webfont.eot');
src:
local('Open Sans Light'),
local('OpenSans Light'),
url('../fonts/OpenSans-Light-webfont.eot?#iefix') format('embedded-opentype'),
url('../fonts/OpenSans-Light-webfont.woff') format('woff'),
url('../fonts/OpenSans-Light-webfont.svg#open_sanslight') format('svg');
}
html
{
overflow: auto;
background-color: #fff;
font-size: 14px;
}
body
{
font-family: 'Open Sans', sans-serif;
line-height: 1.5;
color: #4d4e53;
background-color: white;
}
a, a:visited, a:active {
color: #0095dd;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
header
{
display: block;
padding: 0px 4px;
}
tt, code, kbd, samp {
font-family: Consolas, Monaco, 'Andale Mono', monospace;
}
.class-description {
font-size: 130%;
line-height: 140%;
margin-bottom: 1em;
margin-top: 1em;
}
.class-description:empty {
margin: 0;
}
#main {
float: left;
width: 70%;
}
article dl {
margin-bottom: 40px;
}
article img {
max-width: 100%;
}
section
{
display: block;
background-color: #fff;
padding: 12px 24px;
border-bottom: 1px solid #ccc;
margin-right: 30px;
}
.variation {
display: none;
}
.signature-attributes {
font-size: 60%;
color: #aaa;
font-style: italic;
font-weight: lighter;
}
nav
{
display: block;
float: right;
margin-top: 28px;
width: 30%;
box-sizing: border-box;
border-left: 1px solid #ccc;
padding-left: 16px;
}
nav ul {
font-family: 'Lucida Grande', 'Lucida Sans Unicode', arial, sans-serif;
font-size: 100%;
line-height: 17px;
padding: 0;
margin: 0;
list-style-type: none;
}
nav ul a, nav ul a:visited, nav ul a:active {
font-family: Consolas, Monaco, 'Andale Mono', monospace;
line-height: 18px;
color: #4D4E53;
}
nav h3 {
margin-top: 12px;
}
nav li {
margin-top: 6px;
}
footer {
display: block;
padding: 6px;
margin-top: 12px;
font-style: italic;
font-size: 90%;
}
h1, h2, h3, h4 {
font-weight: 200;
margin: 0;
}
h1
{
font-family: 'Open Sans Light', sans-serif;
font-size: 48px;
letter-spacing: -2px;
margin: 12px 24px 20px;
}
h2, h3.subsection-title
{
font-size: 30px;
font-weight: 700;
letter-spacing: -1px;
margin-bottom: 12px;
}
h3
{
font-size: 24px;
letter-spacing: -0.5px;
margin-bottom: 12px;
}
h4
{
font-size: 18px;
letter-spacing: -0.33px;
margin-bottom: 12px;
color: #4d4e53;
}
h5, .container-overview .subsection-title
{
font-size: 120%;
font-weight: bold;
letter-spacing: -0.01em;
margin: 8px 0 3px 0;
}
h6
{
font-size: 100%;
letter-spacing: -0.01em;
margin: 6px 0 3px 0;
font-style: italic;
}
table
{
border-spacing: 0;
border: 0;
border-collapse: collapse;
}
td, th
{
border: 1px solid #ddd;
margin: 0px;
text-align: left;
vertical-align: top;
padding: 4px 6px;
display: table-cell;
}
thead tr
{
background-color: #ddd;
font-weight: bold;
}
th { border-right: 1px solid #aaa; }
tr > th:last-child { border-right: 1px solid #ddd; }
.ancestors, .attribs { color: #999; }
.ancestors a, .attribs a
{
color: #999 !important;
text-decoration: none;
}
.clear
{
clear: both;
}
.important
{
font-weight: bold;
color: #950B02;
}
.yes-def {
text-indent: -1000px;
}
.type-signature {
color: #aaa;
}
.name, .signature {
font-family: Consolas, Monaco, 'Andale Mono', monospace;
}
.details { margin-top: 14px; border-left: 2px solid #DDD; }
.details dt { width: 120px; float: left; padding-left: 10px; padding-top: 6px; }
.details dd { margin-left: 70px; }
.details ul { margin: 0; }
.details ul { list-style-type: none; }
.details li { margin-left: 30px; padding-top: 6px; }
.details pre.prettyprint { margin: 0 }
.details .object-value { padding-top: 0; }
.description {
margin-bottom: 1em;
margin-top: 1em;
}
.code-caption
{
font-style: italic;
font-size: 107%;
margin: 0;
}
.source
{
border: 1px solid #ddd;
width: 80%;
overflow: auto;
}
.prettyprint.source {
width: inherit;
}
.source code
{
font-size: 100%;
line-height: 18px;
display: block;
padding: 4px 12px;
margin: 0;
background-color: #fff;
color: #4D4E53;
}
.prettyprint code span.line
{
display: inline-block;
}
.prettyprint.linenums
{
padding-left: 70px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.prettyprint.linenums ol
{
padding-left: 0;
}
.prettyprint.linenums li
{
border-left: 3px #ddd solid;
}
.prettyprint.linenums li.selected,
.prettyprint.linenums li.selected *
{
background-color: lightyellow;
}
.prettyprint.linenums li *
{
-webkit-user-select: text;
-moz-user-select: text;
-ms-user-select: text;
user-select: text;
}
.params .name, .props .name, .name code {
color: #4D4E53;
font-family: Consolas, Monaco, 'Andale Mono', monospace;
font-size: 100%;
}
.params td.description > p:first-child,
.props td.description > p:first-child
{
margin-top: 0;
padding-top: 0;
}
.params td.description > p:last-child,
.props td.description > p:last-child
{
margin-bottom: 0;
padding-bottom: 0;
}
.disabled {
color: #454545;
}

View File

@@ -0,0 +1,111 @@
/* JSDoc prettify.js theme */
/* plain text */
.pln {
color: #000000;
font-weight: normal;
font-style: normal;
}
/* string content */
.str {
color: #006400;
font-weight: normal;
font-style: normal;
}
/* a keyword */
.kwd {
color: #000000;
font-weight: bold;
font-style: normal;
}
/* a comment */
.com {
font-weight: normal;
font-style: italic;
}
/* a type name */
.typ {
color: #000000;
font-weight: normal;
font-style: normal;
}
/* a literal value */
.lit {
color: #006400;
font-weight: normal;
font-style: normal;
}
/* punctuation */
.pun {
color: #000000;
font-weight: bold;
font-style: normal;
}
/* lisp open bracket */
.opn {
color: #000000;
font-weight: bold;
font-style: normal;
}
/* lisp close bracket */
.clo {
color: #000000;
font-weight: bold;
font-style: normal;
}
/* a markup tag name */
.tag {
color: #006400;
font-weight: normal;
font-style: normal;
}
/* a markup attribute name */
.atn {
color: #006400;
font-weight: normal;
font-style: normal;
}
/* a markup attribute value */
.atv {
color: #006400;
font-weight: normal;
font-style: normal;
}
/* a declaration */
.dec {
color: #000000;
font-weight: bold;
font-style: normal;
}
/* a variable name */
.var {
color: #000000;
font-weight: normal;
font-style: normal;
}
/* a function name */
.fun {
color: #000000;
font-weight: bold;
font-style: normal;
}
/* Specify class=linenums on a pre to get line numbering */
ol.linenums {
margin-top: 0;
margin-bottom: 0;
}

View File

@@ -0,0 +1,132 @@
/* Tomorrow Theme */
/* Original theme - https://github.com/chriskempson/tomorrow-theme */
/* Pretty printing styles. Used with prettify.js. */
/* SPAN elements with the classes below are added by prettyprint. */
/* plain text */
.pln {
color: #4d4d4c; }
@media screen {
/* string content */
.str {
color: #718c00; }
/* a keyword */
.kwd {
color: #8959a8; }
/* a comment */
.com {
color: #8e908c; }
/* a type name */
.typ {
color: #4271ae; }
/* a literal value */
.lit {
color: #f5871f; }
/* punctuation */
.pun {
color: #4d4d4c; }
/* lisp open bracket */
.opn {
color: #4d4d4c; }
/* lisp close bracket */
.clo {
color: #4d4d4c; }
/* a markup tag name */
.tag {
color: #c82829; }
/* a markup attribute name */
.atn {
color: #f5871f; }
/* a markup attribute value */
.atv {
color: #3e999f; }
/* a declaration */
.dec {
color: #f5871f; }
/* a variable name */
.var {
color: #c82829; }
/* a function name */
.fun {
color: #4271ae; } }
/* Use higher contrast and text-weight for printable form. */
@media print, projection {
.str {
color: #060; }
.kwd {
color: #006;
font-weight: bold; }
.com {
color: #600;
font-style: italic; }
.typ {
color: #404;
font-weight: bold; }
.lit {
color: #044; }
.pun, .opn, .clo {
color: #440; }
.tag {
color: #006;
font-weight: bold; }
.atn {
color: #404; }
.atv {
color: #060; } }
/* Style */
/*
pre.prettyprint {
background: white;
font-family: Consolas, Monaco, 'Andale Mono', monospace;
font-size: 12px;
line-height: 1.5;
border: 1px solid #ccc;
padding: 10px; }
*/
/* Specify class=linenums on a pre to get line numbering */
ol.linenums {
margin-top: 0;
margin-bottom: 0; }
/* IE indents via margin-left */
li.L0,
li.L1,
li.L2,
li.L3,
li.L4,
li.L5,
li.L6,
li.L7,
li.L8,
li.L9 {
/* */ }
/* Alternate shading for lines */
li.L1,
li.L3,
li.L5,
li.L7,
li.L9 {
/* */ }

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,337 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: wpcf7cfApi</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Class: wpcf7cfApi</h1>
<section>
<header>
<h2><span class="attribs"><span class="type-signature"></span></span>wpcf7cfApi<span class="signature">()</span><span class="type-signature"></span></h2>
<div class="class-description">public API</div>
</header>
<article>
<div class="container-overview">
<h2>Constructor</h2>
<h4 class="name" id="wpcf7cfApi"><span class="type-signature"></span>new wpcf7cfApi<span class="signature">()</span><span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="scripts_es6.js.html">scripts_es6.js</a>, <a href="scripts_es6.js.html#line1351">line 1351</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id=".repeaterAddSub"><span class="type-signature">(static) </span>repeaterAddSub<span class="signature">($form, repeaterDataId)</span><span class="type-signature"></span></h4>
<div class="description">
Append a new sub-entry to the repeater with the name `repeaterDataId` inside the form `$form`
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>$form</code></td>
<td class="type">
<span class="param-type">String</span>
|
<span class="param-type">JQuery</span>
</td>
<td class="description last">JQuery object or css-selector representing the form</td>
</tr>
<tr>
<td class="name"><code>repeaterDataId</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">*data-id* attribute of the repeater. Normally this is simply the name of the repeater. However, in case of a nested repeater you need to append the name with the correct suffix. For example `my-nested-repeater__1__3`. Hint (check the `data-id` attribute in the HTML code to find the correct suffix)</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="scripts_es6.js.html">scripts_es6.js</a>, <a href="scripts_es6.js.html#line1358">line 1358</a>
</li></ul></dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="wpcf7cfApi.html">wpcf7cfApi</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.5</a> on Mon Sep 07 2020 10:41:43 GMT+0200 (Central European Summer Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>

View File

@@ -0,0 +1,688 @@
=== Conditional Fields for Contact Form 7 ===
Contributors: Jules Colle
Donate link: https://shop.bdwm.be/contact-form-7-conditional-fields-pro/
Author: Jules Colle
Website: http://bdwm.be
Tags: wordpress, contact form 7, forms, conditional fields
Requires at least: 5.0
Tested up to: 6.2
Stable tag: 2.4.1
Requires PHP: 7.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Adds conditional logic to Contact Form 7.
== Description ==
This plugin adds conditional logic to [Contact Form 7](https://wordpress.org/plugins/contact-form-7/).
If you edit your CF7 form, you will see an additional tag called "Conditional fields Group". Everything you put between the start and end tag will be hidden by default.
After you have added the field group(s), go to the "Conditional fields" tab to create one or more conditions that will make the group(s) appear.
= How to use it =
[Follow this tutorial](https://conditional-fields-cf7.bdwm.be/conditional-fields-for-contact-form-7-tutorial/)
== Main features ==
= Support for required fields =
Required fields inside hidden groups will never trigger validation errors.
= Hide/show info in emails based on what groups are visible =
Conditional groups can now be added to the emails as well.
Just wrap the content with `[group-name] ... [/group-name]` tags.
= Groups can be nested =
Groups can be nested, both in the form and in the email
Example form:
`
[group group-1]
[group group-inside-1]
...
[/group]
[/group]`
Example email:
`
[group-1]
[group-inside-1]
...
[/group-inside-1]
[/group-1]`
= Advanced =
Advanced users can code up the conditions as plain text instead of using the select boxes, using the Text View.
== Need more power? ==
Just like WordPress, the power of Contact Form 7 lies in its [rich eco-system of extensions](https://conditional-fields-cf7.bdwm.be/list-of-all-contact-form-7-extensions/) that build on top of it. However, it can be difficult to find a set of complex extensions that work well together.
That's why I created Conditional Fields Pro. It adds some powerful features to Contact form 7 and guarantees that everything will run smoothly with Conditional Fields.
Pro features include:
* Repeatable fields (repeaters)
* Forms with multiple steps (multistep)
* Custom conditions with JavaScript functions
* Additional operators ( greater than, less than, .. )
[Get the PRO version of Conditional Fields for Contact Form 7!](https://conditional-fields-cf7.bdwm.be/contact-form-7-conditional-fields-pro/)
== Installation ==
Please follow the [standard installation procedure for WordPress plugins](http://codex.wordpress.org/Managing_Plugins#Installing_Plugins).
Follow [this tutorial](https://conditional-fields-cf7.bdwm.be/conditional-fields-for-contact-form-7-tutorial/) if you are not sure how to use the plugin.
== Frequently Asked Questions ==
= Email message is not showing the correct values / Wrong values are submitted =
<strong>All field names should be unique</strong>
Even though your fields might never show up at the same time, it is still important to realize that WPCF7CF will not remove the fields, it merely hides them. So all fields will be submitted when the form is sent. Because of this no two fields can have the same name.
Incorrect form (2 input elements having the same name "a"):
`
[group group-1][select a "1" "2" "3"][/group]
[group group-2][select a "1" "2" "3"][/group]
`
Correct form (all groups and fields have unique names):
`
[group group-1][select a "1" "2" "3"][/group]
[group group-2][select b "1" "2" "3"][/group]
`
= All my groups show up all the time and never get hidden. =
<strong>Reason #1: Javascript error</strong>
Check your browser console (F12) for any javascript errors. WPCF7CF loads it's scripts at the bottom of the HTML page, so if some javascript error gets triggered before that, the code will not be executed in most browsers.
Before reaching out to the support forum try to determine which plugin or theme is causing the problem, by gradually disabling plugins and changing theme.
<strong>Reason #2: wp_footer() isn't loaded</strong>
Check if your theme is calling the `wp_footer()` function. Typically this function will be called in your theme's footer.php file.
The conditional fields javascript code is loaded during wp_footer, so a call to this function is crucial. If there is no such call in your theme, go to your theme's footer.php file and add this code right before the closing `</body>` tag:
`&lt;?php wp_footer(); ?&gt;`
== Screenshots ==
1. Conditional fields in action
2. Defining rules to show/hide groups of input elements in the backend interface
== Upgrade Notice ==
= 2.0 =
Make sure to also update CF7 to the latest version! (Version 2.0 is only compatible with CF7 versions 5.4 and up. Version 1.9.16 is only compatible with CF7 version 5.3.*)
= 2.2 =
Make sure to also update CF7 to the latest version! (Version 2.2 is only compatible with CF7 versions 5.6 and up. Version 2.1.6 is only compatible with CF7 version 5.5.*)
= 2.2.10 =
Because the nature of the changes introduced in version 5.7 of Contact Form 7 you might need to make some manual changes to your forms and/or to your wp-config.php file. Please check the changelog. You could also wait for the release of version 5.7.1 of Contact Form 7. We hope the author will have address some of the issues by then.
= 2.2.11 =
Reverted autop-fix because it was causing addional errors. Bottom line: Make sure you are om Conditional Fields version 2.2.11 and CF7 version 5.6.4
== Changelog ==
= 2.4.1 (2023-11-16) =
* Patch minor access-control vulnerability reported by [patchstack](https://patchstack.com/database/vulnerability/cf7-conditional-fields/wordpress-conditional-fields-for-contact-form-7-plugin-2-4-broken-access-control-vulnerability?_a_id=110)
* Fully tested with Contact Form 7 version 5.8.3
= 2.4 (2023-11-13) =
* Removed webpack build. (This might cause JS errors in outdated browsers.)
* Fix admin validator Error. Thanks to [joostdekeijzer](https://github.com/pwkip/contact-form-7-conditional-fields/pull/113)
* Fix some jQuery code. Thanks to [hirasso](https://github.com/pwkip/contact-form-7-conditional-fields/pull/111)
= 2.3.12 (2023-10-27) =
* Fully tested with Contact Form 7 version 5.8.2
= 2.3.11 (2023-10-03) =
* Fully tested with Contact Form 7 version 5.8.1
= 2.3.10 (2023-08-07) =
* Fully tested with Contact Form 7 version 5.8
= 2.3.9 (2023-05-31) =
* Fully tested with Contact Form 7 version 5.7.7
= 2.3.8 (2023-04-23) =
* Fully tested with Contact Form 7 version 5.7.6
= 2.3.7 (2023-04-13) =
* PRO: Fix obscure bug with disable_on_hide. Disabled fields didn't get recognized after calling reset() on the form element or after adding a repeater, causing conditions relying on disabled fields to malfunction.
= 2.3.6 (2023-04-11) =
* Fully tested with WP version 6.2
= 2.3.5 (2023-03-24) =
* Fully tested with Contact Form 7 version 5.7.5.1
* Note: Previously it was possible to add a contact-form shortcode with only the title and not the ID. But since the last update of CF7 this seems to throw an error. Use the official shortcode provided by CF7 to prevent this.
= 2.3.4 (2023-02-19) =
* Fully tested with Contact Form 7 version 5.7.4
= 2.3.3 (2023-01-26) =
* PRO: Fix [summary]. CF7 5.7.3 introduced a tag-check function which [summary] did not pass.
* Fully tested with Contact Form 7 version 5.7.3
= 2.3.2 (2022-12-28) =
* Fully tested with Contact Form 7 version 5.7.2
= 2.3.1 (2022-12-17) =
* PRO: fix problem with line breaks in multistep forms.
= 2.3 (2022-12-16) =
* Fully tested with Contact Form 7 version 5.7.1
* PRO: Changed containing element for repeater and step controls from DIV to P. Otherwise CF7 would create additional P elements.
= 2.2.11 (2022-12-13) =
* DO NOT UPDATE TO CONTACT FORM VERSION 5.7!! At least wait for version 5.7.1 before updating
* Reverted autop-fix because it was causing addional errors.
* Reverted compatibility declaration to CF7 version 5.6.4
= 2.2.10 (2022-12-11) =
* Fully tested with Contact Form 7 version 5.7 (when WP_DEBUG is false). Note: due to some errors in Contact Form 7 version 5.7 you will need to make sure WP_DEBUG is set to false in your wp-config.php file.
* disable automatic insertion of paragraphs. Recent CF7 updates have changed the autop mechanism, causing too many problems with parsing the HTML code. If you still want to use autop (at your own risk) copy this code to your functions.php file: `add_filter( 'wpcf7_autop_or_not', '__return_true', 41, 0);`. Untill further notice Conditional Fields and Conditional Fields for Contact Form 7 will not use the automatic paragraph feature of CF7. Always try to write clean and valid HTML code. [GH issue 85](https://github.com/pwkip/contact-form-7-conditional-fields/issues/85)
= 2.2.9 (2022-10-19) =
* Fully tested with Contact Form 7 version 5.6.4
* Add action hook: [wpcf7cf_step_completed](https://conditional-fields-cf7.bdwm.be/wpcf7cf_step_completed/)
= 2.2.8 (2022-10-14) =
* Fix acceptance field bug
= 2.2.7 (2022-10-14) =
* Remove unwanted whitespace between closing and opening group tags in mail messages.
* Fix problems with acceptance fields [More info](https://conditional-fields-cf7.bdwm.be/acceptance/)
* Redesign of [form tester](https://conditional-fields-cf7.bdwm.be/form-tester/)
= 2.2.6 (2022-09-08) =
* PRO: Fix issues with validation in nested repeaters [GH issue 92](https://github.com/pwkip/contact-form-7-conditional-fields/issues/92)
* Fix error with optional file field in hidden group [GH issue 92](https://github.com/pwkip/contact-form-7-conditional-fields/issues/92)
= 2.2.5 (2022-09-04) =
* PRO: Fix bug with togglebutton
= 2.2.4 (2022-09-01) =
* Fully tested with Contact Form 7 version 5.6.3
* JS code refactoring
* Allow adding class names to group. For example: [group g class:my-class][/group]
= 2.2.3 (2022-08-10) =
* Fully tested with Contact Form 7 version 5.6.2
* [Fix](https://wordpress.org/support/topic/only-textmode-with-smartgrid-plugin/#post-15895061) for smartgrid plugin
* Some code refactoring
= 2.2.2 (2022-08-07) =
* Performance improvements
= 2.2.1 (2022-07-21) =
* Fully tested with Contact Form 7 version 5.6.1
= 2.2 (2022-06-17) =
* Make compatibile with Contact Form 7 version 5.6
= 2.1.6 (2022-06-07) =
* Fix bug: text view cleared after making a change to form code when there are more than 50 conditions.
= 2.1.5 (2022-05-22) =
* Fully tested with Contact Form 7 version 5.5.6.1
= 2.1.4 (2022-05-16) =
* It's no longer needed to save the form before adding conditions. Available groups are updated instantaneously after adding/changing them in the form editor.
* Fix problems when group is named "children" [GH issue 74](https://github.com/pwkip/contact-form-7-conditional-fields/issues/74)
* Fix problems with unsaved changes notice [GH issue 91](https://github.com/pwkip/contact-form-7-conditional-fields/issues/91)
* Tested up to WP 6.0
= 2.1.3 (2022-04-18) =
* check for user_cap 'wpcf7_edit_contact_forms' instead of 'wpcf7_edit_contact_form' in several places. Thanks, [@paybox](https://wordpress.org/support/topic/some-notices-appearing-fix-suggested/)!
* PRO multistep: make "Next step" and "Previous step" buttons translatable by third party plugins like wpml and loco translate.
* PRO multistep: show spinner while validating a step.
* PRO Fix additional disable_on_hide bug with multistep [GH issue 87-4](https://github.com/pwkip/contact-form-7-conditional-fields/issues/87)
* Replace all occurences of text domain 'contact-form-7' with 'cf7-conditional-fields'
= 2.1.2 (2022-02-23) =
* Fully tested with Contact Form 7 version 5.5.6
= 2.1.1 (2022-02-14) =
* Fully tested with Contact Form 7 version 5.5.5
* Make scroll to success message less annoying. [GH Issue 90](https://github.com/pwkip/contact-form-7-conditional-fields/issues/90)
* Add extra check to make sure that scroll to success message only happens when the e-mail is sent. [GH Issue 90](https://github.com/pwkip/contact-form-7-conditional-fields/issues/90)
* PRO: fix disable_on_hide bugs. [GH sssue 87](https://github.com/pwkip/contact-form-7-conditional-fields/issues/87)
= 2.1 (2022-01-27) =
* Tested up to wp 5.9
* Scroll success message into view after successful form submission. [GH Issue 90](https://github.com/pwkip/contact-form-7-conditional-fields/issues/90)
* Small changes [GH PR 86](https://github.com/pwkip/contact-form-7-conditional-fields/pull/86)
* Make 'change' event bubble up [GH PR 88](https://github.com/pwkip/contact-form-7-conditional-fields/pull/88)
= 2.0.9 (2022-01-20) =
* Fully tested with Contact Form 7 version 5.5.4
= 2.0.8 (2021-11-28) =
* Check how code changes in CF7 related to `wpcf7_contact_form_properties` impact the plugin, and update TODO comments accordingly.
* Fully tested with Contact Form 7 version 5.5.3
* Write additional tests for forms loaded via AJAX
* only show compatibility notices to users with the update_plugins capabilities
= 2.0.7 (2021-10-26) =
* Fully tested with Contact Form 7 version 5.5.2 (and also make the warning message disappear if all plugins are up to date)
= 2.0.6 (2021-10-26) =
* Fully tested with Contact Form 7 version 5.5.2
= 2.0.5 (2021-10-13) =
* Fully tested with Contact Form 7 version 5.5.1
= 2.0.4 (2021-07-19) =
* Fix issue with required file fields
* Fully tested with Contact Form 7 version 5.4.2
= 2.0.3 (2021-05-02) =
* Fully tested with Contact Form 7 version 5.4.1
* (dev note: fixed automated tests)
= 2.0.2 (2021-04-06) =
* Fix bug: third-party required fields not triggering validation. Thanks [@dedotombo](https://wordpress.org/support/topic/bugfix-skip_validation_for_hidden_fields-issue/)!
= 2.0.1 (2021-03-31) =
* Force height:auto on groups. (Fixes regression errors with groups inside repeaters)
* Allow more funky characters as conditional fields values (there was a problem with less than sign <)
* Fix bug with hidden required file and multifile fields causing validation errors
* Implemented extra tests so these errors cannot reoccur in future updates.
= 2.0 (2021-03-29) =
* WARNING! 2.0 requires at least Contact Form 7 version 5.4 to work!
* Make plugin compatible with CF7 5.4
* Modify wpcf7cf_generate_summary function, so it can be used without $_POST
* fix animaton when showing group
= 1.9.16 (2021-03-09) =
* Make notice dismissable
= 1.9.15 (2021-03-03) =
* PRO: add [disable_on_hide](https://conditional-fields-cf7.bdwm.be/disable_on_hide/) attribute, which allows using multiple fields with the same name.
* Make plugin translatable. Big thanks to Yordan Soares for the [PR](https://github.com/pwkip/contact-form-7-conditional-fields/pull/73)
* Fix [PHP Error if all mails are disabled](https://github.com/pwkip/contact-form-7-conditional-fields/issues/68)
* PRO: Fix [rename $settings to $wpcf7cf_settings](https://github.com/pwkip/contact-form-7-conditional-fields/issues/75)
* Compatibility with [CF7 Smart-grid layout plugin](https://wordpress.org/support/topic/rule-sets-only-saving-when-in-text-mode/)
* Added global variable WPCF7CF_CF7_MAX_VERSION to indicate latest version of CF7 that was succesfully tested with this plugin.
* Show notice in admin if the current CF7 version is anything other than WPCF7CF_CF7_MAX_VERSION
= 1.9.14 (2020-10-03) =
* PRO:Repeater: Hide Remove button initially when repeater has min:0
* PRO:Multistep: Disable Next button while validating step.
* IE11 compat: Fix classList bug (occured in IE11 if form contained SVG elements)
= 1.9.13 (2020-09-28) =
* IE11 compatibility: Add Array.from polyfill
= 1.9.12 (2020-09-24) =
* PRO:Multistep: add new event 'wpcf7cf_step_invalid', triggered after step validation failed. [Example usage](https://conditional-fields-cf7.bdwm.be/multistep-automatically-scroll-to-the-first-invalid-field/)
* PRO:Multifile: Fix bug where multifle* was not sending attachments
= 1.9.11 (2020-09-07) =
* PRO:Repeater: Fix bug [group inside repeater not visible when shown by default #64](https://github.com/pwkip/contact-form-7-conditional-fields/issues/64)
* PRO:Multifile: Add new tag: [multifile]. Allows to upload multiple files at once.
* PRO:Repeater: Fix bug that occured when removing sub-repeater before the animation of the previous removal was finished.
* PRO:Repeater: Introduce global JS API function [wpcf7cf.repeaterAddSub](https://conditional-fields-cf7.bdwm.be/docs/javascript-api/wpcf7cf-repeateraddsub/)
* PRO:Repeater: Introduce global JS API function [wpcf7cf.repeaterAddSubAtIndex](https://conditional-fields-cf7.bdwm.be/docs/javascript-api/wpcf7cf-repeateraddsubatindex/)
* PRO:Repeater: Introduce global JS API function [wpcf7cf.repeaterRemoveSub](https://conditional-fields-cf7.bdwm.be/docs/javascript-api/wpcf7cf-repeaterremovesub/)
* PRO:Repeater: Introduce global JS API function [wpcf7cf.repeaterRemoveSubAtIndex](https://conditional-fields-cf7.bdwm.be/docs/javascript-api/wpcf7cf-repeaterremovesubatindex/)
* PRO:Multistep: Introduce global JS API function [wpcf7cf.multistepMoveToStep](https://conditional-fields-cf7.bdwm.be/docs/javascript-api/multistepmovetostep/)
* PRO:Multistep: Introduce global JS API function [wpcf7cf.multistepMoveToStepWithValidation](https://conditional-fields-cf7.bdwm.be/docs/javascript-api/multistepmovetostepwithvalidation/)
= 1.9.10 (2020-08-19) =
* PRO: Fix multistep bug: general error message does not appear if step validation fails
= 1.9.9 (2020-07-29) =
* Fix bug when saving conditions from Text View
* Tested with WP 5.5
= 1.9.8 (2020-07-20) =
* Make sure all posted data is analyzed after submitting (part of) a form. A recent update of CF7 stripped away some information, resulting in PHP Notices.
= 1.9.7 (2020-07-07) =
* fix IE11 compatibility
= 1.9.6 (2020-07-04) =
* PRO: Fixed bug: checkboxes and multiselect validation not working inside repeater
= 1.9.5 (2020-07-01) =
* PRO: Fixed bug: multistep forms interference with other forms after calling wpcf7cf.initForm()
* PRO: Fixed bug: function operator no longer working.
= 1.9.4 (2020-06-23) =
* Fixed bug: JS error when conditonal fields settings where not saved manually by the user.
= 1.9.3 (2020-06-21) =
* Ignore conditions where group or field name does not exist, instead of throwing an error
* Get rid of PHP notice related to new settings
* Something went wrong with SVN commit 1.9.1 and 1.9.2 (so although these version might show up, it's not really a valid version)
= 1.9 (2020-06-21) =
* Performance improvements
* Added extra setting: "Conditional Fields UI". If you have a lot of conditions, set this to "Text mode" for better performance in the admin interface.
* Improved styling on Conditional Fields Settings page
* Improved [docs](https://conditional-fields-cf7.bdwm.be/)
* Improved the [form tester](https://conditional-fields-cf7.bdwm.be/form-tester/)
* PRO: Multistep bug that was causing checkboxes and multiselect to not trigger validation errors
* PRO: Summary added support for files, checkboxes and multiselect
* Added test to ensure that normal view entries are always converted to text view correctly
= 1.8.7 (2020-06-01) =
* PRO: Change auto-update mechanism
* Some minor JS refactoring
* Improved on some edge cases with `equals ""` and `not equals ""`
* Improved test suites.
= 1.8.6 (2020-04-18) =
* Fixed: accidentally packed the entire jQuery library in scripts.js
* Cleaned up some console.logs that was still hanging around in the code.
= 1.8.5 (2020-04-17) =
* Tested with WP 5.4
* fix multiselect
* fix required file field inside mutistep
* allow group names to contain `.` and `:` (https://github.com/pwkip/contact-form-7-conditional-fields/issues/46)
* fix possible conflicts with require_once 'init.php' (https://wordpress.org/support/topic/conflict-with-theme-because-of-require_once/)
* Created some unit tests and integration tests, so hopefully no more regression bugs from now on! (next step: automated CI before publish)
* Got rid of warnings and notices when creating a new form.
* Fix small clear_on_hide bug with select field (https://github.com/pwkip/contact-form-7-conditional-fields/issues/51)
* PRO: fix "not empty" when using first_as_label in select field. (closes guthub issue #48)
* PRO: fix error with nested repeater buttons text
* PRO: new version of plugin_update_checker, compatible with PHP 7.3+
= 1.8.4 (2020-03-05) =
* PRO: Multistep: Improve autoscroll behavior (Tried to make it smoother and less annoying)
* PRO: Multistep: Add wpcf7-not-valid class to input fields as needed after step-validation. Removed some other useless classes.
= 1.8.3 (2020-03-01) =
* Fix JS error on submit (reported by [@wasi7186](https://wordpress.org/support/topic/js-uncaught-typeerror-when-form-is-submitted/))
* PRO multistep: On the last step of a multistep form, instead of cloning and hiding the submit button, we now simply move it to the next-step-container. This solves a compatibility issue with a third party recaptcha plugin (and probably some other plugins too)
= 1.8.2 (2020-02-27) =
* Small patch. Add a check in the ajaxComplete event, to make sure xhr.responseJSON is not null or undefined. (this caused a JS error on some websites)
= 1.8.1 (2020-02-23) =
* PRO: Bring form in initial state after submit, including going back to first step of multistep and resetting the initial number of sub-repeaters in each repeater.
* PRO: New field: [[summary]](https://conditional-fields-cf7.bdwm.be/summary/)
* PRO: Make form submission trigger next step (if not on last step)
* PRO: Multistep: automatically scroll to top of form after moving to a different step.
* PRO: Multistep: Replace h3 tag with div as step-title.
* PRO: Made some small changes to the default multistep styles, for basic mobile friendly behaviour.
* PRO: Make multistep compatibility with cf7-image-captcha plugin
= 1.8 (2020-02-03) =
* WPML compatibility: Force conditions to be an array. [link](https://wordpress.org/support/topic/wpml-conditional-fields-not-working-on-translations/#post-12390827)
= 1.7.9 (2020-01-22) =
* PRO (01-02-20) Added quick fix for problem with [_format_date "d m Y"] inside repeater. [link](https://github.com/pwkip/contact-form-7-conditional-fields/issues/38)
* (01-22-20) Fixed Ajax by adding global wpcf7cf variable to window.
* Changed min PHP version to 5.6 (might still be compatible with 5.4, but I suspect some edge case errors with older versions of PHP)
= 1.7.8 (2019-11-26) =
* Updated/added Javascript events for groups, repeaters and multistep + added [documentation](https://conditional-fields-cf7.bdwm.be/docs/examples/javascript-events/)
* Fixed bug where using invalid regex as a value would give a JS error [link](https://wordpress.org/support/topic/star-ratings-6/)
* PRO Multistep: Added attribute to multistep `data-current_step` which holds the current step index. (can be used as css selector like this: `div[data-current_step=1]`)
* PRO Repeater: The string `{{your-repeater_index}}` inside a repeater called `your-repeater` will be replaced with the index of the current sub repeater. [Check out the updated example](https://conditional-fields-cf7.bdwm.be/repeater/)
= 1.7.7 (2019-11-05) =
* PRO: Fix problem with parsing the "function" operator
= 1.7.6 (2019-11-01) =
* Fixed small compatibility problem with CF7 Smart Grid [link](https://wordpress.org/support/topic/problem-on-save-form-when-the-active-tabs-are-not-conditional-form/#post-12085173)
* Fixed some more porblems with parsing conditions (regex changes)
* Got rid of screen_icon notice on CF settings page
= 1.7.5 (2019-10-31) =
* Fixed bug in admin where settings got cleared if using some operators (mostly PRO operators)
= 1.7.4 (2019-10-29) =
* PRO: made repeater (80%) compatible with material-design-for-contact-form-7
* PRO: made exclusive checkbox work with repeater fields
* PRO: trigger events when a repeater adds fields: 'wpcf7cf_repeater_added' - and when a repeater removes fields: 'wpcf7cf_repeater_removed'. Can be called with `$('form').on('wpcf7cf_repeater_removed', function() { /*...*/ })`
* PRO: fixed bug with mutistep (formn did not work correctly if there were multiple forms on one page).
= 1.7.3 (2019-10-24) =
* removed @babel/polyfill. All seems to be working fine without it in IE11. JS file is now back to 25kb instead of 100kb.
= 1.7.2 (2019-10-24) =
* Bug fix: new javascript files where throwing errors. Should be okay now. (Also included JS source map for easier debugging)
= 1.7.1 (2019-10-23) =
* PRO: Added basic support for multistep. No options available yet. You can insert [step] tags inside your code. [More info](https://conditional-fields-cf7.bdwm.be/multistep/)
* Set up an NPM dev environment with babel and webpack. This means all the client side JS code will look super ugly, and it's also more bytes. But the plus side is that the plugin should also work fine in older browsers now.
* Tested with WP version 5.3
= 1.7 (2019-10-18) =
* code rewrite. Made code more testable by focusing more on a functional approach. Not completely finished yet, but getting there.
* FIXED clear_on_hide not working for multi select [github issue 35](https://github.com/pwkip/contact-form-7-conditional-fields/issues/35)
* PRO: FIXED [github issue 34](https://github.com/pwkip/contact-form-7-conditional-fields/issues/34) - A real nest fest is now possible. You can put groups inside repeaters inside repeaters inside groups ...
* FIXED make clear_on_hide restore initial values instead of clearing [github issue 31](https://github.com/pwkip/contact-form-7-conditional-fields/issues/31)
* WP-admin: Renamed "Import/Export" to "Text view". Conditions specified in the input fields are now semi-automatically synced with the text view.
* Internal change: When saving conditions, instead of posting all the input fields, the input fields are added to the "text view" textarea, and only the textarea will be sent. This is to prevent issues with PHP max_input_vars
= 1.6.5 (2019-10-15) =
* Patched a minor security issue. From now on, only users with the 'wpcf7_edit_contact_form' capability will be able to reset the Conditional Fields settings to their defaults. Big thanks to Chloe from Wordfence for pointing this out!
* Tested the plugin with WP version 5.2.4
= 1.6.4 (2019-07-04) =
* PRO: Repeater: Fixed invalid HTML for the remove button
* Free: Initialize form.$groups as a new jQuery object instead of an empty array, in order to prevent exotic bugs in case $groups aren't loaded by the time form.displayFields() is called. (https://wordpress.org/support/topic/typeerror-cannot-read-property-addclass-of-undefined-at-wpcf7cfform/)
= 1.6.3 (2019-07-04) =
* Removed the word "Pro" from the title in the free plugin
= 1.6.2 (2019-06-25) =
* Small changes to tag generator buttons
* Multistep bug fix. All group conditions are evaluated a second time after the page has fully loaded.
* PRO: added new operator 'function', allowing you to write custom javascript functions to determine whether or not a group should be shown. [link](https://conditional-fields-cf7.bdwm.be/advanced-conditional-logic-with-custom-javascript-functions/)
* PRO: fix bug with < (less than) operator
= 1.6.1 (2019-06-03) =
* JS refactoring and small compatibility fix after code rewrite.
* FREE: Added "Get PRO" button under Contact > Conditional Fields
= 1.6 (2019-06-01) =
* JS code rewrite
* PRO: allow groups inside repeater
* PRO: make plugin ready for PRO release.
= 1.5.5 (2019-05-20) =
* Fixed and explained how to disable loading of the styles and scripts and only enable it on certain pages. [More info](https://conditional-fields-cf7.bdwm.be/docs/faq/can-i-load-js-and-css-only-when-necessary/)
* Made sure default settings get set after activating plugin, without the need to visit the Contact > Conditional Fields page first.
* PRO: extended the repeater with min and max paramaters and the possibility to change the add and remove buttons texts
* PRO: enabling the pro plugin will show a notification to disable the free plugin, instead of throwing a PHP error.
= 1.5.4 (2019-05-06) =
* Make sure scripts get loaded late enough (wp_enqueue_scripts priority set to 20), because there was a problem with multistep where the multistep script was changing a value after the cf script ran. https://wordpress.org/support/topic/1-5-x-not-expanding-selected-hidden-groups-with-multi-step-on-previous-page/
= 1.5.3 (2019-05-03) =
* Refix the fix from version 1.4.3 that got unfixed in version 1.5 somehow 🙄
= 1.5.2 (2019-05-03) =
* by reverting changes in 1.5.1, the possibility to load forms via AJAX was destroyed. So, from now on the wpcf7cf scripts will be loaded in the 'wp_enqueue_scripts' hook. Analogous with the WPCF7_LOAD_JS constant, a new constant is defined called WPCF7CF_LOAD_JS wich is set to true by default.
= 1.5.1 (2019-05-02) =
* revert changes: enqueue scripts in 'wpcf7_contact_form' hook instead of 'wpcf7_enqueue_scripts', because loading it in the latter would cause problems with plugins that disable WPCF7_LOAD_JS (like for example contact-form-7-paypal-add-on).
= 1.5 (2019-04-21) =
* Make it possible to load forms with AJAX. [fixed github issue 25](https://github.com/pwkip/contact-form-7-conditional-fields/issues/25). [updated docs](https://conditional-fields-cf7.bdwm.be/docs/faq/how-to-initialize-the-conditional-logic-after-an-ajax-call/)
* Massive code reorganization in scripts.js
* Fixed bug that could appear after removing an AND condition.
* solve WPCF7_ADMIN_READ_WRITE_CAPABILITY - https://github.com/pwkip/contact-form-7-conditional-fields/pull/16
* disable part of the faulty remove_hidden_post_data function. - https://github.com/pwkip/contact-form-7-conditional-fields/pull/17
* Fix "Dismiss notice" on Conditional Fields Settings page
* use the "wpcf7_before_send_mail" hook instead of "wpcf7_mail_components" to hide mail groups. The wpcf7_before_send_mail hook is called earlier, so it allows to also hide groups in the attachment field and in messages.
* Allow conditional group tags in success and error messages. https://github.com/pwkip/contact-form-7-conditional-fields/issues/23
* duplicating a form will also duplicate conditions https://github.com/pwkip/contact-form-7-conditional-fields/issues/28
= 1.4.3 (2019-04-12) =
* Really fix clear_on_hide problem (https://wordpress.org/support/topic/clear_on_hide-still-not-working-right-after-1-4-2-update/)
= 1.4.2 (2019-04-10) =
* Disabled mailbox syntax errors if there are group tags present. (this is overkill, and should be changed if the necassary hooks become available) https://wordpress.org/support/topic/filter-detect_invalid_mailbox_syntax/
* Checked issue: https://github.com/pwkip/contact-form-7-conditional-fields/issues/26 (nothing changed, but turns out to be working fine)
* Fixed issue where mail_2 added extra lines in the email message. https://github.com/pwkip/contact-form-7-conditional-fields/issues/30
* Made the clear_on_hide property a bit more useful (https://github.com/pwkip/contact-form-7-conditional-fields/issues/27)
* Got rid of warning in PHP 7 (https://wordpress.org/support/topic/compatibility-warning-message-regarding-wpcf7_admin_read_write_capability/)
* Fixed some javascript errors that appeared on non-CF7CF subpages of CF7
* Tested WP version 5.1.1
= 1.4.1 (2018-08-21) =
* Fixed some CSS issues (https://wordpress.org/support/topic/crash-view-admin-the-list-of-posts-entry/)
* Dropped support for PHP version 5.2, now PHP 5.3+ is required to run the plugin. Let's push things forward!
* Added conditional group support to mail attachments field (https://github.com/pwkip/contact-form-7-conditional-fields/issues/22)
* Added repeater field to PRO version.
= 1.4 (2018-08-15) =
* Added basic drag and drop functionality to the back-end so conditional rules can be rearranged.
* Added possibility to create inline groups by adding the option inline. Example: `[group my-group inline] ... [/group]`
* Added property clear_on_hide to clear all fields within a group the moment the group gets hidden. Example: `[group my-group clear_on_hide] ... [/group]`
* Added AND conditions and added a bunch of other options in the PRO version (should be released very soon now)
* Bug fix thanks to Aurovrata Venet (@aurovrata) https://wordpress.org/support/topic/bug-plugin-overwrite-cf7-hidden-fields/
* Bug fix thanks to 972 creative (@toddedelman) https://wordpress.org/support/topic/conditional-fields-not-opening-using-radio-buttons/#post-10442923
= 1.3.4 =
* small fix (https://wordpress.org/support/topic/wpcf7_contactform-object-is-no-longer-accessible/)
= 1.3.3 =
* Changes tested with WP 4.7.5 and CF7 4.8
* Changed the inner mechanics a bit to make the plugin more edge-case proof and prepare for future ajax support
* Fix problems introduced by CF7 4.8 update
* Because the CF7 author, Takayuki Miyoshi, decided to get rid of the 'form-pre-serialize' javascript event, the hidden fields containing data about which groups are shown/hidden will now be updated when the form is loaded and each time a form value changes. This might make the plugin slightly slower, but it is the only solution I found so far.
* Small bug fix (https://wordpress.org/support/topic/php-depreciated-warning/#post-9151404)
= 1.3.2 =
* Removed a piece of code that was trying to load a non existing stylesheet
* Updated FAQ
* Code rearangement and additions for the upcomming Conditional Fields Pro plugin
= 1.3.1 =
* Fixed bug in 1.3 that broke everything
= 1.3 =
* Fixed small bug with integration with Contact Form 7 Multi-Step Forms
* Also trigger hiding/showing of groups while typing or pasting text in input fields
* Added support for input type="reset"
* Added animations
* Added settings page to wp-admin: Contact > Conditional Fields
= 1.2.3 =
* Make plugin compatible with CF7 Multi Step by NinjaTeam https://wordpress.org/plugins/cf7-multi-step/
* Improve compatibility with Signature Addon some more.
= 1.2.2 =
* Fix critical bug that was present in version 1.2 and 1.2.1
= 1.2.1 =
* Improve compatibility with <a href="https://wordpress.org/plugins/contact-form-7-signature-addon/">Contact Form 7 Signature Addon</a>: now allowing multiple hidden signature fields.
= 1.2 =
* Made compatible with <a href="https://wordpress.org/plugins/contact-form-7-multi-step-module/">Contact Form 7 Multi-Step Forms</a>
* Small bug fix by Manual from advantia.net: now only considering fields which are strictly inside hidden group tags with form submit. Important in some edge cases where form elements get hidden by other mechanisms, i.e. tabbed forms.
* Started work on WPCF7CF Pro, made some structural code modifications so the free plugin can function as the base for both plugins.
* Removed some debug code
* Updated readme file
= 1.1 =
* Added import feature
* Added support for nested groups in email
* Tested on WP version 4.7.2 with Contact Form 7 version 4.6.1
= 1.0 =
* I feel that at this point the plugin is stable enough in most cases, so it's about time to take it out of beta :)
* Update JS en CSS version numbers
* Fix PHP warning with forms that are not using conditional fields (https://wordpress.org/support/topic/conditional-formatting-error/)
* Tested on WP 4.7.1
= 0.2.9 =
* Re-added wpcf7_add_shortcode() function if wpcf7_add_form_tag() is not found, because some people claimed to get a "function not found" error for the wpcf7_add_form_tag function with the latest version of CF7 installed. (https://wordpress.org/support/topic/activation-issue-5/ and https://wordpress.org/support/topic/http-500-unable-to-handle-request-error-after-update/)
* Fixed some PHP notices (https://wordpress.org/support/topic/undefined-index-error-in-ajax-response/)
* Attempted to fix error with the CF7 success page redirects plugin (https://wordpress.org/support/topic/warning-invalid-argument-error-for-forms-without-conditional-fields/)
= 0.2.8 =
* forgot to update version number in 0.2.7, so changing version to 0.2.8 now.
= 0.2.7 =
* Added support for conditional fields in the email (2) field
* Got rid of some PHP warnings
* Saving a form only once, directly after adding or removing conditions, caused conditional logic not to work. This is fixed now. Thanks to @cpaprotna for pointing me in the right direction. (https://wordpress.org/support/topic/no-more-than-3-conditional-statements/)
* Fix validation error with hidden checkbox groups (https://wordpress.org/support/topic/hidden-group-required-field-is-showing-error/)
= 0.2.6 =
* Fixed problems with exclusive checkboxes in IE (https://wordpress.org/support/topic/internet-explorer-conditional-exclusive-checkboxes/)
= 0.2.5 =
* Changed deprecated function wpcf7_add_shortcode to wpcf7_add_form_tag as it was causing errors in debug mode. (https://wordpress.org/support/topic/wpcf7_add_shortcode-deprecated-notice-2/)
* Removed the hide option and fixed the not-equals option for single checkboxes
= 0.2.4 =
* Fixed bug that destroyed the conditional fields in email functionality
= 0.2.3 =
* Added support for conditional fields in the other email fields (subject, sender, recipient, additional_headers). Thanks @stevish!
* WP 4.7 broke the required conditional fields inside hidden groups, implemented in version 0.2. Thanks again to @stevish for pointing this out.
* Got rid of checking which groups are hidden both on the front-end (JS) and in the back-end (PHP). Now this is only done in the front-end.
* Tested the plugin with WP 4.7
= 0.2.2 =
* Prevent strict standards notice to appear while adding new group via the "Conditional Fields Group" popup.
* Only load cf7cf admin styles and scripts on cf7 pages.
* groups are now reset to their initial states after the form is successfully submitted.
= 0.2.1 =
* Bug fix: arrow kept spinning after submitting a form without conditional fields. (https://wordpress.org/support/topic/version-0-2-gives-a-continues-spinning-arrow-after-submitting/)
* Removed anonymous functions from code, so the plugin also works for PHP versions older than 5.3.
* Suppress errors generated if user uses invalid HTML markup in their form code. These errors could prevent form success message from appearing.
= 0.2 =
* Added support for required conditional fields inside hidden groups. A big thank you to @stevish for implementing this.
* Added support for conditional fields in the email messages. This one also goes entirely to @stevish. Thanks man!
* Added @stevish as a contributer to the project :)
* Fix form not working in widgets or other places outside of the loop. Thanks to @ciprianolaru for the solution (https://wordpress.org/support/topic/problem-with-unit_tag-when-not-in-the-loop-form-not-used-in-post-or-page/#post-8299801)
= 0.1.7 =
* Fix popup warning to leave page even tough no changes have been made. Thanks to @hhmaster2045 for reporting the bug. https://wordpress.org/support/topic/popup-warning-to-leave-page-even-though-no-changes-have-been-made
* Added export option for easier troubleshooting.
* Don't include front end javascript in backend.
= 0.1.6 =
* made compatible with wpcf7-form-control-signature-wrap plugin https://wordpress.org/support/topic/signature-add-on-not-working
= 0.1.5 =
* fixed PHP notice thanks to @natalia_c https://wordpress.org/support/topic/php-notice-80
* tested with WP 4.5.3
= 0.1.4 =
* Prevent conflicts between different forms on one page.
* Prevent conflicts between multiple instances of the same form on one page. (https://wordpress.org/support/topic/bug-153)
* Changed regex to convert \[group\] tags to &lt;div&gt; tags, as it was posing some conflicts with other plugins (https://wordpress.org/support/topic/plugin-influence-cf7-send-button-style)
= 0.1.3 =
* Removed fielset, id and class attributes for group tags, because they weren't used anyway and broke the shortcode
* If extra attributes are added to the group shortcode, this will no longer break functionality (even though no attributes are supported)
= 0.1.2 =
* Make code work with select element that allows multiple options.
* Only load javascript on pages that contain a CF7 form
= 0.1.1 =
Fixed bug with exclusive checkboxes (https://wordpress.org/support/topic/groups-not-showing)
= 0.1 =
First release

View File

@@ -0,0 +1,73 @@
/* initially hide all groups (even before JS is loaded), so the page will never render them while loading */
[data-class="wpcf7cf_group"], .wpcf7cf_remove, .wpcf7cf_add {
display:none;
}
.wpcf7cf_repeater_sub {
margin-bottom: 20px;
}
.wpcf7cf_repeater_controls, .wpcf7cf_step_controls {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
margin-top: 20px;
}
.wpcf7cf_multistep .wpcf7cf_step {
/* display:none; */
width: 100%;
}
.wpcf7cf_multistep .wpcf7cf_step .step-title {
display: none;
}
.wpcf7cf_multistep .wpcf7cf_steps-dots {
display: flex;
width: 100%;
margin-bottom: 20px;
flex-wrap: wrap;
}
.wpcf7cf_multistep .wpcf7cf_steps-dots .dot .step-index {
display: inline-block;
border-radius: 50%;
background: #dfdfdf;
color: #000000;
width: 40px;
height: 40px;
line-height: 40px;
text-align: center;
}
.wpcf7cf_multistep .wpcf7cf_steps-dots .dot {
border-bottom: 5px solid #dfdfdf;
text-align: center;
flex: 1;
padding: 15px;
min-width: 120px;
}
.wpcf7cf_multistep .wpcf7cf_steps-dots .dot.completed {
border-bottom: 5px solid #333;
}
.wpcf7cf_multistep .wpcf7cf_steps-dots .dot.active {
border-bottom: 5px solid #333;
font-weight: bold;
}
.wpcf7cf_multistep .wpcf7cf_steps-dots .dot.completed .step-index {
background-color: #333;
color: #ffffff;
}
.wpcf7cf_multistep .wpcf7cf_steps-dots .dot.active .step-index {
background-color: #333;
color: #ffffff;
}
.wpcf7cf_step_controls .disabled {
pointer-events: none;
cursor: default;
opacity: .5;
}

View File

@@ -0,0 +1,43 @@
<div class="control-box">
<fieldset>
<legend><?php echo sprintf( esc_html( $description ) ); ?></legend>
<table class="form-table">
<tbody>
<tr>
<th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-name' ); ?>"><?php _e( 'Name', 'cf7-conditional-fields' ); ?></label></th>
<td><input type="text" name="name" class="tg-name oneline" id="<?php echo esc_attr( $args['content'] . '-name' ); ?>" /></td>
</tr>
<tr>
<th scope="row"><label for="clear_on_hide"><?php _e( 'Clear on hide', 'cf7-conditional-fields' ); ?></label></th>
<td><input type="checkbox" name="clear_on_hide" class="option" id="clear_on_hide" /></td>
</tr>
<?php if (WPCF7CF_IS_PRO) { ?>
<tr>
<th scope="row"><label for="disable_on_hide"><?php echo esc_html( __( 'Disable on hide', 'cf7-conditional-fields' ) ); ?></label></th>
<td><input type="checkbox" name="disable_on_hide" class="option" id="disable_on_hide" /></td>
</tr>
<?php } ?>
<tr>
<th scope="row"><label for="inline"><?php echo esc_html( __( 'Inline', 'cf7-conditional-fields' ) ); ?></label></th>
<td><input type="checkbox" name="inline" class="option" id="inline" /></td>
</tr>
</tbody>
</table>
</fieldset>
</div>
<div class="insert-box">
<input type="text" name="<?php echo $type; ?>" class="tag code" readonly="readonly" onfocus="this.select()" />
<div class="submitbox">
<input type="button" class="button button-primary insert-tag" value="<?php _e( 'Insert Tag', 'cf7-conditional-fields' ); ?>" />
</div>
<br class="clear" />
</div>

View File

@@ -0,0 +1,297 @@
<?php
define('WPCF7CF_SLUG', 'wpcf7cf');
define('WPCF7CF_OPTIONS', WPCF7CF_SLUG.'_options');
define('WPCF7CF_TEXT_DOMAIN', WPCF7CF_SLUG.'_text_domain');
define('WPCF7CF_DEFAULT_ANIMATION', 'yes');
define('WPCF7CF_DEFAULT_ANIMATION_INTIME', 200);
define('WPCF7CF_DEFAULT_ANIMATION_OUTTIME', 200);
define('WPCF7CF_DEFAULT_CONDITIONS_UI', 'normal');
define('WPCF7CF_DEFAULT_NOTICE_DISMISSED', false);
if ( ! defined( 'WPCF7_ADMIN_READ_WRITE_CAPABILITY' ) ) {
define( 'WPCF7_ADMIN_READ_WRITE_CAPABILITY', 'publish_pages' );
}
global $wpcf7cf_default_settings_glob;
$wpcf7cf_default_settings_glob = false;
function wpcf7cf_get_default_settings() {
global $wpcf7cf_default_settings_glob;
if ($wpcf7cf_default_settings_glob) return $wpcf7cf_default_settings_glob;
$wpcf7cf_default_settings_glob = array(
'animation' => WPCF7CF_DEFAULT_ANIMATION,
'animation_intime' => WPCF7CF_DEFAULT_ANIMATION_INTIME,
'animation_outtime' => WPCF7CF_DEFAULT_ANIMATION_OUTTIME,
'conditions_ui' => WPCF7CF_DEFAULT_CONDITIONS_UI,
'notice_dismissed' => WPCF7CF_DEFAULT_NOTICE_DISMISSED
);
$wpcf7cf_default_settings_glob = apply_filters('wpcf7cf_default_options', $wpcf7cf_default_settings_glob);
return $wpcf7cf_default_settings_glob;
}
global $wpcf7cf_settings_glob;
$wpcf7cf_settings_glob = false;
function wpcf7cf_get_settings() {
global $wpcf7cf_settings_glob;
if ($wpcf7cf_settings_glob) {
return $wpcf7cf_settings_glob;
}
$wpcf7cf_default_settings = wpcf7cf_get_default_settings();
$wpcf7cf_saved_settings = get_option(WPCF7CF_OPTIONS);
if (!$wpcf7cf_saved_settings) {
$wpcf7cf_saved_settings = [];
}
$wpcf7cf_settings_glob = array_merge($wpcf7cf_default_settings,$wpcf7cf_saved_settings);
return $wpcf7cf_settings_glob;
}
function wpcf7cf_set_options($settings) {
global $wpcf7cf_settings_glob;
$wpcf7cf_settings_glob = $settings;
update_option(WPCF7CF_OPTIONS, $wpcf7cf_settings_glob);
}
function wpcf7cf_reset_options() {
delete_option(WPCF7CF_OPTIONS);
}
add_action( 'admin_enqueue_scripts', 'wpcf7cf_load_page_options_wp_admin_style' );
function wpcf7cf_load_page_options_wp_admin_style() {
wp_register_style( 'wpcf7cf_admin_css', plugins_url('admin-style.css',__FILE__), [], WPCF7CF_VERSION );
wp_enqueue_style( 'wpcf7cf_admin_css' );
}
add_action('admin_menu', 'wpcf7cf_admin_add_page');
function wpcf7cf_admin_add_page() {
add_submenu_page('wpcf7', __( 'Conditional Fields', 'cf7-conditional-fields' ), __( 'Conditional Fields', 'cf7-conditional-fields' ), WPCF7_ADMIN_READ_WRITE_CAPABILITY, 'wpcf7cf', 'wpcf7cf_options_page' );
}
function wpcf7cf_options_page() {
$settings = wpcf7cf_get_settings();
if (isset($_POST['reset'])) {
echo '<div id="message" class="updated fade"><p><strong>' . __( 'Settings restored to defaults', 'cf7-conditional-fields' ) . '</strong></p></div>';
} else if (isset($_REQUEST['settings-updated'])) {
echo '<div id="message" class="updated fade"><p><strong>' . __( 'Settings updated', 'cf7-conditional-fields' ) . '</strong></p></div>';
}
?>
<div class="wrap wpcf7cf-admin-wrap">
<h2><?php _e( 'Conditional Fields for Contact Form 7 Settings', 'cf7-conditional-fields'); ?></h2>
<?php if (!$settings['notice_dismissed']) { ?>
<div class="wpcf7cf-admin-notice notice notice-warning is-dismissible" data-notice-id="">
<div style="padding: 10px 0;">
<?php _e( '<strong>Notice</strong>: These are global settings for Conditional Fields for Contact Form 7.', 'cf7-conditional-fields'); ?>
<br><br>
<strong><?php _e( 'How to create/edit conditional fields?', 'cf7-conditional-fields'); ?></strong>
<ol>
<li><?php _e( 'Create a new Contact Form or edit an existing one', 'cf7-conditional-fields'); ?></li>
<li><?php _e( 'Create at least one [group] inside the form', 'cf7-conditional-fields'); ?></li>
<li><?php _e( 'Save the Contact Form', 'cf7-conditional-fields'); ?></li>
<li><?php _e( 'Go to the <strong><em>Conditional Fields</em></strong> Tab', 'cf7-conditional-fields'); ?></li>
</ol>
<a href="https://conditional-fields-cf7.bdwm.be/conditional-fields-for-contact-form-7-tutorial/" target="_blank"><?php _e( 'Show me an example', 'cf7-conditional-fields'); ?></a> | <a class="notice-dismiss-alt" href="#"><?php _e( 'Dismiss notice', 'cf7-conditional-fields'); ?></a>
</div>
</div>
<?php } ?>
<form action="options.php" method="post">
<?php settings_fields(WPCF7CF_OPTIONS); ?>
<input type="hidden" name="<?php echo WPCF7CF_OPTIONS.'[notice_dismissed]' ?>" value="<?php echo $settings['notice_dismissed'] ?>" />
<?php
echo '<h3>' . __( 'Default animation Settings', 'cf7-conditional-fields') . '</h3>';
wpcf7cf_input_fields_wrapper_start();
wpcf7cf_input_select('animation', array(
'label' => __( 'Animation', 'cf7-conditional-fields'),
'description' => __( 'Use animations while showing/hiding groups', 'cf7-conditional-fields'),
'select_options' => array('yes' => __( 'Enabled', 'cf7-conditional-fields'), 'no'=> __( 'Disabled', 'cf7-conditional-fields'))
));
wpcf7cf_input_field('animation_intime', array(
'label' => __( 'Animation In time', 'cf7-conditional-fields'),
'description' => __( 'A positive integer value indicating the time, in milliseconds, it will take for each group to show.', 'cf7-conditional-fields'),
));
wpcf7cf_input_field('animation_outtime', array(
'label' => __( 'Animation Out Time', 'cf7-conditional-fields'),
'description' => __( 'A positive integer value indicating the time, in milliseconds, it will take for each group to hide.', 'cf7-conditional-fields'),
));
wpcf7cf_input_fields_wrapper_end();
submit_button();
if (!WPCF7CF_IS_PRO) {
?>
<h3><?php _e( 'Conditional Fields PRO', 'cf7-conditional-fields'); ?></h3>
<?php _e( 'Get Conditional Fields PRO to unlock the full potential of CF7', 'cf7-conditional-fields'); ?>
<ul class="wpcf7cf-list">
<li><?php _e( 'Repeaters', 'cf7-conditional-fields'); ?></li>
<li><?php _e( 'Regular expressions', 'cf7-conditional-fields'); ?></li>
<li><?php _e( 'Toggle buttons', 'cf7-conditional-fields'); ?></li>
<li><?php _e( 'Additional operators', 'cf7-conditional-fields'); ?>< <code>&lt;</code> <code>&gt;</code> <code>&le;</code> <code>&ge;</code> <code><?php _e( 'is empty', 'cf7-conditional-fields'); ?></code></li>
<li><?php _e( 'Multistep (with Summary)', 'cf7-conditional-fields'); ?></li>
<li><?php _e( 'More comming soon (Calculated Fields, ...)', 'cf7-conditional-fields'); ?></li>
</ul>
<p><a target="_blank" class="button button-primary" href="https://conditional-fields-cf7.bdwm.be/contact-form-7-conditional-fields-pro/"><?php _e( 'Get PRO', 'cf7-conditional-fields'); ?></a></p>
<?php
}
do_action('wpcf7cf_after_animation_settings');
echo '<h3>' . __( 'Advanced Settings', 'cf7-conditional-fields') . '</h3>';
wpcf7cf_input_fields_wrapper_start();
wpcf7cf_input_select('conditions_ui', array(
'label' => __( 'Conditional Fields UI', 'cf7-conditional-fields'),
'description' => sprintf(
// translators: max recommended conditions
__( 'If you want to add more than %s conditions, it\'s recommended to switch to <strong>Text mode</strong> mode for better performance.', 'cf7-conditional-fields' ), WPCF7CF_MAX_RECOMMENDED_CONDITIONS ),
'select_options' => array('normal'=> __( 'Normal', 'cf7-conditional-fields'), 'text_only' => __( 'Text mode', 'cf7-conditional-fields'))
));
wpcf7cf_input_fields_wrapper_end();
submit_button();
?>
</form></div>
<h3><?php _e( 'Restore Default Settings', 'cf7-conditional-fields' ); ?></h3>
<form method="post" id="reset-form" action="">
<p class="submit">
<input name="reset" class="button button-secondary" type="submit" value="<?php _e( 'Restore defaults', 'cf7-conditional-fields' ); ?>" >
<input type="hidden" name="action" value="reset" />
</p>
</form>
<script>
(function($){
$('#reset-form').submit(function() {
return confirm( __( 'Are you sure you want to reset the plugin settings to the default values? All changes you have previously made will be lost.', 'cf7-conditional-fields' ) );
});
}(jQuery))
</script>
<?php
}
function wpcf7cf_input_fields_wrapper_start() {
echo '<table class="form-table" role="presentation"><tbody>';
}
function wpcf7cf_input_fields_wrapper_end() {
echo '</tbody></table>';
}
function wpcf7cf_input_field($slug, $args) {
$settings = wpcf7cf_get_settings();
$defaults = array(
'label'=>'',
'desription' => '',
'default' => wpcf7cf_get_default_settings()[$slug],
'label_editable' => false
);
$args = wp_parse_args( $args, $defaults );
extract($args);
$label; $description; $default; $label_editable;
if (!key_exists($slug, $settings)) {
$settings[$slug] = $default;
$settings[$slug.'_label'] = $label;
}
?>
<tr>
<th scope="row">
<?php if ($label_editable) { ?>
<span class="label editable"><input type="text" data-default-value="<?php echo $label ?>" value="<?php echo $settings[$slug.'_label'] ?>" id="<?php echo WPCF7CF_OPTIONS.'_'.$slug.'_label' ?>" name="<?php echo WPCF7CF_OPTIONS.'['.$slug.'_label]' ?>"></span>
<?php } else { ?>
<label for="<?php echo WPCF7CF_OPTIONS.'_'.$slug ?>"><?php echo $label ?></label>
<?php } ?>
</th>
<td>
<input type="text" data-default-value="<?php echo $default ?>" value="<?php echo $settings[$slug] ?>" id="<?php echo WPCF7CF_OPTIONS.'_'.$slug ?>" name="<?php echo WPCF7CF_OPTIONS.'['.$slug.']' ?>">
<p class="description" id="<?php echo WPCF7CF_OPTIONS.'_'.$slug ?>-description">
<?php echo $description ?><?php if (!empty($default)) echo ' (' . __( 'Default:', 'cf7-conditional-fields' ) . ' '.$default.')' ?>
</p>
</td>
</tr>
<?php
}
function wpcf7cf_input_select($slug, $args) {
$settings = wpcf7cf_get_settings();
$defaults = array(
'label'=>'',
'desription' => '',
'select_options' => array(), // array($name => $value)
'default' => wpcf7cf_get_default_settings()[$slug],
);
$args = wp_parse_args( $args, $defaults );
extract($args);
$label; $description; $select_options; $default;
if (!key_exists($slug, $settings)) {
$settings[$slug] = $default;
}
?>
<tr>
<th scope="row"><label for="<?php echo WPCF7CF_OPTIONS.'_'.$slug ?>"><?php echo $label ?></label></th>
<td>
<select id="<?php echo WPCF7CF_OPTIONS.'_'.$slug ?>" data-default-value="<?php echo $default ?>" name="<?php echo WPCF7CF_OPTIONS.'['.$slug.']' ?>">
<?php foreach($select_options as $value => $text) { ?>
<option value="<?php echo $value ?>" <?php echo $settings[$slug]==$value?'selected':'' ?>><?php echo $text ?></option>
<?php } ?>
</select>
<p class="description" id="<?php echo WPCF7CF_OPTIONS.'_'.$slug ?>-description">
<?php echo $description ?><?php if (!empty($default)) echo ' (' . __( 'Default:', 'cf7-conditional-fields' ) . ' '.$select_options[$default].')' ?>
</p>
</td>
</tr>
<?php
}
add_action('admin_init', 'wpcf7cf_admin_init');
function wpcf7cf_admin_init(){
if(isset($_POST['reset']) && current_user_can( 'wpcf7_edit_contact_forms' ) ) {
wpcf7cf_reset_options();
}
register_setting( WPCF7CF_OPTIONS, WPCF7CF_OPTIONS, 'wpcf7cf_options_sanitize' );
}
function wpcf7cf_options_sanitize($input) {
return $input;
}
add_action( 'wp_ajax_wpcf7cf_dismiss_notice', 'wpcf7cf_dismiss_notice' );
function wpcf7cf_dismiss_notice() {
$notice_id = sanitize_text_field($_POST['noticeId'] ?? '');
$notice_suffix = $notice_id ? '_'.$notice_id : $notice_id;
$settings = wpcf7cf_get_settings();
$settings['notice_dismissed'.$notice_suffix] = true;
wpcf7cf_set_options($settings);
}