@@ -161,10 +161,6 @@ public function __construct() {
161161
162162 add_action ( 'wp_ajax_nopriv_rtmedia_api ' , array ( $ this , 'rtmedia_api_process_request ' ) );
163163 add_action ( 'wp_ajax_rtmedia_api ' , array ( $ this , 'rtmedia_api_process_request ' ) );
164-
165- if ( defined ( 'RTMEDIA_GODAM_ACTIVE ' ) && RTMEDIA_GODAM_ACTIVE ) {
166- add_action ( 'rest_api_init ' , [ $ this , 'register_rest_pre_dispatch_filter ' ] );
167- }
168164 }
169165
170166 /**
@@ -1473,39 +1469,4 @@ public function api_new_media_upload_dir( $args ) {
14731469 return $ args ;
14741470 }
14751471 }
1476-
1477- /**
1478- * Registers the rest_pre_dispatch filter during rest_api_init.
1479- */
1480- public function register_rest_pre_dispatch_filter () {
1481- add_filter ( 'rest_pre_dispatch ' , [ $ this , 'handle_rest_pre_dispatch ' ], 10 , 3 );
1482- }
1483-
1484- /**
1485- * Callback for rest_pre_dispatch filter.
1486- *
1487- * @param mixed $result Result to return instead of the request. Default null to continue with request.
1488- * @param WP_REST_Server $server Server instance.
1489- * @param WP_REST_Request $request Request object.
1490- *
1491- * @return mixed Modified result or original $result.
1492- */
1493- public function handle_rest_pre_dispatch ( $ result , $ server , $ request ) {
1494- $ route = $ request ->get_route ();
1495- $ method = $ request ->get_method ();
1496-
1497- if ( 'GET ' === $ method && preg_match ( '#^/wp/v2/media/(\d+)$# ' , $ route , $ matches ) ) {
1498- $ media_id = (int ) $ matches [1 ];
1499- $ post = get_post ( $ media_id );
1500-
1501- if ( $ post && 'attachment ' === $ post ->post_type ) {
1502- $ controller = new WP_REST_Attachments_Controller ( 'attachment ' );
1503- $ response = $ controller ->prepare_item_for_response ( $ post , $ request );
1504-
1505- return rest_ensure_response ( $ response );
1506- }
1507- }
1508-
1509- return $ result ;
1510- }
15111472}
0 commit comments