_wp_image_editor_choose() WP 3.5.0
Tests which editors are capable of supporting the request.
Эта функция считается внутренней для использования самим ядром. Не рекомендуется использовать эту функцию в своем коде.
Хуки из функции
Возвращает
Строку/false
. Class name for the first editor that claims to support the request. False if no editor claims to support the request.
Использование
_wp_image_editor_choose( $args );
- $args(массив)
- Array of arguments for choosing a capable editor.
По умолчанию: empty array
Список изменений
С версии 3.5.0 | Введена. |
Код _wp_image_editor_choose() wp image editor choose WP 5.7.1
function _wp_image_editor_choose( $args = array() ) {
require_once ABSPATH . WPINC . '/class-wp-image-editor.php';
require_once ABSPATH . WPINC . '/class-wp-image-editor-gd.php';
require_once ABSPATH . WPINC . '/class-wp-image-editor-imagick.php';
/**
* Filters the list of image editing library classes.
*
* @since 3.5.0
*
* @param string[] $image_editors Array of available image editor class names. Defaults are
* 'WP_Image_Editor_Imagick', 'WP_Image_Editor_GD'.
*/
$implementations = apply_filters( 'wp_image_editors', array( 'WP_Image_Editor_Imagick', 'WP_Image_Editor_GD' ) );
foreach ( $implementations as $implementation ) {
if ( ! call_user_func( array( $implementation, 'test' ), $args ) ) {
continue;
}
if ( isset( $args['mime_type'] ) &&
! call_user_func(
array( $implementation, 'supports_mime_type' ),
$args['mime_type']
) ) {
continue;
}
if ( isset( $args['methods'] ) &&
array_diff( $args['methods'], get_class_methods( $implementation ) ) ) {
continue;
}
return $implementation;
}
return false;
}