The Plugin Generated xxx Characters of Unexpected Output During Activation


While developing a custom WordPress plugin I saw this error when activating it. 

The Plugin Generated xxx Characters of Unexpected Output During Activation

I did a little Googling and found that there are a few most common causes:

  1. A white space before or after the PHP opening or closing tags
  2. A file encoded in UTF-8
  3. Another issue when something is called at the wrong time, or a call that cannot be resolved without intervention
  4. Using the WordPress add_option function. Switching to update_option instead can resolve the problem.

In my case it was #1 that blew it up for me.  Who woulda thunk a blank line would be so horrible?  

Anyway, hope this helps someone down the road who is pulling their hair out like I was.

HTTP / HTTPS fix for WordPress

So, one of those pesky LaneCC blog network users had a problem with a syndicated blog post that included an iframe embedded YouTube video losing the HTTPS today.  I looked into it and found an additional filter to add to the plugin, so we’re up to v1.1.  Woo Hoo!  Anyway, you can still get it on GIT.

If you have a WordPress website hosted on a secure server (HTTPS) and you try to put a YouTube video in a post or page, the video stopped showing up about 3 months ago.  This is because web browsers started to recognize that showing non-secure content (HTTP) on a secure web page makes the secure web page not secure anymore.  It used to be that you would just get a little warning in your browser saying that a page had mixed content and you could continue on at your own risk.  Apparently that wasn’t good enough, so the browsers just started blocking the non-secure content.  Bummer.

HttpsIn my day job at Lane Community College, one of my duties is to manage a blog network built around WordPress MU.  Luckily I’m just the guy that handles updates and things like that.  Some other guy has to field the several hundred potentially irritated people that can’t get videos to show up on their blogs.

So, here’s the tech version of what happened.  WordPress uses something called OEMBEDs.  This allows you to simply copy and paste the URL of a video on the YouTube website into a WordPress page or post and have that video show up.  Rather than having to use shortcodes, or plugins, or some other intermediate step, you just use the address of the movie.  Pretty slick, when it works.  As I mentioned above, it breaks when you’re on a secure server though.  What happens is that WordPress, as of about v3.6, looks at the OEMBED for YouTube and recognizes of you’re trying to embed an HTTPS link.  Then it sends a request to YouTube with the address of the video.  What breaks is when YouTube sends the video back it uses HTTP, even though you requested it using HTTPS.  Stupid.  

So, after that long, but very informative explanation, here’s the fix.  You simply install a plugin that adds a filter to WordPress.  When it sees something coming in with an HTTP address, it rewrites it as HTTPS.  Kind of a brute force way of dealing with a silly problem, but it’s working.

The plugin I wrote isn’t available on, but you can get it here on GIT.  


Sessions in custom WordPress applications

old-wordpressSo, I spent a couple hours trying to figure out why I suddenly couldn’t pass variables page to page in a custom WordPress application using $_SESSION.  Turns out that in one of the major releases in the last year or so they did something that kills $_SESSION variables.  Not sure how or why, but doing a Google search hinted at that.  

Quick fix though.  Like most things with WordPress, there’s a plugin for that.  I installed Simple Session Support and it took care of the problem.  I’m sure it does a bunch of stuff in the background, but, basically, you can now use $_SESSION variables again just like the old days.  Nothing to configure.  It just works.

Hopefully this saves someone the couple hours it took me to figure it out.

Require Login For Single WordPress Page

By default, anyone who comes to your WordPress website can see any page on that website.  What if you want your website to be open to everyone, except you really need to have a page or two that only registered, logged in users see?  Example?  A company intranet, a calendar that’s only for family or a contact info page that’s only for family.  Whatever the reason, there are only a few ways to make sure a page isn’t open to the world.

Make the page private

You know what I mean.  When you’re editing your page you look over on the right side just above the Publish/Save button an see a “Visibility” option.  You can make that private and the page is hidden from the public, but it’s also hidden from all other registered users.  When set to private a page also doesn’t show up in the main menus or anywhere else.  It’s basically hidden from everyone from the one who made it private.

Password protect the page

Under that same “Visibility” section you can also choose “Password protected”.  This is good.  The page shows up in the menus and all that, but this option asks for a password for this particular page.  Basically, you set a password for this page and then you have to share that password with anyone you want have access to the page.  That’s not quite what I’m after.

Create a new page template

