WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Купить персональные IPV4 и IPV6 прокси

wp_prepare_themes_for_js хук-фильтр . WP 3.8.0

Позволяет изменить данные тем на странице админки themes.php.

Также позволяет отсортировать/изменить/удалить темы отображаемые на странице тем.

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

add_filter( 'wp_prepare_themes_for_js', 'filter_function_name_3365' );
function filter_function_name_3365( $prepared_themes ){
	// filter...

	return $prepared_themes;
}
$prepared_themes(массив)
Массив тем.

Примеры

#1 Удалим тему из списка тем на странице админки

# Disable base theme from showing on themes.php admin page
add_filter( 'wp_prepare_themes_for_js', function( $themes ){
	unset( $themes['dh5'] );
	return $themes;
} );

#2 Что содержит каждый элемент массива тем

add_filter( 'wp_prepare_themes_for_js', function( $themes ){
	print_r( $themes );
} );

/*
Array (

	[twentynineteen] => Array(

			[id]   => twentynineteen
			[name] => Twenty Nineteen
			[screenshot] => Array (
				[0] => https://dh5.com/content/themes/twentynineteen/screenshot.png
			)

			[description] => Our 2019 default theme is designed to show off the power of the block editor. It features custom styles for all the default blocks, and is built so that what you see in the editor looks like what you’ll see on your website. Twenty Nineteen is designed to be adaptable to a wide range of websites, whether you’re running a photo blog, launching a new business, or supporting a non-profit. Featuring ample whitespace and modern sans-serif headlines paired with classic serif body text, it’s built to be beautiful on all screen sizes.
			[author] => the WordPress team
			[authorAndUri] => <a href="https://wordpress.org/">the WordPress team</a>
			[version]    => 1.4
			[tags]       => One Column, flexible-header, Accessibility Ready, Custom Colors, custom-menu, Custom Logo, Editor Style, Featured Images, Footer Widgets, rtl-language-support, Sticky Post, threaded-comments, translation-ready
			[parent]     => 
			[active]     => 
			[hasUpdate]  => 
			[hasPackage] => 
			[update]     => 
			[actions] => Array
				(
					[activate] => https://dh5.com/core/wp-admin/themes.php?action=activate&stylesheet=twentynineteen&_wpnonce=9296974cb0
					[customize] => https://dh5.com/core/wp-admin/customize.php?theme=twentynineteen&return=%2Fcore%2Fwp-admin%2Fthemes.php
					[delete] => https://dh5.com/core/wp-admin/themes.php?action=delete&stylesheet=twentynineteen&_wpnonce=ac50870200
				)

		),
	[dh5] => array( ... ),
	[dh5-child] => array( ... ),

)

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

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

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

wp_prepare_themes_for_js()
wp_prepare_themes_for_js
wp-admin/includes/theme.php 685
$prepared_themes = apply_filters( 'wp_prepare_themes_for_js', $prepared_themes );

Где используется хук (в ядре WP)

Использование не найдено.
Комментариев нет
    Здравствуйте, !     Войти . Зарегистрироваться