Mostly Harmless

Mostly about my amusement

Archives (page 5 of 97)

Internet Explorer. Oh, the pain. Make it stop.

I like CSS. It’s clean, (mostly) standards based and while not all browsers will agree on goofy features, some basics should just work. CSS3 Flexbox support should be on that list for current versions of browsers.

Guess which browser doesn’t support “flex-direction: column”? Internet Explorer will not be updated by Microsoft for anything except security patches. The CSS works fine in the Edge browser.

In my last post I described how to get CSS to visually crop and center featured images. With Internet Explorer 11 the cropping worked but the image wasn’t vertically centered. The “overflow: hidden” did it’s job but the image displayed from the top and the rest was hidden.

Centering images using javascript

This is not a new problem and I found this article on how to use a little jQuery to make a browser do it’s thing. When it’s one image then you can use the class assigned to it.

I ended up adding this class to each featured image.

mh-thumbnail-<?php the_ID(); ?>;

Then I outputted this script where any featured image was.

<script type="text/javascript">
jQuery(document).ready(function() {

	var imageHeight_<?php the_ID(); ?>,
	wrapperHeight_<?php the_ID(); ?>,
	overlap_<?php the_ID(); ?>,
	container_<?php the_ID(); ?> = jQuery('.mh-thumbnail-<?php the_ID(); ?>');

	function centerImage() {
		imageHeight_<?php the_ID(); ?> = container_<?php the_ID(); ?>.find('img').height();
		wrapperHeight_<?php the_ID(); ?> = container_<?php the_ID(); ?>.height();
		overlap_<?php the_ID(); ?> = (wrapperHeight_<?php the_ID(); ?> - imageHeight_<?php the_ID(); ?>) / 2;
			container_<?php the_ID(); ?>.find('img').css('margin-top', overlap_<?php the_ID(); ?>);
	}

	if( BrowserDetect.browser == 'Explorer' ){
		jQuery(window).on("load resize", centerImage);
	}
});
</script>

That sucks. It’s doable, but I needed to use “the_ID()” because each featured image needed it’s own calculation to center correctly.

I did not want that “jQuery(window).on” to fire for anything except but Internet Explorer. jQuery removed the ability to easily detect the browser and for good reason: you should write scripts based on the browser’s capabilities and not the version or software vendor. My javascript skills are worse than my CSS.

I ended up using this script and I can detect “Explorer” now. Adding a line to my child theme’s functions.php file took care of that.

wp_enqueue_script( 'mh-browserdetect', get_stylesheet_directory_uri() . '/browserdetect.js' );

The end result is that for any current browser the CSS does it’s job. For Internet Explorer the javascript gives it that little push to get it to play nicely. I haven’t tried Internet Explorer 8 but I’m not sure I care to.

Working with version 11 already made me feel like I need a bath.

Center cropping featured images in CSS

I’m lazy and I like to try and figure out how to get the results I want without a lot of work. In the recent past I’ve uploaded featured images that were 1200 pixels wide and varying heights. I’m playing with a child theme of  Twenty Sixteen and wanted to center crop the existing featured images.

I could have re-sampled the cropped images one at a time in Photoshop Elements or ImageMagick (for some CLI bash shell fun). Or I could have used the Regenerate Thumbnails plugin and let that go. Instead I messed with CSS until it worked the way I liked. Read more

Disabling select features in WordPress

One of the new features arriving in WordPress 4.4 will be the ability to embed posts from a self-hosted WordPress blog  into oEmbed consumers such as another WordPress blog. Like this.

Feature Plugin Merge Proposal: oEmbed

Neat huh? I like it, though I haven’t been able to do the same with my own posts yet. This feature will be on by default in 4.4 though it could be disabled via a plugin.

What if you want to disable all the new features?

When a new feature is rolled out, it is enabled by default. That makes sense as no one adopts a feature that is disabled. But new features are not for everyone and you can control that via a plugin.

Why a plugin? Because it’s supportable. It doesn’t need to be a plugin, it could be a simple line of code in your child theme’s functions.php file.

