Technology Tips and Tricks – The Mansurovs
17Feb/100

How to Update Category and Tag Descriptions in Wordpress

Do you ever put category and tag descriptions while creating them? I used to do it in the beginning, but then as I got busy I started simply inserting tags and categories without any descriptions attached to them. Over time, I was getting a little annoyed by the fact that some categories and tags have names, while others do not, so I created a quick SQL code to take care of this issue. Basically, the SQL code just goes through all Wordpress tags and categories and copies the category/tag name into the description field.

Make sure to backup your database before you do this!

Here is the code for updating category description:

UPDATE wp_term_taxonomy LEFT JOIN wp_terms ON wp_term_taxonomy.term_id = wp_terms.term_id
SET wp_term_taxonomy.description = wp_terms.name
WHERE wp_term_taxonomy.taxonomy = 'category'

And here is the code for updating tag description:

UPDATE wp_term_taxonomy LEFT JOIN wp_terms ON wp_term_taxonomy.term_id = wp_terms.term_id
SET wp_term_taxonomy.description = wp_terms.name
WHERE wp_term_taxonomy.taxonomy = 'post_tag'
Tagged as: ,
Posted in: CMS
No Comments
19 Views
17Feb/101

Wordpress does not Import Categories and Tags

I recently had to go through the nightmare of converting from standard Wordpress installation to Wordpress MU. The reason why I say "nightmare", is because the process turned out to be rather complex and painful in terms of keeping all data consistent. My original plan was to simply export the data from Wordpress standalone and then import it into Wordpress MU. But after I imported everything, things did not work out as well as I hoped they would. For whatever reason, all of my categories and tags were messed up and when I went to the categories page in Wordpress admin page, the categories showed 0 posts and the same thing happened with my tags.

I then tried to look for other ways to do this right and stumbled upon a suggestion in Google to simply rename the database table names. Everything seemed to work perfectly, until I started encountering database inconsistency issues with three separate blogs in one Wordpress MU installation. It turned out that Wordpress MU works by assigning one category/tag ID for the same category name that is used across different blogs. Inevitably, my categories and tags eventually started conflicting with different category IDs assigned to the same category/tag.

Wanting to fix this problem as soon as possible, I went back and tried to do it right from the beginning. It turns out that the best way to do it without creating any potential database inconsistencies is through export/import process within Wordpress. Once I exported and imported everything, the problem with categories and tags not showing up came back to haunt me!

I looked at the data on table level and everything seemed to be mapped correctly, very similar to what I had in my original Wordpress installation. I kept on digging until I accidentally tried something and it worked! I tried assigning the first Wordpress post "Hello world!" to one of the categories and voila - it showed up! So, if you are experiencing the same problem with categories and tags in Wordpress, here is what you should do:

  1. Make sure not to delete the original "Hello World!" post that gets automatically created by Wordpress. If you have already deleted it, create a new dummy post that you can later delete.
  2. Make sure that the Wordpress import process is successfully finished.
  3. After all posts and pages have been imported, go to "Edit" under "Posts" and edit the "Hello World!" or dummy post.
  4. Go through each of the categories and put a checkmark in front of every single category.
  5. Save the post.
  6. Visit both the "Categories" page in the admin section and the main page and make sure that all categories show up correctly with the correct number of posts attached to them.

This will fix the category mapping issue. Now let's move on to tags.

The problem with tags is much more complex than with categories. If you have a large site with thousands of tags, you do not want to be manually inputting those one by one. Gladly, I found a good solution that worked for me!

You will need to have access to an SQL query tool to grab the tags data. Fire up PHPMyAdmin or whatever else you are using and type the following query against your current Wordpress MU database:

SELECT CONCAT(wp_1_terms.name, ',') FROM wp_1_terms LEFT JOIN wp_1_term_taxonomy ON wp_1_terms.term_id = wp_1_term_taxonomy.term_id
WHERE wp_1_term_taxonomy.taxonomy = 'post_tag'

The above query should return a bunch of lines with all of your tags with a comma at the end. Obviously, you will need to change the wordpress blog ID if you are using a different blog ID than "1". Start from the top and select everything all the way to the bottom, then press CTRL+C to copy the tags data.

Next, go to the same "Hello World!" dummy post and copy-paste the tags data into the tags input field and save the post.

All of your tags should now be correctly mapped! :)

Tagged as: ,
Posted in: CMS
1 Comment
34 Views
16Feb/100

SiteWide Tags Categories Showing as Numbers

