PluginProbe
WPGet API – Connect to any external REST API / 2.1.5
WPGet API – Connect to any external REST API v2.1.5
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 2.1.5, at includes/class-licenses.php

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