PluginProbe
Redirection / 3.6.2
Redirection v3.6.2
5.10.0 5.9.0 5.8.1 5.8.0 3.7.2 3.7.3 4.0 4.0.1 4.1 4.1.1 4.2 4.2.1 4.2.2 4.2.3 4.3 4.3.1 4.3.2 4.3.3 4.4 4.4.1 4.4.2 4.5 4.5.1 4.6.2 4.7.1 All 130 releases
redirection / api / api-plugin.php

api-plugin.php in Redirection 3.6.2, at api/api-plugin.php

57 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * 'Plugin' functions for Redirection
5 */
6 class Redirection_Api_Plugin extends Redirection_Api_Route {
7 public function __construct( $namespace ) {
8 register_rest_route( $namespace, '/plugin', array(
9 $this->get_route( WP_REST_Server::READABLE, 'route_status' ),
10 $this->get_route( WP_REST_Server::EDITABLE, 'route_fixit' ),
11 ) );
12
13 register_rest_route( $namespace, '/plugin/delete', array(
14 $this->get_route( WP_REST_Server::EDITABLE, 'route_delete' ),
15 ) );
16
17 register_rest_route( $namespace, '/plugin/test', array(
18 $this->get_route( WP_REST_Server::EDITABLE, 'route_test' ),
19 ) );
20 }
21
22 public function route_status( WP_REST_Request $request ) {
23 include_once dirname( REDIRECTION_FILE ) . '/models/fixer.php';
24
25 $fixer = new Red_Fixer();
26 return $fixer->get_status();
27 }
28
29 public function route_fixit( WP_REST_Request $request ) {
30 include_once dirname( REDIRECTION_FILE ) . '/models/fixer.php';
31
32 $fixer = new Red_Fixer();
33 return $fixer->fix( $fixer->get_status() );
34 }
35
36 public function route_delete() {
37 if ( is_multisite() ) {
38 return $this->getError( 'Multisite installations must delete the plugin from the network admin', __LINE__ );
39 }
40
41 $plugin = Redirection_Admin::init();
42 $plugin->plugin_uninstall();
43
44 $current = get_option( 'active_plugins' );
45 array_splice( $current, array_search( basename( dirname( REDIRECTION_FILE ) ) . '/' . basename( REDIRECTION_FILE ), $current ), 1 );
46 update_option( 'active_plugins', $current );
47
48 return array( 'location' => admin_url() . 'plugins.php' );
49 }
50
51 public function route_test() {
52 return array(
53 'success' => true,
54 );
55 }
56 }
57