All posts by Matt Danskine

25Sep/17

Disabling Form Fields

I have an app I’m working on where the admins want to be able to disable certain form fields so they can’t be updated if your’e not an admin.  In other words, if you are a user updating your information, you can change xx and xxx fields, but not x or xxxx.  I figured, no problem, just add “disabled=’disabled'” to the fields you don’t want users updating if you’re not logged in as an admin.  

The problem…
When you add “disabled=’disabled'” to a form field, that form field doesn’t submit any data via _POST or _GET.  This translates to your app updating the fields with nothing,  effectively deleting the information in the database.  

The solution…
Instead of “disabled=’disabled'”, use “readonly=’readonly'”.  

The second problem…
“readonly=’readonly'” only works on <input> tags.  You can’t readonly a <select>.

The final solution…
I found this on Stack Overflow.  I’m not crazy about the solution because it simply creates a second variable of the same name.  This seems sloppy to me because, as the author admits, different web servers might deal with it differently.  I prefer to write code that is going to work everywhere.  

My solution was to change the form fields I didn’t want edited by anyone who isn’t an admin to unnamed <input>s with the “readonly=’readonly'” attribute set, then create a hidden form field with the proper name and the proper value that would take the place of the select field that couldn’t be made read only.

Hopefully that makes sense.  It means adding a bunch of code, but it’s going to work on any PHP script because it’s going to change what gets displayed depending on your user level.  If you’re an admin, you’ll see the <select> field with all the options.  If you’re not an admin, you’ll see a grayed out <input> that you can’t change, but you still see what is in the database.

29Jul/17

Single Property Websites

I received an email from a real estate client a couple weeks ago asking about a website for a single property she has listed for sale.  Single property websites used to be labor intensive and difficult to make right.  With WordPress, all things become easier.  I was able to give her a well designed, nicely laid out and fully responsive website for next to nothing in a very short timeline.  Probably not something you would want to do for every listing, but for those higher dollar listings, it’s a great way to make the seller feel like you’re doing everything you can to market their home!

Don’t be shy if you would like to talk about doing one, or even having me set you up to be able to do an unlimited number of single property sites.  It doesn’t have to cost a lot.

You can reach me at matt@fotan.net

Here’s what this one looks like…  You can also see the site at 796bellwoodln.com

26Jul/17

City of Winston, Oregon

The city had me create a website for them about a million years ago when 800×600 screens were HUGE!  It was about time for an update, so I gave them a WordPress site that allows them to manage all their own “stuff”.  Like:

  • Special Announcements
  • Minutes of public meetings (Gigabytes worth of MP3 and PDF files)
  • Playing of above streamed from the website
  • A document management system for PDFs like budget documents, business forms and city ordinances.  Having these saved as PDFs and managed through a document management system makes sure that the latest versions of these documents are always available.

Being WordPress, they also have the ability to adjust colors, add/edit/remove pages, use the blog to display things in a chronological order and keep them available forever.

This was a fun website conversion.  If you would like to talk about converting your website to WordPress, let me know.  I’m always happy to help.

16Jun/17

Lane Titans Custom WordPress Child Theme

At the day job I was tasked with creating a WordPress child theme for the college sports teams.  Since I’m a Bootstrap kind of guy, and Lane has standardized on Bootstrap as a framework, I found a pretty basic theme that uses Bootstrap for its core and proceeded to modify the stuff that didn’t look right.  The results are quite good and saved the college $5000/year over the framework most of the rest of the college sports teams use.  Good day for me.  I like paying my way.  

