BP_GOPP_Image_Editor_GS::test( array $args = array() )

Checks to see if current environment supports Ghostscript and whether we’re compatible with args if any.

Description

In particular if given ‘path’ argument then checks filename (but not its existence or magic bytes).

Parameters

$args

(Optional)

Default value: array()

Return

(bool)

Source

File: bp-document/classes/class-bp-gopp-image-editor-gs.php

	public static function test( $args = array() ) {
		// Ensure given 'mime_type' arg, as if not _wp_image_editor_choose() won't call supports_mime_type() subsequently
		// and will return this as a supporting implementation, which is probably not what callers expect.
		if ( ! isset( $args['mime_type'] ) ) {
			return false;
		}

		// Check that exec() is (probably) available and we're not in safe_mode.
		if ( ! function_exists( 'exec' ) || ini_get( 'safe_mode' ) ) {
			return false;
		}

		// Must have path to Ghostscript executable.
		if ( ! self::gs_cmd_path() ) {
			return false;
		}

		// No manipulation supported - dedicated to producing JPEG preview.
		if ( isset( $args['methods'] ) ) {
			$unsupported_methods = array( 'resize', 'multi_resize', 'crop', 'rotate', 'flip', 'stream' );
			if ( array_intersect( $unsupported_methods, $args['methods'] ) ) {
				return false;
			}
		}

		// Do strict file name check if given path.
		if ( isset( $args['path'] ) && true !== self::gs_valid( $args['path'], true /*no_read_check*/ ) ) {
			return false;
		}

		return true;
	}

Changelog

Changelog
Version Description
BuddyBoss 1.4.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.