Skip to content

Commit 5eae87a

Browse files
committed
Show shortcode on page
1 parent 14d29ea commit 5eae87a

1 file changed

Lines changed: 28 additions & 19 deletions

File tree

admin/class-paystack-forms-admin.php

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ function kkd_pff_paystack_remove_fullscreen( $qtInit ) {
137137
return $qtInit;
138138
}
139139
function kkd_pff_paystack_disable_wyswyg( $default ){
140-
global $post_type, $_wp_theme_features;;
140+
global $post_type, $_wp_theme_features;
141141

142142

143143
if ($post_type == 'paystack_form') {
@@ -222,22 +222,10 @@ function kkd_pff_paystack_editor_help_metabox( $post ) {
222222
do_meta_boxes( null, 'custom-metabox-holder', $post );
223223
}
224224
add_action( 'edit_form_after_title', 'kkd_pff_paystack_editor_help_metabox' );
225-
function kkd_pff_paystack_editor_add_help_metabox() {
226-
227-
add_meta_box(
228-
'awesome_metabox_id',
229-
'Help Section',
230-
'kkd_pff_paystack_editor_help_metabox_details',
231-
'paystack_form',
232-
'custom-metabox-holder' //Look what we have here, a new context
233-
);
234-
235-
}
236-
add_action( 'add_meta_boxes', 'kkd_pff_paystack_editor_add_help_metabox' );
237-
225+
238226
function kkd_pff_paystack_editor_help_metabox_details( $post ) {
239227
echo '<input type="hidden" name="eventmeta_noncename" id="eventmeta_noncename" value="' .
240-
wp_create_nonce( plugin_basename(__FILE__) ) . '" />';
228+
wp_create_nonce( plugin_basename(__FILE__) ) . '" />';
241229

242230
?>
243231
<div class="awesome-meta-admin">
@@ -250,12 +238,27 @@ function kkd_pff_paystack_editor_help_metabox_details( $post ) {
250238

251239
</div>
252240

241+
<?php
242+
}
243+
function kkd_pff_paystack_editor_shortcode_details( $post ) {
244+
?>
245+
<p class="description">
246+
<label for="wpcf7-shortcode">Copy this shortcode and paste it into your post, page, or text widget content:</label>
247+
<span class="shortcode wp-ui-highlight">
248+
<input type="text" id="wpcf7-shortcode" onfocus="this.select();" readonly="readonly" class="large-text code"
249+
value="[pff-paystack id=&quot;<?php echo $post->ID; ?>&quot;]"></span>
250+
</p>
251+
253252
<?php
254253
}
255254

256255
add_action( 'add_meta_boxes', 'kkd_pff_paystack_editor_add_extra_metaboxes' );
257256
function kkd_pff_paystack_editor_add_extra_metaboxes() {
258257

258+
if ($_GET['action'] == 'edit') {
259+
add_meta_box( 'kkd_pff_paystack_editor_help_shortcode', 'Paste shortcode on preferred page', 'kkd_pff_paystack_editor_shortcode_details', 'paystack_form', 'custom-metabox-holder');
260+
}
261+
add_meta_box( 'kkd_pff_paystack_editor_help_data', 'Help Section', 'kkd_pff_paystack_editor_help_metabox_details', 'paystack_form', 'custom-metabox-holder');
259262
add_meta_box('kkd_pff_paystack_editor_add_form_data', 'Extra Form Description', 'kkd_pff_paystack_editor_add_form_data', 'paystack_form', 'normal', 'default');
260263
add_meta_box('kkd_pff_paystack_editor_add_recur_data', 'Recurring Payment', 'kkd_pff_paystack_editor_add_recur_data', 'paystack_form', 'side', 'default');
261264
add_meta_box('kkd_pff_paystack_editor_add_email_data', 'Email Receipt Settings', 'kkd_pff_paystack_editor_add_email_data', 'paystack_form', 'normal', 'default');
@@ -442,16 +445,21 @@ function kkd_pff_paystack_editor_add_subaccount_data() {
442445
// Get the location data if its already been entered
443446
$subaccount = get_post_meta($post->ID, '_subaccount', true);
444447
$txnbearer = get_post_meta($post->ID, '_txnbearer', true);
448+
$merchantamount = get_post_meta($post->ID, '_merchantamount', true);
445449

446450

447451
if ($subaccount == "") {$subaccount = '';}
452+
if ($merchantamount == "") {$merchantamount = '';}
448453
echo '<p>Sub Account code:</p>';
449454
echo '<input type="text" name="_subaccount" value="' . $subaccount . '" class="widefat" />';
450455
echo '<p>Transaction Charge bearer:</p>';
451-
echo '<select class="form-control" name="_txnbearer" id="parent_id" style="width:100%;">
452-
<option value="account" '.kkd_pff_paystack_txncheck('account',$txnbearer).'>Merchant (default)</option>
453-
<option value="subaccount" '.kkd_pff_paystack_txncheck('subaccount',$txnbearer).'>Sub Account</option>
454-
</select>';
456+
echo '<select class="form-control" name="_txnbearer" id="parent_id" style="width:100%;">
457+
<option value="account" '.kkd_pff_paystack_txncheck('account',$txnbearer).'>Merchant (default)</option>
458+
<option value="subaccount" '.kkd_pff_paystack_txncheck('subaccount',$txnbearer).'>Sub Account</option>
459+
</select>';
460+
echo '<p>Merchant Amount:</p>';
461+
echo '<input type="text" name="_merchantamount" value="' . $merchantamount . '" class="widefat" />';
462+
455463
}
456464
function kkd_pff_paystack_save_data($post_id, $post) {
457465

@@ -488,6 +496,7 @@ function kkd_pff_paystack_save_data($post_id, $post) {
488496
$form_meta['_agreementlink'] = $_POST['_agreementlink'];
489497
$form_meta['_subaccount'] = $_POST['_subaccount'];
490498
$form_meta['_txnbearer'] = $_POST['_txnbearer'];
499+
$form_meta['_merchantamount'] = $_POST['_merchantamount'];
491500

492501
// Add values of $form_meta as custom fields
493502

0 commit comments

Comments
 (0)