This is another fix to Donncha's Sitewide Tags plugin that eliminates the problem of having certain categories show up as numbers in the sitewide blog in Wordpress MU. In my Wordpress MU installation, there was a problem with specific categories showing up as numbers for whatever reason (I figured out the reason later and went through the nightmare of permanently fixing it). When I looked at the sitewide blog tables, some of the categories were written as numbers instead of full category names and category slugs. Apparently, Donncha's plugin relies on Wordpress MU handling the category IDs that are supposed to be the same across all blogs - i.e. a category in blog 1 should have the same category ID as a category in blogs 2, as long as the category names and slugs are the same. When I looked at my installation, I found out that I had different category IDs for the same categories, due to the fact that I simply renamed some of the main tables instead of importing/exporting them when I migrated to Wordpress MU from standalone Wordpress installation. I certainly didn't feel like redoing everything from scratch and looked for an alternative solution that would work for me, so here it is.

Find the line: "$post->post_category = wp_get_post_categories( $post_id );" and modify the below foreach code as shown below:

    foreach( $post->post_category as $c ) {
        $cat = get_category( $c );
        $cats[] = array('name' => wp_specialchars($cat->name), 'slug' => wp_specialchars($cat->slug));
    }

Then, locate the first "switch_to_blog( $tags_blog_id );" line and modify the code as shown below:

    switch_to_blog( $tags_blog_id );

    /*
     * We first need to insert the categories into the new 'terms' table
     * Then we need to get the ID of the category and use it while inserting the post
     */
    if( is_array( $cats ) && !empty( $cats ) ) {
        foreach( $cats as $t => $d ) {
            /* Here is where we insert the category */
            wp_insert_category( array('cat_name' => $d['name'], 'category_description' => $d['name'], 'category_nicename' => $d['slug'], 'category_parent' => '') );

            /* Now get the category ID to be used for the post */
            $category_id[] = $wpdb->get_var( "SELECT term_id FROM wp_" . $tags_blog_id . "_terms WHERE slug = '" . $d['slug'] . "'" );
        }
    }

The last change is to use the category IDs that we grabbed above while posting the entry. Locate the line that says "$post->comment_status = 'closed';" and insert a single line as shown below right above wp_insert_post:

        /* Use the category ID in the post */
        $post->post_category = $category_id;

        $p = wp_insert_post( $post );

That's it, now all categories will always have the right category name/slug in your sitewide tags blog!
P.S. The above code changes have already been applied to SiteWide tags plugin by Donncha, so make sure to get the latest version from wordpress.org.

15Feb/100

How to Stop Duplicate Twitter Notifications in SiteWide Tags

If you are using Donncha's Sitewide Tags plugin for Wordpress MU along with Alex King's Twitter Tools, you might get frustrated with the fact that you will see two duplicate notifications on Twitter - one from the original blog entry, and one from the sitewide blog.

Here is how you can stop duplicate twitter tools notifications in sitewide tags - you will have to edit Twitter Tools:

Open up "twitter-tools.php" in the plugin folder, then locate the "do_tweet" function in the code. Right under "function do_tweet($tweet = '') {", insert the below code:

		global $wpdb;
		if (isset($wpdb->blogid) && $wpdb->blogid == "4") {
			return false;
		}

My sitewide blog ID is "4", so if yours is different, make sure to change the number to the corresponding blog ID. You can locate the blog ID in wpmu-blogs.php page. Save the file and you are done!

I know this is not the most elegant way of doing this, so if you come up with a better method, please let me know.

4Feb/101

Welcome to our new "Tech" section!

Welcome to our new Technology section! Here, we will be posting guides, "howto"s and other useful information for technology gurus and geeks!

As I pointed out in my quick post here, Karim will be heading this section and share his technology tips and tricks. I haven't yet had a chance to work on feeds and other custom enhancements for this section, but I'm planning to work on them within the next couple of weeks.

Stay tuned! We are very excited about this!

Tagged as:
Posted in: Technology News
1 Comment
0 Views
10Dec/090

Another book review from Packt Publishing

Packt Publishing approached me once again to review their upcoming book "ModSecurity 2.5" after my last review of their "Qmail Quickstarter" book. It is supposed to be a detailed book on Apache Module Mod_Security, which I have been using since the very early versions of the product. I agreed to review it and they already shipped it to me, so I will post a review of the book sometime next week, if the time allows.

I really like the books from Packt Publishing, because they cover some specific topics that very few other publishers write about. Their books are a great reference for system administrators and tech junkies like me :)

Tagged as: ,
Posted in: Book Reviews
No Comments
4 Views
19Nov/094

