PluginProbe
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder / 3.6.0
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder v3.6.0
3.6.0 3.5.0 trunk 1.0.10 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.6.1 1.0.7 1.0.8 1.0.9 1.1 1.1.1 1.2 1.3 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.5 1.5.1 All 110 releases
buttonizer-multifunctional-button / app / Api / Utils / UseLegacyModule.php

UseLegacyModule.php in Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder 3.6.0, at app/Api/Utils/UseLegacyModule.php

74 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 * SOFTWARE LICENSE INFORMATION
4 *
5 * Copyright (c) 2017 Buttonizer, all rights reserved.
6 *
7 * This file is part of Buttonizer
8 *
9 * For detailed information regarding to the licensing of
10 * this software, please review the license.txt or visit:
11 * https://buttonizer.pro/license/
12 */
13
14 namespace Buttonizer\Api\Utils;
15
16 use Buttonizer\Core\Utils\PermissionCheck;
17 use Buttonizer\Migration\LegacyFallback;
18
19 /**
20 * Go back to an absorbed plugin's old system.
21 *
22 * The counterpart of the acquired plugin's own "use legacy version" link, kept
23 * available to users who moved to Buttonizer so the move never costs them the
24 * escape hatch they had before.
25 *
26 * @endpoint /wp-json/buttonizer/use_legacy_module
27 * @methods POST
28 */
29 class UseLegacyModule
30 {
31 /**
32 * Register route
33 */
34 public function registerRoute()
35 {
36 register_rest_route('buttonizer', '/use_legacy_module', [
37 [
38 'methods' => ['POST'],
39 'args' => [
40 'nonce' => [
41 'validate_callback' => function ($value) {
42 return wp_verify_nonce($value, 'wp_rest');
43 },
44 'required' => true
45 ],
46 ],
47 'callback' => [$this, 'useLegacy'],
48 'permission_callback' => function () {
49 return PermissionCheck::hasPermission(true);
50 }
51 ]
52 ]);
53 }
54
55 /**
56 * Restore the old system.
57 */
58 public function useLegacy()
59 {
60 $redirect = LegacyFallback::restore();
61
62 if (!$redirect) {
63 return new \WP_Error('no_legacy_system', 'There is no legacy system to go back to on this site.', [
64 'status' => 404
65 ]);
66 }
67
68 return [
69 'status' => 'success',
70 'redirect' => $redirect,
71 ];
72 }
73 }
74