<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Steve Taylor &#187; XHTML/CSS</title>
	<atom:link href="http://sltaylor.co.uk/blog/category/xhtml-css/feed/" rel="self" type="application/rss+xml" />
	<link>http://sltaylor.co.uk</link>
	<description>Freelance WordPress developer in London - XHTML, CSS &#38; design</description>
	<lastBuildDate>Wed, 25 Apr 2012 20:43:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Tweaks for WordPress Subscribers</title>
		<link>http://sltaylor.co.uk/blog/wordpress-subscribers/</link>
		<comments>http://sltaylor.co.uk/blog/wordpress-subscribers/#comments</comments>
		<pubDate>Tue, 30 Dec 2008 21:55:43 +0000</pubDate>
		<dc:creator>Steve Taylor</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[XHTML/CSS]]></category>

		<guid isPermaLink="false">http://sltaylor.co.uk/?p=74</guid>
		<description><![CDATA[I&#8217;m currently building a WordPress site where I want people to be able to sign up as Subscribers. They won&#8217;t have the option to write anything to the site, so they won&#8217;t be Authors or Editors&#8212;Subscribers seems appropriate. I&#8217;ve ended up having to tweak WordPress in several ways to make the system work as I [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently building a WordPress site where I want people to be able to sign up as Subscribers. They won&#8217;t have the option to write anything to the site, so they won&#8217;t be Authors or Editors&#8212;Subscribers seems appropriate.</p>
<p>I&#8217;ve ended up having to tweak WordPress in several ways to make the system work as I want. At the moment I&#8217;m erring on the side of coding minor adjustments into my custom themes. Plugins are more flexible, but if you just need to change a small thing, coding it into the theme leaves your site with less overhead from another plugin being loaded.</p>
<p>So, here are a few little plugin-free techniques for tweaking you WP Subscriber system.</p>
<p><span id="more-74"></span></p>
<p>(In all this, remember that <code>functions.php</code> is your friend. It&#8217;s a standard WP theme file that gets included in every request to your site, front- or back-end. It&#8217;s generally used&#8212;of course&#8212;to include custom functions for your theme, but you can also use it just to run code to tweak your installation.)</p>
<h2>Allowing Subscribers to see Private posts and pages</h2>
<p>I want to be able to create pages that are only viewable when Subscribers (or Admins, of course) are logged in. Unfortunately, for some reason the &#8220;Private&#8221; visibility status that you can assign to posts or pages in WordPress excludes Subscribers&#8212;only higher user roles can see Private content.</p>
<p>Installing a full role management plugin is overkill for this, so I trawled around for and eventually found the core functions that allow you to add specific capabilities to a role (check out <a href="http://codex.wordpress.org/Roles_and_Capabilities#Capability_vs._Role_Table">this handy table</a> for a quick overview of roles and capabilities). I popped these lines into <code>functions.php</code>, which seem to do the trick nicely:</p>
<pre name="code" class="php">$subRole = get_role( 'subscriber' );
$subRole-&gt;add_cap( 'read_private_pages' );</pre>
<h2>Redirecting logins to home page</h2>
<p>When Subscribers log in, you don&#8217;t necessarily want them dumped onto the WP dashboard&#8212;with loads of info on the blogging aspect that&#8217;s irrelevant to them. Of course there&#8217;s plugins to do this, but how about a few lines of theme code? <span class="removed_link" title="http://nathany.com/developer/redirecting-wordpress-subscribers/">Nathan Youngman</span> sorted me out with this:</p>
<pre name="code" class="php">function loginRedirect( $redirect_to, $request_redirect_to, $user ) {
	if ( is_a( $user, 'WP_User' ) &#038;&#038; $user-&gt;has_cap( 'edit_posts' ) === false ) {
		return get_bloginfo( 'siteurl' );
	}
	return $redirect_to;
}
add_filter( 'login_redirect', 'loginRedirect', 10, 3 );</pre>
<p>Check Nathan&#8217;s post for a description of the code. Note for now that the <code>edit_posts</code> capability is used as a check for the Subscriber role; all other roles can do this, but Subscribers can&#8217;t.</p>
<h3>What about the logout?</h3>
<p>Good question, glad you asked. I have a bit on my sidebar with links to special Subscriber-only pages, including the profile page (<code>/wp-admin/profile.php</code>). For the logout link, if you want to do it properly, and want to redirect to the home page, use something like this:</p>
<pre name="code" class="php">&lt;a href="&lt;?php echo wp_logout_url( get_bloginfo( 'url' ) ); ?&gt;"&gt;Log out&lt;/a&gt;</pre>
<h2>Customizing the WordPress screens</h2>
<p>How about a little customization of the login screen and the WordPress admin area? A custom logo, at least? Again, plugins can help, but if you want to just slap some code into <code>functions.php</code>&#8230;</p>
<p>Here&#8217;s the code to pull in a CSS file for the login screen. Note that I close then re-open the PHP block to output straight HTML; the code extracts below assume that they&#8217;re extacted from a larger file that begins with <code>&lt;?php</code> and ends with <code>?&gt;</code>.</p>
<pre name="code" class="php">function customLogin() { ?&gt;
	&lt;link media="all" type="text/css" href="&lt;?php bloginfo( 'template_directory' ); ?&gt;/style-login.css" rel="stylesheet"&gt;
&lt;?php }
add_action( 'login_head', 'customLogin' );</pre>
<p>Put <code>style-login.css</code> in your theme directory.</p>
<p>Here&#8217;s the code for adding custom CSS to WordPress itself.</p>
<pre name="code" class="php">function customAdmin() {
	global $user; ?&gt;
	&lt;link media="all" type="text/css" href="&lt;?php bloginfo( 'template_directory' ); ?&gt;/style-admin.css" rel="stylesheet">
&nbsp;&lt;?php
	if ( !current_user_can( 'edit_posts' ) ) { ?&gt;
		&lt;link media="all" type="text/css" href="&lt;?php bloginfo( 'template_directory' ); ?&gt;/style-admin-subscribers.css" rel="stylesheet"&gt;
	&lt;?php }
}
add_action( 'admin_head', 'customAdmin' );</pre>
<p>Again, put the CSS files in your theme directory.</p>
<p>I&#8217;ve included an extra bit in there which adds a subscriber-specific stylesheet (try saying that when you&#8217;ve had a few). Again, the <code>edit_posts</code> capability is used to check to see if the current user is a Subscriber.</p>
<h3>Hiding the Dashboard</h3>
<p>Why include Subscriber-only CSS? There&#8217;s many possibilities, but for now it&#8217;s a quick-and-dirty way of hiding the dashboard from them. You can get rid of the link down the side with this in your <code>style-admin-subscribers.css</code>:</p>
<pre name="code" class="css">ul#adminmenu li#menu-dashboard { display: none !important; }</pre>
<p>What if they manage to navigate there anyway? Try hiding all the boxes:</p>
<pre name="code" class="css">.postbox { display: none !important; }</pre>
<p>Again, these are rather inelegant hacks. But they do the job (so far!), and leave the site a little leaner plugin-wise.</p>
]]></content:encoded>
			<wfw:commentRss>http://sltaylor.co.uk/blog/wordpress-subscribers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS debugging in Internet Explorer</title>
		<link>http://sltaylor.co.uk/blog/css-debugging-in-internet-explorer/</link>
		<comments>http://sltaylor.co.uk/blog/css-debugging-in-internet-explorer/#comments</comments>
		<pubDate>Thu, 11 Oct 2007 21:10:49 +0000</pubDate>
		<dc:creator>Steve Taylor</dc:creator>
				<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[XHTML/CSS]]></category>

		<guid isPermaLink="false">http://sltaylor.co.uk/blog/2007/10/css-debugging-in-internet-explorer/</guid>
		<description><![CDATA[I develop XHTML/CSS primarily in Firefox, followed by testing in tweaks in other browsers. Apart from Firefox being my primary browser anyway, most of the reason for this is that there are some tools for it that have become as essential to me as my text editor (these days, that&#8217;s TopStyle). This handy trio are: [...]]]></description>
			<content:encoded><![CDATA[<p>I develop XHTML/CSS primarily in Firefox, followed by testing in tweaks in other browsers. Apart from Firefox being my primary browser anyway, most of the reason for this is that there are some tools for it that have become as essential to me as my text editor (these days, that&#8217;s <a href="http://www.newsgator.com/Individuals/TopStyle/Default.aspx">TopStyle</a>). This handy trio are:</p>
<ul>
<li><a href="http://www.getfirebug.com/">Firebug</a> &#8211; simply incredible</li>
<li><a href="http://chrispederick.com/work/web-developer/">Web Developer Toolbar</a> &#8211; still very valuable, with some great little features</li>
<li><a href="http://www.iosart.com/firefox/colorzilla/">ColorZilla</a> &#8211; a good colour picker, plus some things that the others do, but slightly quicker to access</li>
</ul>
<p>This is all great. However, more often than not, the times when you <em>really</em> need this sort of stuff is in Internet Explorer &#8211; especially pre-7 versions.</p>
<p>I&#8217;ve not had much luck in IE 6 with the <a href="http://www.getfirebug.com/lite.html">Firebug Lite</a> implementation. I have just come across a good bookmarklet called <a href="http://www.westciv.com/xray/">XRAY</a>. Compared to the Swiss Army Knives above, it&#8217;s very basic, but it provides key information about page elements that can really speed debugging along.</p>
]]></content:encoded>
			<wfw:commentRss>http://sltaylor.co.uk/blog/css-debugging-in-internet-explorer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vertically aligned content and sidebar with CSS</title>
		<link>http://sltaylor.co.uk/blog/vertically-aligned-content-and-sidebar-with-css/</link>
		<comments>http://sltaylor.co.uk/blog/vertically-aligned-content-and-sidebar-with-css/#comments</comments>
		<pubDate>Wed, 20 Jun 2007 20:17:30 +0000</pubDate>
		<dc:creator>Steve Taylor</dc:creator>
				<category><![CDATA[XHTML/CSS]]></category>

		<guid isPermaLink="false">http://sltaylor.co.uk/blog/2007/06/vertically-aligned-content-and-sidebar-with-css/</guid>
		<description><![CDATA[One of the steps backwards taken with CSS is control of vertical stuff. Getting coloured sidebar and content areas to be equal height even when their contents are vertically unequal, and vertically centering something in a box are just two things that are (1) dead easy with tables, (2) quite common design requirements, and (3) [...]]]></description>
			<content:encoded><![CDATA[<p>One of the steps backwards taken with CSS is control of vertical stuff. Getting coloured sidebar and content areas to be equal height even when their contents are vertically unequal, and vertically centering something in a box are just two things that are (1) dead easy with tables, (2) quite common design requirements, and (3) a bit fiddly at best with current CSS standards.</p>
<p>Things may be changing with <a href="http://www.w3.org/TR/css3-layout/">new CSS standards</a>, and with the evolution of various <a href="http://www.student.oulu.fi/~laurirai/www/css/middle/">hacks</a> and <a href="http://www.jakpsatweb.cz/css/css-vertical-center-solution.html">workarounds</a>. Anyway, I just found a solution for a site I&#8217;m working on which seems to work well in this instance. I may have reinvented some wheel or other, but here it is.</p>
<p><span id="more-23"></span></p>
<p>The design involves a content area and sidebar looking a bit like this (scaled down &#038; simplified here!):</p>
<p><img src="http://sltaylor.co.uk/wp-content/uploads/2007/06/css-vertical1.jpg" alt="css-vertical1" title="css-vertical1" width="418" height="210" class="aligncenter size-full wp-image-126" /></p>
<p>My solution is partly based on the common technique of using a vertically repeated background image to delineate the sidebar and content areas. This usually puts the image as the background of the <code>body</code> tag, giving top-to-bottom vertical columns. Here, I need the rounded top and bottom, and there&#8217;s the header and footer (not shown here) to account for, too.</p>
<p>Here&#8217;s the markup for my solution:</p>
<pre name="code" class="xhtml">&lt;div id=&quot;main-top&quot;&gt;&lt;/div&gt;
&lt;div id=&quot;main&quot;&gt;
	&lt;div id=&quot;content&quot;&gt;
		[content here]
	&lt;/div&gt;
	&lt;div id=&quot;sidebar&quot;&gt;
		[sidebar here]
	&lt;/div&gt;
	&lt;div id=&quot;main-bottom&quot;&gt;&lt;/div&gt;
&lt;/div&gt;</pre>
<p><code>main-top</code> and <code>main-bottom</code> take care of the rounded top and bottom, with full-width background images and a fixed height (not forgetting the <a href="http://www.positioniseverything.net/explorer/expandingboxbug.html">Expanding Box</a> and <a href="http://www.mezzoblue.com/archives/2004/09/16/minheight_fi/"><code>min-height</code></a> fixes for good ol&#8217; IE 6).</p>
<p><code>main</code> is given a vertically repeated background image, about 5px high, for the sidebar&#8217;s gradient and the white background for the content. (This design actually has a slight vertical gradient in the content area, too. Setting it as a non-repeating top-aligned background image for <code>content</code>, and giving <code>content</code> a <code>min-height</code> equal to the image&#8217;s height, sorted that out.)</p>
<p>The content and sidebar are floated right (don&#8217;t forget IE&#8217;s <a href="http://www.positioniseverything.net/explorer/doubled-margin.html">double float margin</a> bug!).</p>
<p>The key here is setting <code>main-bottom</code> to <code>clear:both</code> and &#8211; my new (for me) innovation &#8211; placing it <em>inside</em> the <code>div</code> with the class <code>main</code>. It clears the content and sidebar, exposing the repeated background on <code>main</code>.</p>
<p>Hey presto, equal-height content and sidebar.</p>
]]></content:encoded>
			<wfw:commentRss>http://sltaylor.co.uk/blog/vertically-aligned-content-and-sidebar-with-css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google, SEO &amp; CSS image replacement</title>
		<link>http://sltaylor.co.uk/blog/google-seo-css-image-replacement/</link>
		<comments>http://sltaylor.co.uk/blog/google-seo-css-image-replacement/#comments</comments>
		<pubDate>Sat, 09 Jun 2007 12:06:37 +0000</pubDate>
		<dc:creator>Steve Taylor</dc:creator>
				<category><![CDATA[search engines]]></category>
		<category><![CDATA[XHTML/CSS]]></category>

		<guid isPermaLink="false">http://sltaylor.co.uk/blog/2007/06/google-seo-css-image-replacement/</guid>
		<description><![CDATA[I&#8217;ve just been reading about possible clashes between the CSS &#8220;image replacement&#8221; technique that I use and Google&#8217;s rules about spam techniques. Image replacement involves using CSS to hide the text for an element (e.g. a &#60;h1&#62;), and setting the background-image for that element to replace it with an image. Users with visual browsers with [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just been reading about possible clashes between the <a href="http://www.mezzoblue.com/tests/revised-image-replacement/">CSS &#8220;image replacement&#8221; technique</a> that I use and Google&#8217;s rules about spam techniques.</p>
<p>Image replacement involves using CSS to hide the text for an element (e.g. a <code>&lt;h1&gt;</code>), and setting the <code>background-image</code> for that element to replace it with an image. Users with visual browsers with CSS get the image; text-only browsers, bots, etc., just see plain text.</p>
<p>It&#8217;s not without its detractors and slight drawbacks, but it&#8217;s a widespread technique. A quick scan of big-name sites as of writing found it in evidence on <a href="http://www.stopdesign.com/">stopdesign.com</a>, <a href="http://www.mezzoblue.com/">mezzoblue.com</a> and <a href="http://www.adobe.com/">adobe.com</a>.</p>
<p><span id="more-21"></span></p>
<p>However:</p>
<blockquote cite="http://www.google.com/support/webmasters/bin/answer.py?answer=66353"><p>Hiding text or links in your content can cause your site to be perceived as untrustworthy since it presents information to search engines differently than to visitors. (<a href="http://www.google.com/support/webmasters/bin/answer.py?answer=66353">Google Webmaster Help Center</a>)</p></blockquote>
<p>This obviously caused some panic among developers using image replacement. While Google seem to have made some comments saying that they would distinguish between legitimate usage and spamming, they&#8217;re pretty vague about what constitutes one or the other. The ever-informative 456bereastreet.com <a href="http://www.456bereastreet.com/archive/200510/google_seo_and_using_css_to_hide_text/">have a good summary</a>. But while their conclusion is quite reassuring, it&#8217;s two years old &#8211; an aeon in web technology &#8211; and still vague:</p>
<blockquote cite="http://www.456bereastreet.com/archive/200510/google_seo_and_using_css_to_hide_text/"><p>While it&#8217;s good to know that sites are not currently being removed without a manual review, that could change in the future. So I would advise anyone making extensive use of CSS techniques that hide text to make sure that it can&#8217;t be mistaken for spamming.</p></blockquote>
<p>How do you make sure? They don&#8217;t say.</p>
<p>More recently, <span class="removed_link" title="http://www.seocritique.com/sem/seo/css-image-replacement">SEO Critique</span> took the approach of checking out high-profile designers with close links to Google and seeing if they used image replacement:</p>
<blockquote cite="http://www.seocritique.com/sem/seo/css-image-replacement"><p>Rand Fishkin at SEOmoz does use CSS image replacement on the SEOmoz.org site, albeit sparingly. &#8230; I figure that Rand goes to enough conferences and has enough interaction with Googlers like Matt Cutts and Vanessa Fox that if there was a danger of imminent death by penalty he would know and would quickly order the offense removed. Hence, used sparingly and in the strict spirit of If a Blind Person Were Using a Text Reader How Would It Sound? My opinion is that using CSS image replacement is probably okay.</p></blockquote>
<p>Probably not an issue to get panicked about, then, but one to keep your eye on. I&#8217;ll carry on using it judiciously until further notice.</p>
]]></content:encoded>
			<wfw:commentRss>http://sltaylor.co.uk/blog/google-seo-css-image-replacement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IE CSS box height bug</title>
		<link>http://sltaylor.co.uk/blog/ie-css-box-height-bug/</link>
		<comments>http://sltaylor.co.uk/blog/ie-css-box-height-bug/#comments</comments>
		<pubDate>Wed, 25 Apr 2007 20:05:55 +0000</pubDate>
		<dc:creator>Steve Taylor</dc:creator>
				<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[XHTML/CSS]]></category>

		<guid isPermaLink="false">http://sltaylor.co.uk/blog/2007/04/ie-css-box-height-bug/</guid>
		<description><![CDATA[A small but infuriating CSS bug in IE&#8230; No shit. I&#8217;m creating a box with rounded corners around some content using my usual method: Place empty &#60;div&#62;s with ids above and below the content &#60;div&#62; Create background images for the top and bottom of the box &#60;div&#62;s, and put them in (with fixed width and [...]]]></description>
			<content:encoded><![CDATA[<p>A small but infuriating CSS bug in IE&#8230; No shit.</p>
<p>I&#8217;m creating a box with rounded corners around some content using my usual method:</p>
<ul>
<li>Place empty <code>&lt;div&gt;</code>s with <code>id</code>s above and below the content <code>&lt;div&gt;</code></li>
<li>Create background images for the top and bottom of the box <code>&lt;div&gt;</code>s, and put them in (with fixed width and height for the <code>&lt;div&gt;</code>) with CSS</li>
<li>Continue the border along either side of the content <code>&lt;div&gt;</code> with CSS borders</li>
</ul>
<p>All well and good. Only, on IE6/Win, the top <code>&lt;div&gt;</code> wouldn&#8217;t shrink to less than about 16px, leaving a gap of whitespace below the 8px high background image.</p>
<p>After much searching, I found a workaround buried in the life-saving <a href="http://www.positioniseverything.net/explorer/expandingboxbug.html">Explorer Exposed</a> pages. You can read about the ins and outs over there; here you&#8217;re just going to get a nice quick fix.</p>
<p>Put this in the CSS rule for the <code>&lt;div&gt;</code>:</p>
<pre name="code" class="css">overflow: hidden;</pre>
]]></content:encoded>
			<wfw:commentRss>http://sltaylor.co.uk/blog/ie-css-box-height-bug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  sltaylor.co.uk/blog/category/xhtml-css/feed/ ) in 0.32527 seconds, on May 17th, 2012 at 1:34 pm UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on May 17th, 2012 at 2:34 pm UTC -->
