芝麻web文件管理V1.00
编辑当前文件:/home/soundframestudio/smith.soundframestudios.net/wp-content/plugins/redirection/api/api-log.php
$this->get_filter_args( $orders, $filters ), $this->get_route( WP_REST_Server::READABLE, 'route_log', [ $this, 'permission_callback_manage' ] ), ) ); register_rest_route( $namespace, '/bulk/log/(?P
delete)', [ $this->get_route( WP_REST_Server::EDITABLE, 'route_bulk', [ $this, 'permission_callback_delete' ] ), 'args' => array_merge( $this->get_filter_args( $orders, $filters ), [ 'items' => [ 'description' => 'Comma separated list of item IDs to perform action on', 'type' => 'array', 'items' => [ 'description' => 'Item ID', 'type' => [ 'string', 'number' ], ], ], ] ), ] ); } /** * Checks a manage capability * * @param WP_REST_Request $request Request. * @return Bool */ public function permission_callback_manage( WP_REST_Request $request ) { return Redirection_Capabilities::has_access( Redirection_Capabilities::CAP_LOG_MANAGE ); } /** * Checks a delete capability * * @param WP_REST_Request $request Request. * @return Bool */ public function permission_callback_delete( WP_REST_Request $request ) { return Redirection_Capabilities::has_access( Redirection_Capabilities::CAP_LOG_DELETE ); } /** * Get log list * * @param WP_REST_Request $request The request. * @return WP_Error|array Return an array of results, or a WP_Error */ public function route_log( WP_REST_Request $request ) { return $this->get_logs( $request->get_params() ); } /** * Perform bulk action on logs * * @param WP_REST_Request $request The request. * @return WP_Error|array Return an array of results, or a WP_Error */ public function route_bulk( WP_REST_Request $request ) { $params = $request->get_params(); if ( isset( $params['items'] ) && is_array( $params['items'] ) ) { $items = $params['items']; foreach ( $items as $item ) { if ( is_numeric( $item ) ) { Red_Redirect_Log::delete( intval( $item, 10 ) ); } elseif ( isset( $params['groupBy'] ) ) { $delete_by = 'url-exact'; if ( in_array( $params['groupBy'], [ 'ip', 'agent' ], true ) ) { $delete_by = sanitize_text_field( $params['groupBy'] ); } Red_Redirect_Log::delete_all( [ 'filterBy' => [ $delete_by => $item ] ] ); } } } elseif ( isset( $params['global'] ) && $params['global'] ) { Red_Redirect_Log::delete_all( $params ); } return $this->route_log( $request ); } private function get_logs( array $params ) { if ( isset( $params['groupBy'] ) && in_array( $params['groupBy'], [ 'ip', 'url', 'agent' ], true ) ) { return Red_Redirect_Log::get_grouped( sanitize_text_field( $params['groupBy'] ), $params ); } return Red_Redirect_Log::get_filtered( $params ); } }