| | 941 | * Runs the activation hooks for a newly activated theme |
| | 942 | * |
| | 943 | * @since unknown |
| | 944 | * @uses do_action() Calls 'activate_theme-{theme-slug}' action on template and stylesheet |
| | 945 | * |
| | 946 | * @param string $template Template name |
| | 947 | * @param string $stylesheet Stylesheet name |
| | 948 | */ |
| | 949 | function run_theme_activation_hook($template, $stylesheet) { |
| | 950 | if ( $stylesheet != $template ) |
| | 951 | do_action('activate_theme-' . $stylesheet); |
| | 952 | do_action('activate_theme-' . $template); |
| | 953 | } |
| | 954 | |
| | 955 | /** |
| | 956 | * Runs the deactivation hooks for a disabled theme |
| | 957 | * |
| | 958 | * @since unknown |
| | 959 | * @uses do_action() Calls 'activate_theme-{theme-slug}' action on template and stylesheet |
| | 960 | * |
| | 961 | * @param string $template Template name |
| | 962 | * @param string $stylesheet Stylesheet name |
| | 963 | */ |
| | 964 | function run_theme_deactivation_hook($template, $stylesheet) { |
| | 965 | if ( $template != $stylesheet ) |
| | 966 | do_action('deactivate_theme-' . $stylesheet); |
| | 967 | do_action('deactivate_theme-' . $template); |
| | 968 | } |
| | 969 | |
| | 970 | /** |
| | 971 | * Set the activation hook for a theme. |
| | 972 | * |
| | 973 | * Warning: Must be called from a file directly within the themes root folder, not a subdir |
| | 974 | * |
| | 975 | * @since 2.7 |
| | 976 | * |
| | 977 | * @param string $file Filename of a file inside the themes folder |
| | 978 | * @param string $function The Activation callback |
| | 979 | */ |
| | 980 | function register_theme_activation_hook($file, $function) { |
| | 981 | $file = str_replace('\\', '/', $file); //Win32 => unix |
| | 982 | $theme = preg_replace('|^.*/|', '', dirname($file)); //greedy replace until final folder remainss |
| | 983 | |
| | 984 | add_action('activate_theme-' . $theme, $function); |
| | 985 | } |
| | 986 | |
| | 987 | /** |
| | 988 | * Set the deactivation hook for a theme. |
| | 989 | * |
| | 990 | * Warning: Must be called from a file directly within the themes root folder, not a subdir |
| | 991 | * |
| | 992 | * @since 2.7 |
| | 993 | * |
| | 994 | * @param string $file Filename of a file inside the themes folder |
| | 995 | * @param string $function The Activation callback |
| | 996 | */ |
| | 997 | function register_theme_deactivation_hook($file, $function) { |
| | 998 | $file = str_replace('\\', '/', $file); //Win32 => unix |
| | 999 | $theme = preg_replace('|^.*/|', '', dirname($file)); //greedy replace until final folder remainss |
| | 1000 | add_action('deactivate_theme-' . $theme, $function); |
| | 1001 | } |
| | 1002 | |
| | 1003 | /** |