引导覆盖WordPress的默认行为


Bootstrap overriding the default behavior of wordpress

我已经将引导程序添加到我的管理页面,这在任何地方都被覆盖了。我该如何解决这个问题?我已经问过了 wordpress.stackexchange.com 他们建议我在这里问。我用谷歌搜索过,但我没有得到具体的答案。我无法添加屏幕截图。您可以访问屏幕截图WordPress堆栈交换

add_action( 'admin_enqueue_scripts', 'scripts_for_admin_page' ); 

然后注册并排队

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

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) ?>

法典参考处于活动状态:http://codex.wordpress.org/Function_Reference/is_plugin_active

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