WordPress Hack

Post by: bingorabbit
Published on December 23rd, 2007
Filed under: my.hacks
Tags: , , , , ,

WP, or WordPress, one of the most well known blogging softwares on the internet, which my blog really depends on :D . It’s very easy to deal with, customize and implement new features as much as you want – If you didn’t find them implemented yet – . One of the most booming features of wordpress, that was really implemented to facilitate the use of the system is Widgets , it’s a simple way to manage the sidebar through the admin panel by just Draggin’ & Dropin’ widgets from this sidebar to another.

Widgets Admin Panel

A problem that I was facing in a project I was working on, is that the customer needed the widgets to show it name instead of its number, so it shows Text (Info), instead of Text 1

Widgets Naming

I searched for a solution for that, but I found nothing on wordpress’ support forums, although I found some unanswered issues regarding this, I started digging in the system, when I found that the widget naming is one of the functions found in wp-includes/widgets.php .

At this file, exactly on line 605, it says:

$name = sprintf(__('Text %d'), $i);

so I changed this to :

$title = $options[$i]['title'];
$name = __('Text (' . $title . ')');

Added a title “info” to Text 1 widget, and with a simple refresh, I got this:

Widget After

I think this might ease things up to those who deal with enormous number of widgets in their sidebar.

This is only valid in WordPress 2.3, and I dunnu if it will work in the next versions of the system.

..or you may would like to check other posts that can be useful..

  1. My WordPress-GSoC Idea
  2. I got my WordPress T-Shirt
  3. Baker is Out!
  4. WordPress 2.9, Carmen
  5. On WordPress.tv

11 Responses to “WordPress Hack”

  1. kamasheto says:

    Heh, good job buddy =)

  2. GaMaL says:

    hmmmm,
    Howa ana msh 3aref eeh elle 7asal belzabt !!
    bas it looks gr8 !

  3. bingorabbit says:

    @Kama: Thanks pal :)

    @Psycho: I once asked you about widgets and if you did use them before, lama kona fi nady el tagdef, u answered that you didn’t do so, the theme you are using now is widget enabled, try it and you will know what I’m talking about :)

  4. Mona says:

    Yeah great system for blogging but I still with Joomla’s side it has the best CMS in the world award oh yeah there is a contest in google code for joomla project and drupal if you are intrested to participate…

    I forgot to tell you that google sent me a T-shirt for participating in google 2007 summer of code it was a great surprise for me that google send me something even zarf fady :D without writing a line of code …

    Good job…

  5. bingorabbit says:

    I admit that Joomla is a marvelous CMS, but an enormous one! :D

    About GSOC, it’s the first time to hear about that, I’m gonna check it and tell you what I have reached :D , may be I’m gonna participate in the Drupal contest I think, but it says:

    If you’re a student age 13 or older who has not yet begun university studies, we’d love to see you help out these projects

    Is it limited for those only?!

    LOL@ ZARF FADY :D , gamda btw :D , mabrok el T-Shirt :D

    Thanks for passing by :)

  6. Dan says:

    Hey, I’m trying to have some custom text widgets that go with the theme I’m creating. Could you tell me the lines within widgets.php that create the text widgets and give it the user configure option. It seams I’ve been unable to find all the correct sections. Thanks!

  7. bingorabbit says:

    it’s where it says
    function wp_widget_text_register()

  8. Dan says:

    Thanks, I got all the code and created a double of the text widget, but the original text widgets saves over the new one, even though I edited the name and anything else I could fine. They must have the same Database location or something. How do I change where the Widget is being saved?

    What happens is I use Text 1 and have it say “ABC”. Then I use New 1 and have it say “XYZ”, but both Text 1 and New 1 say “ABC” after I save.

  9. bingorabbit says:

    That can’t be, because that was tried before, can you please provide me with your wordpress version?!

  10. Dan says:

    I’m using 2.3.2. It has be possible, because it’s like creating an entirely new widget… but I don’t know where I’m going wrong.

  11. bingorabbit says:

    can I have a look at that?! :)

Leave a Reply