Style highlighted / selected text - CSS Tutorial

Date: 26th October 2008 at 12:56 pm | Filed under: scripts | Author: Sam Burdge

Ever wondered how to change the default style of highlighted or selected text in your html page? I have found that this is possible using CSS3, although IE has no support for this so it doesn't work at all in IE.

In this example the background is set to green and the text set to white. Drag over this text to highlight it.

Here's the CSS:

/* Safari */
::selection {
background: #000000;
color: #ffffff;
}
/* Firefox */
::-moz-selection {
background: #000000;
color: #ffffff;
}

::selection is supported by the latest versions of Opera and Firefox 2 and upwards. ::-moz-selection is supported by the latest versions of Safari.

Leave a Comment

WordPress - Change Default Email Address Plugin

Date: 20th February 2008 at 12:04 am | Filed under: development, plugins, wordpress | Author: Sam Burdge

This WordPress plugin changes the default email address that all notifications sent from your blog are addressed from. The default address for all emails sent by your blog is currently wordpress@ yoursite.com.

I had seen some tutorials / forum entries previously where people suggested editing the core WordPress file 'pluggable.php' to overide this default. This method does work, however you would have to repeat the hack every time you upgrade to a new version of WordPress so it is not an ideal solution.

Faced with this problem for a site I was working on recently, I wrote this basic plugin which allows you to configure your own email address in the format: Your Name <yourname@yoursite.com>.

Installation:

  1. Upload the file wp_change_default_email.php to your wp-content/plugins folder
  2. Activate the plugin from the Plugins page in WordPress

Usage:

  1. In the Plugins page in WordPress click the edit button next to the plugin in the list.
  2. Scroll down until you see a note saying 'Configure it'
  3. Enter your name and email as shown
  4. If you don't enter a new address the default 'wordpress@' will remain

Download:


5 Responses to “WordPress - Change Default Email Address Plugin”

  • Comment by Shane
    Date: February 29th, 2008 at 8:33 am

    Works great - thank you!

  • Comment by Change Default Email Address » Wordpress Plugins
    Date: July 9th, 2008 at 6:56 am

    [...] Version: 0.1 - License: n/a - Author: Sam Burge - Plugin Page - » Download [...]

  • Comment by Shane
    Date: August 25th, 2008 at 10:27 pm

    Is there a newer version than 0.1? I upgraded to WordPress 2.6.1 and the Plugins area is telling me that there is a new version, but the new version links to:
    GALLERY LIGHTBOX PLUGIN
    http://wordpress.org/extend/plugins/wp-25-gallery-lightbox-plugin/

    Also, just an FYI, version 0.1 now conflicts with the Subscribe2 plugin.

  • Comment by Greg
    Date: September 17th, 2008 at 8:06 pm

    Very handy little plug-in, works like a charm, thanks.

    I’m experiencing a little weirdness, though. I downloaded it from your site. When I install it, it works fine but I get an alert telling me there’s a new version 1.3 (the code says “Version 0.1″) and the link to get the new version points at http://wordpress.org/extend/plugins/wp-25-gallery-lightbox-plugin/ which is clearly wrong. The “Upgrade automatically” option doesn’t work either, with the error mentioning wp-25-gallery.

    Since it works, the only reason I care is I don’t want the little orange flag over “Plugins” in my dashboard, but seems like something you’d want to know.

  • Comment by huski
    Date: October 23rd, 2008 at 10:19 am

    wordpress 2.5
    not working for me, i made the two changes , name and email to the php file, verified the changes were saved in the php file, but it continues to send wordpress and wordpress@domain

    ????

Leave a Comment

Removing defualt borders from links in Firefox (CSS)

Date: 14th January 2008 at 6:13 pm | Filed under: development, scripts | Author: Sam Burdge

One of Firefox's default styles is to put a dotted line border around active links. For many sites this is not an issue, and can even be helpful to the user, making it clear when they have clicked on a link. However, with some sites, especially when using images as links in the nav, it can look really ugly. To get rid of the dotted borders use the following CSS:

a:active, a:focus {outline: 0;}

3 Responses to “Removing defualt borders from links in Firefox (CSS)”

Leave a Comment

wordpress post navigation hacks

Date: 24th October 2007 at 2:34 pm | Filed under: development, scripts, wordpress | Author: Sam Burdge

This article covers using the global parameter $paged and the query $wp_query->max_num_pages; to create custom navigation links for previous and next posts. For some reason wordpress treats posts in the past as "next" and posts in the future as "previous" as explained in this exerpt from the WordPress website:
Read on…

2 Responses to “wordpress post navigation hacks”

  • Comment by gus
    Date: October 30th, 2008 at 1:18 pm

    Thanks for this interesting technique. I finally realized, though, that this works only for “paged” templates, like the index and categories and tag pages. Can you suggest a technique to use on single-post templates?

    I understand that some of this functionality is built in to the next_post_link and previous_post_link tags already, but it is still difficult to make one of them go away if you are using them with nested divs or other complicated bits of CSS — because you don’t have direct access to the anchor tag. Any suggestions for crafting an equivalent “if” statement that will make the previous or next link not show when not needed on a single-post page?

    Also, how much of a performance hit will the $wp_query call cause in the above code?

  • Comment by Sam Burdge
    Date: October 30th, 2008 at 11:34 pm

    Hi Gus

    With the next_post_link / previous_post_link functions you should use the ‘format’ parameter to keep your divs from displaying when the link is not needed. For example:


    <div id="post_nav">
    < ?php next_post_link('%link', 'Next Post'); ?>
    </div>

    will still display the div. While:


    < ?php
    $post_link_format='<div id="post_nav">%link</div>’;
    next_post_link($post_link_format, ‘Next Post’); ?>

    would only show the div when the link is needed.

Leave a Comment