使用大量独立的样式表为站点创建子主题,并从主题和插件中注册/排队。我想更改<link>
最终输出中的标记,同时避免网站所有者更新父主题后发生冲突。
目标是不重新注册/重新排队.css
已由父主题和/或插件设置的文件,同时有效地将一组新参数传递给wp_register_style
作用
例如,当前这是父主题&;插件正在做:
// parent theme or plugin\'s php
wp_register_style( \'a_stylesheet\', $uri . \'css/a-stylesheet.css\', array(), $version, \'screen\' );
// html output
<link rel=\'stylesheet\' id=\'a_stylesheet-css\' href=\'http://domain.com/wp-content/themes/theme/css/a-stylesheet.css\' type=\'text/css\' media=\'screen\' />
目标是让儿童主题实际上改变
wp_register_style
打电话,就像这样:
// child theme\'s php
some_function_to_reregister( \'already_registered_file\', $inherit, $inherit, $inherit, \'handheld\' )
// if the above doesn\'t exist, do nothing; else, re-register with the new argument(s).
// html output
<link rel=\'stylesheet\' id=\'a_stylesheet-css\' href=\'http://domain.com/wp-content/themes/theme/css/a-stylesheet.css\' type=\'text/css\' media=\'handheld\' />
这将改变
<link media>
把某事归因于某人
handheld
而不是
screen
, 但保留父主题/插件所做的所有其他操作,如果文件尚未在其他地方注册(即更新后),则跳过注册。
似乎这将是一种比从父主题和插件中取消注册/取消排队css更有效的方法,只需将其复制/粘贴回子主题,并在将来的更新中产生意外的破坏。