
跨版本PHP代码转换终极教程
wp_get_custom_css ( $stylesheet = '' )
wp_get_custom_css: 这个函数返回一个主题或当前网站的自定义CSS,这取决于它被调用的环境。它通常在wp_head动作中使用,以输出自定义CSS。
获取保存的自定义CSS内容进行渲染。
function wp_get_custom_css( $stylesheet = '' ) { $css = ''; if ( empty( $stylesheet ) ) { $stylesheet = get_stylesheet(); } $post = wp_get_custom_css_post( $stylesheet ); if ( $post ) { $css = $post->post_content; } /** * Filters the custom CSS output into the head element. * * @since 4.7.0 * * @param string $css CSS pulled in from the Custom CSS post type. * @param string $stylesheet The theme stylesheet name. */ $css = apply_filters( 'wp_get_custom_css', $css, $stylesheet ); return $css; }