Library

Importer Not Functioning

I have loads of posts, but the WordPress importer doesn’t like WordPress 3.9.1 in the slightest. Hopefully, they’ll resolve this soon. This importer has worked famously up until now. I tested a few other importers, and nothing is working with the file that WordPress exported (in WordPress format). Well, that’s a little frustrating.

[Tweet “The WordPress Importer plug-in is not working with WP 3.9.1 @WordPress”]

The plugin: http://wordpress.org/plugins/wordpress-importer/

My post in their support forum:
http://wordpress.org/support/topic/upload-doesnt-happen

Update 6/25/14: There’s one response to my support forum post. At least I know I’m not the only one!

My next step is to turn on debugging. If that doesn’t result in any clues, then I’ll export the blog in a different format (CSV, perhaps) and try a different kind of importer. If THAT doesn’t work, I’ll just have to move the posts manually (ugh). Thankfully, this is a fairly unique circumstance at this point. However, I’m surprised that it isn’t easier to export and import to and from WordPress. It should be.

Update 7/17/14: I gave up on the WordPress Importer when I found this article: “Best 10 Free WordPress Plugins.” I installed the WP CSV plug-in on my old blog, and installed the Really Simple CSV Importer plug-in on this blog. That did the trick!

Now to clean things up a bit around here.

Adding a Search Page to a WordPress Website

One of my sites doesn’t have a search box on the home page, and we wanted to go about offering an easy search option. I found this incredibly helpful article: http://codex.wordpress.org/Creating_a_Search_Page — I followed the directions listed under “Using the page.php” heading.

A few notes regarding the posted directions: The first step says to save the file, but not where. Save it to the themes directory under wp-content. That’s where you will upload it in the end. I keep a mirror of the website on my hard drive (makes things like sync’ing files and such a lot easier).

Secondly, you uploaded the new search page template… now what?

Go to the Pages manager, add a new page, and select “Search Page” from the template drop-down under Page Attributes. You’ll find the page attributes module on the right-hand side of the page.

Lastly, there’s no need to add any content to your new search page – it won’t show up. If you want the search page to look/feel different, head over to the Editor (under Appearance), select the searchpage.php file you created, and edit away.

For example, I went back in and choose a different page template from which to base the search page template on. The theme this site uses has a full-width page template that I liked better for this type of page. That was a quick fix tho – same instructions, just replace a different content loop.

Take a Closer Look, Be Safe

A few days ago, a close friend told me that someone tried to steal their email account! To add to that scare, I was recently forwarded a scam offer that looked legit until I looked a little closer. I decided to take these two warnings and post a few bits for you to look out for too.

Be aware and be safe.

What to look for on the website:

  • Does the site URL (in the address bar) match the site you THINK you are on?
    Not sure? Do a Google search for the site you think your on and compare the URLs.
  • When you click on the back button or try to close the window, are there a bunch of intentionally misleading pop up boxes asking you to stay?

What to look for in that email:

  • Does the from address match what you expect? (info@e.bay.com is not the same as info@ebay.com)
  • If suspicious, go to the website referenced in the email separately from the email. In other words, open the browser and either use your own bookmark, type in the URL, or Google the company.
  • If you are told to make a phone call to your bank (or a company). Don’t use the phone # in the email. Use the phone number published the bank/company website (that you went to independently of the suspect email).

A couple of the sites I reference are:

Basic Security

  • Make your passwords long
  • Use different passwords for different sites
  • Don’t share you passwords on websites, with tech support, through emails, or on post-it notes.
    (if you’d like to keep track of your passwords, use a secure method like keepass)
  • Change your passwords from time to time
  • Answer security questions with fake answers (social media makes those pretty easy to hack these days!)
  • Check and adjust your privacy settings on all social media periodically

Design Pet Peeve

I don’t want to view your article in a 20 section side-show. I’d like to just view the article in one page, thanks. At the very least, give me the option.

One site that is bad at this is REAL Simple. Ironic? I thought so. Great magazine, terrible site design… even the homepage is overly cluttered and overwhelming. Almost every article I clicked on turned out in side-show format, and I quickly lost interest. It just takes too long and too many clicks to get through a simple 1 or 2 page article in slide-show format.

