ACF

Updater::modify_plugin_detailspublicACF 5.0.0

Returns the plugin data visible in the 'View details' popup

Метод класса: Updater{}

Хуков нет.

Возвращает

$result.

Использование

$Updater = new Updater();
$Updater->modify_plugin_details( $result, $action, $args );
$result(объект) (обязательный)
The current result of plugin data.
$action(строка)
The action being performed.
По умолчанию: null
$args(объект)
Data about the plugin being retried.
По умолчанию: null

Список изменений

С версии 5.0.0 Введена.

Код Updater::modify_plugin_details() ACF 6.4.2

public function modify_plugin_details( $result, $action = null, $args = null ) {

	$plugin = false;

	// Only for 'plugin_information' action.
	if ( $action !== 'plugin_information' ) {
		return $result;
	}

	// Find plugin via slug.
	$plugin = $this->get_plugin_by( 'slug', $args->slug );
	if ( ! $plugin ) {
		return $result;
	}

	// Get data from connect or cache.
	$response = $this->get_plugin_info( $plugin['id'] );

	// Bail early if no response.
	if ( ! is_array( $response ) ) {
		return $result;
	}

	// Remove tags (different context).
	unset( $response['tags'] );

	// Convert to object.
	$response = (object) $response;

	$sections = array(
		'description'    => '',
		'installation'   => '',
		'changelog'      => '',
		'upgrade_notice' => '',
	);
	foreach ( $sections as $k => $v ) {
		$sections[ $k ] = $response->$k;
	}
	$response->sections = $sections;

	return $response;
}