Acronis Backup & Recovery Review

I have been thinking of writing this review for a while now, since I have been using Acronis products for more than 3 years now, since version 8. The reason why I wanted to write this review, is to express my frustration with this backup product and help others make the right decision on whether this product should be used for enterprise backup and recovery.

Honestly speaking, when I saw this product for the first time, I was amazed by its ability to backup hard drives sector by sector and the speed of the backup process. There was nothing comparable on the market back then and Norton Ghost wasn't even close in comparison. After trying the Acronis Workstation product, which worked very well for our needs, I assumed that the Acronis Enterprise Server was just as good and went ahead and bought the product. I wanted to use it in all of our servers (approximately 12 Windows and Linux servers) for our offline backups and get rid of the much hated Symantec Backup Exec that we were using for years.

Continue reading 'Acronis Backup & Recovery Review'

19Oct/090

Beware of wordpress plugins

I was going through some of the popular wordpress plugins on wordpress.org the other day and found a plugin called "flash clock widget" that I kind of liked. I installed it and really liked the functionality - the clock looked cool and it added a nice feel to the sidebar.

Flash Clock Widget

Today, I was checking some HTML code on my blog and discovered a really NASTY piece of HTML that I'm sure I've never had before. It was an external link to some sort of bookcase. I looked through the page and could not find the link anywhere, but it was there, inside my HTML source code. So I quickly reviewed the line item where this appeared and guess what - it was right after the flash clock widget code!

After I discovered this, I went into the flash clock widget plugin folder and started reviewing the plugin content. Everything seemed to be OK until I got to line number 69 that had this:

$flashtag .= ClockFlash_pleaseInstall();

Hmm, that looked suspicious - ClockFlash_pleaseInstall? I then looked for the "ClockFlash_pleaseInstall" function within the code and found this inside the function:

if($options['link'] == '' || $reset == '1')
{
$options['link'] = file_get_contents( 'http://bestaccountantservices.com/upgrade/Clock1/link.php' );
$needsave = 1;
}

Wait a second...this flash plugin pulls stuff from another website? I then opened the link in my browser and voila! Busted! The advertising was coming from that website! Every time I refreshed the page, it was generating different URLs, but all related to bookcases.

It is very sad to see such abuse of a plugin. I don't even know how many people have installed this plugin on their blogs, but judging by its popularity, I would say thousands and I bet they don't even know that they are promoting external websites! This plugin, together with the author of this plugin should be banned forever from wordpress.org and wordpress users should be notified about it.

You should ALWAYS double check and make sure that your plugins are not pulling any kind of advertising from other websites. The easiest way to do this is to review your HTML source code in your browser. Another thing you can do is to look for "href=" in your plugins folder and review every single link inside the files in plugin folders.

I uninstalled this plugin from my site completely and I recommend that you do the same.

Tagged as:
Posted in: CMS
No Comments
1 Views
16Jun/090

ERP (Enterprise Resource Planning) - Part One

I finally had some time today to get the first part of this article completed and I decided to post it as a sneak preview. I will expand on this topic and am planning to add a lot more information later.

1) What is ERP?

ERP stands for "Enterprise Resource Planning". ERP is a software product that is capable of running and integrating multiple different organizational functions such as accounting/financials, human resources and payroll in a shared database. Without going much into detail on what this means, let me jump right into a real life example. I'm assuming that you know a little about the employment process, perhaps from your work experience.

Let's say you are applying for a job. The process is pretty straightforward nowadays - you find a good position worth applying for either online or through other resources such as recruitment agencies, then submit your resume and wait for a call or email follow-up. After a while you get screened and interviewed by a company that is interested in your skills. Then, if you are the right candidate, you get hired.

Continue reading 'ERP (Enterprise Resource Planning) - Part One'

9Apr/0935

Converting vBulletin to UTF-8

While working on a new multilingual project, a need arose to convert my current vBulletin database to UTF-8. I thought the process would be relatively simple, but it turned out to be a nightmare that I struggled with three days. And yes, I did try the "vCharset Converter" module, which is unmaintained, sucks bad and never works. I ended up successfully converting the database to UTF-8 and everything so far has been working great, so I decided to post a quick how-to for those who are planning to convert their vBulletin forums. My previous database charset was "latin1/latin1_swedish_ci" (MySQL default) and I was using "windows-1251" codepage to accomodate Cyrillic characters in my forum. Here is the procedure:

Continue reading 'Converting vBulletin to UTF-8'

Tagged as:
Posted in: CMS, Databases
35 Comments
325 Views