I am liking their Pinterest boards though. Good stuff there.

More on Dates in PHP

I ran into quite a few blips when I tried to post some dates to the MySQL database. Very often,  I got all zeros input into the database. Then, it showed the wrong dates (1969 or something). The following code is what I arrived at after a lot a research, a call to my Mom for more research, and a bit of testing. I’m thrilled to finally have this working!

To start off with, your date must be in YYYY-MM-DD format. For me, that was simple. Just change the initial session variable.

 $_SESSION['tdate'] = Date("Y-m-d");
 //or for testing
 $_SESSION['tdate'] = "2012-09-12";
 $fv = array();

 //$fv (form values) array filled from $_POST data and validated //then //execute INSERT INTO with date
 $insert_vars = "Fname, Lname, `date-regis`";
 $insert_vals = "'" . $fv['fname'] . "', '" . $fv['lname'] . 
 ", '" . $fv['regdate'] . "'";

 $isql = "INSERT INTO " . $mydatabase .
 "(" . $insert_vars . ") " .
 "VALUES (" . $insert_vals . ")";

 $iresult = mysql_query($isql, $con);

 if(! $iresult )
  {
    die('Could not enter data: ' . mysql_error());
  }

 //lastly, I wanted to display the date a bit differently
 $datetodisplay = date("m/d/Y", strtotime($row['date-regis']));

A few things to note about the above code.

  1. I’ve learned to never use hyphens in MySQL column names a little too late. Thankfully, the back tick (`) helps keep me from having to reinvent the wheel (see the column `date-regis`).
  2. The date in YYYY-MM-DD format is insert into the database enclosed in single quotes (‘) just like a string.
  3. The last line of code there can be used to initialize your dates into the proper format for the databases, if need be.

As the title suggests, I’ve written on dates in PHP before. That post is all about comparing dates.

Redirecting in PHP

I mistakenly thought redirecting the user would be a simple and well documented process in php. NOT! I’ll get right to what actually works.

function redirect($url) {
 if (strlen($url) > 0) {
 if (headers_sent()) {
 echo "<script>document.location.href='" . $url . "';</script>";
 echo "<noscript><meta http-equiv="refresh" content="0;'" . $url . "'" /></noscript>";
 }
 else {
 header("Location: " . $url);
 }
 exit();
 }
 }

The above block of code is placed in the header, and it contains 3 methods of redirection. I doubt the php “header()” option will work at all, but I left it in for completeness. header() has to run before ANYTHING else on the page does, and no matter how I put that in, it did not work in a situation where I needed to pass it $url.

The preferred method is to use that tiny bit of JavaScript, and I put META refresh in there as a backup for the odd situation when JavaScript is disabled.

Credit where credit is due:

Comparing Dates, Learning PHP

I’m learning a lot of PHP here recently. I’ve never programmed in it before, but it is a fun little language. The nuances of the syntax are interesting sometimes – very typo prone! I’ve found several sites invaluable in getting the hang of the syntax, but I only recently thought to put them in here. If I find more, I’ll add them in later!

#1: I’ve referenced w3schools a lot over the years for a lot of different langues. It is a fantastic site for basic reference.

The useful site that spawned this post is actually where I found a simple method for comparing dates utilizing the strtotime function. I love how he did it “the hard way” first. That is totally how I was planning on doing it, and why I was searching for an easier way!
http://www.highlystructured.com/comparing_dates_php.html

Reading the post is worthwhile, but sometimes I just want to skip to the code. The following is a sample of the code I wrote based on Mike D’Agostino’s helpful writing.

$regopen = 0;
//convert dates to comparable formats
$date1 = strtotime($startdate);
$date2 = strtotime($earlydate);
$date3 = strtotime($enddate);
$today = strtotime($todaydate);
//now to compare - it's so easy its beautiful
If (($today >= $date1) AND ($today <= $date3)) {
$regopen = 1;
   //early pricing or regular?
$cost = $costreg;
If ($today <= $date2) $cost = $costearly;
}