@@ -130,49 +130,7 @@ function pform_add_action_button($actions, $post){
130130 }
131131 add_filter ( 'page_row_actions ' , 'pform_add_action_button ' , 10 , 2 );
132132
133- add_action ( 'admin_init ' , 'custom_export_function ' );
134-
135- function custom_export_function (){
136-
137- if ( isset ( $ _REQUEST ['action ' ] ) && 'view_submissions ' == $ _REQUEST ['action ' ] ) {
138- $ data = array (
139- 'hello ' => 'world '
140- );
141-
142- ?>
143- <h1>Paystack Forms API KEYS Settings!</h1>
144- <form method="post" action="options.php">
145- <?php settings_fields ( 'paystack-form-settings-group ' ); do_settings_sections ( 'paystack-form-settings-group ' ); ?>
146- <table class="form-table paystack_setting_page">
147- <tr valign="top">
148- <th scope="row">Mode</th>
149- <td><input type="text" name="mode" value="<?php echo esc_attr ( get_option ('mode ' ) ); ?> " /></td>
150- </tr>
151- <tr valign="top">
152- <th scope="row">Test Secret Key</th>
153- <td><input type="text" name="tsk" value="<?php echo esc_attr ( get_option ('tsk ' ) ); ?> " /></td>
154- </tr>
155-
156- <tr valign="top">
157- <th scope="row">Test Public Key</th>
158- <td><input type="text" name="tpk" value="<?php echo esc_attr ( get_option ('tpk ' ) ); ?> " /></td>
159- </tr>
160-
161- <tr valign="top">
162- <th scope="row">Live Secret Key</th>
163- <td><input type="text" name="lsk" value="<?php echo esc_attr ( get_option ('lsk ' ) ); ?> " /></td>
164- </tr>
165- <tr valign="top">
166- <th scope="row">Live Public Key</th>
167- <td><input type="text" name="lsk" value="<?php echo esc_attr ( get_option ('lpk ' ) ); ?> " /></td>
168- </tr>
169- </table>
170-
171- <?php
172- }
173-
174- // exit;
175- }
133+
176134 function wpa_47010 ( $ qtInit ) {
177135 $ qtInit ['buttons ' ] = 'fullscreen ' ;
178136 return $ qtInit ;
@@ -301,6 +259,7 @@ function add_extra_metaboxes() {
301259
302260 }
303261
262+
304263 function wpt_form_data () {
305264 global $ post ;
306265
@@ -349,18 +308,14 @@ function wpt_form_data() {
349308
350309 function wpt_form_data_meta ($ post_id , $ post ) {
351310
352- // verify this came from the our screen and with proper authorization,
353- // because save_post can be triggered at other times
354311 if ( !wp_verify_nonce ( @$ _POST ['eventmeta_noncename ' ], plugin_basename (__FILE__ ) )) {
355312 return $ post ->ID ;
356313 }
357314
358315 // Is the user allowed to edit the post or page?
359- if ( !current_user_can ( 'edit_post ' , $ post ->ID ))
316+ if ( !current_user_can ( 'edit_post ' , $ post ->ID )){
360317 return $ post ->ID ;
361-
362- // OK, we're authenticated: we need to find and save the data
363- // We'll put it into an array to make it easier to loop though.
318+ }
364319
365320 $ form_meta ['_amount ' ] = $ _POST ['_amount ' ];
366321 $ form_meta ['_paybtn ' ] = $ _POST ['_paybtn ' ];
@@ -369,6 +324,11 @@ function wpt_form_data_meta($post_id, $post) {
369324 $ form_meta ['_txncharge ' ] = $ _POST ['_txncharge ' ];
370325 $ form_meta ['_loggedin ' ] = $ _POST ['_loggedin ' ];
371326 $ form_meta ['_filelimit ' ] = $ _POST ['_filelimit ' ];
327+ ///
328+ $ form_meta ['_subject ' ] = $ _POST ['_subject ' ];
329+ $ form_meta ['_heading ' ] = $ _POST ['_heading ' ];
330+ $ form_meta ['_message ' ] = $ _POST ['_message ' ];
331+ $ form_meta ['_sendreceipt ' ] = $ _POST ['_sendreceipt ' ];
372332
373333 // Add values of $form_meta as custom fields
374334
@@ -384,8 +344,47 @@ function wpt_form_data_meta($post_id, $post) {
384344 }
385345
386346 }
347+ add_action ('save_post ' , 'wpt_form_data_meta ' , 1 , 2 );
348+
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="3" name="_message" class="widefat" > ' .$ message .'</textarea> ' ;
384+
385+ }
387386
388- add_action ( ' save_post ' , ' wpt_form_data_meta ' , 1 , 2 ); // save the custom fields
387+
389388
390389 }
391390
0 commit comments