1 | <?php |
---|
2 | /** |
---|
3 | * Licence Manager Comment |
---|
4 | * |
---|
5 | * @category Views |
---|
6 | * @package gdpr-cookie-compliance |
---|
7 | * @author Moove Agency |
---|
8 | */ |
---|
9 | |
---|
10 | if ( ! defined( 'ABSPATH' ) ) { |
---|
11 | exit; |
---|
12 | } // Exit if accessed directly |
---|
13 | |
---|
14 | ?> |
---|
15 | <h2 class="gdpr-tt gdpr-tt-licence"> |
---|
16 | <?php esc_html_e( 'Licence Manager', 'gdpr-cookie-compliance' ); ?> |
---|
17 | <?php do_action( 'gdpr_cc_licence_manager_action_button', false ); ?> |
---|
18 | </h2> |
---|
19 | <hr /> |
---|
20 | <?php |
---|
21 | |
---|
22 | $is_bulk_view = false; |
---|
23 | if ( function_exists('is_multisite') && is_multisite() ) : |
---|
24 | $is_bulk_view = isset( $_GET['view'] ); |
---|
25 | endif; |
---|
26 | |
---|
27 | $gdpr_default_content = new Moove_GDPR_Content(); |
---|
28 | $option_name = $gdpr_default_content->moove_gdpr_get_option_name(); |
---|
29 | $gdpr_options = get_option( $option_name ); |
---|
30 | $gdpr_options = is_array( $gdpr_options ) ? $gdpr_options : array(); |
---|
31 | $option_key = $gdpr_default_content->moove_gdpr_get_key_name(); |
---|
32 | $gdpr_key = $gdpr_default_content->gdpr_get_activation_key( $option_key ); |
---|
33 | |
---|
34 | if ( $is_bulk_view ) : ?> |
---|
35 | <div class="gdpr-msba-wrap"> |
---|
36 | <?php |
---|
37 | wp_nonce_field( 'gdpr_tab_licence_bulk', 'gdpr_lt_nonce_bulk' ); |
---|
38 | if ( function_exists('is_multisite') && is_multisite() ) : |
---|
39 | if ( ! class_exists('Moove_GDPR_Content') ) : |
---|
40 | ?> |
---|
41 | <div class="notice notice-error is-dismissible"> |
---|
42 | <p><?php _e( 'Please activate the GDPR Cookie Compliance base plugin first.', 'gdpr-cc-ms-activator' ); ?></p> |
---|
43 | </div> |
---|
44 | <?php |
---|
45 | else : |
---|
46 | $args = array( |
---|
47 | 'fields' => 'ids', |
---|
48 | 'number' => 2000 |
---|
49 | ); |
---|
50 | $sites = get_sites( $args ); |
---|
51 | if ( $sites && ! empty( $sites ) && count( $sites ) >= 1 ) : |
---|
52 | |
---|
53 | $table_cnt = ''; |
---|
54 | $licence_key = ''; |
---|
55 | $gdpr_default_content = new Moove_GDPR_Content(); |
---|
56 | $option_key = $gdpr_default_content->moove_gdpr_get_key_name(); |
---|
57 | ob_start(); |
---|
58 | if ( $sites && ! empty( $sites ) && count( $sites ) >= 1 ) : |
---|
59 | foreach ( $sites as $blogid ) : |
---|
60 | $blog_details = get_blog_details( $blogid ); |
---|
61 | switch_to_blog( $blogid ); |
---|
62 | $gdpr_key = $gdpr_default_content->gdpr_get_activation_key( $option_key ); |
---|
63 | ?> |
---|
64 | <tr class="<?php echo isset( $gdpr_key['activation'] ) ? '' : 'msba-na' ?>"> |
---|
65 | <td data-bid="<?php echo $blogid ?>"> |
---|
66 | <input name="gdpr_msb_licence_activator_tool[]" type="checkbox" <?php echo isset( $gdpr_key['activation'] ) ? '' : 'checked="checked"' ?> value="<?php echo esc_attr( $blogid ); ?>" id="gdpr_msb_licence_activator_tool_<?php echo esc_attr( $blogid ); ?>" class="on-off"> |
---|
67 | </td> |
---|
68 | <td> |
---|
69 | <label for="gdpr_msb_licence_activator_tool_<?php echo esc_attr( $blogid ); ?>"> |
---|
70 | <?php |
---|
71 | $name = esc_attr( $blog_details->blogname ); |
---|
72 | $name = $name ? $name : get_home_url( $blogid ); |
---|
73 | echo $name; |
---|
74 | ?> |
---|
75 | |
---|
76 | </label> |
---|
77 | </td> |
---|
78 | <td class="msba-licence_k"> |
---|
79 | <?php |
---|
80 | echo isset( $gdpr_key['key'] ) ? apply_filters( 'gdpr_licence_key_visibility', $gdpr_key['key'] ) : 'N/A'; |
---|
81 | $licence_key = $licence_key ? $licence_key : ( isset( $gdpr_key['key'] ) ? $gdpr_key['key'] : '' ); |
---|
82 | ?> |
---|
83 | </td> |
---|
84 | <td class="msba-status"> |
---|
85 | <?php echo isset( $gdpr_key['activation'] ) ? '<span class="gdpr-admin-lbl gdpr-active">Active</span>' : '<span class="gdpr-admin-lbl gdpr-inactive">Not Active</span>'; ?> |
---|
86 | </td> |
---|
87 | </tr> |
---|
88 | <?php |
---|
89 | restore_current_blog(); |
---|
90 | endforeach; |
---|
91 | endif; |
---|
92 | $table_cnt = ob_get_clean(); |
---|
93 | ?> |
---|
94 | <div class="licence-key-wrap-m"> |
---|
95 | <form action="gdpr_msba_bulk_activate" class="licence-key-wrap" data-ajax="<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>" method="post" id="moove_gdpr_tab_cd_settings"> |
---|
96 | <label for="" style="margin: 0 15px 0 0; line-height: 30px;">Licence Key</label> |
---|
97 | <div class="input-wrap"> |
---|
98 | <input type="text" style="margin: 0;" class="form-control" name="gdpr_msba_licence_key" value="<?php echo $licence_key; ?>" required> |
---|
99 | </div> |
---|
100 | <!-- .input-wrap --> |
---|
101 | <button type="submit" class="button button-primary gdpr-msba-bulk-activate" style="margin-left: 15px;">Bulk Activate</button> |
---|
102 | </form> |
---|
103 | <div class="msba-progress-bar" style="display: none;"> |
---|
104 | <div class="msba-progress" style="height:12px;width:0%"></div> |
---|
105 | </div> |
---|
106 | </div> |
---|
107 | <!-- .licence-key-wrap --> |
---|
108 | <table class="wp-list-table widefat fixed striped table-view-list posts"> |
---|
109 | <thead> |
---|
110 | <tr> |
---|
111 | <td class="manage-column column-cb check-column" style="width: 40px;"> |
---|
112 | <input name="gdpr_msb_licence_activator_tool_all" type="checkbox"> |
---|
113 | </td> |
---|
114 | <th> |
---|
115 | Install Name |
---|
116 | </th> |
---|
117 | <th> |
---|
118 | Licence Key |
---|
119 | </th> |
---|
120 | <th> |
---|
121 | Status |
---|
122 | </th> |
---|
123 | </tr> |
---|
124 | |
---|
125 | </thead> |
---|
126 | <tbody> |
---|
127 | <?php echo $table_cnt; ?> |
---|
128 | </tbody> |
---|
129 | </table> |
---|
130 | <?php |
---|
131 | endif; |
---|
132 | endif; |
---|
133 | |
---|
134 | else : |
---|
135 | ?> |
---|
136 | <div class="notice notice-error is-dismissible"> |
---|
137 | <p><?php _e( 'This tool supports only WordPress Multisite installs. !', 'gdpr-cc-ms-activator' ); ?></p> |
---|
138 | </div> |
---|
139 | <?php |
---|
140 | endif; |
---|
141 | ?> |
---|
142 | </div> |
---|
143 | <!-- .wrap --> |
---|
144 | <?php |
---|
145 | else : ?> |
---|
146 | <form action="<?php echo esc_url( admin_url( 'admin.php?page=moove-gdpr_licence&tab=licence' ) ); ?>" method="post" id="moove_gdpr_license_settings"> |
---|
147 | <table class="form-table"> |
---|
148 | <tbody> |
---|
149 | <tr> |
---|
150 | <td colspan="2" class="gdpr_license_log_alert" style="padding: 0;"> |
---|
151 | <?php |
---|
152 | $is_valid_license = false; |
---|
153 | $nonce = isset( $_POST['gdpr_lt_nonce_k'] ) ? sanitize_key( wp_unslash( $_POST['gdpr_lt_nonce_k'] ) ) : false; |
---|
154 | ; |
---|
155 | if ( isset( $_POST['moove_gdpr_license_key'] ) && isset( $_POST['gdpr_activate_license'] ) && wp_verify_nonce( $nonce, 'gdpr_tab_licence_v' ) ) : |
---|
156 | $license_key = sanitize_text_field( wp_unslash( $_POST['moove_gdpr_license_key'] ) ); |
---|
157 | if ( $license_key ) : |
---|
158 | $license_manager = new Moove_GDPR_License_Manager(); |
---|
159 | $is_valid_license = $license_manager->get_premium_add_on( $license_key, 'activate' ); |
---|
160 | if ( $is_valid_license && isset( $is_valid_license['valid'] ) && true === $is_valid_license['valid'] ) : |
---|
161 | update_option( |
---|
162 | $option_key, |
---|
163 | array( |
---|
164 | 'key' => $is_valid_license['key'], |
---|
165 | 'activation' => $is_valid_license['data']['today'], |
---|
166 | �� ) |
---|
167 | ); |
---|
168 | // VALID. |
---|
169 | $gdpr_key = $gdpr_default_content->gdpr_get_activation_key( $option_key ); |
---|
170 | $messages = isset( $is_valid_license['message'] ) && is_array( $is_valid_license['message'] ) ? implode( '<br>', $is_valid_license['message'] ) : ''; |
---|
171 | do_action( 'gdpr_get_alertbox', 'success', $is_valid_license, $license_key ); |
---|
172 | else : |
---|
173 | // INVALID. |
---|
174 | do_action( 'gdpr_get_alertbox', 'error', $is_valid_license, $license_key ); |
---|
175 | endif; |
---|
176 | endif; |
---|
177 | elseif ( isset( $_POST['gdpr_deactivate_license'] ) && wp_verify_nonce( $nonce, 'gdpr_tab_licence_v' ) ) : |
---|
178 | $gdpr_default_content = new Moove_GDPR_Content(); |
---|
179 | $option_key = $gdpr_default_content->moove_gdpr_get_key_name(); |
---|
180 | $gdpr_key = $gdpr_default_content->gdpr_get_activation_key( $option_key ); |
---|
181 | |
---|
182 | if ( $gdpr_key && isset( $gdpr_key['key'] ) && isset( $gdpr_key['activation'] ) ) : |
---|
183 | $license_manager = new Moove_GDPR_License_Manager(); |
---|
184 | $is_valid_license = $license_manager->premium_deactivate( $gdpr_key['key'] ); |
---|
185 | |
---|
186 | update_option( |
---|
187 | $option_key, |
---|
188 | array( |
---|
189 | 'key' => $gdpr_key['key'], |
---|
190 | 'deactivation' => strtotime( 'now' ), |
---|
191 | ) |
---|
192 | ); |
---|
193 | |
---|
194 | $gdpr_key = $gdpr_default_content->gdpr_get_activation_key( $option_key ); |
---|
195 | |
---|
196 | if ( $is_valid_license && isset( $is_valid_license['valid'] ) && true === $is_valid_license['valid'] ) : |
---|
197 | // VALID. |
---|
198 | do_action( 'gdpr_get_alertbox', 'success', $is_valid_license, $gdpr_key ); |
---|
199 | else : |
---|
200 | // INVALID. |
---|
201 | do_action( 'gdpr_get_alertbox', 'error', $is_valid_license, $gdpr_key ); |
---|
202 | endif; |
---|
203 | endif; |
---|
204 | elseif ( $gdpr_key && isset( $gdpr_key['key'] ) && isset( $gdpr_key['activation'] ) ) : |
---|
205 | $license_manager = new Moove_GDPR_License_Manager(); |
---|
206 | $is_valid_license = $license_manager->get_premium_add_on( $gdpr_key['key'], 'check' ); |
---|
207 | $gdpr_key = $gdpr_default_content->gdpr_get_activation_key( $option_key ); |
---|
208 | if ( $is_valid_license && isset( $is_valid_license['valid'] ) && true === $is_valid_license['valid'] ) : |
---|
209 | // VALID. |
---|
210 | do_action( 'gdpr_get_alertbox', 'success', $is_valid_license, $gdpr_key ); |
---|
211 | else : |
---|
212 | // INVALID. |
---|
213 | do_action( 'gdpr_get_alertbox', 'error', $is_valid_license, $gdpr_key ); |
---|
214 | endif; |
---|
215 | endif; |
---|
216 | ?> |
---|
217 | </td> |
---|
218 | </tr> |
---|
219 | <?php do_action( 'gdpr_licence_input_field', $is_valid_license, $gdpr_key ); ?> |
---|
220 | </tbody> |
---|
221 | </table> |
---|
222 | <?php do_action( 'gdpr_licence_action_button', $is_valid_license, $gdpr_key ); ?> |
---|
223 | <?php do_action( 'gdpr_cc_general_buttons_settings' ); ?> |
---|
224 | <?php wp_nonce_field( 'gdpr_tab_licence_v', 'gdpr_lt_nonce_k' ); ?> |
---|
225 | </form> |
---|
226 | |
---|
227 | <?php do_action( 'gdpr_cc_licence_manager_action_button', true ); ?> |
---|
228 | <?php endif; ?> |
---|
229 | <div class="gdpr-admin-popup gdpr-admin-popup-deactivate" style="display: none;"> |
---|
230 | <span class="gdpr-popup-overlay"></span> |
---|
231 | <div class="gdpr-popup-content"> |
---|
232 | <div class="gdpr-popup-content-header"> |
---|
233 | <a href="#" class="gdpr-popup-close"><span class="dashicons dashicons-no-alt"></span></a> |
---|
234 | </div> |
---|
235 | <!-- .gdpr-popup-content-header --> |
---|
236 | <div class="gdpr-popup-content-content"> |
---|
237 | <h4><strong><?php esc_html_e( 'Please confirm that you would like to de-activate this licence.', 'gdpr-cookie-compliance' ); ?> </strong></h4><p><strong><?php esc_html_e( 'This action will remove all of the premium features from your website.', 'gdpr-cookie-compliance' ); ?></strong></p> |
---|
238 | <button class="button button-primary button-deactivate-confirm"> |
---|
239 | <?php esc_html_e( 'Deactivate Licence', 'gdpr-cookie-compliance' ); ?> |
---|
240 | </button> |
---|
241 | </div> |
---|
242 | <!-- .gdpr-popup-content-content --> |
---|
243 | </div> |
---|
244 | <!-- .gdpr-popup-content --> |
---|
245 | </div> |
---|
246 | <!-- .gdpr-admin-popup --> |
---|