Going in no particular order:

Disable oEmbed provider

This only applies to WordPress 4.4 (not released yet) but install and activate Pascal Birchler’s Disbable oEmbeds plugin. That will eliminate the capability for your site to be an oEmbed provider.

Disable XML-RPC

You could use a plugin but it’s one line of code. Edit your child theme’s functions.php file and add this one line.

add_filter( 'xmlrpc_enabled', '__return_false' );

Done.

Disable emoji support

Install and activate Otto’s Classic Smilies plugin. Otto doesn’t appreciate emojis either and as an added benefit you get back the classic smilies from previous WordPress versions.

Disable Ping-o-matic and other notifications

Install and activate Scott Reilly’s Silent Publish plugin.

From the plugin page:

This plugin gives you the ability to publish a post without triggering pingbacks, trackbacks, or notifying update services.

To make this the default behavior (Silent Publish is off by default) add this one line to your child theme’s functions.php file.

add_filter( 'c2c_silent_publish_default', '__return_true' );

Now when you go to the post editor page, you will see the “Silent publish?” checked on by default.

Disable Google fonts

Some people do not like anything related to Google and that’s fine. While I personally think this makes my WordPress site look awkward, here’s a plugin that does that.

Install and activate Remove Google Fonts References plugin.

Limit login attempts

I use Jetpack for a lot of things and Brute Protect prevents known attack IPs from reaching your site. If you want to limit your login attempts without using that plugin then try this one from BestWebSoft.

I selected that plugin because it’s actively supported by the author and has many options.

Disable Gravatars

Update: I forgot about Gravatars. 😉

There are a couple of ways to do that and the absolute simplest way is use the admin >> Settings >> Discussion and scroll down to the Avatars and uncheck that box. WP beginner has a post with a video on how to do that.

Use the Disabler plugin

Some more settings (including XML-RPC) can be toggled with the Disabler plugin. You can disable the following with a check box.

  • Disable Texturization
  • Disable auto-correction of WordPress capitalization
  • Disable paragraphs (i.e. <p> tags) from being automatically inserted in your posts.
  • Disable self pings (i.e. trackbacks/pings from your own domain).
  • Disable all RSS feeds.
  • Disable XML-RPC.
  • Disable auto-saving of posts.
  • Disable post revisions.
  • Disable WordPress from printing it’s version in your headers (only seen via View Source).
  • Disable WordPress from sending your URL information when checking for updates.

I use this plugin to disable self-pings.

Plugins are not that difficult to maintain

One of the common complaints about WordPress is “Why can’t there be a check box in the admin GUI to disable these features?” A quick count above shows that would be 16 boxes to work with.

Aaron Jorbin had a good reply on the make/core blog but it may not be clear to everyone: giving users too many options makes their site more difficult to support.

Ideally, there would be one plugin for all of this (hint to Mika and the other Disabler authors) but for anyone rolling out WordPress installations, these disabled settings can hard coded into a custom plugin.

Why do it that way? Just like disabling the XML-RPC feature, it’s often just a few lines of code. A custom plugin can accomplish what you want while limiting options in the administration backend.

 

My new Seiko 5 automatic watch

It’s good to have hobbies and lately I’ve been looking into different watches. My old everyday watch is a Citizen Eco-drive. It’s nice enough but it’s a) got roman numerals (why…?), b) the face is really busy and c) has more features than I had any interest in. After a couple of years of use I scratched the heck out of it (the metal, not the glass).

I really wanted a Hamilton field watch. Those are automatic (self-winding) have a 40mm diameter and has a simple face with the date and time. They’re also $350-$700 depending on which model you like. I’m a hobbyist but that’s a little much for me right now.

So I started looking at different brands and came up with this solution. Via Amazon I purchased the following.

  • $54 Seiko 5 SNK803 automatic watch
  • $36 brushed stainless steel push button clasp
  • $18 Honey Oil-Tan Leather Watch Strap

The total was $108 with free shipping. I paid too much for the clasp but I wanted one that matched the brushed steel of the watch itself.

