PHP生成的CSS没有生效。

时间:2022-09-16 09:48:03

What I have:

A style-color.php document that dynamically writes/outputs CSS code that should ordinarily be applied to my website's pages (note: this is a theme file for a WordPress based website).

一个类型颜色。php文档,动态地写/输出CSS代码,通常应该应用到我的网站页面(注意:这是一个基于WordPress的网站的主题文件)。

My problem:

The file works perfectly locally however does not on my live website. By process of elimination, the only real difference that come to mind between my local and live environments are security hardening measures I've applied to the live environment and potentially chmod settings.

该文件在本地运行良好,但在我的实时网站上没有。通过消除的过程,我在本地和现场环境之间唯一真正的区别是,我已经将安全强化措施应用到现场环境和潜在的chmod设置中。

Security hardening: I've disabled various security hardening measures but to no avail.

安全强化:我已经禁用了各种安全措施,但没有效果。

PHP生成的CSS没有生效。

chmod settings: The style-colors.php is contained in themes > some-theme-name > style-colors.php and the respective permissions are 755 > 755 > 644.

修改文件权限设置:style-colors。php包含在>主题名称>风格的颜色中。php和相应的权限是755 > 755 > 644。

My question:

Is there anything obvious I'm overlooking with regards to the permissions or anything else that might be preventing style-colors.php from behaving as it should?

有什么明显的我可以忽略的权限或其他可能阻止风格颜色的东西。php的行为应该怎样?

1 个解决方案

#1


0  

try this code it be work.

试试这个代码就行了。

    <?php
    $root = dirname(dirname(dirname(dirname(dirname(__FILE__)))));
    if ( file_exists( $root.'/wp-load.php' ) ) {
        require_once( $root.'/wp-load.php' );
    } elseif ( file_exists( $root.'/wp-config.php' ) ) {
        require_once( $root.'/wp-config.php' );
    }
    header("Content-type: text/css");
    // start output buffer
    ob_start();


    $theme_color="#d5266c";
 ?>
    a:hover,
    a:focus{
        color:<?php echo $theme_color;?>;
    }

#1


0  

try this code it be work.

试试这个代码就行了。

    <?php
    $root = dirname(dirname(dirname(dirname(dirname(__FILE__)))));
    if ( file_exists( $root.'/wp-load.php' ) ) {
        require_once( $root.'/wp-load.php' );
    } elseif ( file_exists( $root.'/wp-config.php' ) ) {
        require_once( $root.'/wp-config.php' );
    }
    header("Content-type: text/css");
    // start output buffer
    ob_start();


    $theme_color="#d5266c";
 ?>
    a:hover,
    a:focus{
        color:<?php echo $theme_color;?>;
    }