jQuery UI Themes Messed Up

If you have included the jQuery UI, and are trying to use one of their themes, and it keeps showing up all messed up, you may need to include a few other files that you don’t know about.

Make sure you download the entire development bundle.  Inside the development bundle, you’ll find some additional css files in there.

Let’s say you are using the datepicker.

You’ll want to include css files in this order:

development-core/css/core.css

development-core/css/datepicker.css

theme/smoothness/jquery-1.8.2.customer.css

PHP move_uploaded_files permission denied

This turned out to be a fairly simple fix after much frustration.

I did this in ssh, so if you don’t have that, you’ll have to find another article.

open ssh, cd to your web root.

type ls -l

to see all the permissions.  You’ll see come stuff like -rw-ww- owner group 4096 time filename

you’ll need to change your upload directory to have the same group and owner as your other web files.

So let’s get started

mkdir data

chown owner

chgrp group

chmod 777 data

That’s it.

replace “data” with your folder name

replace “owner” and “group” to match the settings from when you did ls -l

lftp crontab linux options how to

first lets make a working directory. Open up ssh or go to the command console and type

cd /var/

Create a directory here

mkdir test

now create a file with vi (or use whatever editor you like, I personally hate vi but it’s what it on my server)

vi myFile.exe

Now type in the following:

#!/bin/bash
/usr/local/bin/lftp -e ‘lcd /var/test/ && set ftp:ssl-protect-data yes && set ftp:passive-mode yes && open ftp://server:port -d -u “username”,”password” && mirror “.” && exit’
If using vi, type ESC then :wq to write the file.  you should now be back at the command console.
If you type ls you should see the file listed now.
Now type:
chmod u+x myFile.exe
Now your file is ready to execute.  You can type ./myFile.exe from the command line and it should run the lftp commands.  Just a note, the mirror command above will copy all the files (not recursively).  The lcd command changes the local directory where files will be downloaded to.
You’ll notice that I have the full path to the lftp program.  You’ll need that.  If you don’t know where it’s installed you can do:
find / -name ‘lftp’
Now let’s create the crontab. Type:
crontab -e
That should open up your crontab file. Enter a new line and enter:
30 18 * * * unbuffer /var/test/myFile.exe > /var/test/log.txt
That should do it.
Now, all the files on your ftp server will be downloaded to your computer at 6:30pm every day.  Pretty nifty!

Transferring WordPress to new server

Just wanted to make a note here as there are plenty of tutorial on transferring wordpress to another server.

Dont’ forget to do a find and replace on the .sql file that you backed up.

Also, after the transfer, my site would just hang.  After trying to track down the error, I renamed my wp-config.php file to wp-config.php.bak.  Reloaded the site, and let wordpress create me a new one.  I did not run the install as all my information was already there.  A quick refresh and everything was working!

Shortcodes not rendering in WordPress

I have tried to use several plugins that use shortcodes in the post of page, such as, [contact] or [download].

But when I view the page, the shortcode is not rendered, instead is just shows me the shortcode.

To fix this, your template just have the following code in it:

<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
	<?php if ( is_front_page() ) { ?>
		<h2><?php the_title(); ?></h2>
	<?php } else { ?>
		<h1><?php the_title(); ?></h1>
	<?php } ?>
	<?php the_content(); ?>
<?php endwhile; ?>
That will fix all your shortcode problems.

Getting WordPress to work on GoDaddy’s free hosting account…finally!

Aye….another failed attempt.  Close.   If someone can provide some suggestions, I think we can get there….

Tested in Firefox 3.6.6  Does not work in Chrome.  IE….won’t even try.

It took me a few tries….okay, a bunch of tries, but in the end it’s a really simple fix to get WordPress 3.0 to work on GoDaddy’s free hosting account.

From my experience, I have not had any issues on the front end of wordpress, it is only the admin that breaks.

To fix this, you’ll have to edit some files, but it’s not a big edit.

To get started, open up wp-admin/index.php

Change the top of index.php file to look like this:

<?php

ob_start();