So, to recap, I wanted a page that shows up in the menus just like any other page but whose content can only be seen by users who have an account on the website and have logged in.  For all others, I want the page content hidden.  Here’s what I came up with because I couldn’t find a plugin that accomplished this without annoying upgrade messages or adding a lot of bloat for no reason.

  1. Create a new page template by making a copy of your theme’s existing page.php template.  I named mine “page_logged_in.php”.
  2. Once you have your page you need to edit the file in whatever editor you like.  I use Dreamweaver, but any text editor will work just as well.  The first bit of code you need to add names the template so you can find it later.  (This is what you’ll select in the WordPress admin when creating your new page.)  Just add the following code to the very top of the code.  There will most likely be something similar already there.  If so, just replace it.
  3. Now you need to add a little code to see if the user is logged in.  This is pretty easy.  WordPress has hooks built in for this.  The following can be added directly below the Template Name code above, also at the top of the page before any of the standard WordPress stuff.


  4. Now, go to the very bottom of the page and add the following code.  This will call wp_die() to halt WordPress and display a notice to the visitor saying they need to log in to view the page.

     This little snippet does a couple things.  If it runs (if the user isn’t logged in) then it halts the page and displays a message that says “To view this page you must first log in.”  The words “log in” are a link created by wp_login_url() which is another WordPress hook.  You may notice get_permalink() embedded in wp_login_url().  What this does is gets the address of the page you’re on so that when the user clicks the link to log in, they come back to your password protected page once they log in.  You can forward them pretty much anywhere you want, but I like to bring people back to where they started to minimize confusion.


    Now just save the page template and upload it to your web server where your template files are.  Hopefully you simply duplicated page.php where it already lived, so this is a no brainer.

  6. Next, go to WordPress and create a new page.  Under “Page template”, select the new page template we just created.

  7. Save your new page and that’s all there is to it. That page will now appear just like any other page in your menus, but when a user who is not logged in tries to visit it, they will receive the notice you included above.

Hope this helps.  I looked for a way to do this for about a half a day.  This seems to be a simply way to go about it.


Create Calendar .ICS files with PHP

On a project I was working on recently it would have been cool if we could dynamically create an ICS file so people could download and import events into their calendars.  I did some looking and found several “scripts” that all claimed to do the trick, but none worked quite right.  I kind of pieced them together and came up with this.

 Lets look at a few things.  The header section tells your browser that we’re making an ICS file and it shouldn’t try to display it.  In fact, it should bring up a download dialogue so you can save it to your computer.

The next section sets up the file as a Microsoft Outlook file.  Seems like, without that, there are issues when you go to import it.  Like your calendar needs to know the file is formatted for Outlook.

The biggest section outputs the actual data that shows up in the event.  In my application I put this section in a loop to create the events list.  The $created variable is simply a date.  I used a PHP date function to create the variable.  The rest is pretty well documented.  Oh, and $random_number is really just a random number.  No secret here.

The next section sets up how reminders for the events happen.  You can edit the text as well.

The last section should be left alone.  It’s just closing out the opening tags above.

Not a great explanation of how it works, but you should be able to copy and paste the code and make it work for you.  Hopefully it helps if you need it.

Create DB Table from .SQL (dump) file

Not a really complex thing, but something that comes in handy if you’re moving data around and need to quickly create MySQL db tables through PHP.



 Pretty simple to use.  Just place the function at the top of your page (or at least somewhere higher up the file than when you call it) and give it the name (path included) to the .sql file. 

Something like:


Creates tables with or without data.  Simply takes whatever kind of sql dump you give it and re-creates the database or table it came from.


Section 508 (Website Accessibility)

Section 508Working with Lane Community College I have to make sure my work conforms to Section 508.  Very big deal for education, and anyone who wants their website available to the widest possible market, really.  It used to be that blind folks and people with certain disabilities were just kind of ignored as far as the web goes.  That’s not the case anymore.  Screen readers have come a long way.  Just for fun I used the accessibility functions on my iPad last week.  It’s pretty amazing just how clear of a picture you can get of a web page without your eyes assuming all the proper “stuff” has been done.  Doing the audit on the DQP website really opened my eyes (no pun intended). 

Officially the law only requires government agency web sites to be accessible, but, if you have a web site, why would you not want those who need assistive technology to be able to use your website.  Even if the only thing on your website is your name, phone number and address, you still want the blind guy across town to spend money at your place of business, right?  Imagine if all your competitors don’t have the forethought to do the work on their website and yours is the only one the aforementioned blind guy across town can read…

