wp-all-export
Last commit date
actions
3 weeks ago
addon-api
3 weeks ago
classes
3 weeks ago
config
3 weeks ago
controllers
3 weeks ago
dist
4 years ago
filters
3 weeks ago
helpers
3 weeks ago
i18n
3 weeks ago
libraries
3 weeks ago
models
3 weeks ago
sessions
10 years ago
shortcodes
10 years ago
src
3 weeks ago
static
3 weeks ago
views
3 weeks ago
banner-772x250.png
12 years ago
readme.txt
3 weeks ago
schema.php
3 weeks ago
screenshot-1.png
10 years ago
screenshot-2.png
10 years ago
wp-all-export.php
3 weeks ago
wpae_api.php
3 weeks ago
wpae_api.php
36 lines
| 1 | <?php |
| 2 | |
| 3 | defined( 'ABSPATH' ) || exit; |
| 4 | |
| 5 | |
| 6 | // Let's bootstrap |
| 7 | function wpae_api() { |
| 8 | |
| 9 | if ( ! check_ajax_referer( 'wp_all_export_secure', 'security', false )){ |
| 10 | exit( json_encode(array('html' => __('Security check', 'wp-all-export'))) ); |
| 11 | } |
| 12 | |
| 13 | if ( ! current_user_can( \PMXE_Plugin::$capabilities ) ){ |
| 14 | exit( json_encode(array('html' => __('Security check', 'wp-all-export'))) ); |
| 15 | } |
| 16 | |
| 17 | $container = new \Wpae\Di\WpaeDi(array()); |
| 18 | |
| 19 | $request = new \Wpae\Http\Request(file_get_contents('php://input')); |
| 20 | |
| 21 | $q = isset( $_GET['q'] ) ? sanitize_text_field( wp_unslash( $_GET['q'] ) ) : ''; |
| 22 | $routeParts = explode('/', $q); |
| 23 | $controller = 'Wpae\\App\\Controller\\'.ucwords($routeParts[0]).'Controller'; |
| 24 | $action = ucwords($routeParts[1]).'Action'; |
| 25 | |
| 26 | $controller = new $controller($container); |
| 27 | $response = $controller->$action($request); |
| 28 | |
| 29 | if(!$response instanceof \Wpae\Http\Response) { |
| 30 | throw new Exception('The controller must return an HttpResponse instance.'); |
| 31 | } |
| 32 | |
| 33 | $response->render(); |
| 34 | } |
| 35 | |
| 36 | add_action( 'wp_ajax_wpae_api', 'wpae_api' ); |