简体   繁体   English

用CSS设计wordpress插件

[英]design wordpress plugin with css

I wrote a small plugin and i want to add some css design my plugin meta boxes in the WordPress system. 我写了一个小插件,我想在WordPress系统中添加一些CSS设计我的插件元框。 All the scripts of adding a css file to WordPress plugin that I found are referring to including a css file in the plugin output page on the website itself. 我发现将css文件添加到WordPress插件的所有脚本都是指在网站本身的插件输出页面中包含css文件。 - wp_enqueue_scripts -wp_enqueue_scripts

the solution i created is to use this piece of code in my plugin page: 我创建的解决方案是在插件页面中使用以下代码:

echo '<style type="text/css">';
include( '/css/style.css' );
echo '</style>';  

But if feels to me like an unprofessional solution so I wanted to ask if anyone knows a better solution 但是,如果我觉得这是不专业的解决方案,那么我想问问是否有人知道更好的解决方案

You can use wp_enqueue_style() yourself, with plugins_url() : 您可以通过wp_enqueue_style()自己使用wp_enqueue_style() plugins_url()

function my_styles(){
    $css_path = plugins_url('/css/style.css', __FILE__);
    wp_enqueue_style('my_stylesheet', $css_path);
}
add_action( 'admin_init', 'my_styles' );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM