dougao1542 2019-01-18 18:12
浏览 66

我的样式没有被浏览器呈现。 难道我做错了什么?

I have enqueue a stylesheet into a plugin I built. When I load the page I can see that there is a link tag created linking to my stylesheet. I can view the stylesheet in chrome's source tab. However the class is not applied to my element.

My Element without it's class being applied

Header showing the link to my style sheet

Source tab showing the stylesheet

I've added this line to the top of my file to make sure that the stylesheet is enqueued before the subsequent html is rendered

<?php echo wp_style_is($this->product_controller->plugin_name) ? 'enqueued' : 'nope'; ?>

this always echos out 'enqueued'

when my class is instantiated this function runs. This calls the function on whatever controller is passed in.

private function add_default_actions($controller, $classname)
{
    $prefixed_name = "pp_" . $classname;
    $this->loader->add_action( 'admin_enqueue_scripts', $controller, 'enqueue_styles' );
    $this->loader->add_action( 'admin_enqueue_scripts', $controller, 'enqueue_scripts' );
    //when a request is made to to admin-ajax.php
    $this->loader->add_action( 'wp_ajax_' . $prefixed_name, $controller, 'ajax_handler');
    $this->loader->add_action( 'wp_ajax_' . $prefixed_name, $controller, 'check_nonce');
}

this is the function that gets run in my $controller

public function enqueue_styles()
{
    $location = plugin_dir_url( __FILE__ ) . 'css/'. $this->classname .'.css';
    wp_enqueue_style( $this->plugin_name, $location, array(), $this->version, 'all' );
}

I'm trying to turn a h2 tag blue so that I know my styles is getting rendered and my browser is like, nope.

  • 写回答

1条回答 默认 最新

  • doulun1666 2019-01-22 15:46
    关注

    The issue was that I was calling it classname instead of class. That fixed it.

    I've been working in javascript too long.

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog