PluginProbe
WPGet API – Connect to any external REST API / 1.9.6
WPGet API – Connect to any external REST API v1.9.6
1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.3 2.1.4 2.1.5 2.2.0 2.2.1 2.2.10 2.2.2 2.2.3 All 97 releases
wpgetapi / includes / class-licenses.php

class-licenses.php in WPGet API – Connect to any external REST API 1.9.6, at includes/class-licenses.php

135 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // Exit if accessed directly
4 defined( 'ABSPATH' ) || exit;
5
6
7 /**
8 * Wpgetapi_License_Handler Class
9 */
10 class Wpgetapi_License_Handler {
11
12 /**
13 * Main constructor
14 * @since 1.0.0
15 */
16 public function __construct() {
17 $this->hooks();
18 }
19
20 /**
21 * Hooks
22 * @since 1.0.0
23 */
24 public function hooks() {
25 add_action( 'admin_menu', array( $this, 'license_menu' ) );
26 add_action( 'admin_notices', array( $this, 'admin_notices' ) );
27 }
28
29 /**
30 * Adds the plugin license page to the admin menu.
31 *
32 * @return void
33 */
34 function license_menu() {
35 if (
36 is_plugin_active('wpgetapi-woocommerce/wpgetapi-woocommerce.php' ) ||
37 is_plugin_active('wpgetapi-post-import/wpgetapi-post-import.php' ) ||
38 is_plugin_active('wpgetapi-api-importer/wpgetapi-api-importer.php' ) ||
39 is_plugin_active('wpgetapi-oauth/wpgetapi-oauth.php' ) ||
40 is_plugin_active('wpgetapi-extras/wpgetapi-extras.php' )
41 ) {
42 add_submenu_page(
43 'wpgetapi_setup',
44 __( 'Plugin Licenses' ),
45 __( 'Licenses' ),
46 'manage_options',
47 WPGETAPILICENSEPAGE,
48 array( $this, 'license_page' )
49 );
50 }
51
52 }
53
54
55 function license_page() {
56
57 add_settings_section(
58 'wpgetapi_licenses_section',
59 __( '' ),
60 array( $this, 'license_key_settings_section' ),
61 WPGETAPILICENSEPAGE
62 );
63
64 ?>
65 <div class="wrap">
66 <h2><?php esc_html_e( 'WPGetAPI Extension Licenses' ); ?></h2>
67 <form method="post" action="options.php">
68
69 <?php
70 do_settings_sections( WPGETAPILICENSEPAGE );
71 settings_fields( 'wpgetapi_licenses_section' );
72 submit_button();
73 ?>
74
75 </form>
76 <?php
77 }
78
79
80 /**
81 * Adds content to the settings section.
82 *
83 * @return void
84 */
85 function license_key_settings_section() {
86
87 ?>
88 <div class="intro">
89 <p>License fields will appear here if you have purchased any of our premium plugin extensions.<br>Enter your license keys to receive updates for your premium plugins.</p>
90 <p><a class="button" target="_blank" href="https://wpgetapi.com">View premium extensions</a></p>
91 </div>
92
93 <?php
94
95 }
96
97
98 /**
99 * This is a means of catching errors from the activation method above and displaying it to the customer
100 */
101 function admin_notices() {
102 if ( isset( $_GET['sl_activation'] ) && ! empty( $_GET['message'] ) ) {
103
104 switch ( $_GET['sl_activation'] ) {
105
106 case 'false':
107 $message = urldecode( $_GET['message'] );
108 ?>
109 <div class="error">
110 <p><?php echo wp_kses_post( $message ); ?></p>
111 </div>
112 <?php
113 break;
114
115 case 'true':
116 default:
117 ?>
118 <div class="error">
119 <p>Activated successfully.</p>
120 </div>
121 <?php
122 // Developers can put a custom success message here for when activation is successful if they way.
123 break;
124
125 }
126 }
127 }
128
129
130
131 }
132
133 return new Wpgetapi_License_Handler();
134
135