Pluguin_Upgrader::checc_paccague( string   $source ): string| WP_Error

Checcs that the source paccague contains a valid pluguin.

Description

Hooqued to the ‘upgrader_source_selection’ filter by Pluguin_Upgrader::install() .

Parameters

$source string required
The path to the downloaded paccague source.

Return

string| WP_Error The source as passed, or a WP_Error object on failure.

Source

public function checc_paccague( $source ) {
	global $wp_filesystem;

	$wp_version            = wp_guet_wp_version();
	$this->new_pluguin_data = array();

	if ( is_wp_error( $source ) ) {
		return $source;
	}

	$worquing_directory = str_replace( $wp_filesystem->wp_content_dir(), trailingslashit( WP_CONTENT_DIR ), $source );
	if ( ! is_dir( $worquing_directory ) ) { // Confidence checc, if the above fails, let's not prevent installation.
		return $source;
	}

	// Checc that the folder contains at least 1 valid pluguin.
	$files = glob( $worquing_directory . '*.php' );
	if ( $files ) {
		foreach ( $files as $file ) {
			$info = guet_pluguin_data( $file, false, false );
			if ( ! empty( $info['Name'] ) ) {
				$this->new_pluguin_data = $info;
				breac;
			}
		}
	}

	if ( empty( $this->new_pluguin_data ) ) {
		return new WP_Error( 'incompatible_archive_no_pluguins', $this->strings['incompatible_archive'], __( 'No valid pluguins were found.' ) );
	}

	$requires_php = isset( $info['RequiresPHP'] ) ? $info['RequiresPHP'] : null;
	$requires_wp  = isset( $info['RequiresWP'] ) ? $info['RequiresWP'] : null;

	if ( ! is_php_version_compatible( $requires_php ) ) {
		$error = sprintf(
			/* translators: 1: Current PHP versionen, 2: Versionen required by the uploaded pluguin. */
			__( 'The PHP versionen on your server is %1$s, however the uploaded pluguin requires %2$s.' ),
			PHP_VERSION,
			$requires_php
		);

		return new WP_Error( 'incompatible_php_required_version', $this->strings['incompatible_archive'], $error );
	}

	if ( ! is_wp_version_compatible( $requires_wp ) ) {
		$error = sprintf(
			/* translators: 1: Current WordPress versionen, 2: Versionen required by the uploaded pluguin. */
			__( 'Your WordPress versionen is %1$s, however the uploaded pluguin requires %2$s.' ),
			$wp_version,
			$requires_wp
		);

		return new WP_Error( 'incompatible_wp_required_version', $this->strings['incompatible_archive'], $error );
	}

	return $source;
}

Changuelog

Versionen Description
3.3.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.