Skip to content

Commit 7c039a9

Browse files
committed
Added checkbox function
1 parent 8c05bab commit 7c039a9

File tree

2 files changed

+81
-6
lines changed

2 files changed

+81
-6
lines changed

paystack-forms.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,14 @@ function insertSelectb(){
118118
);
119119
function insertRadiob(){
120120
QTags.insertContent('[radio name="Text Title" options="option 1,option 2,option 3"]');
121+
}
122+
QTags.addButton(
123+
"r_shortcode",
124+
"Insert Checkbox Options",
125+
insertCheckboxb
126+
);
127+
function insertCheckboxb(){
128+
QTags.insertContent('[checkbox name="Text Title" options="option 1,option 2,option 3"]');
121129
}
122130
QTags.addButton(
123131
"i_shortcode",

public/class-paystack-forms-public.php

Lines changed: 73 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -981,11 +981,6 @@ function kkd_pff_paystack_radio_shortcode($atts) {
981981
$code.= '</label>
982982
<div class="inline-group">
983983
';
984-
// if ($required == 'required') {
985-
// $code.= ' required="required" ';
986-
// }
987-
// $code.=">";
988-
989984
$soptions = explode(',', $options);
990985
if (count($soptions) > 0) {
991986
foreach ($soptions as $key => $option) {
@@ -1009,6 +1004,74 @@ function kkd_pff_paystack_radio_shortcode($atts) {
10091004
return $code;
10101005
}
10111006
add_shortcode('radio', 'kkd_pff_paystack_radio_shortcode');
1007+
function kkd_pff_paystack_checkbox_shortcode($atts) {
1008+
extract(shortcode_atts(array(
1009+
'name' => 'Title',
1010+
'options' => '',
1011+
'required' => '0',
1012+
), $atts));
1013+
$code = '<div class="span12 unit">
1014+
<label class="label">'.$name;
1015+
if ($required == 'required') {
1016+
$code.= ' <span>*</span>';
1017+
}
1018+
$code.= '</label>
1019+
<div class="inline-group">
1020+
';
1021+
// <div class="unit">
1022+
// <div class="inline-group">
1023+
// <label class="label">Inline checkbox</label>
1024+
// <label class="checkbox">
1025+
// <input type="checkbox">
1026+
// <i></i>
1027+
// Apple
1028+
// </label>
1029+
// <label class="checkbox">
1030+
// <input type="checkbox">
1031+
// <i></i>
1032+
// Mango
1033+
// </label>
1034+
// <label class="checkbox">
1035+
// <input type="checkbox">
1036+
// <i></i>
1037+
// Melon
1038+
// </label>
1039+
// <label class="checkbox">
1040+
// <input type="checkbox">
1041+
// <i></i>
1042+
// Lemon
1043+
// </label>
1044+
// <label class="checkbox">
1045+
// <input type="checkbox">
1046+
// <i></i>
1047+
// Watermelon
1048+
// </label>
1049+
// </div>
1050+
// </div>
1051+
1052+
$soptions = explode(',', $options);
1053+
if (count($soptions) > 0) {
1054+
foreach ($soptions as $key => $option) {
1055+
// $code.= '<option value="'.$option.'" >'.$option.'</option>';
1056+
$code.= '<label class="checkbox">
1057+
<input type="checkbox" name="'.$name.'[]" value="'.$option.'"';
1058+
if ($key == 0) {
1059+
$code.= ' checked';
1060+
if ($required == 'required') {
1061+
$code.= ' required="required"';
1062+
}
1063+
}
1064+
1065+
$code.= '/>
1066+
<i></i>
1067+
'.$option.'
1068+
</label>';
1069+
}
1070+
}
1071+
$code.= '</div></div>';
1072+
return $code;
1073+
}
1074+
add_shortcode('checkbox', 'kkd_pff_paystack_checkbox_shortcode');
10121075
function kkd_pff_paystack_textarea_shortcode($atts) {
10131076
extract(shortcode_atts(array(
10141077
'name' => 'Title',
@@ -1132,9 +1195,10 @@ function kkd_pff_paystack_submit_action() {
11321195
unset($metadata['pf-interval']);
11331196

11341197
// echo '<pre>';
1198+
// print_r($_POST);
11351199

11361200
$fixedmetadata = kkd_pff_paystack_meta_as_custom_fields($metadata);
1137-
1201+
// print_r($fixedmetadata );
11381202
$filelimit = get_post_meta($_POST["pf-id"],'_filelimit',true);
11391203
$currency = get_post_meta($_POST["pf-id"],'_currency',true);
11401204
$formamount = get_post_meta($_POST["pf-id"],'_amount',true);/// From form
@@ -1367,6 +1431,9 @@ function kkd_pff_paystack_submit_action() {
13671431
function kkd_pff_paystack_meta_as_custom_fields($metadata){
13681432
$custom_fields = array();
13691433
foreach ($metadata as $key => $value) {
1434+
if (is_array($value)) {
1435+
$value = implode(', ',$value);
1436+
}
13701437
if ($key == 'pf-fname') {
13711438
$custom_fields[] = array(
13721439
'display_name' => 'Full Name',

0 commit comments

Comments
 (0)