/**

* Dashboard Administration Panel

All we’ve done here is add the line ob_start();

Next, at the very, very bottom of that page…I mean the very bottom, put the following code:

<?php
$buffer = ob_get_contents();
ob_end_clean();
$buffer = str_replace(array(‘<html>’, ‘</html>’), ”, $buffer);
$handle = fopen(“./temp.html”, ‘w+’);
fwrite($handle, $buffer);
fclose($handle);
?>
<script type=”text/javascript”>
$(document).ready(function() {
$(“head”).remove();
$(“body”).remove();
$.get(“./temp.html”, function(data){ $(“html”).append(data); } );
});
</script>
That’s it!
Save that, and refresh your admin index page.
What we have done here is essentially grab all the data that would be output by WordPress before GoDaddy’s get’s is greasy fingers on it, store that in a file.  Then we wait for the entire page to load, let GoDaddy do what they need to do, then wipe the page clean.  We then send out a request to get the non-abducted code and make that your page.  The ole switch-a-roo!
Of course, you probably stopped reading this after you saw that it worked and are now back here reading again to find out why none of the links work. 🙂
Well, we only changed the index.php page.  If you notice in your browser, you are probably now on post.php or edit.php.  This means that each file will need to have the above fix added to it.  I know, so much work, but totally worth it for about a half hour of work.
Caveat: GoDaddy’s puts those ads in there for a reason, so I’d advise to leave them on frontend of your site.  Yeah, I know, I hate them, but hey, a free account for a banner ad, not a bad price to pay.   I took them off my admin for one, because it broke it!, but two because, I’m the admin!!!  They don’t need to advertise to me, I already have an account with them.
-Happy coding!

Common Linux Commands I use

unzip archive:

> unzip filename.zip

or

>tar cfv test.tar test/

to get hidden files as well

Move contents of directory A to directory B

> mv -i ./A/* ./B

Copy contents of directory A to directory B

> cp -r ./A/* ./B

Remove directory

>rmdir ./A

or

>rm -rf ./A to remove all subdirectories and file

Untar file

tar -xvf ./file.tar

if zipped also use -zxvf

Taken from: http://www.geekvenue.net/chucktips/jason/chuck/994016279/index_html

If you would like to preserve the permissions of the files you backup, use the p option with the tar command. This will save the uid, gid as well as the specific permission attributes of the files (read, write, execute etc.)

tar pzcvf tarball.tgz .

You should also use the p option with the tar extraction command:

tar pxvf tarball.tgz .

PHP include vs require_once

After 10 years of PHP programming, it has finally settled with me the difference between require_once() and include().

Now, there are other differences as recorded in the manual, but I never really cared about it, until today.

I have 4 files: index.php, config.php, functions.php, and plugins/config.php.  All of which are nested inside the other respectively using an include.

In the last config.php file, I am declaring a function…say, function what(){ }

While using include, I get the error, cannot redeclare function what as previously declared.  The interesting thing was that the two places it said that it was begin redeclared in were the same file!

Strange.  I happened to realized that during the order in which PHP includes files, was that it was redeclaring the function as it bubbled up the chain of includes.

changing to require_once() fixed the problem!

Magento Nav Function for Dynamic Menus

I finally got tired of messing with Magento Menus.  The drawItem function really sucked when I needed to customize something.

Here is a little function that WORKS!!

function allebrumNav($parentId, $levels=1, $exclude=array(), $current_level=1){
if($current_level == 1){ $menu .= ‘<li><a href=”‘.Mage::getModel(‘catalog/category’)->load($parentId)->getUrl().'”>’.Mage::getModel(‘catalog/category’)->load($parentId)->getName().'</a><ul>’; }
$i = 1;
foreach(Mage::getModel(‘catalog/category’)->load($parentId)->getChildrenCategories() as $cat){
if(!in_array($cat->getId(), $exclude)){
$menu .= ‘<li><a href=”‘.$cat->getUrl().'”>’.$cat->getName().'</a>’;
if($current_level != $levels){ $menu .= ‘<ul>’.allebrumNav($cat->getId(), $levels, $exclude, $current_level+1).'</ul>’; }
$menu .= ‘</li>’;
$i++;
}
}
if($current_level == 1){ $menu .= ‘</ul></li>’; }
return $menu;
}

To Use the function simple call:

The 1st Parameter is the Parent Category ID to start with. It will start there and read all the children categories.

The 2nd Parameter is how many levels down to read into.

The 3rd Parameter is and array of Category IDs to exclude from the list. Example: array(“32”, “35”, “6”)