finished-snk803

I like it. The band needs to be broken in but it’s a light, no nonsense watch. it’s not solar powered like my Citizen watch but the old fashioned self-winding appeals to me.

What are the building codes there again?

In China’s Hunan province a glass bottom bridge exists and lets brave tourists walk across. Another one is scheduled for opening and will be the longest glass bottom bridge in the world. I don’t know if I’ll ever visit either but I am sure that if I do I’m not crossing. Here’s how I know.

In 2011 Lily and I took the kids to China. Part of that trip included stopping at Shanghai and we visited the Pearl Tower. The tower is concrete and very orderly, tourists lined up and took a fast elevator to the observation deck. Part of the deck goes around the perimeter and has thick glass panels for the floor.

It’s at least an 800 foot drop. It’s very safe but when you are walking around it and looking down you don’t think about the safety. It didn’t help that the kids worked up their courage and started jumping on the floor panels. That’s not what freaked me out though.

the-girl-skydeck

Making our way around the deck we came across a part that had those bank teller line posts. Except these posts were set at the corners of a new looking and very clean glass floor panel. Instead of a velvet rope, it had yellow plastic tape.

There was YELLOW DO NOT CROSS TAPE TELLING YOU NOT TO STEP ON THAT GLASS FLOOR PANEL.

That freaked me out. I wish I took a photo but instead I grabbed the kids and we went to the inside of the deck where the floor was concrete. The tower is amazing but at that moment I had to find an Internet connection. I really wanted to visit Google in the worst way possible. I had to look something up.

Call now! You can be “licensed” too! While supplies last!

I like the WP Tavern and the people who run it. Recently they did something very cool and implemented a comment policy. I had gotten into a small debate there and do not want to use those comments as my own personal soapbox.

No one should abuse the comments on someone else’s site to take over a post like that. That’s just rude and more than a little inappropriate.

*Pulls out and gets on top of my own personal soapbox*

The following words are defined by me as terms of endearment like so:

  1. Boneheaded – adjective: describing an action that is not smart, possibly foolish.
  2. Boneheadee – noun: someone who does something boneheaded.

I’m writing these things on the off chance someone claims I am besmirching their character. I’m not, I think they went about something in a foolish way.

What is this post about?

Over at The WP Tavern there was a couple of posts about this “thing” where someone did something (really boneheaded) and the expected outcome of settling out of court (remarkably, not so boneheaded) was arrived at.

But one of the points from the boneheadee was that he now has a “license” from the WordPress Foundation to use the word “WordPress” in a subdomain. Yes, I am cherry picking here as I don’t really want to link to a bonehead site. 😉

I now have a license from WordPress to use, even after they stop allowing the use of w-o-r-d-p-r-e-s-s in subdomains .

I get his “I did something amazingly foolish and I now want to save some face” but that statement is just incorrect. The section of that posted online agreement says the following.

c. Consistent with the WPF policy regarding doman names and notwithstanding any other provision in this Agreement, WPF shall not object to Yablon’s use of the WordPress Marks as part of any subdomains or subdirectories associated with any second level domain name registered to and controlled exclusively by Yablon, including for example, wordrpess.answerguy.com or answerguy.com/wordpress, in connection with services that involve use of the WordPress platform and support the WordPress brand services that do not otherwise violate the rights of WPF.

This isn’t new and has been published for years on the WordPress Foundation’s page about trademarks. Anyone can do that without getting sued. Besides, the verbiage above has some conditions. It’s not a statement for that person to do as he sees fit.

Words matter and to say a paragraph that just reaffirms their existing policy isn’t a license. It says that the boneheadee can do what the policy has said for years.

Now IANAL but that doesn’t look like a license to me as much as a statement of “Hey, if you play nice and do as we’ve been saying for a while now, then we’re cool.” The point is that this person feels that the trademark policy will have to be changed in the future.

I don’t think he’s a lawyer either or if he is not a very good one. If a trademark holder can permit use of by someone, why couldn’t they do so to a community? You know, via some policy statement?