Features Include

  • Totally custom design.
  • Full Customizer integration.  (Customizer is the WordPress admin interface for dealing with design aspects of your theme and website.)
  • Ability to change the logo (Titan Athletics) through the Customizer.
  • Ability to change the tagline in the top gold bar (OFFICIAL ATHLETICS WEBSITE…) through the Customizer.
  • Ability to change the semi-opaque background image (behind the slideshow on the home page) through the Customizer.
  • Mega-menu integrated through the stock WordPress menu system so you can change all aspects of the menu structure and design without having to call the web guy.
  • Ability to change the page background color through the Customizer.
  • Upcoming Events automated through a SPUD from 25-Live, the scheduling system the college uses.
  • Full responsive embeds, like YouTube and Vimeo videos as well as images.  (This is mostly stock WordPress behavior, but it needed a little help.)
  • Off the shelf plugins were used for things like OUR VALUED PARTNERS so they can list sponsors. 
  • Team Rosters are also through an off the shelf plugin, but it allows you to totally customize the fields as well as the templates used for outputting the single player bio pages and the tabled rosters used on the team pages.
  • A footer menu built with Bootstrap’s standard navbar code, but using a WordPress menu as its source.  Easy for the end user to change what shows up in the footer through the Customizer.
  • Custom recruiting forms for each sport.
  • Accessible design that complies with government regulations for use with screen readers.  This is ongoing, but, on launch, will be fully compliant.  (Just in case you go to the site and test me on it and it’s not quite there yet…)
  • And, of course, the site is fully responsive so it’s going to look great on a phone, a tablet or a computer.  

Development Server Link:  https://vader.lanecc.edu/lanetitans/

Production Site Link: http://lanetitans.com (Will look very different until the final site is launched…)

16Sep/15

WordPress Dashboard look funny?

Recently (September 2015), when I’m in Dashboard, the left side menu does odd things when you scroll.  Specifically, text links will move around and stack on top of each other.  Not really a big deal, but pretty annoying when you’re trying to write posts, or edit pages, right?

It looks like it’s a known issue with Google Chrome v45.  Luckily, there’s an easy fix.

  1. Go to chrome://flags/#disable-slimming-paint (Just copy/paste it into Chrome’s address bar.)
  2. Enable the “Disable slimming paint” option. (Should be the top entry on the page that comes up. See image below.)
  3. Enable the “Enable slimming paint” option. (Should be the second entry on the page that comes up. See image below.)
  4. Relaunch Chrome. (Using the big button at the bottom of the page.)

 

Screen Shot 2015-09-16 at 12.35.50 PM

Once you relaunch Chrome, it should look right again.

Hope this helps.  I actually found the fix here… https://wordpress.org/support/topic/admin-sidebar-is-all-messed-up

It looks like there is also a plugin on Github that adds some CSS to WordPress to fix the problem, but I have about 50 WordPress websites to manage, so fixing Chrome sounded like a much better idea.

25Aug/15

Portfolio Ketchup (or is that Catch Up?)

I’ve been horrible about adding new projects to my portfolio for, I don’t know, maybe 2 years?  There’s no end in sight to being too busy to get it all updated, so I’m going to do one monster post with a ton of sites and very minimal descriptions.  Then, I’ll try to be better about adding them as I finish them.  So, here we go…

Melrose Elementary School

Melrose Elementary

This is the school where my kids actually outgrew going to school about 4 years ago now.  This was kind of a fun one.  Lots of good content for the parents and a fun little theme that’s kid friendly.  Much of the work I did on it ended up being copied by the district webmaster and used on the district website.  Sort of a compliment, I guess…


Phoenix School

Phoenix School

This is a high school in Roseburg, Oregon for kids who have had trouble in a standard public school.  I was approached by one of the administration (Sorry, I can’t actually remember which one) to put together a theme based on their school mascot.  Came out pretty good.  Not sure if they ever actually used it, but it was a fun one to work on.


 

South Umpqua Real Estate

South Umpqua Land Company

South Umpqua Real Estate was one of those clients who call you, set up a meeting, hire you, write you a deposit check, bug you for the initial design, then fall off the face of the Earth.  l honestly have no clue what happened.  I called and emailed them, but never got a reply after they told me how much they loved the design.


 

Gloria Loupy – Realtor

Gloria Loupy

