【发布时间】:2012-12-03 13:39:01
【问题描述】:
我正在尝试使用挂钩 after_setup_theme 在主题激活时设置图像大小,但它似乎从未真正调用过它。为什么?
if( !function_exists('theme_image_size_setup') )
{
function theme_image_size_setup()
{
//Setting thumbnail size
update_option('thumbnail_size_w', 200);
update_option('thumbnail_size_h', 200);
update_option('thumbnail_crop', 1);
//Setting medium size
update_option('medium_size_w', 400);
update_option('medium_size_h', 9999);
//Setting large size
update_option('large_size_w', 800);
update_option('large_size_h', 9999);
}
}
add_action( 'after_setup_theme ', 'theme_image_size_setup' );
相反,我做了一个解决方案,但如果有一个钩子,它不会感觉最佳:
if ( is_admin() && isset($_GET['activated'] ) && $pagenow == 'themes.php' ) {
theme_image_size_setup();
}
这行得通...但是为什么after_setup_theme 钩子上没有响应?
【问题讨论】:
标签: php wordpress wordpress-theming