plugin_row_metaхук-фильтрWP 2.8.0

Позволяет изменить метаданные (ссылка, версия и т.д.) выводимые для каждого плагина в таблице плагинов.

Пример таких данных (версия, автор, детали) для плагина Query Monitor:

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

add_filter( 'plugin_row_meta', 'wp_kama_plugin_row_meta_filter', 10, 4 );

/**
 * Function for `plugin_row_meta` filter-hook.
 * 
 * @param string[] $plugin_meta An array of the plugin's metadata, including the version, author, author URI, and plugin URI.
 * @param string   $plugin_file Path to the plugin file relative to the plugins directory.
 * @param array    $plugin_data An array of plugin data.
 * @param string   $status      Status filter currently applied to the plugin list. Possible values are: 'all', 'active', 'inactive', 'recently_activated', 'upgrade', 'mustuse', 'dropins', 'search', 'paused', 'auto-update-enabled', 'auto-update-disabled'.
 *
 * @return string[]
 */
function wp_kama_plugin_row_meta_filter( $plugin_meta, $plugin_file, $plugin_data, $status ){

	// filter...
	return $plugin_meta;
}
$plugin_meta(массив)

Элементы, которые будут выведены в данных плагина (строке таблицы под описанием плагина). Обычно сюда нам нужно добавить свой элемент. Например:

Array (
	[0] => Версия 3.5.2
	[1] => Автор: <a href="https://querymonitor.com/">John Blackbourn</a>
	[2] => <a href="https://example.com/wp-admin/plugin-install.php?tab=plugin-information&plugin=query-monitor&TB_iframe=true&width=600&height=550" class="thickbox open-plugin-details-modal" aria-label="Подробности о Query Monitor" data-title="Query Monitor">Детали</a>
)
$plugin_file(строка)
Путь к файлу плагина относительно каталога плагинов. Например: query-monitor/query-monitor.php
$plugin_data(массив)

Данные плагина. Например:

Array (
	[id] => w.org/plugins/query-monitor
	[slug] => query-monitor
	[plugin] => query-monitor/query-monitor.php
	[new_version] => 3.5.2
	[url] => https://wordpress.org/plugins/query-monitor/
	[package] => https://downloads.wordpress.org/plugin/query-monitor.3.5.2.zip
	[icons] => Array
		(
			[2x] => https://ps.w.org/query-monitor/assets/icon-256x256.png?rev=2056073
			[1x] => https://ps.w.org/query-monitor/assets/icon.svg?rev=2056073
			[svg] => https://ps.w.org/query-monitor/assets/icon.svg?rev=2056073
		)

	[banners] => Array
		(
			[2x] => https://ps.w.org/query-monitor/assets/banner-1544x500.png?rev=1629576
			[1x] => https://ps.w.org/query-monitor/assets/banner-772x250.png?rev=1731469
		)

	[banners_rtl] => Array
		(
		)

	[Name] => Query Monitor
	[PluginURI] => https://querymonitor.com/
	[Version] => 3.5.2
	[Description] => Панель инструментов разработчика для WordPress.
	[Author] => John Blackbourn
	[AuthorURI] => https://querymonitor.com/
	[TextDomain] => query-monitor
	[DomainPath] => /languages/
	[Network] =>
	[RequiresWP] =>
	[RequiresPHP] => 5.3.6
	[Title] => Query Monitor
	[AuthorName] => John Blackbourn
)
$status(строка)

Текущая "вкладка" в списке плагинов. Может быть

  • all
  • active
  • inactive
  • recently_activated
  • upgrade
  • mustuse
  • dropinss
  • search

По умолчанию: 'all'

Примеры

0

#1 Добавим ссылку на страницу с донатом в данные плагина

Код из плагина Featured Image Generator:

add_filter( 'plugin_row_meta', 'fig_add_plugin_row_meta', 10, 2);

function fig_add_plugin_row_meta($meta, $file) {
	if ($file == plugin_basename( __FILE__ )) {
		$meta[] = '<a href="https://www.paypal.me/watcharapon/0usd" target="_blank">Donate</a>';
	}

	return $meta;
}

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

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

Где вызывается хук

WP_Plugins_List_Table::single_row()
plugin_row_meta
wp-admin/includes/class-wp-plugins-list-table.php 1254
$plugin_meta = apply_filters( 'plugin_row_meta', $plugin_meta, $plugin_file, $plugin_data, $status );

Где используется хук в WordPress

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