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