I've looked through the answers on here and none quite match my situation. I have custom CSS that a user can edit and it is saved in the options. I use wp_enqueue_style
to include a PHP file with a CSS content header and then load the CSS from the options. However, in order to load from the options I must include wp-load.php. I know this isn't the best way of doing things. How exactly should I achieve this instead?
Plugin main file:
add_action('wp_print_styles', 'wp123_load_css');
function wp123_load_css()
{
wp_register_style('wp123-custom-css', plugins_url('/include/wp-123-style.php', __FILE__));
wp_enqueue_style('wp123-custom-css');
}
wp-123-style.php:
<?php
header('Content-type: text/css');
require_once('../../../../wp-load.php');
$options = get_option('wp123_options');
?>
<?php echo $options['custom_css']; ?>
What is the correct way of outputting the CSS file without having to include wp-load.php? Any help and suggestions are much appreciated!