The Footer Statement!

When you visit the supposed “licensed” site you’ll see this around the bottom.

We use “wordpress” as a subdomain of Answer Guy Central under license from The WordPress Foundation.

Hey, it’s his site and he can put whatever he likes, even if it’s loose with the facts.

The Plugin!

But this did get me thinking.

Why not come up with a plugin that will check your host name in your site URL settings contains “wordpress” and if so, is it as a subdomain or directory?

If your site was using WordPress (case insensitive) in your home_url() then add to the loop_end() action a nice statement about that.

Yes, using wp_footer() is safer. But when I use that and tested on many themes, including the Twenty Ten through Twenty Sixteen themes, the output was either obscured by a (stage) left sidebar or it put the HTML in places I didn’t really want.

By using this simple code I can put the notice at the end of the main loop.

add_action( 'loop_end' , 'mh_licensed' );
function mh_licensed( $query ) {
   if( $query->is_main_query() ) {
      // Stuff is echo'ed here
   }
}

This introduces HTML where the theme designer didn’t intend but for most themes it works out. It puts right after the end of the loop the text I want.

If you use “WordPress” (it’s case insensitive) in your sub-domain then you’ll get this text and link at the end.

We use “wordpress” in our subdomain in compliance with The WordPress Foundation Trademark Policy.

If your site is using /wordpress/ or some combination in the URL settings then add these words.

We use “wordpress” in our subdirectory name in compliance with The WordPress Foundation Trademark Policy.

But if your site contains WordPress in the domain name such as wordpressneedsme.com or themisguidedwordpresspeople.com then the output this.

We use WordPress as part of out second level domain in direct violation of The WordPress Foundation Trademark Policy. We are horrible people and you only hate us because you do not understand that we are trying to save WordPress. From itself. And people like YOU. We are smarter than you and you do not understand the intricacies of business and trademarks. It is not your fault and we do not want to reveal the details of our Grand and Glorious Scheme™.

*Drinks more coffee*

I may change that last text. I think it comes off as being too humble.

If you’re not using Those Nine Letters™ in your home_url() then nothing will be outputted.

I’ve posted a gist of my plugin code and if you want, download a copy of that code using the “Download ZIP” button.

download-gist-zip

The ZIP name and directory will be goofy but you can install that plugin using your WordPress dashboard.

The code is ugly but it should work for you. And with this plugin you’ll be telling all of your visitors that you’re a good WordPress community member. 😉

Note: The soapbox featured image is by Mark Longair and is being used courtesy of the Attribution-ShareAlike 2.0 Generic (CC BY-SA 2.0) license. Why not visit Mark’s Flickr page and admire his images?

My small Windows 10 review

It was my 240GB SanDisk SSD Plus drive that bit the dust. I’m calling the manufacturer because I got the drive in July.

I’m getting a lot of practice rebuilding my PC. With that drive out I move the 3 TB into the first slot. Once that was done I re-installed Windows 10 and I’m back and running.

If you have Windows 7 and haven’t upgraded yet then you should. On my setup since there was no touch screen it’s defaults to acting and behaving like the previous versions.

There is one new feature I like: built in virtual desktops. If you use that you just click the Task View icon on the task bar and add a new desktop. The only thing I changed was as follows.

In the lower right hand corner is the notification icon, click that and you’ll get to see the “All settings” box. Click that then navigate to System -> Multitasking and change the Virtual Desktop settings from “Only the desktop I’m using”

old-settings

to “All desktops”.

new-settings

That way you can alt-tab through all your programs. When I created multiple desktops and could not see the other running apps in the task bar I did a double take.

Aside from the new look, Windows 10 runs just as well as my old Windows 7 did. It’s a free upgrade and I’m glad that I made the switch.

I was all set to write a small Windows 10 review too

Yesterday I came home and did my usual routine.

  1. Ate dinner (I get home after 7 PM).
  2. Changed and watched some quick TV.
  3. Eventually headed to my PC to check the Interwebz (meaning: play FPS video games, my son wanted to show me something he earned on Steam).

