Saturday, November 26, 2011

Meta Box in WP options page

I have tried to add meta boxes in wordpress options page. Here is the solution

http://andrewferguson.net/2008/09/26/using-add_meta_box/

Sunday, May 15, 2011

External Javascript in Wordpress

JS for admin pages:
Wordpress provides some very important action hooks to hook external js in admin pages.
admin_enqueue_scripts : it prints external js in every pages in your admin sides,very much awful,isn't it? Better method is also available.cheers!

Suppose you create a setting page for your plugins and it uses js files.You have to follow some rules to be using this js file only for this script.
(i) $a = add_menu_page(.....) || add_submenu_page() || any page
(ii)ehco $a(let $a = settings_page_WPAffiliateLinks);
(iii)extend it with this hooks like this
admin_print_scripts-settings_page_WPAffiliateLinks
very simple isn't it?

js for client sides
You can use some build in functin like is_home(),is_single() to print your js scripts for client sides.




Saturday, May 14, 2011

MYSQL IS NOT CASE SENSITIVE

i thought mysql is case sensitive,but unfortunately it is not case senstive!Here is the rules to make database table fields case sensitive:

CREATE TABLE IF NOT EXISTS wp_affiliate(
`id` int unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(20) NOT NULL collate utf8_bin,
`afflink` varchar(50) NOT NULL,
`countt` int unsigned DEFAULT 0,
`countu` int unsigned DEFAULT 0,
`clktime` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`comment` varchar(254) DEFAULT '',
PRIMARY KEY(id),
UNIQUE(name)
)
The name field is case sensitive.It's a great thing i discovered while working on wordpress database
Bugs: if your make this change to your table wordpress function may not work(in my case).SO i am using some straight mysql query.