0

I've added bootstrap to my admin page, and that is overridden everywhere. How can I fix that problem? I've asked it on wordpress.stackexchange.com they suggested me to ask here. I've googled around but i did not get specific answer. I can't add a screenshot. you can visit the screen shot at wordpress stackexchange

add_action( 'admin_enqueue_scripts', 'scripts_for_admin_page' ); 

then register and enqueue

4

1 回答 1

0

您的问题与 CSS 有关。您正在 WordPress 主题之上加载 Bootstrap 的 CSS,这会覆盖其他元素并导致不需要的结果,这是预期的。

Bootstrap 的 CSS 包含顶级 DOM 元素的样式,因此您会看到覆盖问题。 引导 CSS 源

您需要弄清楚您需要从 Bootstrap 中获得哪些 CSS 元素,并针对您的 WordPress 插件来定位它们。考虑 BootStrap 中的以下更改:

引导 CSS:

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 10px 0;
  font-family: inherit;
  font-weight: bold;
  line-height: 20px;
  color: inherit;
  text-rendering: optimizelegibility;
}

您的插件 CSS:

#myPlugin h1,
#myPlugin h2,
#myPlugin h3,
#myPlugin h4,
#myPlugin h5,
#myPlugin h6 {
  margin: 15px 0;
  font-family: inherit;
  font-weight: bold;
  line-height: 20px;
  color: inherit;
  text-rendering: optimizelegibility;
}

另外,作为另一个想法。在您的 WordPress 管理页面中,而不是:

add_action( 'admin_enqueue_scripts', 'scripts_for_admin_page' ); 

你应该考虑

<?php include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); ?> <?php is_plugin_active($plugin) ?>

Codex 参考是插件激活的:http ://codex.wordpress.org/Function_Reference/is_plugin_active

正如其他人在另一个线程中指出的那样,这实际上归结为 CSS 开发和开发 WordPress 插件的最佳实践。

于 2013-10-29T23:00:43.340 回答