Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
$this->get_filter_args( $orders, $filters ),
$this->get_route( WP_REST_Server::READABLE, 'route_404', [ $this, 'permission_callback_manage' ] ),
$this->get_route( WP_REST_Server::EDITABLE, 'route_delete_all', [ $this, 'permission_callback_delete' ] ),
) );
register_rest_route( $namespace, '/bulk/404/(?Pdelete)', array(
$this->get_route( WP_REST_Server::EDITABLE, 'route_bulk', [ $this, 'permission_callback_delete' ] ),
'args' => array_merge( $this->get_filter_args( $orders ), [
'items' => [
'description' => 'Comma separated list of item IDs to perform action on',
'type' => 'string',
'required' => true,
'sanitize_callback' => [ $this, 'sanitize_bulk' ],
],
] ),
) );
}
public function sanitize_bulk( $param ) {
return explode( ',', $param );
}
public function permission_callback_manage( WP_REST_Request $request ) {
return Redirection_Capabilities::has_access( Redirection_Capabilities::CAP_404_MANAGE );
}
public function permission_callback_delete( WP_REST_Request $request ) {
return Redirection_Capabilities::has_access( Redirection_Capabilities::CAP_404_DELETE );
}
public function route_404( WP_REST_Request $request ) {
return $this->get_404( $request->get_params() );
}
public function route_bulk( WP_REST_Request $request ) {
$params = $request->get_params();
$items = $request['items'];
foreach ( $items as $item ) {
if ( is_numeric( $item ) ) {
RE_404::delete( intval( $item, 10 ) );
} else {
RE_404::delete_all( $this->get_delete_group( $params ), $item );
}
}
return $this->route_404( $request );
}
private function get_delete_group( array $params ) {
if ( isset( $params['groupBy'] ) && $params['groupBy'] === 'ip' ) {
return 'ip';
}
return 'url-exact';
}
public function route_delete_all( WP_REST_Request $request ) {
$params = $request->get_params();
if ( isset( $params['items'] ) && is_array( $params['items'] ) ) {
foreach ( $params['items'] as $url ) {
RE_404::delete_all( $this->get_delete_group( $params ), $url );
}
} else {
$first_filter = isset( $params['filterBy'] ) ? array_keys( $params['filterBy'] )[0] : false;
RE_404::delete_all( $first_filter ? $first_filter : false, $first_filter ? $params['filterBy'][ $first_filter ] : false );
unset( $params['filterBy'] );
}
unset( $params['page'] );
return $this->get_404( $params );
}
private function get_404( array $params ) {
if ( isset( $params['groupBy'] ) && in_array( $params['groupBy'], array( 'ip', 'url' ), true ) ) {
return RE_Filter_Log::get_grouped( 'redirection_404', $params['groupBy'], $params );
}
return RE_Filter_Log::get( 'redirection_404', 'RE_404', $params );
}
}