• marketing guy

    (@el-terrible-bmw)


    The problem is that the plugin currently loads both frontend and admin styles all the time.

    There should be 2 individual functions for each stylesheet. The front end stylesheet should hook to wp_enqueue_scripts action and the admin stylesheet to admin_init or similar.

    Otherwise, the frontend styles are applied on admin pages too, like the .date class which messed up the default WordPress columns.

    Here’s an example:

    // register front-end styles
    add_action(‘wp_enqueue_scripts’, ‘front_end_styles’);
    function front_end_styles() {
    wp_enqueue_style(‘gp-css1’,plugin_dir_url( __FILE__ ).”includes/style.css”);
    }

    // register admin styles
    add_action(‘admin_init’, ‘admin_styles’);
    function admin_styles() {
    wp_enqueue_style(‘gp-css’,plugin_dir_url( __FILE__ ).”includes/goldprice_admin.css”);
    }

    https://wordpress.org/plugins/gold-price/

  • The topic ‘Styles are not loaded properly’ is closed to new replies.