-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.php
More file actions
65 lines (57 loc) · 2.1 KB
/
settings.php
File metadata and controls
65 lines (57 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
if (!defined('ABSPATH')) {
exit;
}
include_once('license-checker.php');
// Registering the settings submenu under the FAQ post type
function faq_license_submenu() {
add_submenu_page(
'edit.php?post_type=faq',
'License Settings',
'License Settings',
'manage_options',
'faq-license-settings',
'faq_license_settings_page_callback'
);
}
add_action('admin_menu', 'faq_license_submenu');
// The callback function for rendering the settings page
function faq_license_settings_page_callback() {
$message = '';
$license_status = 'unknown';
if (isset($_POST['submit_license'])) {
// License checking
$license_key = sanitize_text_field($_POST['license_key']);
$product_id = "EKeffS79qIwGp5MyHRS6oQ==";
$verification_result = check_gumroad_license($license_key, $product_id);
// Handle the result of the verification
if($verification_result) {
$message = "License verified successfully!";
$license_status = 'valid';
} else {
$message = "License verification failed. Please check your license key.";
$license_status = 'invalid';
}
}
// Render the settings page
echo '<div class="wrap">';
echo '<h1>License Settings for WP Accessible FAQ</h1>';
if (!empty($message)) {
echo '<div id="message" class="updated fade"><p>' . $message . '</p></div>';
}
echo '<form method="post" action="">';
echo '<table class="form-table">';
echo '<tbody>';
echo '<tr>';
echo '<th scope="row">License Key</th>';
echo '<td>';
echo '<input name="license_key" type="text" value="' . get_option('faq_plugin_license_key') . '" class="regular-text">';
echo '</td>';
echo '</tr>';
echo '</tbody>';
echo '</table>';
echo '<p class="submit"><input type="submit" name="submit_license" id="submit" class="button button-primary" value="Save Changes"></p>';
echo '</form>';
echo '</div>';
}
// Remember to handle where and how you're storing the license key and status, such as in the WordPress options table.