Posts Tagged "plugin"

In which I finally fix a theme

Posted by: debrain website in website
3
Sep

The more time I spend digging around themes, the more I learn about WordPress, PHP, and CSS. I am consistently downloading themes that don’t work correctly with my Gallery2 plug-in. Don’t confuse this with the new, built-in WordPress gallery. This is the independent application with a plug-in that powers my photos page. With few exceptions, the themes I download consistently break the footer on my photo page or the sidebar on my library page generated by Now Reading. I really like the current theme, Fall Season 1.1, but the footer on the photo page was not playing well with the plug-in. For a while, I wanted to blame the two previously mentioned plug-ins, but they both play well with WordPress Default theme. That fact lead me to the logical conclusion that the themes are broken. I have also started to “fix” the themes that don’t come with dynamic (changeable) sidebars. I downloaded Fresh Editorial today looked to be dynamic when I grabbed it, the proper code was in place for the functions file, but was absent in the sidebar file. I think I understand why, it was a bit complicated to make the sidebar look the same after updating it, but with a little tweaking, it would be possible. I have chosen not to spend more time on it at this point, as their site doesn’t support FireFox 3 so i am unable to leave comments unless I visit their site with Internet Explorer. See comments for why I was unable to leave a comment. I also found a wonderful Christmas theme, Winter Red. Winter Red will need tweaking as both the library page and the photo page are seriously out of whack.

All this to say I think I am the only one getting anything out of metablogging, but in the hopes that someone else using WordPress and these themes happens to search for how to fix things, I’d like to have an answer for them.

Tags: , , ,

You may not have noticed there is an event countdown widget1 in my sidebar. Since no one has complained, I gather that no one is particularly upset that I countdown to a few select events and birthdays. Really, it’s a reminder to me that it’s coming soon because I do tend to forget things.

Yesterday, I discovered a small bug in the display of the events. I’m not sure if it has always been there and I’m blind or what, needless to say, I live in GMT-5 time zone give or take a little daylight savings time, it’s lovely here. The weather is ever changing, there are interesting birds and animals. However, the code as written doesn’t address possible time zone issues. The code assumes that the host computer is in the same time zone as the event, which is not always accurate. In an ideal world the plug-in/widget would ask me to input my desired time zone and adjust accordingly, someday I may sit down and “fix” it so that it does inquire. In my case, the server hosting this application lives in California, GMT-8 give or take a DST. What does it mean? My events calendar is about 3 hours off when it displays an event. For example, it’s midnight in GMT-5 and an event occurs at 8:00AM. As the code is written, the event is is not 8 hours away, it’s 12 hours away. In another example, an event that happened 2 hours ago is listed as one hour in the future with the code as written.

I don’t write PHP from scratch, I just read it, usually understand it and then alter it to suit my needs. But this time, I really just wanted a quick fix. This particular code was written in PHP and WordPress, so rather than trace the code from top to bottom across two files, I chose the one file I knew I needed to change and went to work. I changed random and not so random numbers and hoped that I would find it while refreshing the events list. Chaos ensued. After spending too much time, I gave in and read the code across the two files as well as comparing it to the two web pages that are produced from those files. One file is the admin interface page where all events are entered into the php database and stored as variables in the table. The other file waits to be called by a widget or page, and then pulls data out of the database, applies code to it, and displays it. All I have to say for my efforts is, “DUH!”

