PluginProbe
MakeCommerce for WooCommerce / 3.0.14
MakeCommerce for WooCommerce v3.0.14
4.1.0 4.0.8 trunk 1.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 2.0.0 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2.0 2.2.1 2.2.2 All 96 releases
← All changes | api/api.php +130 -351 trunk3.0.14 View file →
@@ -24,16 +24,8 @@
24 24 */
25 25 class API {
26 26
27 27 /**
28 - * Shipping+ confirmation page and the authorization data guarding its form.
29 - */
30 - public const SHIPPING_PLUS_SLUG = 'makecommerce_shipping_plus';
31 - public const SHIPPING_PLUS_CAPABILITY = 'manage_options';
32 - public const SHIPPING_PLUS_NONCE_ACTION = 'mc_shipping_plus_confirm';
33 - public const SHIPPING_PLUS_NONCE_FIELD = 'mc_shipping_plus_nonce';
34 -
35 - /**
36 28 * The ID of this plugin.
37 29 *
38 30 * @since 3.0.0
39 31 * @access private
@@ -145,10 +137,9 @@
145 137 */
146 138 public function fill_ordersview_paymentmethod_column( $column, $post_id ) {
147 139
148 140 if ( 'makecommerce_payment_method' === $column ) {
149 - $order = wc_get_order( $post_id );
150 - echo $order->get_meta( '_makecommerce_preselected_method', true );
141 + echo get_post_meta( $post_id, '_makecommerce_preselected_method', true );
151 142 }
152 143 }
153 144
154 145 /**
@@ -225,227 +216,145 @@
225 216
226 217 /**
227 218 * Return array with fields for settings
228 219 */
229 - return [
230 - [ 'type' => 'title', 'desc' => \MakeCommerce::get_logo_html() ],
231 - [
232 - 'type' => 'title',
233 - 'title' => __('MakeCommerce Shipping+ is now available', 'wc_makecommerce_domain'),
234 - 'desc' => sprintf(
235 - __('You\'re still using the legacy version — <a href="%s">click here to switch to the new module</a>', 'wc_makecommerce_domain'),
236 - admin_url('admin.php?page=makecommerce_shipping_plus')
237 - ),
238 - 'id' => 'mk_api_settings'
239 - ],
240 - ['type' => 'sectionend', 'id' => 'mk_api_settings'],
241 - [
220 + return array(
221 + array( 'type' => 'title', 'desc' => \MakeCommerce::get_logo_html() ),
222 + array(
242 223 'type' => 'title',
243 224 'title' => __('MakeCommerce API access credentials', 'wc_makecommerce_domain'),
244 225 'desc' => __('To use MakeCommerce/Maksekeskus services you need to enter API credentials below here <br/> <br/>', 'wc_makecommerce_domain').
245 - sprintf( __('To further configure the Payment methods please go to <a href="%s">MakeCommerce Checkout Options</a>, links to settings of our Shipment methods are listed below', 'wc_makecommerce_domain'), 'admin.php?page=wc-settings&tab=checkout&section=makecommerce'),
226 + sprintf( __('To further configure the Payment methods please go to <a href=."%s">MakeCommerce Checkout Options</a>, links to settings of our Shipment methods are listed below', 'wc_makecommerce_domain'), 'admin.php?page=wc-settings&tab=checkout&section=makecommerce'),
246 227 'id' => 'mk_api_settings'
247 - ],
248 - [
249 - 'type' => 'select',
250 - 'title' => __('Current environment', 'wc_makecommerce_domain'),
251 - 'desc' => __('See more about <a href="https://maksekeskus.ee/en/for-developers/test-environment/">MakeCommerce Test environment</a>', 'wc_makecommerce_domain'),
252 - 'default' => 'live',
253 - 'options' => [
254 - 'live' => __('Live', 'wc_makecommerce_domain'),
255 - 'test' => __('Test', 'wc_makecommerce_domain'),
256 - ],
228 + ),
229 + array(
230 + 'type' => 'select',
231 + 'title' => __('Current environment', 'wc_makecommerce_domain'),
232 + 'desc' => __('See more about <a href="https://maksekeskus.ee/en/for-developers/test-environment/">MakeCommerce Test environment</a>', 'wc_makecommerce_domain'),
233 + 'default' => 'live',
234 + 'options' => array(
235 + 'live' => __('Live', 'wc_makecommerce_domain'),
236 + 'test' => __('Test', 'wc_makecommerce_domain'),
237 + ),
257 238 'id' => 'mk_api_type'
258 - ],
259 - [
260 - 'id' => 'mk_shop_id',
261 - 'type' => 'text',
262 - 'title' => __('Shop ID (live)', 'wc_makecommerce_domain'),
263 - 'desc' => __('Get it from <a href="https://merchant.maksekeskus.ee/api.html" target="_blank">Merchant Portal</a>','wc_makecommerce_domain'),
264 - 'class' => 'input-text regular-input',
265 - ],
266 - [
267 - 'id' => 'mk_private_key',
268 - 'type' => 'text',
269 - 'title' => __('Secret key (live)', 'wc_makecommerce_domain'),
270 - 'class' => 'input-text regular-input',
271 - ],
272 - [
273 - 'id' => 'mk_public_key',
274 - 'type' => 'text',
275 - 'title' => __('Publishable key (live)', 'wc_makecommerce_domain'),
276 - 'class' => 'input-text regular-input',
277 - ],
278 - [
279 - 'id' => 'mk_test_shop_id',
280 - 'type' => 'text',
281 - 'title' => __('Shop ID (test)', 'wc_makecommerce_domain'),
282 - 'class' => 'input-text regular-input',
283 - 'default' => 'f64b4f20-5ef9-4b7b-a6fa-d623d87f0b9c',
284 - 'desc' => __('Get it from <a href="https://merchant.test.maksekeskus.ee/api.html" target="_blank">Merchant Portal Test</a>','wc_makecommerce_domain'),
285 - ],
286 - [
287 - 'id' => 'mk_test_private_key',
288 - 'type' => 'text',
289 - 'title' => __('Secret key (test)', 'wc_makecommerce_domain'),
290 - 'default' => 'MPjcVMoRZPAucsTuGK5ZukOlV7BlzgSvXOowJUkk9IFSQPVooRwcVOxzz3mhEpgM',
291 - 'class' => 'input-text regular-input',
292 - ],
293 - [
294 - 'id' => 'mk_test_public_key',
295 - 'type' => 'text',
296 - 'title' => __('Publishable key (test)', 'wc_makecommerce_domain'),
297 - 'default' => '7Hog41ci2mKkmtviMycWxpNx14pNP70m',
298 - 'class' => 'input-text regular-input',
299 - ],
300 - [
301 - 'type' => 'select',
302 - 'title' => __('Label print format', 'wc_makecommerce_domain'),
303 - 'desc' => __('In which format should shipping labels be printed. (*make sure you have API access to see more options)', 'wc_makecommerce_domain'),
304 - 'default' => 'A4',
305 - 'options' => $this->label_formats(),
306 - 'id' => 'mk_label_format'
307 - ],
308 - ['type' => 'sectionend', 'id' => 'mk_api_settings'],
309 - [
310 - 'type' => 'title',
311 - 'desc' => '<br><hr><br>',
312 - ],
313 - [
314 - 'title' => __( 'Parcel Machine Map Settings', 'wc_makecommerce_domain' ),
315 - 'type' => 'title',
316 - 'desc' => __( 'Before using, please read more about the functionalities, benefits and security measures of our parcel machine map from', 'wc_makecommerce_domain' ) .
317 - ' ' . sprintf('<a target="_blank" href="%s">' .
318 - __( 'our plugin instructions', 'wc_makecommerce_domain' ) .
319 - '</a>', __( 'https://makecommerce.net/integration-modules/makecommerce-plugin-for-woocommerce/#map-view-for-the-selection-of-parcel-machines', 'wc_makecommerce_domain' ) ),
320 - 'id' => 'mc_map_settings',
321 - ],
322 - [
323 - 'title' => __( 'Enable map selection for parcel machines', 'wc_makecommerce_domain' ),
324 - 'label' => __( 'Allow customers to select their desired parcel machine from a map view', 'wc_makecommerce_domain' ),
325 - 'type' => 'checkbox',
326 - 'default' => 'no',
327 - 'id' => 'mc_parcel_machine_map',
328 - ],
329 - [
330 - 'title' => __( 'Define Google Javascript API key', 'wc_makecommerce_domain' ),
331 - 'type' => 'text',
332 - 'desc_tip' => __( 'In order to enable the map feature for parcel machine seletion, a Google Javascript API key needs to be obtained', 'wc_makecommerce_domain' ),
333 - 'class' => 'ui-map-identifier',
334 - 'id' => 'mc_google_api_key',
335 - ],
336 - [
337 - 'title' => __( 'Use Google Geocoding', 'wc_makecommerce_domain' ),
338 - 'label' => __( 'Geocoding allows the map to centralize on the shipping address', 'wc_makecommerce_domain' ),
339 - 'type' => 'checkbox',
340 - 'default' => 'no',
341 - 'id' => 'mc_map_geocoding',
342 - ],
343 - [
344 - 'title' => __( 'Define a Google Geocoding API key', 'wc_makecommerce_domain' ),
345 - 'type' => 'text',
346 - 'desc_tip' => __( 'A separate API key is recommended to be defined for Geocoding due to security reasons', 'wc_makecommerce_domain' ),
347 - 'class' => 'ui-map-identifier',
348 - 'id' => 'mc_map_geocoding_api_key',
349 - ],
350 - [
351 - 'type' => 'sectionend',
352 - 'id' => 'mc_map_settings',
353 - ],
354 - [
355 - 'type' => 'title',
356 - 'desc' => '<br><hr><br>',
357 - ],
358 - [
359 - 'id' => 'mk_module_title',
360 - 'type' => 'title',
361 - 'title' => __('Makecommerce modules', 'wc_makecommerce_domain'),
362 - 'desc' => __('Our plugin adds several modules to your shop. Here you can switch off modules that are not important for you, they will disappear from Woocommerce settings menus.<br> Each active module have their own settings dialog, where they must also be Enabled before use.', 'wc_makecommerce_domain'),
363 - 'class' => '',
364 - ],
365 - [
366 - 'id' => 'mk_transport_apt_omniva',
367 - 'type' => 'checkbox',
368 - 'default' => 'yes',
369 - 'title' => __('Omniva Parcel Machine', 'wc_makecommerce_domain'),
370 - 'desc' => __('enable Omniva parcel machines shipping method', 'wc_makecommerce_domain').' ('. sprintf(__('<a href="%s">module settings</a>', 'wc_makecommerce_domain'), admin_url('admin.php?page=wc-settings&tab=shipping&section=parcelmachine_omniva')).')',
371 - 'class' => '',
372 - ],
373 - [
374 - 'id' => 'mk_transport_apt_smartpost',
375 - 'type' => 'checkbox',
376 - 'default' => 'yes',
377 - 'title' => __('SmartPosti Parcel Machine', 'wc_makecommerce_domain'),
378 - 'desc' => __('enable SmartPosti parcel machines shipping method', 'wc_makecommerce_domain').' ('. sprintf(__('<a href="%s">module settings</a>', 'wc_makecommerce_domain'), admin_url('admin.php?page=wc-settings&tab=shipping&section=parcelmachine_smartpost')).')',
379 - 'class' => '',
380 - ],
381 - [
382 - 'id' => 'mk_transport_apt_dpd',
383 - 'type' => 'checkbox',
384 - 'default' => 'no',
385 - 'title' => __('DPD', 'wc_makecommerce_domain') . ' ' . __('parcel machine', 'wc_makecommerce_domain'),
386 - 'desc' => __('enable DPD parcel machine shipping method', 'wc_makecommerce_domain').' ('. sprintf(__('<a href="%s">module settings</a>', 'wc_makecommerce_domain'), admin_url('admin.php?page=wc-settings&tab=shipping&section=parcelmachine_dpd')).')',
387 - 'class' => '',
388 - ],
389 - [
390 - 'id' => 'mk_transport_apt_lp_express_lt',
391 - 'type' => 'checkbox',
392 - 'default' => 'no',
393 - 'title' => __('LP Express', 'wc_makecommerce_domain') . ' ' . __('parcel machine', 'wc_makecommerce_domain'),
394 - 'desc' => __('enable LP Express parcel machine shipping method', 'wc_makecommerce_domain').' ('. sprintf(__('<a href="%s">module settings</a>', 'wc_makecommerce_domain'), admin_url('admin.php?page=wc-settings&tab=shipping&section=parcelmachine_lp_express_lt')).')',
395 - 'class' => '',
396 - ],
397 - [
398 - 'id' => 'mk_transport_courier_omniva',
399 - 'type' => 'checkbox',
400 - 'default' => 'yes',
401 - 'title' => __('Omniva Courier', 'wc_makecommerce_domain'),
402 - 'desc' => __('enable Omniva courier shipping method', 'wc_makecommerce_domain').' ('. sprintf(__('<a href="%s">module settings</a>', 'wc_makecommerce_domain'), admin_url('admin.php?page=wc-settings&tab=shipping&section=courier_omniva')).')',
403 - 'class' => '',
404 - ],
405 - [
406 - 'id' => 'mk_transport_courier_smartpost',
407 - 'type' => 'checkbox',
408 - 'default' => 'yes',
409 - 'title' => __('Smartpost Courier', 'wc_makecommerce_domain'),
410 - 'desc' => __('enable Smartpost courier shipping method', 'wc_makecommerce_domain').' ('. sprintf(__('<a href="%s">module settings</a>', 'wc_makecommerce_domain'), admin_url('admin.php?page=wc-settings&tab=shipping&section=courier_smartpost')).')',
411 - 'class' => '',
412 - ],
413 - [
414 - 'id' => 'mk_transport_courier_dpd',
415 - 'type' => 'checkbox',
416 - 'default' => 'yes',
417 - 'title' => __('DPD Courier', 'wc_makecommerce_domain'),
418 - 'desc' => __('enable DPD courier shipping method', 'wc_makecommerce_domain').' ('. sprintf(__('<a href="%s">module settings</a>', 'wc_makecommerce_domain'), admin_url('admin.php?page=wc-settings&tab=shipping&section=courier_dpd')).')',
419 - 'class' => '',
420 - ],
421 - [
422 - 'id' => 'mk_javascript_ui',
423 - 'type' => 'api_javascript_ui',
424 - ],
425 - ['type' => 'sectionend', 'id' => 'mk_api_settings']
426 - ];
239 + ),
240 + array(
241 + 'id' => 'mk_shop_id',
242 + 'type' => 'text',
243 + 'title' => __('Shop ID (live)', 'wc_makecommerce_domain'),
244 + 'desc' => __('Get it from <a href="https://merchant.maksekeskus.ee/api.html" target="_blank">Merchant Portal</a>','wc_makecommerce_domain'),
245 + 'class' => 'input-text regular-input',
246 + ),
247 + array(
248 + 'id' => 'mk_private_key',
249 + 'type' => 'text',
250 + 'title' => __('Secret key (live)', 'wc_makecommerce_domain'),
251 + 'class' => 'input-text regular-input',
252 + ),
253 + array(
254 + 'id' => 'mk_public_key',
255 + 'type' => 'text',
256 + 'title' => __('Publishable key (live)', 'wc_makecommerce_domain'),
257 + 'class' => 'input-text regular-input',
258 + ),
259 + array(
260 + 'id' => 'mk_test_shop_id',
261 + 'type' => 'text',
262 + 'title' => __('Shop ID (test)', 'wc_makecommerce_domain'),
263 + 'class' => 'input-text regular-input',
264 + 'default' => 'f64b4f20-5ef9-4b7b-a6fa-d623d87f0b9c',
265 + 'desc' => __('Get it from <a href="https://merchant.test.maksekeskus.ee/api.html" target="_blank">Merchant Portal Test</a>','wc_makecommerce_domain'),
266 + ),
267 + array(
268 + 'id' => 'mk_test_private_key',
269 + 'type' => 'text',
270 + 'title' => __('Secret key (test)', 'wc_makecommerce_domain'),
271 + 'default' => 'MPjcVMoRZPAucsTuGK5ZukOlV7BlzgSvXOowJUkk9IFSQPVooRwcVOxzz3mhEpgM',
272 + 'class' => 'input-text regular-input',
273 + ),
274 + array(
275 + 'id' => 'mk_test_public_key',
276 + 'type' => 'text',
277 + 'title' => __('Publishable key (test)', 'wc_makecommerce_domain'),
278 + 'default' => '7Hog41ci2mKkmtviMycWxpNx14pNP70m',
279 + 'class' => 'input-text regular-input',
280 + ),
281 + array(
282 + 'type' => 'select',
283 + 'title' => __('Label print format', 'wc_makecommerce_domain'),
284 + 'desc' => __('In which format should shipping labels be printed. (*make sure you have API access to see more options)', 'wc_makecommerce_domain'),
285 + 'default' => 'A4',
286 + 'options' => $this->label_formats(),
287 + 'id' => 'mk_label_format'
288 + ),
289 + array('type' => 'sectionend', 'id' => 'mk_api_settings'),
290 + array(
291 + 'type' => 'title',
292 + 'desc' => '<br><hr><br>',
293 + ),
294 + array(
295 + 'id' => 'mk_module_title',
296 + 'type' => 'title',
297 + 'title' => __('Makecommerce modules', 'wc_makecommerce_domain'),
298 + 'desc' => __('Our plugin adds several modules to your shop. Here you can switch off modules that are not important for you, they will disappear from Woocommerce settings menus.<br> Each active module have their own settings dialog, where they must also be Enabled before use.', 'wc_makecommerce_domain'),
299 + 'class' => '',
300 + ),
301 + array(
302 + 'id' => 'mk_transport_apt_omniva',
303 + 'type' => 'checkbox',
304 + 'default' => 'yes',
305 + 'title' => __('Omniva Parcel Machine', 'wc_makecommerce_domain'),
306 + 'desc' => __('enable Omniva parcel machines shipping method', 'wc_makecommerce_domain').' ('. sprintf(__('<a href="%s">module settings</a>', 'wc_makecommerce_domain'), admin_url('admin.php?page=wc-settings&tab=shipping&section=parcelmachine_omniva')).')',
307 + 'class' => '',
308 + ),
309 + array(
310 + 'id' => 'mk_transport_apt_smartpost',
311 + 'type' => 'checkbox',
312 + 'default' => 'yes',
313 + 'title' => __('Smartpost Parcel Machine', 'wc_makecommerce_domain'),
314 + 'desc' => __('enable Smartpost parcel machines shipping method', 'wc_makecommerce_domain').' ('. sprintf(__('<a href="%s">module settings</a>', 'wc_makecommerce_domain'), admin_url('admin.php?page=wc-settings&tab=shipping&section=parcelmachine_smartpost')).')',
315 + 'class' => '',
316 + ),
317 + array(
318 + 'id' => 'mk_transport_apt_dpd',
319 + 'type' => 'checkbox',
320 + 'default' => 'no',
321 + 'title' => __('DPD', 'wc_makecommerce_domain') . ' ' . __('parcel machine', 'wc_makecommerce_domain'),
322 + 'desc' => __('enable DPD parcel machine shipping method', 'wc_makecommerce_domain').' ('. sprintf(__('<a href="%s">module settings</a>', 'wc_makecommerce_domain'), admin_url('admin.php?page=wc-settings&tab=shipping&section=parcelmachine_dpd')).')',
323 + 'class' => '',
324 + ),
325 + array(
326 + 'id' => 'mk_transport_courier_omniva',
327 + 'type' => 'checkbox',
328 + 'default' => 'yes',
329 + 'title' => __('Omniva Courier', 'wc_makecommerce_domain'),
330 + 'desc' => __('enable Omniva courier shipping method', 'wc_makecommerce_domain').' ('. sprintf(__('<a href="%s">module settings</a>', 'wc_makecommerce_domain'), admin_url('admin.php?page=wc-settings&tab=shipping&section=courier_omniva')).')',
331 + 'class' => '',
332 + ),
333 + array(
334 + 'id' => 'mk_transport_courier_smartpost',
335 + 'type' => 'checkbox',
336 + 'default' => 'yes',
337 + 'title' => __('Smartpost Courier', 'wc_makecommerce_domain'),
338 + 'desc' => __('enable Smartpost courier shipping method', 'wc_makecommerce_domain').' ('. sprintf(__('<a href="%s">module settings</a>', 'wc_makecommerce_domain'), admin_url('admin.php?page=wc-settings&tab=shipping&section=courier_smartpost')).')',
339 + 'class' => '',
340 + ),
341 + array(
342 + 'id' => 'mk_checkout_sco',
343 + 'type' => 'checkbox',
344 + 'title' => __('SimpleCheckout', 'wc_makecommerce_domain'),
345 + 'desc' => __('enable SimpleCheckout&trade; Checkout method', 'wc_makecommerce_domain').' ('. sprintf(__('<a href="%s">module settings</a>', 'wc_makecommerce_domain'), admin_url('admin.php?page=wc-settings&tab=checkout&section=makecommerce_sc')).')',
346 + 'class' => '',
347 + ),
348 + array(
349 + 'id' => 'mk_javascript_ui',
350 + 'type' => 'api_javascript_ui',
351 + ),
352 + array('type' => 'sectionend', 'id' => 'mk_api_settings')
353 + );
427 354 }
428 355
429 356 /**
430 - * Function for resetting machines and payment methods when API type is changed
431 - *
432 - * @since 3.2.1
433 - */
434 - public function mk_delete_api_cache() {
435 -
436 - global $wpdb;
437 - $tableName = $wpdb->prefix . MAKECOMMERCE_TABLENAME;
438 -
439 - // Delete machines' cache and timer
440 - delete_option( 'mk_machines_expires' );
441 - delete_option( 'mk_machines_cache' );
442 -
443 - // Delete payment methods
444 - $wpdb->query( 'TRUNCATE TABLE `'.$tableName.'`' );
445 - }
446 -
447 - /**
448 357 * Notice for missing API information
449 358 *
450 359 * @since 3.0.0
451 360 */
@@ -462,136 +371,6 @@
462 371 <?php } ?>
463 372 </p>
464 373 </div>
465 374 <?php
466 - }
467 -
468 -
469 - public function shipping_api_notice()
470 - {
471 - ?>
472 - <div class="notice notice-success">
473 - <p>
474 - <strong><?php echo __('MakeCommerce Shipping+ is now available', 'wc_makecommerce_domain'); ?> </strong> <br/>
475 - <?php echo __("You're still using the legacy version —", 'wc_makecommerce_domain'); ?>
476 - <a href="<?php echo admin_url('admin.php?page=makecommerce_shipping_plus'); ?>"><?php echo __('click here to switch to the new module', 'wc_makecommerce_domain'); ?></a>
477 - </p>
478 - </div>
479 - <?php
480 - }
481 -
482 - // Separate Admin page for Shipping+ confirmation, when user checks shipping+ in old version
483 - public function enqueue_shipping_plus_assets($hook): void
484 - {
485 - if ($hook !== 'admin_page_makecommerce_shipping_plus') {
486 - return;
487 - }
488 -
489 - wp_enqueue_style(
490 - 'makecommerce-bootstrap',
491 - plugin_dir_url(__DIR__) . 'makecommerce/assets/bootstrap.5.3.3.min.css'
492 - );
493 -
494 - wp_enqueue_style(
495 - 'shipping-confirm',
496 - 'https://static.maksekeskus.ee/modules/woocommerce/css/shipping-confirm.css'
497 - );
498 -
499 - wp_enqueue_script(
500 - 'makecommerce-bootstrap',
501 - plugin_dir_url(__DIR__) . 'makecommerce/assets/bootstrap.bundle.min.js',
502 - [],
503 - null,
504 - true
505 - );
506 - }
507 - public function add_shipping_plus_admin_page()
508 - {
509 - add_submenu_page(
510 - 'shipping_plus',
511 - 'Shipping+ Confirmation',
512 - 'Shipping+ Confirmation',
513 - self::SHIPPING_PLUS_CAPABILITY,
514 - self::SHIPPING_PLUS_SLUG,
515 - [$this, 'render_shipping_plus_page']
516 - );
517 - }
518 -
519 - public function remove_shipping_confirm_menu(): void {
520 - remove_submenu_page( 'shipping_plus', self::SHIPPING_PLUS_SLUG );
521 - }
522 -
523 - public function render_shipping_plus_page()
524 - {
525 - $file = plugin_dir_path(__FILE__) . 'templates/shipping_confirm.php';
526 -
527 - if (file_exists($file)) {
528 - include $file;
529 - } else {
530 - echo '<div class="wrap"><h1>Page not found</h1></div>';
531 - }
532 - }
533 -
534 - public function hide_shipping_admin_notices(): void
535 - {
536 - $screen = get_current_screen();
537 -
538 - if ($screen && $screen->id === 'admin_page_makecommerce_shipping_plus') {
539 - remove_all_actions('admin_notices');
540 - remove_all_actions('all_admin_notices');
541 - }
542 - }
543 -
544 - public function save_shipping_plus_confirmation(): void
545 - {
546 - $current_page = isset($_GET['page']) ? sanitize_text_field(wp_unslash($_GET['page'])) : '';
547 -
548 - if (
549 - isset($_POST['accept_shipping']) &&
550 - $current_page === self::SHIPPING_PLUS_SLUG
551 - ) {
552 - // Only users who are allowed to see this page may confirm the migration
553 - if (!current_user_can(self::SHIPPING_PLUS_CAPABILITY)) {
554 - wp_die(
555 - esc_html__('You do not have permission to change MakeCommerce settings.', 'wc_makecommerce_domain'),
556 - esc_html__('Forbidden', 'wc_makecommerce_domain'),
557 - ['response' => 403]
558 - );
559 - }
560 -
561 - check_admin_referer(self::SHIPPING_PLUS_NONCE_ACTION, self::SHIPPING_PLUS_NONCE_FIELD);
562 -
563 - update_option('mc_shipping_plus_confirmed', 'yes');
564 - update_option('mc_shipping_plus', 'yes');
565 - update_option('makecommerce_install_status', 'upgrade');
566 - $this->mc_shipping_plus_creds_migration();
567 - wp_redirect(admin_url('admin.php?page=makecommerce_dashboard'));
568 - exit;
569 - }
570 - }
571 -
572 - /**
573 - * Run credentials migration when 'mc_shipping_plus' is turned on
574 - *
575 - * @return void
576 - */
577 - private function mc_shipping_plus_creds_migration(): void
578 - {
579 - $migration_map = [
580 - 'mc_shop_id' => 'mk_shop_id',
581 - 'mc_secret_key' => 'mk_private_key',
582 - 'mc_public_key' => 'mk_public_key',
583 - 'mc_test_shop_id' => 'mk_test_shop_id',
584 - 'mc_test_secret_key' => 'mk_test_private_key',
585 - 'mc_test_public_key' => 'mk_test_public_key',
586 - 'mc_api_mode' => 'mk_api_type',
587 - ];
588 -
589 - foreach ($migration_map as $new_key => $old_key) {
590 - $old_value = get_option($old_key, null);
591 -
592 - if ($old_value !== null) {
593 - update_option($new_key, $old_value);
594 - }
595 - }
596 375 }
597 376 }