PluginProbe
WPGet API – Connect to any external REST API / 2.2.8
WPGet API – Connect to any external REST API v2.2.8
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-wpgetapi-license-handler.php

class-wpgetapi-license-handler.php in WPGet API – Connect to any external REST API 2.2.8, at includes/class-wpgetapi-license-handler.php

145 lines 2.9 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 * Checks if our extensions are installed
31 *
32 */
33 public function has_extension() {
34
35 if ( is_plugin_active( 'wpgetapi-woocommerce/wpgetapi-woocommerce.php' ) ||
36 is_plugin_active( 'wpgetapi-post-import/wpgetapi-post-import.php' ) ||
37 is_plugin_active( 'wpgetapi-api-importer/wpgetapi-api-importer.php' ) ||
38 is_plugin_active( 'wpgetapi-oauth/wpgetapi-oauth.php' ) ||
39 is_plugin_active( 'wpgetapi-extras/wpgetapi-extras.php' )
40 ) {
41 return true;
42 }
43 }
44
45
46 /**
47 * Adds the plugin license page to the admin menu.
48 *
49 * @return void
50 */
51 public function license_menu() {
52
53 add_submenu_page(
54 'wpgetapi_setup',
55 __( 'Plugin Licenses' ),
56 __( 'Licenses' ),
57 'manage_options',
58 WPGETAPILICENSEPAGE,
59 array( $this, 'license_page' )
60 );
61 }
62
63
64 public function license_page() {
65
66 add_settings_section(
67 'wpgetapi_licenses_section',
68 '',
69 array( $this, 'license_key_settings_section' ),
70 WPGETAPILICENSEPAGE
71 );
72
73 ?>
74 <div class="wrap">
75 <h2><?php esc_html_e( 'WPGetAPI Extension Licenses' ); ?></h2>
76 <form method="post" action="options.php">
77
78 <?php
79 do_settings_sections( WPGETAPILICENSEPAGE );
80 settings_fields( 'wpgetapi_licenses_section' );
81
82 // only show save button if extensions installed
83 if ( $this->has_extension() ) {
84 submit_button();
85 }
86
87 ?>
88
89 </form>
90 <?php
91 }
92
93
94 /**
95 * Adds content to the settings section.
96 *
97 * @return void
98 */
99 public function license_key_settings_section() {
100
101 ?>
102 <div class="intro">
103 <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>
104 <p><a class="button button-primary" target="_blank" href="https://wpgetapi.com/">View Premium Extensions</a></p>
105 </div>
106
107 <?php
108 }
109
110
111 /**
112 * This is a means of catching errors from the activation method above and displaying it to the customer
113 */
114 public function admin_notices() {
115 if ( isset( $_GET['sl_activation'] ) && ! empty( $_GET['message'] ) ) {
116
117 switch ( $_GET['sl_activation'] ) {
118
119 case 'false':
120 $message = urldecode( $_GET['message'] );
121 ?>
122 <div class="error">
123 <p><?php echo wp_kses_post( $message ); ?></p>
124 </div>
125 <?php
126 break;
127
128 case 'true':
129 default:
130 ?>
131 <div class="error">
132 <p>Activated successfully.</p>
133 </div>
134 <?php
135 // Developers can put a custom success message here for when activation is successful if they way.
136 break;
137
138 }
139 }
140 }
141 }
142
143 return new Wpgetapi_License_Handler();
144
145