PluginProbe
MakeCommerce for WooCommerce / 3.5.4
MakeCommerce for WooCommerce v3.5.4
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 +0 -148 trunk3.5.4 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
@@ -227,18 +219,8 @@
227 219 * Return array with fields for settings
228 220 */
229 221 return [
230 222 [ '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 223 [
242 224 'type' => 'title',
243 225 'title' => __('MakeCommerce API access credentials', 'wc_makecommerce_domain'),
244 226 'desc' => __('To use MakeCommerce/Maksekeskus services you need to enter API credentials below here <br/> <br/>', 'wc_makecommerce_domain').
@@ -462,136 +444,6 @@
462 444 <?php } ?>
463 445 </p>
464 446 </div>
465 447 <?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 448 }
597 449 }