Skip to content

Commit b810d1c

Browse files
committed
remove leftover code
1 parent e4ff594 commit b810d1c

File tree

2 files changed

+0
-118
lines changed

2 files changed

+0
-118
lines changed

inc/api.php

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -351,59 +351,6 @@ public function get_optimized_images( $api_key = '' ) {
351351
return $this->request( '/optml/v1/stats/images', 'GET', [], [ 'application' => $app_key ] );
352352
}
353353

354-
/**
355-
* Get the watermarks from API.
356-
*
357-
* @param string $api_key The API key.
358-
*
359-
* @return array|bool|WP_Error
360-
*/
361-
public function get_watermarks( $api_key = '' ) {
362-
if ( ! empty( $api_key ) ) {
363-
$this->api_key = $api_key;
364-
}
365-
366-
return $this->request( '/optml/v1/settings/watermark' );
367-
}
368-
369-
/**
370-
* Remove the watermark from the API.
371-
*
372-
* @param integer $post_id The watermark post ID.
373-
* @param string $api_key The API key.
374-
*
375-
* @return array|bool|WP_Error
376-
*/
377-
public function remove_watermark( $post_id, $api_key = '' ) {
378-
if ( ! empty( $api_key ) ) {
379-
$this->api_key = $api_key;
380-
}
381-
382-
return $this->request( '/optml/v1/settings/watermark', 'DELETE', [ 'watermark' => $post_id ] );
383-
}
384-
385-
/**
386-
* Add watermark.
387-
*
388-
* @param array $file The file to be uploaded.
389-
*
390-
* @return array|bool|mixed|object
391-
*/
392-
public function add_watermark( $file ) {
393-
394-
$headers = [
395-
'Content-Disposition' => 'attachment; filename=' . $file['file']['name'],
396-
];
397-
398-
$response = $this->request( 'wp/v2/media', 'POST', file_get_contents( $file['file']['tmp_name'] ), $headers );
399-
400-
if ( $response === false ) {
401-
return false;
402-
}
403-
404-
return $response;
405-
}
406-
407354
/**
408355
* Call the images endpoint.
409356
*

inc/rest.php

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,6 @@ class Optml_Rest {
8181
'clear_offload_errors' => 'GET',
8282
'get_offload_conflicts' => 'GET',
8383
],
84-
'watermark_routes' => [
85-
'poll_watermarks' => 'GET',
86-
'add_watermark' => 'POST',
87-
'remove_watermark' => 'POST',
88-
],
8984
'conflict_routes' => [
9085
'poll_conflicts' => 'GET',
9186
'dismiss_conflict' => 'POST',
@@ -175,7 +170,6 @@ public function register() {
175170
$this->register_service_routes();
176171

177172
$this->register_image_routes();
178-
$this->register_watermark_routes();
179173
$this->register_conflict_routes();
180174
$this->register_cache_routes();
181175
$this->register_media_offload_routes();
@@ -217,14 +211,6 @@ public function register_media_offload_routes() {
217211
}
218212
}
219213

220-
/**
221-
* Method to register watermark specific routes.
222-
*/
223-
public function register_watermark_routes() {
224-
foreach ( self::$rest_routes['watermark_routes'] as $route => $details ) {
225-
$this->reqister_route( $route, $details );
226-
}
227-
}
228214

229215
/**
230216
* Method to register conflicts specific routes.
@@ -650,57 +636,6 @@ public function poll_optimized_images( WP_REST_Request $request ) {
650636
return $this->response( $final_images );
651637
}
652638

653-
/**
654-
* Get watermarks from API.
655-
*
656-
* @param WP_REST_Request $request rest request.
657-
*
658-
* @return WP_REST_Response
659-
*/
660-
public function poll_watermarks( WP_REST_Request $request ) {
661-
$api_key = $request->get_param( 'api_key' );
662-
$request = new Optml_Api();
663-
$watermarks = $request->get_watermarks( $api_key );
664-
if ( ! isset( $watermarks['watermarks'] ) || empty( $watermarks['watermarks'] ) ) {
665-
return $this->response( [] );
666-
}
667-
$final_images = array_splice( $watermarks['watermarks'], 0, 10 );
668-
669-
return $this->response( $final_images );
670-
}
671-
672-
/**
673-
* Add watermark.
674-
*
675-
* @param WP_REST_Request $request rest request.
676-
*
677-
* @return WP_REST_Response
678-
*/
679-
public function add_watermark( WP_REST_Request $request ) {
680-
$file = $request->get_file_params();
681-
$request = new Optml_Api();
682-
$response = $request->add_watermark( $file );
683-
if ( $response === false ) {
684-
return $this->response( __( 'Error uploading image. Please try again.', 'optimole-wp' ), 'error' );
685-
}
686-
687-
return $this->response( __( 'Watermark image uploaded succesfully !', 'optimole-wp' ) );
688-
}
689-
690-
/**
691-
* Remove watermark.
692-
*
693-
* @param WP_REST_Request $request rest request.
694-
*
695-
* @return WP_REST_Response
696-
*/
697-
public function remove_watermark( WP_REST_Request $request ) {
698-
$post_id = $request->get_param( 'postID' );
699-
$api_key = $request->get_param( 'api_key' );
700-
$request = new Optml_Api();
701-
702-
return $this->response( $request->remove_watermark( $post_id, $api_key ) );
703-
}
704639

705640
/**
706641
* Get conflicts from API.

0 commit comments

Comments
 (0)