Gloria Loupy was a realtor who worked for a pretty big regional brokerage. In the middle of development, she suddenly jumped ship and went to a different company.  The site was basically finished, but she never got to use it.  Bummer, really.  It’s a pretty nice, simple design.


 

Gorden Hanks – Realtor

Gorden Hanks

Gorden is a buddy who needed a website. I did this for him late one night after a few too many beers. We never used it, but I always liked it.


BSA Pack 235

BSA Pack 235

Ok, I’m a little guilty on this one.  It was my kids’ Cub Scout Pack.  And I was the Cub Master.  I still think I did a pretty nice job on it though.  


 

Ok.  That’s enough for this post.  I guess I’ll do a bunch kind of like this.  That way I don’t spend the whole weekend on this little catch up project.

19Aug/15

Forms with Multiple Checkbox Arrays

When I’m making web forms I can never remember exactly how to set “stuff” up.  I’m thinking I’m probably not the only one with this leaky brain problem.  Anyway, I was setting up a pretty large form today and had to create a group of check boxes.  When you’re doing a checkbox group and actually need to be able to see all of the checkboxes that were checked so you can save the info to a database, you have to jump through a couple hoops. First of all, here’s what you get when you do a search for “checkbox group html” in Google.

That seems right, right?  Just name each checkbox in the group the same thing, and you’re good to go.  The problem is that when you try to read those values in PHP, all you get is the last one (value3, in this case). To get all three values, you need to make the checkboxes part of an array, like this.

Then, when you need to get the values, you just step through the array, like any other array.

Pretty simple.  Just thought I would share so maybe it helps someone else.    

04Apr/14

One-Click WordPress Installer

old-wordpress-150x150So, I install a lot of WordPress.  It gets painful going to wordpress.org, downloading the latest stable version, unzipping it then uploading the zillion files up to the server through FTP.  Especially if you’re not on some crazy fast internet connection.  Personally, my home internet sucks, so it got to the point where it was taking 15 minutes, or so, to install WordPress.  That’s not fun.

space monkeyAnyway, I started looking around and I found a couple scripts that did a simple install from the server.  In other words, you upload a tiny file, run it and the install happens from the server.  Great!  Exactly what I was looking for!  Except they all still required you to edit the wp-config.php file, or they looked like they were designed by a monkey that just came back from outer space.

Luckily I finally found one that was old, but workable.  I spent a little time with it and made it pretty good.  Now, installing WordPress exactly the way I want it takes about a minute and a half.  All but the last 10 seconds is spent setting up the space on the server.  Not bad.  

Check it out on Github.  That’s where the latest version will always be.

Find it useful?  Help make it better, or buy me a beer to say thanks.  I love beer.  It makes me so much more productive.

If you’re too impatient to go to Github, here’s the guts of of what the script does.

  • Downloads the latest, stable version of WordPress
  • Displays a form:
    • DB Host, DB User, DB Password
    • Creates a random DB prefix for security purposes (you can also set your own)
    • FTP Domain, FTP User, FTP Password, FTP SSL?
    • Memory Limit (For PHP.  When we got to something like v3.7 my server started puking once in a while because it would run out of memory.)
    • List of plugins to download along with WordPress
  • Renames wp-config-sample.php to wp-config.php and updates:
    • Randomly creates the SALT fields
    • Adds code and the FTP information so you can actually use the Update links in Dashboard.
    • Fills in the DB information
    • Adds the memory limit line
  • Deletes the tar ball of the install package
  • Deletes license.txt, because it’s silly to have
  • Deletes readme.html, because it’s silly to have
  • Creates .htaccess file and makes it writable to the user (664)
  • Forwards to install.php (This is where the db is set up by WP)
20Mar/14

The Plugin Generated xxx Characters of Unexpected Output During Activation

the-plugin-generated-x-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.

22Nov/13

HTTP / HTTPS fix for WordPress

***UPDATE***
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 wordpress.org, but you can get it here on GIT.