PHP within css is possible?

Asked

Viewed 321 times

1

I am changing the logo of the Wordpress ligin screen. For this I am using PHP to filter the function by changing the CSS. But since I have several services like this, I need to do it dynamically, that is, use the same code for several websites. Then it’ll stay that way:

function my_f(){
echo '<style type="text/css">
   h1 a{background-image:url( php tem que ser aqui "exemplo: function();" )
   } 
</style>';
}

This is generating a problem, because php is seeing it as string.

  • You might be interested in this: https://wordpress.org/plugins/login-logo/

1 answer

1

There is no way to perform a function you can catch the return of function:

function funcaoDeExemplo() {
    return 'algo aqui.jpg';
}

function my_f(){
echo '<style type="text/css">
   h1 a{background-image:url(' . funcaoDeExemplo() .  ')
   } 
</style>';
}

If what you want to run PHP in the front-end layer is not possible "directly", understand more about front-end and back-end first:

So the interaction depends on other means or change approach completely.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.