@@ -256,6 +256,8 @@ function help_metabox_details( $post ) {
256256 function add_extra_metaboxes () {
257257
258258 add_meta_box ('wpt_form_data ' , 'Extra Form Description ' , 'wpt_form_data ' , 'paystack_form ' , 'normal ' , 'default ' );
259+ add_meta_box ('wpt_recur_data ' , 'Recurring Payment ' , 'wpt_recur_data ' , 'paystack_form ' , 'side ' , 'default ' );
260+ add_meta_box ('wpt_email_data ' , 'Email Receipt Settings ' , 'wpt_email_data ' , 'paystack_form ' , 'normal ' , 'default ' );
259261
260262 }
261263
@@ -289,11 +291,11 @@ function wpt_form_data() {
289291 echo '<input type="number" name="_amount" value=" ' . $ amount . '" class="widefat pf-number" /> ' ;
290292 echo '<p>Pay button Description:</p> ' ;
291293 echo '<input type="text" name="_paybtn" value=" ' . $ paybtn . '" class="widefat" /> ' ;
292- // echo '<p>Transaction Charges:</p>';
293- // echo '<select class="form-control" name="_txncharge" id="parent_id" style="width:100%;">
294- // <option value="merchant"'.txncheck('merchant',$txncharge).'>Merchant Pays(Include in fee)</option>
295- // <option value="customer" '.txncheck('customer',$txncharge).'>Client Pays(Extra Fee added)</option>
296- // </select>';
294+ echo '<p>Transaction Charges:</p> ' ;
295+ echo '<select class="form-control" name="_txncharge" id="parent_id" style="width:100%;">
296+ <option value="merchant" ' .txncheck ('merchant ' ,$ txncharge ).'>Merchant Pays(Include in fee)</option>
297+ <option value="customer" ' .txncheck ('customer ' ,$ txncharge ).'>Client Pays(Extra Fee added)</option>
298+ </select> ' ;
297299 echo '<p>User logged In:</p> ' ;
298300 echo '<select class="form-control" name="_loggedin" id="parent_id" style="width:100%;">
299301 <option value="no" ' .txncheck ('no ' ,$ loggedin ).'>User must not be logged in</option>
@@ -305,7 +307,62 @@ function wpt_form_data() {
305307 echo '<input ttype="number" name="_filelimit" value=" ' . $ filelimit . '" class="widefat pf-number" /> ' ;
306308
307309 }
310+ function wpt_email_data () {
311+ global $ post ;
312+
313+ // Noncename needed to verify where the data originated
314+ echo '<input type="hidden" name="eventmeta_noncename" id="eventmeta_noncename" value=" ' .
315+ wp_create_nonce ( plugin_basename (__FILE__ ) ) . '" /> ' ;
316+
317+ // Get the location data if its already been entered
318+ $ subject = get_post_meta ($ post ->ID , '_subject ' , true );
319+ $ heading = get_post_meta ($ post ->ID , '_heading ' , true );
320+ $ message = get_post_meta ($ post ->ID , '_message ' , true );
321+ $ sendreceipt = get_post_meta ($ post ->ID , '_sendreceipt ' , true );
322+
323+ if ($ subject == "" ) {$ subject = 'Thank you for your payment ' ;}
324+ if ($ sendreceipt == "" ) {$ sendreceipt = 'yes ' ;}
325+ if ($ heading == "" ) {$ heading = "We've received your payment " ;}
326+ if ($ message == "" ) {$ message = 'Your payment was received and we appreciate it. ' ;}
327+ // Echo out the field
328+ echo '<p>Send Email Receipt:</p> ' ;
329+ echo '<select class="form-control" name="_sendreceipt" id="parent_id" style="width:100%;">
330+ <option value="no" ' .txncheck ('no ' ,$ sendreceipt ).'>Don \'t send</option>
331+ <option value="yes" ' .txncheck ('yes ' ,$ sendreceipt ).'>Send</option>
332+ </select> ' ;
333+ echo '<p>Email Subject:</p> ' ;
334+ echo '<input type="text" name="_subject" value=" ' . $ subject . '" class="widefat" /> ' ;
335+ echo '<p>Email Heading:</p> ' ;
336+ echo '<input type="text" name="_heading" value=" ' . $ heading . '" class="widefat" /> ' ;
337+ echo '<p>Email Body/Message:</p> ' ;
338+ echo '<textarea rows="6" name="_message" class="widefat" > ' .$ message .'</textarea> ' ;
339+
340+ }
341+ function wpt_recur_data () {
342+ global $ post ;
343+
344+ // Noncename needed to verify where the data originated
345+ echo '<input type="hidden" name="eventmeta_noncename" id="eventmeta_noncename" value=" ' .
346+ wp_create_nonce ( plugin_basename (__FILE__ ) ) . '" /> ' ;
347+
348+ // Get the location data if its already been entered
349+ $ recur = get_post_meta ($ post ->ID , '_recur ' , true );
350+ $ recurplan = get_post_meta ($ post ->ID , '_recurplan ' , true );
351+
352+ if ($ recur == "" ) {$ recur = 'no ' ;}
353+ if ($ recurplan == "" ) {$ recurplan = '' ;}
354+ // Echo out the field
355+ echo '<p>Reccuring Payment:</p> ' ;
356+ echo '<select class="form-control" name="_recur" id="parent_id" style="width:100%;">
357+ <option value="no" ' .txncheck ('no ' ,$ recur ).'>None</option>
358+ <option value="custom" ' .txncheck ('yes ' ,$ recur ).'>User Sets Interval</option>
359+ <option value="plan" ' .txncheck ('yes ' ,$ recur ).'>Paystack Plan</option>
360+ </select> ' ;
361+ echo '<p>Paystack Recur Plan:</p> ' ;
362+ echo '<input type="text" name="_recurplan" value=" ' . $ recurplan . '" class="widefat" />
363+ <small>Plan amount must match amount on extra form description.</small> ' ;
308364
365+ }
309366 function wpt_form_data_meta ($ post_id , $ post ) {
310367
311368 if ( !wp_verify_nonce ( @$ _POST ['eventmeta_noncename ' ], plugin_basename (__FILE__ ) )) {
@@ -329,6 +386,9 @@ function wpt_form_data_meta($post_id, $post) {
329386 $ form_meta ['_heading ' ] = $ _POST ['_heading ' ];
330387 $ form_meta ['_message ' ] = $ _POST ['_message ' ];
331388 $ form_meta ['_sendreceipt ' ] = $ _POST ['_sendreceipt ' ];
389+ ///
390+ $ form_meta ['_recur ' ] = $ _POST ['_recur ' ];
391+ $ form_meta ['_recurplan ' ] = $ _POST ['_recurplan ' ];
332392
333393 // Add values of $form_meta as custom fields
334394
@@ -346,43 +406,6 @@ function wpt_form_data_meta($post_id, $post) {
346406 }
347407 add_action ('save_post ' , 'wpt_form_data_meta ' , 1 , 2 );
348408
349- add_action ( 'add_meta_boxes ' , 'add_email_metaboxes ' );
350- function add_email_metaboxes () {
351-
352- add_meta_box ('wpt_email_data ' , 'Email Receipt Settings ' , 'wpt_email_data ' , 'paystack_form ' , 'normal ' , 'default ' );
353-
354- }
355- function wpt_email_data () {
356- global $ post ;
357-
358- // Noncename needed to verify where the data originated
359- echo '<input type="hidden" name="eventmeta_noncename" id="eventmeta_noncename" value=" ' .
360- wp_create_nonce ( plugin_basename (__FILE__ ) ) . '" /> ' ;
361-
362- // Get the location data if its already been entered
363- $ subject = get_post_meta ($ post ->ID , '_subject ' , true );
364- $ heading = get_post_meta ($ post ->ID , '_heading ' , true );
365- $ message = get_post_meta ($ post ->ID , '_message ' , true );
366- $ sendreceipt = get_post_meta ($ post ->ID , '_sendreceipt ' , true );
367-
368- if ($ subject == "" ) {$ subject = 'Thank you for your payment ' ;}
369- if ($ sendreceipt == "" ) {$ sendreceipt = 'yes ' ;}
370- if ($ heading == "" ) {$ heading = "We've received your payment " ;}
371- if ($ message == "" ) {$ message = 'Your payment was received and we appreciate it. ' ;}
372- // Echo out the field
373- echo '<p>Send Email Receipt:</p> ' ;
374- echo '<select class="form-control" name="_sendreceipt" id="parent_id" style="width:100%;">
375- <option value="no" ' .txncheck ('no ' ,$ sendreceipt ).'>Don \'t send</option>
376- <option value="yes" ' .txncheck ('yes ' ,$ sendreceipt ).'>Send</option>
377- </select> ' ;
378- echo '<p>Email Subject:</p> ' ;
379- echo '<input type="text" name="_subject" value=" ' . $ subject . '" class="widefat" /> ' ;
380- echo '<p>Email Heading:</p> ' ;
381- echo '<input type="text" name="_heading" value=" ' . $ heading . '" class="widefat" /> ' ;
382- echo '<p>Email Body/Message:</p> ' ;
383- echo '<textarea rows="6" name="_message" class="widefat" > ' .$ message .'</textarea> ' ;
384-
385- }
386409
387410
388411
0 commit comments