I had already determined that the problem existed because the of host server being in a different time zone and hoped to alter the script to tell the host server to pretend it was in my time zone. That didn’t work so much, so I read about what the different time statements were. I spent some time at PHP-Date.com and PHP.net reading about various date/time functions like current_time(), date_default_timezone_set(), date_default_timezone_get(), gmmktime(), strtotime() and a few more. The solution turned out to be very simple once I read the code and looked up what each command did. In my defense, there are nine variables but between the two files, the order is constantly rearranged so I had mixed up four of the variables, thinking they held values they didn’t hold. I discovered that current_time() was a WordPress function and MYSQL function. The actual line I tried to alter was current_time(timestamp, $gmt = 1), the however, I don’t know how variable for $gmt is used by WordPress nor what the possible values are beyond 0 and 1. I tried to alter it up through 10 and didn’t find the correct value, I added single quote/apostrophe around timestamp, I tried using mysql instead but that seemed to break it the most. Dates were displayed as seconds, rather than years, months, weeks, hours, minutes, and seconds. Why on earth would that happen? Well, Unix/Linux uses a time system based on the Gregorian calendar and midnight on January 1, 1970, also referred to as Unix Epoch. All dates/times are expressed as seconds before (negative values) or after (positive values) that date. Fun factoid: The 24 hours (a.k.a. 86400 seconds) representing August 5, 2008 are 1217919600 through 1218005940. The previous timestamps are generated using the php command strtotime() because I desperately need to something to show for the last 24 hours. Should you like to experiment with this, I recommend using using your favorite search engine and looking up the terms “unix time” or “POSIX time” along with the word converter. Please be aware that based on the command used to call the timestamp, results will vary so you may not get the same result across several different converters. I didn’t count them all, but there didn’t seem to be a shortage of unique commands to call time for various purposes, such is the nature of UNIX/Linux. One of the reasons for the difference is a problem calculating leap seconds. I’ll spare you the details.

As I just mentioned, strtotime() was a php function. While searching, I found that the php-date.com page had an interactive strtotime() box, strtotime() was used several places in the timestamp section. I could display the current GMT time, then practice using different commands to alter the displayed time. After reading that, I wondered why both strtotime() and current_time() were used. So I changed current_time() to strtotime(’+ 3 hours’) because I knew it would display the correct time based on experiments at php-date.com, at least until DST ends. Solving it this way seems crazy because somewhere in California the current time is converted from GMT to GMT-8 and I basicall changed it to GMT-8+3. Some day I’ll learn how to use the time zone things and just use GMT-5, but all it did today was break the plug-in, so I’ll leave it for now.


1 A widget is a piece of code inserted into a spot on the sidebar to perform a function. There are many widgets that have been in my side bar including a search bar, the answer to why this site is orange for August 2008, a random image from my photo gallery, and Now Reading (a list of books).

siggy

Tags: , , , , , , , , , ,

Time to backup again

Posted by: debrain garden, website in garden, website
30
Apr

I have finally finished going through all my posts, 103, checking for tags, categories, bad coding, and a random spot check of grammar and spelling. I will admit that the first 75 or so got a good going over, mostly. There were 10 or so in that first 75 that I have gone over multiple times, so they only received a cursory glance. The last 28 or so, let’s just say, I checked out during those. I’ll recheck them eventually. I did update my blog to be tableless! So very excited about that. I will admit that I am not sure if I used proper CSS to manage the photo layout, but I did it as best I could. There are a few things that didn’t go right, but I worked around them. Time to perform a backup from WordPress so that I don’t lose my categories again. I had one of my plug-ins break, but found a fix on the author’s webpage, though I don’t understand why it fixed, it is. Now Reading breaks with WordPress 2.5.1, I tried downloaded 4.4.4beta, but that was useless. I rolled back to 4.4.1 and went into my permalinks menu, didn’t change anything but click on update and the plug-in magically began working again.

My garden is underway in the basement with a grow light. I have several more broccoli plants breaking ground and one hot pepper plant. I picked up some tomato seeds and trays for the seeds, planted those a half hour ago. In preparation for two of my wisdom teeth departing on Thursday, I am packing as much as I can into these last few days. I have no idea how I will react to anesthesia, I haven’t had it since I was a kid. I also don’t know how much pain will be involved, so I am planning on losing a few days. By Sat. morning, I am hoping to be back up to snuff.

Tags: , , , , , ,

I spent the afternoon updating all the behind-the-scenes gadgets for this site. I was originally going to play with my test site, but noticed that things were asking to be updated, ever so politely. Unfortunately, so update I have to download, extract, and ftp the extracted files. The brighter side appears to be an early spring cleaning. More than half wanted updates, and I deleted the ones I was no longer using. Less clutter is better. One of the updates involves a plugin that will automatically link posts/entries in the same series. I originally tried this plugin for my MCF Africa posts, but the theme I was using wouldn’t play well with the other plugins when the series one was activated. I’m going to try it again today by making a series of small posts today and linking them in a series based on today.

Tags: , ,