I turned on my monitor and my PC was frozen at the BIOS boot screen. Weird. A quick reboot and I received the following message on my screen.

The SSD you put into this PC less than 2 months ago is about to suffer imminent and permanent death. Please back up all of your data again and press F2 to continue. Press F10 to enter the BIOS.

P.S. You suck.

That may not be the exact wording. You get the idea.

That PC is soon going to turn 6 years old. When this happened with the original drive a couple of months ago I believed it. I leave my PC on all the time and the old HD was slowing down and giving me grief.

Now it seems like there is something screwy with the system itself. Either that or I hit the jackpot and my SSD is dead but I find that unlikely.

I turned off the whole works, unplugged the PC and contemplated running to Best Buy and getting a new one right there. Then Lily got home and a calmer head prevailed. I explained what happened and in between my outbursts she got the idea.

Lily: “Don’t just get one right now. Do some research first and then decide.”

Grownups. They just don’t understand the thrill of instant gratification.

Except for being able to play Windows games, the dead PC isn’t that big a deal. Almost all productive work can be done on my old MacBook Air. I have a separate work laptop so my work from home days are not effected. Still, it’s a major pain and will kill more of my down time.

Oh, Windows 10 is good. Except for changing 2 settings and not having any use for the animated start menu, it really is a sensible upgrade from Windows 7.

That time, and that time and the other time

Hey, remember that time when

  • Reviewing a male IT candidate to hire, in the closed room meeting where someone said “Don’t hire him, he’s about the right age for having a baby”?
  • Or that time in another closed room meeting someone else said “I’m going to remove points from that candidate because he’s a man“?
  • Or that time someone else said “I don’t like his attitude, he’s bossy”?
  • Or that time the women crowded around the one man in the room and talked over him? His idea was eventually the one that solve the problem but a week was wasted because he was a man. You remember that time, right?
  • Or the time a women got in a man’s face at work and started screaming at him because in her native culture men don’t talk to women with authority?
  • Or that time at work when women questioned a man’s sexual preferences behind his back because he was effective and managed his project well?
  • Or that time when an extremely well qualified man with certifications, training and experience came to present his company’s product and all the women did was fawn over his looks? That meeting where the women could not even remember the product name or function?
  • Or my favorite, where a man and all of his work was dismissed with a one syllable word that’s not ever used in polite company? You have to remember that time.

None of that ever happened, you have to replace all the above male references with female.

Once you’ve done that, then you have to realize that it happens all the time. I’ve seen it and I’ve almost always replied with “Stop and take that back. I’m not kidding, you will be reported to HR.” The one time I didn’t was when another two coworkers beat me to the punch.

The amount of bullshit professional women deal with is exhausting to look at. To. Look. At. I can’t imagine what it must be like to live with that nonsense day in and day out.

No actually, I can imagine it. I married the smartest woman I know. I do that weird thing where I like to listen to women and I talk to her all the time.

I’ve heard what it was like for her to be a professional with a) an MBA in International Business, b) a second MBA degree in Advanced Accounting, c) being a CPA and d) many years of experience in corporate america managing a department of 40 people. It wasn’t easy for her ever and the misogynistic nonsense was a constant drag. It was a real and tangible component of every work day.

How different would the world be if the playing field removed that nonsense? What else could women accomplish if they didn’t have to deal with the weight of this crap and microaggression?

*Re reads Lily’s education and experience*

Wow. Did I marry up.

I’m a man in an industry that caters to, coddle and promotes men. I get the benefit of that just by showing up. I’m not diminishing my accomplishments. But I have to acknowledge that another group has to work harder than I do to get to the same place. By default. That’s just stupid and stamping that out has to continue.

This whole post is because I read the comments. I do not think that a few vocal trolls replying in large volume indicates how a community is in reality. But it is the trolls that will cost any group of people members from joining or staying just to avoid that bullshit. That would be the worst and I do not ever want to see that in any community I associate with.