Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to I edit the CSS?

Viewing 10 replies - 1 through 10 (of 10 total)
  • Avatar of Tosh
    Tosh
    Participant

    @xberserker

    The CSS is at the bottom of the cubepointsBP.php file.

    Avatar of Hugo
    Hugo
    Moderator

    @hnla

    When there’s a moment it ought to be enqued really rather than added to wp_head as embedded, minor point but keeps things neater and less code to clutter up the head, also it won’t be cached by the browser as embedded.

    Avatar of Tosh
    Tosh
    Participant

    @xberserker

    How would I go about doing that?

    Avatar of thekmen
    thekmen
    Participant

    @thekmen

    @xberserker I have it done in the version with the points page, will def get it over to you tom.

    Avatar of Hugo
    Hugo
    Moderator

    @hnla

    It’s very straightforward, but it occurs the way I’ve used it is probably very pared down so better to study a more thorough implementation so I’m sure Boone won’t mind his being shown as an example :)


    function invite_anyone_add_by_email_css() {
    global $bp;

    if ( $bp->current_component == BP_INVITE_ANYONE_SLUG ) {
    $style_url = WP_PLUGIN_URL . '/invite-anyone/by-email/by-email-css.css';
    $style_file = WP_PLUGIN_DIR . '/invite-anyone/by-email/by-email-css.css';
    if (file_exists($style_file)) {
    wp_register_style('invite-anyone-by-email-style', $style_url);
    wp_enqueue_style('invite-anyone-by-email-style');
    }
    }
    }
    add_action( 'wp_print_styles', 'invite_anyone_add_by_email_css' );


    Clearly you need to place your styles in a stylesheet file, then not sure if you really need to do the check for current_component but otherwise it’s simply finding the paths and if file_exists register it and enque it finally adding the action.

    Avatar of r-a-y
    r-a-y
    Moderator

    @r-a-y

    I’m actually a fan of embedded styles (if it isn’t too many lines that is!)… ‘nix one server request. Although, you could follow Boone’s $bp->current_component code though so that the CSS only prints on certain pages.

    Avatar of Tosh
    Tosh
    Participant

    @xberserker

    The css is minimal, under 20 lines. 17 really. Had some extra in there just commented out for testing. But I’ll remove that on the next version.

    @thekmen Looking forward to it.

    Avatar of Hugo
    Hugo
    Moderator

    @hnla

    @r-a-y really the issue is not with one particular plugin but with the overall notion of plugin authorship. if it isn’t too many lines that is ; minimal, under 20 lines Yes but this is not under your control? By and large a satisfactory implementation of WP or WP/BP will end up relying on a fair number of plugins, if all these plugin authors simply opted for the easiest? (that’s not meant unkindly!) approach a page could end up with line after line of css cluttering the head of a given page, of various pages even; regardless of taking into account that it’s technically faster to parse embedded styles than download and parse external ones too many of them and things slow down.

    The nix one server request Ok but now you have embedded styles appearing across many pages and repeated styles requiring to be parsed each time, I would rather the extra one time call to the server to enable caching of those styles.

    Basic rule of thumb for calling styles is Embedded are used where one is creating a test case and it is more appropriate that ALL necessary document elements are contained within the page; where a page requires to be portable i.e might be rendered locally and to retain the necessary styling the rules are embedded within the document or where one is working on the initial framework and it proves faster and easier to create styles within the same file rather than have to tab constantly to a separate file but where those styles are cut out and moved to an external file when that development phase is finished. External styles are always the preference for general sites due to caching requirements and ease of updating sitewide (granted that with dynamic inclusion updating sitewide is not necessarily an issue)

    It’s all slightly the splitting of hairs though :)

    Avatar of r-a-y
    r-a-y
    Moderator

    @r-a-y

    You’re correct, but you also have no control if you use an external stylesheet for the plugin.

    Could follow the approach of Lester Chan’s WP Page Navi plugin. It checks your theme’s directory to see if a stylesheet for PageNavi exists; if it doesn’t, it uses the stylesheet bundled with the plugin.

    Or if you’re sticking with inline CSS, you could apply a filter so theme designers can override it.

    re: hooking into the [head] – You could take the opposite side of your argument. A lot of sites use WP plugins. If you use twenty plugins that need to hook into the [head], you’ll have twenty server requests. Unless you use some type of concatenation from the server-side or by using a plugin like this (I should note I haven’t used this plugin! lol).

    You’re right though; it is a matter of splitting hairs! ;)

    Avatar of Hugo
    Hugo
    Moderator

    @hnla

    Ah hadn’t come across that pluging before wp-minify

    Yes I like the approach Lester Chan takes.

    To some extent there is still room for improvement in this area, devolving better control in some manner – I see glimpses of how when working but never get a chance to formulate my thoughts.

    One thing is true though at this stage there isn’t sufficient ease of overridding various aspects if you are truly theming, but it will come in time I guess.

Viewing 10 replies - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.