2013-08-07 08:38:38 +02:00
|
|
|
<?php
|
|
|
|
|
2017-12-01 00:09:33 +01:00
|
|
|
if ( class_exists( 'WP_Image_Editor' ) ) :
|
2013-08-07 08:38:38 +02:00
|
|
|
|
|
|
|
class WP_Image_Editor_Mock extends WP_Image_Editor {
|
|
|
|
|
|
|
|
public static $load_return = true;
|
|
|
|
public static $test_return = true;
|
|
|
|
public static $save_return = array();
|
2020-07-04 06:13:17 +02:00
|
|
|
public static $spy = array();
|
|
|
|
public static $edit_return = array();
|
|
|
|
public static $size_return = null;
|
2013-08-07 08:38:38 +02:00
|
|
|
|
2014-12-15 22:24:21 +01:00
|
|
|
// Allow testing of jpeg_quality filter.
|
|
|
|
public function set_mime_type( $mime_type = null ) {
|
|
|
|
$this->mime_type = $mime_type;
|
|
|
|
}
|
|
|
|
|
2013-08-07 08:38:38 +02:00
|
|
|
public function load() {
|
|
|
|
return self::$load_return;
|
|
|
|
}
|
2013-09-12 06:40:13 +02:00
|
|
|
public static function test( $args = array() ) {
|
2013-08-07 08:38:38 +02:00
|
|
|
return self::$test_return;
|
|
|
|
}
|
|
|
|
public static function supports_mime_type( $mime_type ) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
public function resize( $max_w, $max_h, $crop = false ) {
|
2020-07-04 06:13:17 +02:00
|
|
|
self::$spy[ __FUNCTION__ ][] = func_get_args();
|
|
|
|
if ( isset( self::$edit_return[ __FUNCTION__ ] ) ) {
|
|
|
|
return self::$edit_return[ __FUNCTION__ ];
|
|
|
|
}
|
2013-08-07 08:38:38 +02:00
|
|
|
}
|
|
|
|
public function multi_resize( $sizes ) {
|
2020-07-04 06:13:17 +02:00
|
|
|
self::$spy[ __FUNCTION__ ][] = func_get_args();
|
|
|
|
if ( isset( self::$edit_return[ __FUNCTION__ ] ) ) {
|
|
|
|
return self::$edit_return[ __FUNCTION__ ];
|
|
|
|
}
|
2013-08-07 08:38:38 +02:00
|
|
|
}
|
|
|
|
public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false ) {
|
2020-07-04 06:13:17 +02:00
|
|
|
self::$spy[ __FUNCTION__ ][] = func_get_args();
|
|
|
|
if ( isset( self::$edit_return[ __FUNCTION__ ] ) ) {
|
|
|
|
return self::$edit_return[ __FUNCTION__ ];
|
|
|
|
}
|
2013-08-07 08:38:38 +02:00
|
|
|
}
|
|
|
|
public function rotate( $angle ) {
|
2020-07-04 06:13:17 +02:00
|
|
|
self::$spy[ __FUNCTION__ ][] = func_get_args();
|
|
|
|
if ( isset( self::$edit_return[ __FUNCTION__ ] ) ) {
|
|
|
|
return self::$edit_return[ __FUNCTION__ ];
|
|
|
|
}
|
2013-08-07 08:38:38 +02:00
|
|
|
}
|
|
|
|
public function flip( $horz, $vert ) {
|
2020-07-04 06:13:17 +02:00
|
|
|
self::$spy[ __FUNCTION__ ][] = func_get_args();
|
|
|
|
if ( isset( self::$edit_return[ __FUNCTION__ ] ) ) {
|
|
|
|
return self::$edit_return[ __FUNCTION__ ];
|
|
|
|
}
|
2013-08-07 08:38:38 +02:00
|
|
|
}
|
|
|
|
public function save( $destfilename = null, $mime_type = null ) {
|
|
|
|
return self::$save_return;
|
|
|
|
}
|
|
|
|
public function stream( $mime_type = null ) {
|
|
|
|
|
|
|
|
}
|
2020-07-04 06:13:17 +02:00
|
|
|
|
|
|
|
public function get_size() {
|
|
|
|
if ( self::$size_return ) {
|
|
|
|
return self::$size_return;
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::get_size();
|
|
|
|
}
|
2013-08-07 08:38:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
endif;
|