Anyway, here’s some official stuff about Section 508.

In 1998, Congress amended the Rehabilitation Act of 1973 to require Federal agencies to make their electronic and information technology (EIT) accessible to people with disabilities. Inaccessible technology interferes with an ability to obtain and use information quickly and easily. Section 508 was enacted to eliminate barriers in information technology, open new opportunities for people with disabilities, and encourage development of technologies that will help achieve these goals. The law applies to all Federal agencies when they develop, procure, maintain, or use electronic and information technology. Under Section 508 (29 U.S.C. ‘794 d), agencies must give disabled employees and members of the public access to information that is comparable to access available to others. It is recommended that you review the laws and regulations listed below to further your understanding about Section 508 and how you can support implementation.

Section 508 of the Rehabilitation Act (29 U.S.C. ‘794 d), as amended by the Workforce Investment Act of 1998 (P.L. 105 – 220), August 7, 1998

(original source in

If you would like an audit done on your website, and a quote on making sure those with disabilities can use it, shoot me an email.  I’m happy to spend a little time.

Google ChromeFrame

In my new day job, I came across a problem today that I had never seen.  The application I’m working on requires an inordinate amount of JavaScript (in the form of jQuery).  Basically I’m display large amounts of data from a database in a graphical form using jQuery Spidergraphs.  The problem I ran into is that large institutions, such as LCC, are still using Internet Explorer 8 on Windows XP machines because of other software limitations.  The particular jQuery that I’m using needs the <canvas> HTML5 tag in order to display the data, and IE8 doesn’t even know what the <canvas> tag is about.  

After a couple hours of beating my head against the wall and trying different DOCTYPE declarations, I finally figured out that it was in fact the lack of <canvas> that was my problem.  A co-working pointed me to ChromeFrame.  This nifty little script looks at the browser that’s loading a page and, if it’s IE that doesn’t support <canvas> (and other things) it throws up a warning and offers to install a little utility to help you out.  Once you say ok, everything works just like it’s supposed to.  Pretty good time saver.  Not sure why everyone doesn’t just install it.


DQP (The Degree Qualifications Profile)

The DQP Project in Oregon is a joint effort of all seven Oregon University System (OUS) institutions and the state’s seventeen independent community colleges to develop the Degree Qualifications Profile for Oregon. The DQP Project in Oregon will provide a descriptive curricular framework for describing institutions’ degree outcomes across the state, both in their unique characters and in their shared aspects. The project relates directly to the missions of each institution to support their students’ success during college, upon graduation, and in transitions within the Oregon educational system. This statewide partnership of educational institutions has the active support from both the Oregon University System (OUS) Chancellor and the Oregon Community Colleges and Workforce Development (CCWD) Commissioner.”

Now that we have the “official explanation”, here’s why I’m talking about it.  I have been hired for the duration of the DQP grant to act as DQP Web Applications Developer working on-site at Lane Community College.  The project is pretty cool.  Lots of technology and lots of awesome people in the IT department at Lane.  

I started full time with them early in December 2012 and will be there until sometime mid-2015 working on this and other related projects.  The DQP is my core responsibility, so that’s what I’ll talk about here.  I’m going to break it up by section though.  Otherwise this would be one really long post.  

The website itself is set up so that member institutions have one place to go to get and store information on the DQP program.  There is a public side (with public data for everyone to see) and a secure side (where the institutions go to input data that feeds the public side).  


The design of the site is pretty basic.  Logo, mega-menu, breadcrumbs, custom PHP stuff, footer menu…  The entire site layout is CSS with tables being used ONLY for tabular data.  Just the way it’s supposed to be.  I took a lot of time to make sure it loads properly in recent browsers (back to IE 8) and loads quickly considering how much “stuff” is going on behind the scenes.  

Stay tuned for posts about specific areas of the website.  It’s pretty cool stuff.  

If you want, you can check out the DQP at

Brent Gunter (Musician)

Brent is a musician from the Portland area.  He spends a big chunk of the year traveling around doing concerts and needed a way to sell tickets on his website.  He already had the website, but had no idea how to integrate PayPal and a shopping cart.  He called me and I took care of him.  Not a huge project, but it was a pleasure listening to his CD while I worked.

Brent Gunter - E-Commerce and Contact List Integration

He also had an email list he needed to be able to manage through his website.  Pretty easy stuff these days, but it used to require some javascript editing to get those list managers to look like your site.  I think it came out really well.