| Server IP : 188.114.96.2 / Your IP : 104.23.197.230 Web Server : Apache/2.4.59 (Debian) System : Linux EDL-STRETCH 4.19.0-27-amd64 #1 SMP Debian 4.19.316-1 (2024-06-25) x86_64 User : edlftp ( 1002) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/nicolasj/www/b2b.ecoledelangues.be/wp-content/plugins/redirection/api/ |
Upload File : |
<?php
/**
* @api {get} /redirection/v1/export/:module/:format Export redirects for a module in a format
* @apiDescription Export redirects for a module in a format
* @apiGroup Export
*
* @apiParam {String} module The module to export - 1, 2, 3, or 'all'
* @apiParam {String} format The format of the export. Either 'csv', 'apache', 'nginx', or 'json'
*
* @apiSuccess {Array} ip Array of export data
* @apiSuccess {Integer} total Number of items exported
*
* @apiUse 400Error
*/
class Redirection_Api_Export extends Redirection_Api_Route {
public function __construct( $namespace ) {
register_rest_route( $namespace, '/export/(?P<module>1|2|3|all)/(?P<format>csv|apache|nginx|json)', array(
$this->get_route( WP_REST_Server::READABLE, 'route_export' ),
) );
}
public function route_export( WP_REST_Request $request ) {
$module = $request['module'];
$format = 'json';
if ( in_array( $request['format'], array( 'csv', 'apache', 'nginx', 'json' ) ) ) {
$format = $request['format'];
}
$export = Red_FileIO::export( $module, $format );
if ( $export === false ) {
return $this->add_error_details( new WP_Error( 'redirect', 'Invalid module' ), __LINE__ );
}
return array(
'data' => $export['data'],
'total' => $export['total'],
);
}
}