WP HOOKS
akcjaod 3.3.0

after_switch_theme

Args 2Plik wp-includes/theme.phpDokumentacja WP ↗

Opis

Odpala się po aktywacji motywu. Dobry moment na ustawienie opcji domyślnych.

Przykład użycia

add_action( 'after_switch_theme', ... )php
add_action( 'after_switch_theme', 'wpdocs_on_theme_activate' );

function wpdocs_on_theme_activate() {
	update_option( 'wpdocs_theme_version', wp_get_theme()->get( 'Version' ) );
}

The parameters differ according to whether the old theme exists or not. If the old theme is missing, the old name will instead be the slug of the old theme. See {@see 'switch_theme'}.

Parametry

ParametrTypOpis
$old_namestringOld theme name.
$old_theme\WP_ThemeWP_Theme instance of the old theme.

Wywołanie

Rejestracja callbackaphp
// rejestracja funkcji zwrotnej — podaj liczbę argumentów!
add_action( 'after_switch_theme', 'twoja_funkcja', 10, 2 );

function twoja_funkcja($param_1, $param_2) {
	// Twój kod
}

Popularne w tej kategorii