Skip to content

Commit d4d3410

Browse files
committed
* fix issues #1
1 parent 6274451 commit d4d3410

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

contact-form-7-submission-limit.php

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,25 +50,29 @@ function cf7sl_add_pages()
5050
add_action("admin_print_scripts-$page", "cf7sl_admin_scripts");
5151
}
5252

53+
54+
/*
55+
* Main Function
56+
*/
5357
function cf7sl_options_page()
5458
{
5559
if (isset($_POST['setup-update'])) {
5660
$_POST = stripslashes_deep($_POST);
5761

5862
// If atleast one find has been submitted
59-
if (isset($_POST['cf7slfind']) && is_array($_POST['cf7slfind'])) {
60-
foreach ($_POST['cf7slfind'] as $key => $find) {
63+
if (isset($_POST['cf7slformid']) && is_array($_POST['cf7slformid'])) {
64+
foreach ($_POST['cf7slformid'] as $key => $find) {
6165

6266
// If empty ones have been submitted we get rid of the extra data submitted if any.
6367
if (empty($find)) {
64-
unset($_POST['cf7slfind'][$key]);
68+
unset($_POST['cf7slformid'][$key]);
6569
unset($_POST['cf7sllimit'][$key]);
6670
unset($_POST['cf7slreplace'][$key]);
6771
}
6872

6973
// Convert line feeds on non-regex only
7074
if (!isset($_POST['cf7slregex'][$key])) {
71-
$_POST['cf7slfind'][$key] = str_replace("\r\n", "\n", $find);
75+
$_POST['cf7slformid'][$key] = str_replace("\r\n", "\n", $find);
7276
}
7377
}
7478
}
@@ -78,7 +82,7 @@ function cf7sl_options_page()
7882
unset($_POST['submit-import']);
7983

8084
// Delete the option if there are no settings. Keeps the database clean if they aren't using it and uninstalled.
81-
if (empty($_POST['cf7slfind'])) {
85+
if (empty($_POST['cf7slformid'])) {
8286
delete_option('cf7sl_plugin_settings');
8387
} else {
8488
update_option('cf7sl_plugin_settings', $_POST);
@@ -105,9 +109,9 @@ function cf7sl_options_page()
105109
<?php
106110
$i = 0;
107111
// If there are any finds already set
108-
if (isset($cf7sl_settings['cf7slfind']) && is_array($cf7sl_settings['cf7slfind'])) {
112+
if (isset($cf7sl_settings['cf7slformid']) && is_array($cf7sl_settings['cf7slformid'])) {
109113
$i = 1;
110-
foreach ($cf7sl_settings['cf7slfind'] as $key => $find) {
114+
foreach ($cf7sl_settings['cf7slformid'] as $key => $find) {
111115

112116
if (isset($cf7sl_settings['cf7slreplace'][$key])) {
113117
$cf7sl_replace = $cf7sl_settings['cf7slreplace'][$key];
@@ -121,23 +125,23 @@ function cf7sl_options_page()
121125
$cf7sl_limit = '-1';
122126
}
123127

124-
$current_total_submition = get_total_submition($cf7sl_settings['cf7slfind'][$key]);
128+
$current_total_submition = get_total_submition($cf7sl_settings['cf7slformid'][$key]);
125129
$status = "Remaining submissions = " . ($cf7sl_limit - $current_total_submition) . "</br>Form Status = " . get_form_status($cf7sl_limit - $current_total_submition);
126130

127131
echo "<li id='row$i'>";
128132

129133
echo "<div style='float: left'>";
130134
echo "<div style='float: left'>";
131-
echo "<label for='cf7slfind$i'>Form ID:</label>";
135+
echo "<label for='cf7slformid$i'>Form ID:</label>";
132136
echo "<br />";
133-
echo "<select name='cf7slfind[$i]' id='cf7slfind$i' onchange='getFormSelectValue(this);'>";
137+
echo "<select name='cf7slformid[$i]' id='cf7slformid$i' onchange='getFormSelectValue(this);'>";
134138
$forms_list = get_form_list();
135139
if ($forms_list) {
136140
foreach ($forms_list as $key => $value) {
137141
if ($find == $value->ID) {
138-
echo "<option name='cf7slfind[$i]' id='cf7slfind$i' value='" . $value->ID . "' selected>" . $value->post_title . "</option>";
142+
echo "<option name='cf7slformid[$i]' id='cf7slformid$i' value='" . $value->ID . "' selected>" . $value->post_title . "</option>";
139143
} else {
140-
echo "<option name='cf7slfind[$i]' id='cf7slfind$i' value='" . $value->ID . "'>" . $value->post_title . "</option>";
144+
echo "<option name='cf7slformid[$i]' id='cf7slformid$i' value='" . $value->ID . "'>" . $value->post_title . "</option>";
141145
}
142146
}
143147
}
@@ -300,8 +304,8 @@ function cf7sl_ob_call($buffer)
300304
{
301305
// $buffer contains entire page
302306
$cf7sl_settings = get_option('cf7sl_plugin_settings');
303-
if (is_array($cf7sl_settings['cf7slfind'])) {
304-
foreach ($cf7sl_settings['cf7slfind'] as $key => $find) {
307+
if (is_array($cf7sl_settings['cf7slformid'])) {
308+
foreach ($cf7sl_settings['cf7slformid'] as $key => $find) {
305309
error_log($cf7sl_settings['cf7sllimit'][$key]);
306310
if (is_form_in_list($buffer, $find) && is_submition_above_limit($find, $cf7sl_settings['cf7sllimit'][$key])) {
307311
$buffer = preg_replace("/<form\b[^>]*[class=\"wpcf7\-form\"]\b[^>]*>(.*?)<\/form>/is", $cf7sl_settings['cf7slreplace'][$key], $buffer);

js/jquery.dynamicfields.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ function addFormField() {
88
var row ="<li id ='row" + id + "'>" +
99
"<div style='float: left;'>" +
1010
"<div style='float: left;'>" +
11-
"<label for='cf7slfind" + id + "'>Form ID:</label>" +
11+
"<label for='cf7slformid" + id + "'>Form ID:</label>" +
1212
"<br />" +
13-
"<select name='cf7slfind["+ id +"]' id='cf7slfind" + id + "'>" ;
13+
"<select name='cf7slformid["+ id +"]' id='cf7slformid" + id + "'>" ;
1414

1515

1616

1717
for(var i=0;i<formNamesArray.length;i++){
18-
row += "<option name='cf7slfind["+ id +"]' id='cf7slfind"+ id +"' value='"+ formNamesArray[i]['ID']+ "'>" + formNamesArray[i]['post_title']+ "</option>";
18+
row += "<option name='cf7slformid["+ id +"]' id='cf7slformid"+ id +"' value='"+ formNamesArray[i]['ID']+ "'>" + formNamesArray[i]['post_title']+ "</option>";
1919
}
2020

2121

0 commit comments

Comments
 (0)