Send ajax request in wordpress using wpnonce

wpsecuritythumblet’s send ajax request in wordpress using wpnonce

Hei, I am not going to discuss what is wpnonce and why you should use this in your plugin or how important to use this to secure your plugin 😛
But here I am going to discuss how you can use wpnonce in ajax request, I mean if your plugin handles ajax request.
Steps that we need to follow are:

One: Create wpnonce value.
Two: Send wpnonce value as an extra parameter with ajax requestion
Three: Check ajax referrer with the wpnonce value that was created in step one and sent in step two.

Ok, how to create a wpnonce value ?
we need to use wordpress function wp_create_nonce() . See wordpress codex here.
< ?php $my_wpnonce= wp_create_nonce (‘you-look-nice’); ?> // “you-look-nice” is just a string, u can use whatever u want. here $my_wpnonce will get a hash from wp_create_nonce. Oh that is not direct hash of “you-look-nice” but based on user id, time and that string. To know more about this function please check pluggable.php in wp-includes folder

Now send wpnonce value $my_wpnonce as an extra parameter while seding ajax req. Continue reading

āĻ“ā§ŸāĻžāĻ°ā§āĻĄ āĻĒā§āϰ⧇āϏ āϟāĻŋāĻĒā§āϏ-ā§Š

āϝāĻžāϰāĻž āĻāχ āϏāĻŋāϰāĻŋāĻœā§‡āϰ āφāϗ⧇āϰ āĻĻ⧁āχāϟāĻž āĻĒā§‹āĻ¸ā§āϟ āĻĒāĻĄāĻŧ⧇āύāύāĻŋ āϤāĻžāĻĻ⧇āϰ āϜāĻ¨ā§āϝāσ
āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄ āĻĒā§āϰ⧇āϏ āϟāĻŋāĻĒā§āϏ-ā§§(āφāĻŽāĻžāϰ āĻŦā§āϝāĻ•ā§āϤāĻŋāĻ—āϤ āĻŦā§āϞāϗ⧇)
āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄ āĻĒā§āϰ⧇āϏ āϟāĻŋāĻĒā§āϏ-⧍(āφāĻŽāĻžāϰ āĻŦā§āϝāĻ•ā§āϤāĻŋāĻ—āϤ āĻŦā§āϞāϗ⧇)

āĻ“āϕ⧇ āϤāĻžāĻšāϞ⧇ āφāϜāϕ⧇āϰ āϟāĻŋāĻĒā§āϏ āĻļ⧁āϰ⧁ āĻ•āϰāĻž āϝāĻžāĻ•āĨ¤ āĻāϰ āφāϗ⧇ āϞāĻŋāϖ⧇āĻ›āĻŋāϞāĻžāĻŽ āĻ•āĻŋāĻ­āĻžāĻŦ⧇ āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄāĻĒā§āϰ⧇āϏ āĻ•āĻžāĻ¸ā§āϟāĻŽ āĻĒ⧇āϜ āϤ⧈āϰāĻŋ āĻ•āϰāĻž āϝāĻžāϝāĻŧ āϝāĻž āĻ›āĻŋāϞ⧋ āĻ•āĻžāĻ¸ā§āϟāĻŽ āĻŸā§‡āĻŽāĻĒā§āϞ⧇āϟ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇āĨ¤ āĻ•āĻŋāĻ¨ā§āϤ⧁ āĻāĻ•āĻ¤ā§āϰ⧇ āϝāĻž āĻšāϝāĻŧ āĻĒāĻžāϤāĻžāϟāĻž āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄ āĻĒā§āϰ⧇āϏ⧇āϰ āĻĄāĻžāϟāĻžāĻŦ⧇āϜ āĻĨ⧇āϕ⧇ āφāϏ⧇, āĻŽāĻžāύ⧇ āĻĒāĻžāϤāĻžāϰ āĻ•āĻ¨ā§āĻŸā§‡āĻ¨ā§āϟāĨ¤ āĻ•āĻŋāĻ¨ā§āϤ⧁ āϝāĻĻāĻŋ āĻāĻŽāύ āϚāĻžāχ āϝ⧇ āĻāĻ•āϟāĻž āĻ¸ā§āĻŸā§āϝāĻžāϟāĻŋāĻ• āĻĒāĻžāϤāĻž āĻšāĻŦ⧇ āĻ•āĻŋāĻ¨ā§āϤ⧁ āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄ āĻĒā§āϰ⧇āϏ⧇āϰ āϭ⧇āϤāϰ⧇ āĻĨ⧇āϕ⧇ āĻāĻŦāĻ‚ āϐ āĻĒāĻžāϤāĻžāϝāĻŧ āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄ āĻĒā§āϰ⧇āϏ⧇āϰ āϝāĻžāĻŦāϤ⧀āϝāĻŧ āĻŸā§‡āĻŽāĻĒā§āϞ⧇āϟ āĻŸā§āϝāĻžāĻ— āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāĻž āϝāĻžāĻŦ⧇āĨ¤ āϧāϰ⧁āύ āφāĻĒāύāĻŋ āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄ āĻĒā§āϰ⧇āϏ āχāύāĻ¸ā§āϟāϞ⧇āĻļāύ⧇āϰ āϰ⧁āϟ āĻĄāĻŋāϰ⧇āĻ•ā§āϟāϰ⧀āϤ⧇ āĻāĻ•āϟāĻž āĻĢā§‹āĻ˛ā§āĻĄāĻžāϰ āĻŦāĻžāύāĻžāϞ⧇āύ āϝāĻžāϰ āύāĻžāĻŽ myfolder. āϤāĻžāĻšāϞ⧇ āĻāχ āĻĄāĻŋāϰ⧇āĻ•ā§āϟāϰ⧀āϰ āϞāĻŋāĻ™ā§āĻ• āĻšāĻŦ⧇ http://yoursite.com/myfolder āĻĻ⧇āϖ⧁āύ āĻāϟāĻž āĻ•āĻŋāĻ¨ā§āϤ⧁ āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄ āĻĒā§āϰ⧇āϏ⧇āϰ āĻĢā§‹āĻ˛ā§āĻĄāĻžāϰ āύāϝāĻŧāĨ¤
āĻāĻ–āύ āĻāχ āĻĢā§‹āĻ˛ā§āĻĄāĻžāϰ⧇ āĻāĻ•āϟāĻž php āĻĢāĻžāχāϞ⧇ āϤ⧈āϰāĻŋ āĻ•āϰ⧁āύāĨ¤ āϧāϰ⧁āύ myfile.phpāĨ¤
āĻĢāĻžāχāϞ⧇āϰ āĻļ⧁āϰ⧁āϤ⧇āχ āϞāĻŋāϖ⧁āύ āĻāχ āϰāĻ•āĻŽāσ

[code language=”php”]< ?php
define(‘WP_USE_THEMES’, false);
require( dirname(__FILE__) .’/../wp-blog-header.php’);
?>[/code]

āϝāĻĻāĻŋ myfile.php āĻāĻ•āĻĻāĻŽ āϰ⧁āĻŸā§‡ āϰāĻžāϖ⧇āύ āϤāĻžāĻšāϞ⧇

[code language=”php”]< ?php
define(‘WP_USE_THEMES’, false);
require( dirname(__FILE__) .’/wp-blog-header.php’);
?>[/code]

Continue reading

āĻ“ā§ŸāĻžāĻ°ā§āĻĄ āĻĒā§āϰ⧇āϏ āϟāĻŋāĻĒā§āϏ⧍

āĻ—āϤāĻ•āĻžāϞ āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄ āĻĒā§āϰ⧇āϏ āύāĻŋāϝāĻŧ⧇ āϞāĻŋāϖ⧇āĻ›āĻŋāϞāĻžāĻŽ āĻāχ āϟāĻĒāĻŋāϕ⧇ āĻāĻŦāĻ‚ āφāĻŽāĻžāϰ āĻŦā§āϞāϗ⧇ āĻāĻ–āĻžāύ⧇āĨ¤ āφāϜāϕ⧇ āφāĻŦāĻžāϰ āύāϤ⧁āύ āĻ•āĻŋāϛ⧁ āύāĻŋāϝāĻŧ⧇ āϞāĻŋāĻ–āĻŦā§‹ ,āϏāĻžāĻĨ⧇ āϏāĻžāĻĨ⧇ āĻ—āϤāĻ•āĻžāϞ⧇āϰ āϧāĻžāϰāĻŦāĻžāĻšāĻŋāĻ•āϤāĻž āϚāϞāĻŦ⧇āĨ¤ āφāĻŽāϰāĻž āĻāχ āϏāĻŋāϰāĻŋāĻœā§‡āϰ āĻŽā§‚āϞ āωāĻĻā§āĻĻ⧇āĻļā§āϝ āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄ āĻĒā§āϰ⧇āϏ⧇āϰ āύāϰāĻŽāĻžāϞ āχāωāϜāĻžāϰ āĻĨ⧇āϕ⧇ āĻļ⧁āϰ⧁ āĻ•āϰāĻž āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄ āĻĒā§āϰ⧇āϏ āĻŦ⧇āϏāĻĄ āĻ“āϝāĻŧ⧇āĻŦ āĻĄā§‡āϭ⧇āϞāĻĒāĻžāϰ āϏāĻŦāĻžāϰ āϜāĻ¨ā§āϝ āφāĻŽāĻžāϰ āϜāĻžāύāĻž āĻŸā§āϰāĻŋāĻ•ā§āϏ āĻ“ āϤāĻĨā§āϝāϗ⧁āϞ⧋ āĻļ⧇āϝāĻŧāĻžāϰ āĻ•āϰāĻžāσ
āϤāĻŋāύāσ ‘āĻĨā§€āĻŽā§‡ āϏāĻžāĻŦ āĻĨā§€āĻŽ āĻĢāĻžāχāϞ āϝ⧁āĻ•ā§āϤ āĻ•āϰāĻž’

āφāϗ⧇āϰ āĻĻāĻŋāύ āĻŦāϞ⧇āĻ›āĻŋāϞāĻžāĻŽ āĻ•āĻŋāĻ­āĻžāĻŦ⧇ āύāϤ⧁āύ āĻšā§‡āĻĄāĻžāϰ āĻĢāĻžāχāϞ āϝ⧁āĻ•ā§āϤ āĻ•āϰāĻž āϝāĻžāϝāĻŧāĨ¤ āϚāĻžāχāϞ⧇ āύāĻŋāĻšā§‡āϰ āĻŽāϤ⧋ āĻ•āϰ⧇āĻ“ āφāĻŽāϰāĻž āύāϤ⧁āύ āĻĢāĻžāχāϞ āĻĨā§€āĻŽā§‡āϰ āϝ⧇ āϕ⧋āύ āϜāĻžāϝāĻŧāĻ—āĻžāϝāĻŧ āϝ⧁āĻ•ā§āϤ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋāĨ¤ āĻ•āĻžāϰāĻŖ āĻāĻ•āχ āĻĢāĻžāχāϞ⧇ āĻ…āύ⧇āĻ• āĻ•āĻŋāϛ⧁ āϞāĻŋāĻ–āϞ⧇ āĻŸā§āϰāĻžāĻ• āϰāĻžāĻ–āĻž āϏāĻŽāĻ¸ā§āϝāĻž āĻšāϝāĻŧāĨ¤

[code language=”php”]< ?php include (TEMPLATEPATH . ‘/yourfilename.php’); ?>[/code]

yourfilename.php āύāĻžāĻŽā§‡āϰ āĻĢāĻžāχāϞāϟāĻŋ āφāĻĒāύāĻžāϰ āĻŦāĻ°ā§āϤāĻŽāĻžāύ āĻāĻ•ā§āϟāĻŋāĻ­ āĻŦāĻž āϝ⧇ āĻĨā§€āĻŽ āύāĻŋāϝāĻŧ⧇ āĻ•āĻžāϜ āĻ•āϰāϛ⧇āύ āϤāĻžāϰ āϭ⧇āϤāϰ āϰāĻžāϖ⧁āύāĨ¤ āφāϰ āĻ…āĻ¨ā§āϝ āĻĨā§€āĻŽ āĻĢāĻžāχāϞ⧇āϰ āϝ⧇āĻ–āĻžāύ⧇ āĻĻāϰāĻ•āĻžāϰ āϏ⧇āĻ–āĻžāύ⧇ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧁āύāĨ¤ TEMPLATEPATH āφāĻĒāύāĻžāϰ āĻŦāĻ°ā§āϤāĻŽāĻžāύ āĻĨā§€āĻŽā§‡āϰ āĻĄāĻŋāϰ⧇āĻ•ā§āϟāϰ⧀āĨ¤ āĻĒā§āϰāĻļā§āύ āĻ•āϰāϤ⧇ āĻĒāĻžāϰ⧇āύ āĻāĻŽāύ āĻāĻžāĻŽā§‡āϞāĻž āϕ⧇āύ āĻ•āϰāĻŦā§‹ āĻŦāĻž āĻāϟāĻžāϰ āϏ⧁āĻŦāĻŋāϧāĻž āĻ•āĻŋ āϤāĻžāχ āϤ⧋ ? āĻšā§āĻŽ… āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄ āĻĒā§āϰ⧇āϏ āĻĻāĻŋāϝāĻŧ⧇āχ āφāĻĒāύāĻŋ āϚāĻžāχāϞ⧇ āϜ⧁āĻŽāϞāĻžāϰ āĻŽāϤ⧋ āϏāĻžāχāĻŸā§‡ āĻŦāĻžāύāĻŋāϝāĻŧ⧇ āĻĢ⧇āϞāϤ⧇ āĻĒāĻžāϰ⧇āύāĨ¤ āϜ⧁āĻŽāϞāĻžāϤ⧇ āφāĻŽāϰāĻž āĻŽāĻĄā§āϞ āĻĒā§āϞ⧇āϏ āĻšāĻŋāϏāĻžāĻŦ⧇ āϝāĻž āĻŦāϞ⧇ āĻĨāĻžāĻ•āĻŋ āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄ āĻĒā§āϰ⧇āϏ⧇ āϤāĻžāϕ⧇ āĻŦāϞāĻž āĻšāϝāĻŧ āϏāĻžāχāĻĄāĻŦāĻžāϰ(sidebar) āφāϰ āĻŽāĻĄā§āϞ āϗ⧁āϞ⧋āϕ⧇ āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄ āĻĒā§āϰ⧇āϏ⧇āϰ āĻ­āĻžāώāĻžāϝāĻŧ(āĻŦāϞāĻž āϝ⧇āϤ⧇ āĻĒāĻžāϰ⧇) āωāχāĻœā§‡āϏ(widget). āφāĻĒāύāĻŋ āϚāĻžāχāϞ⧇ āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄ āĻĒā§āϰ⧇āϏ⧇ āϝāϤ āχāĻšā§āĻ›āĻž āϏāĻžāχāĻĄ āĻŦāĻžāϰ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāϤ⧇ āĻĒāĻžāϰ⧇āύ āϤāĻŦ⧇ āφāĻĒāύāĻžāϰ āĻĨā§€āĻŽā§‡ āϏ⧇āχ āϏāĻžāĻĒā§‹āĻ°ā§āϟ āĻĨāĻžāĻ•āϤ⧇ āĻšāĻŦ⧇āĨ¤ āĻāχ āĻŦāĻŋāώāϝāĻŧāϟāĻž āύāĻŋāϝāĻŧ⧇ āĻĒāϰ⧇āϰ āĻĒā§‹āĻ¸ā§āĻŸā§‡ āϞāĻŋāĻ–āĻŋ āϤāĻžāĻšāϞ⧇āĨ¤

āϚāĻžāϰāσ ‘āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄ āĻĒā§āϰ⧇āϏ⧇ āϝāϤ āχāĻšā§āĻ›āĻž āϏāĻžāχāĻĄ āĻŦāĻžāϰ āϝ⧁āĻ•ā§āϤ āĻ•āϰāĻž’

āĻĒā§āϰāĻĨāĻŽā§‡āχ āĻŦāϞ⧇ āϰāĻžāĻ–āĻŋ āύāϤ⧁āύ āĻ•āĻŋāϛ⧁ āϜāĻžāύāĻžāϰ āφāĻ—ā§āϰāĻš āύāĻž āĻĨāĻžāĻ•āϞ⧇ āĻŦāĻž āĻāĻ•ā§āϏāĻĒ⧇āϰāĻŋāĻŽā§‡āĻ¨ā§āϟ āĻ•āϰāĻžāϰ āχāĻšā§āĻ›āĻž āύāĻž āĻĨāĻžāĻ•āϞ⧇ āĻāĻ–āύāχ āĻŽāĻžāύ⧇ āĻŽāĻžāύ⧇ āϕ⧇āĻŸā§‡ āĻĒāĻĄāĻŧāϤ⧇ āĻĒāĻžāϰ⧇āύ āύāĻž āĻšāϞ⧇ āĻĒāϰ⧇ āĻĒāĻ¸ā§āϤāĻžāĻŦ⧇āύāĨ¤ :ttt:

‘āϤāĻŋāύ’ āύāĻ‚ āϟāĻŋāĻĒā§āϏ⧇āϰ āĻ•āĻŋāϛ⧁ āĻŦāϞāĻž āĻĻāϰāĻ•āĻžāϰāĨ¤ āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄāĻĒā§āϰ⧇āϏ⧇ āφāĻŽāϰāĻž āύāĻŋāĻšā§‡āϰ āϕ⧋āĻĄ āϟ⧁āϕ⧁ āĻĻāĻŋāϝāĻŧ⧇ āϏāĻžāχāĻĄāĻŦāĻžāϰ āĻĢāĻžāχāϞāϟāĻŋ āϞ⧋āĻĄ āĻ•āϰāĻŋāĨ¤

[code language=”php”]< ?php get_sidebar(); ?>[/code]

āĻāϟāĻž āϝāĻž āĻ•āϰ⧇ āϤāĻž āĻšāϞ⧋ āĻĨā§€āĻŽā§‡āϰ āϭ⧇āϤāϰ sidebar.php āĻĢāĻžāχāϞāϟāĻž include āĻ•āϰ⧇āĨ¤ āĻāĻ–āύ āϝāĻĻāĻŋ āφāĻĒāύāĻžāϰ āĻŦāĻŋāĻļ⧇āώ āĻĒāĻžāϤāĻžāϝāĻŧ āĻŦāĻŋāĻļ⧇āώ āϕ⧋āĻĄ āϞ⧇āĻ–āĻž āϏāĻžāχāĻĄ āĻŦāĻžāϰ āĻĻāϰāĻ•āĻžāϰ āĻšāϝāĻŧ āϤāĻžāĻšāϞ⧇ āĻ•āĻŋ āĻ•āϰāĻŦ⧇āύ āϏ⧇āϟāĻž āϝāĻĻāĻŋ āĻāĻ–āύāĻ“ āύāĻž āϭ⧇āĻŦ⧇ āĻĨāĻžāϕ⧇āύ āϤāĻžāĻšāϞ⧇ āφāĻĒāύāĻžāϰ āωāĻĒāϰ āφāĻŽāĻŋ āĻāĻ–āύāĻŋ āĻ•āĻŋāĻ¨ā§āϤ⧁ āϖ⧇āĻĒ⧇ āϗ⧇āĻ›āĻŋāĨ¤ >:D< āĻšā§āϝāĻžāρ āϏ⧇āχ āφāϗ⧇āϰ āĻŸā§āϰāĻŋāĻ•ā§āϏ āĻāĻ–āύ āϝ⧇ āϏāĻžāχāĻĄ āĻŦāĻžāϰ āĻĢāĻžāχāϞāϟāĻž āφāϛ⧇ āϏ⧇āϟāĻž āĻ•āĻĒāĻŋ āĻ•āϰ⧇ āύāϤ⧁āύ āĻĢāĻžāχāϞ⧇ āĻšāĻŋāϏāĻžāĻŦ⧇ āϏ⧇āχāĻ­ āĻ•āϰ⧁āύ āφāϰ āύāĻžāĻŽ āĻĻāĻŋāύ āφāϗ⧇āϰ āϏ⧇āχ āĻĢāϰāĻŽā§āϝāĻžāĻŸā§‡ āϝ⧇āĻŽāύ sidebar-mycustomsidebar.php āφāϰ āĻāχ āĻĢāĻžāχāϞ⧇ āύāĻŋāĻœā§‡āϰ āχāĻšā§āĻ›āĻž āĻŽāϤ⧋ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰ⧁āύāĨ¤ āφāϰ āĻāϟāĻž āϞ⧋āĻĄ āĻ•āϰ⧁āύ āĻāχ āĻ­āĻžāĻŦ⧇

[code language=”php”]<?php get_sidebar(‘mycustomsidebar’); ?>[/code]

āĨ¤ āĻŽāϜāĻž ?

Continue reading

āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄ āĻĒā§āϰ⧇āϏ āϟāĻŋāĻĒā§āϏ-ā§§

“āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄ āĻĒā§āϰ⧇āϏ āϟāĻŋāĻĒā§āϏ” āĻ āϧāĻžāϰāĻžāĻŦāĻžāĻšāĻŋāĻ• āĻ­āĻžāĻŦ⧇ āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄ āĻĒā§āϰ⧇āϏ āĻŦāĻŋāώāϝāĻŧāĻ• āϛ⧋āϟ āϛ⧋āϟ āϤāĻĨā§āϝ āĻĻ⧇āĻ“āϝāĻŧāĻžāϰ āĻšā§‡āĻ¸ā§āϟāĻž āĻ•āϰāĻŦā§‹āĨ¤
āύ⧋āϟāσ āĻ•āĻŋāϛ⧁ āĻ•āĻŋāϛ⧁ āϟāĻŋāĻĒā§āϏ āĻāĻĄāĻ­āĻžāĻ¨ā§āϏāĻĄ āϞ⧇āϭ⧇āϞ⧇āϰ āĻšāϤ⧇ āĻĒāĻžāϰ⧇ āϝāĻž āĻĒā§āϰāĻĢ⧇āĻļāύāĻžāϞ āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄ āĻĒā§āϰ⧇āϏ āĻŦ⧇āϏāĻĄ āĻ“āϝāĻŧ⧇āĻŦ āĻĄā§‡āϭ⧇āϞāĻĒāĻžāϰāĻĻ⧇āϰ āϜāĻ¨ā§āϝ āĻ•āĻžāĻœā§‡ āĻĻāĻŋāĻŦ⧇ āφāĻļāĻž āĻ•āϰāĻŋāĨ¤

āĻāĻ•āσ āĻ•āĻžāĻ¸ā§āϟāĻŽ āĻšā§‡āĻĄāĻžāϰ āĻĢāĻžāχāϞ āĻŦāĻž header.php āĻĢāĻžāχāϞ āϕ⧋āύ āĻĒāĻžāϤāĻžāϝāĻŧ āϝ⧁āĻ•ā§āϤ āĻ•āϰāĻžāσ
āϏāĻžāϧāĻžāϰāĻŖāϤ āφāĻŽāϰāĻž āĻāĻŽāύ āĻ­āĻžāĻŦ⧇ āĻĨā§€āĻŽ āĻŦāĻžāύāĻžāϝāĻŧ āϝ⧇ āϏāĻžāχāϟ āϝ⧇āύ āĻšā§‡āĻĄāĻžāϰ, āĻŦāĻĄāĻŋ, āĻĢ⧁āϟāĻžāϰ āĻāχ āĻ­āĻžāĻŦ⧇ āĻĨāĻžāϕ⧇āĨ¤ āφāϰ āĻāχ āϚāĻŋāĻ¨ā§āϤāĻž āĻĨ⧇āϕ⧇āχ āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄ āĻĒā§āϰ⧇āϏ āĻĨā§€āĻŽ āĻāϰ āϕ⧋āϰ āĻĢāĻžāχāϞ āĻšāĻŋāϏāĻžāĻŦ⧇ header.php , footer.php āĻĢāĻžāχāϞ āĻĻ⧁āχāϟāĻž āĻĨāĻžāϕ⧇āĨ¤ āφāϰ header.php āĻĢāĻžāχāϞ āϝ⧁āĻ•ā§āϤ āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ index.php, category.php āχāĻ¤ā§āϝāĻžāĻĻāĻŋ āĻĢāĻžāχāϞ⧇ āφāĻŽāϰāĻž āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄ āĻĒā§āϰ⧇āϏ⧇āϰ āĻāĻ•āϟāĻž āĻŸā§‡āĻŽāĻĒā§āϞ⧇āϟ āĻĢāĻžāĻ‚āĻļāύ āϞāĻŋāĻ–āĻŋāσ

[code language=”php”]< ?php get_header(); ?>[/code]

āϝāĻž header.php āĻĢāĻžāχāϞāϟāĻž āϞ⧋āĻĄ āĻ•āϰ⧇
āĻāĻŦāĻ‚ āĻāĻ•āχ āĻ­āĻžāĻŦ⧇ footer.php āĻĢāĻžāχāϞ⧇ āϝ⧁āĻ•ā§āϤ āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ āϞāĻŋāĻ–āĻŋ āĻāχ āϰāĻ•āĻŽāσ Continue reading

Adding no follow for links in wp comments

Don't Follow MeOne of my senior brother just asked me, how to add no follow rel for comments in wordpress. May be there is plugin for this. Look to my code 🙂
How to use:
1.Open the functions.php file in ur current theme and put these code within php tags.

What it will do:
1. Will add ‘no follow’ as rel in url , if comment contains any url.
2. Will ad ‘external’ as rel in url , if comment contains any url.
3. Will add target=”_blank” in comment author’s url so that their web url open’s in new window/new tab as in browser settings
4. Will add target=”_blank” to url, if comment contains any url
5. Wp adds ‘no follow’, ‘external’ rel in comment author’s url by default. So we don’t need to add this 😛

Tips:
1.If possible upgrade to wp2.8.2

[code language=”php”]
function nofollow($text) {
$text = preg_replace(‘/<a /i’,'<a rel="nofollow external" ‘,$text);
$text = preg_replace(‘/<a /i’,'<a target="_blank" ‘,$text);
return $text;
}
function targetblank($text){
$text = preg_replace(‘/<a /i’,'<a target="_blank" ‘,$text);
return $text;
}

add_filter(‘comment_text’, ‘nofollow’);
add_filter(‘get_comment_author_link’,’targetblank’);
[/code]

any question ask me 🙂
p.s.: post image is just for fun 😛

BTW, are you afraid of editing your functions.php ? Ok, no problem you can add the above piece of code using the bellow wp plugin.
[download id=”9″]

Duh, you are totally unhappy with this post, na ? You can to treat your commentors with “cake and cook”, ok no problem.Just forget my post and read this blog post …“The Single, Most Profound Way To Thank Your Commenters”.
Happy now ?

Tinybn for wordpress

Yah, I know my developed tinybn (an ekushey project ,  tinymce plugin to write bangla in tinymce editor) has so many bugs and even I will recommend not to use in any live :P. But we are crazy to write bangla in web in any condition… heh heh.. hmm I didn’t get time to update the scripts. Though updated them to make compatible for tinymce3.x. Yes, I am so lazy …I didn’t udpate the lastest version in ekushey 🙁

Even I made a plugin for wordpress to use this plugin in wordpress editor in Visual mode (that means tinymce is enabled :D).hmm I didn’t release this too. Let me release this for every body. Please keep this mind that it has bugs, yes it has so many bugs but I will be happy if ppl use this and give me feedback so that I can update this when I am free.

Let me show how the tinybn plugin in wordpress will show [ Screenshot taken from my blog,wp2.8.2]
wptinybn

How to use:
1. Download the zip given here for download and then unzip.
2. Copy the folder wp_tinybn_fixed to your wodpress plugin dir.
3.Activate the plugin
4. Try to write any new post/page in visual mode
Licence: GPL2
Download:
[download id=”8″]

Any kind of negative and positive comment/feedback is welcome 🙂

update:
version 2.1 released
1. Fixed bug for js if the language mode is in bangla :P. That was my mistake to migrate the plugin from tinymce2.x compatible to 3.x. I forgot to change the language file setting for bangla language and I didn’t use this plugin while bangla is active in backend :(. Oh I have to fix same thing for jce version of tinybn.
2. Special thank to Hasan

How to use timthumb in WP MU

I think to show the first image as thumb in wp front page or blog layout is very common for any theme. But to use it in wordpress mu version is not direct or need to do some hack or modify the normall process of adding timthub. Normally we upload images from wp media manager and use those in posts. In normal wordpress the upload dir is wp-content/uploads and files and images are uploaded to that directory. In wordpress mu version files are uploaded by user basis folder and for this wp-content/blogs.dir/userid is the uploaded dir for any image. here user id is named as folder name for each user. then wp-content/blogs.dir/userid/files. But when u browse the site the image link format is like http://yoursitename/files/year/month/image name but format is reshaped by the wp mu htacces which real physical path is like wp-content/blogs.dir/userid/files/year/month/image name.
Continue reading

How to make menu like news.bbc.co.uk

bbcNow a days I am a great fan of wordpress. Recently I have done some projects on wordpress and getting expert day by day 😛 heh heh.

This post about how can we make menu in wordpress like news.bbc.co.uk. Now a days some clients want clone sites. They don’t think about all the functionality but the look and feel clone 🙂 .
So to clone the menu like news.bbc.co.uk we what we need:
1. wp function wp_list_categories(args)
2. CSS to give look and feel like news.bbc.co.uk

Before we start let’s check what we are going to do:
here is the image that we are going to make or the menu that we are doing to make using wp_list_categories function and css. Look this menu is 2 level deep. To keep the theme clean u can make a function in functions.php file like bellow and just call the function in theme where u want to place the menu.
Look here we are using echo= 0 as want to just return the output from this function. and depth =2 as we want to make two level hirarachyâ€Ļ check others params that I have used. To know details about the template tag wp_list_categories pls check this page in wp codex.

Now what we need is to apply the css to style the menu like news.bbc.co.ukâ€Ļ one thing to keep in mind. When u will browse through the category I mean u click the any category from the menu and posts will be shown using category.php template then active category will get an extra class automatic which is helpfull to highlight using css but if u browse any single.
[code=’php’]function get_leftcatmenu(){
$excludecats = array();
$excludecats = array(1,2,3); //categories to exlclude
//or
//$includecats = array ();
//$includecats = array(1,2,3); //categories to include

/*
// same thing can be done using a simple plugin and saving the categories in option table , bellow code is for comma seperated cat list
$excludecats = explode(‘,’, get_option(‘bbcnews_leftmenucid’));
$excludecats = implode( “,”,$excludecats);
*/
/*
$includecats = explode(‘,’, get_option(‘bbcnews_leftmenuscid’));
$includecats = implode( “,”,$seccats);

//sample code to exclude
return wp_list_categories(‘orderby=name&amp;amp;style=list&amp;amp;hide_empty=0&amp;amp;show_count=0&amp;amp;title_li=&amp;amp;exclude=’.$excludecats.’&amp;amp;hierarchical=true&amp;amp;depth=2&amp;amp;echo=0′);

// sample code to inlclude
return wp_list_categories(‘orderby=id&amp;amp;style=list&amp;amp;hide_empty=0&amp;amp;show_count=0&amp;amp;title_li=&amp;amp;include=’.$includecats.’&amp;amp;hierarchical=true&amp;amp;depth=2&amp;amp;echo=0′);
*/
}
[/code]
post we need the hightlight the category in the menu to which the single post belongs to. But to make this happen that adding an extra class to the menu to make active while browsing any single posts I have used a plugin 🙂 named “Show Active Category (while browsing a post)“. Note if any post belongs to more one category then it will add extra active class to each category.

Uffâ€Ļ.now check the css code that I used:
Note: this css code works fine in ff3 and ie6 and I have no interest with other browser at this moment.
Code to use in theme:
[code=’php’]

  • home”>

is_home-is_single-is_category-is-not-working-in-wp!

If u are reached here using search engine then I am sure that you are just fucked up 🙁 .. is_home(), is_single(), is_category() are not workingâ€Ļspecially in footer and other places. I faced the same problem. While working with a wordpress theme, this functions were working fine in footer but once I noticed that they are not working as they should be !â€Ļ.

Let me explain why and how this problem occurs and what’s the solution :

I think if u are familiar with the famus LOOP in wordpress. The following is_home(), is_single(), is_category() functions depends on the loop. ACtually when u visit the home page then header.php, index.php, sidebar.php and footer.php files are executed and in the same way when u visit a single post then normally header.php, single.php, sidebar.php and footer.php files are executed. Actually some global page specific query is done for single.php, index.php etc. is_home(), is_single(), is_category() they will work fine if u use the default theme and don’t add any custom query !

Let’s check the code for is_home() function â€Ļ
[code=’php’]/**
* Whether current page view is the blog homepage.
*
* @since 1.5.0
* @uses $wp_query
*
* @return bool True if blog view homepage.
*/
function is_home () {
global $wp_query;
return $wp_query->is_home;
}
[/code]
Ok, for custom query maximum time I use this function get_posts. But to get more control I used query_posts. They are same and share some common arguments but query_posts gives more controls and more arguments to pass to get the exact query. Now Let’s check the code for query_posts() function

[code=’php’]/**
* Setup the Loop based on the query variables.
*
* @uses WP::$query_vars
* @since 2.0.0
*/
function query_posts() {
global $wp_the_query;
$this->build_query_string();
$wp_the_query->query($this->query_vars);
}
[/code]

and code for get_posts

[code=’php’]/**
* Retrieve list of latest posts or posts matching criteria.
*
* The defaults are as follows:
* ‘numberposts’ – Default is 5. Total number of posts to retrieve.
* ‘offset’ – Default is 0. See {@link WP_Query::query()} for more.
* ‘category’ – What category to pull the posts from.
* ‘orderby’ – Default is ‘post_date’. How to order the posts.
* ‘order’ – Default is ‘DESC’. The order to retrieve the posts.
* ‘include’ – See {@link WP_Query::query()} for more.
* ‘exclude’ – See {@link WP_Query::query()} for more.
* ‘meta_key’ – See {@link WP_Query::query()} for more.
* ‘meta_value’ – See {@link WP_Query::query()} for more.
* ‘post_type’ – Default is ‘post’. Can be ‘page’, or ‘attachment’ to name a few.
* ‘post_parent’ – The parent of the post or post type.
* ‘post_status’ – Default is ‘published’. Post status to retrieve.
*
* @since 1.2.0
* @uses $wpdb
* @uses WP_Query::query() See for more default arguments and information.
* @link http://codex.wordpress.org/Template_Tags/get_posts
*
* @param array $args Optional. Override defaults.
* @return array List of posts.
*/
function get_posts($args = null) {
$defaults = array(
‘numberposts’ => 5, ‘offset’ => 0,
‘category’ => 0, ‘orderby’ => ‘post_date’,
‘order’ => ‘DESC’, ‘include’ => ”,
‘exclude’ => ”, ‘meta_key’ => ”,
‘meta_value’ =>”, ‘post_type’ => ‘post’,
‘suppress_filters’ => true
);

$r = wp_parse_args( $args, $defaults );
if ( empty( $r[‘post_status’] ) )
$r[‘post_status’] = ( ‘attachment’ == $r[‘post_type’] ) ? ‘inherit’ : ‘publish’;
if ( ! empty($r[‘numberposts’]) )
$r[‘posts_per_page’] = $r[‘numberposts’];
if ( ! empty($r[‘category’]) )
$r[‘cat’] = $r[‘category’];
if ( ! empty($r[‘include’]) ) {
$incposts = preg_split(‘/[\s,]+/’,$r[‘include’]);
$r[‘posts_per_page’] = count($incposts); // only the number of posts included
$r[‘post__in’] = $incposts;
} elseif ( ! empty($r[‘exclude’]) )
$r[‘post__not_in’] = preg_split(‘/[\s,]+/’,$r[‘exclude’]);

$r[‘caller_get_posts’] = true;

$get_posts = new WP_Query;
return $get_posts->query($r);

}
[/code]

get_posts will not make any problem for is_single(), is_home(), is_category() etc functions.

Solution: To avoid this problem you can use this trick:

[code=’php’]$query_backup = clone($GLOBALS[‘wp_query’]); //keep backup
……
query_posts(…..)

$GLOBALS[‘wp_query’] = $query_backup; //restore from backup
[/code]

Further info: Please keep in mind that the php function clone() will not work in php4, it’s just for php5 becuase Php5 handles objects in different way. Like in php5 you can copy a object in this way
$new_object = clone ($old_object);
here $new_object will not copy the object actually though it will just point to $old_object but in php4 the thing is just copy like bellow.
$new_object = $old_object;

You can check this link for better explanation.

Sometimes pain gives us a way to think 😛

thanks

āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄ āĻĒā§āϰ⧇āϏ⧇āϰ āĻĨā§€āĻŽ āĻ•āĻŋāĻ­āĻžāĻŦ⧇ āĻ•āĻžāϜ āĻ•āϰ⧇-āĻĒāĻ°ā§āĻŦ-ā§§

[āϝāĻĻāĻŋ āφāĻĒāύāĻžāϰ āύāϰāĻŽāĻžāϞ āĻāχāϟāĻŋāĻāĻŽāĻāϞ āĻāĻŦāĻ‚ āĻāĻ•āĻĻāĻŽ āĻŦ⧇āϏāĻŋāĻ• āĻĒāĻŋāĻāχāϚāĻĒāĻŋ āĻœā§āĻžāĻžāύ āύāĻž āĻĨāĻžāϕ⧇ āϤāĻžāĻšāϞ⧇ āĻāχ āĻĒā§‹āĻ¸ā§āĻŸā§‡āϰ āĻ•āĻŋāϛ⧁ āĻŦāĻŋāώāϝāĻŧ āϜāϟāĻŋāϞ āĻŽāύ⧇ āĻšāϤ⧇ āĻĒāĻžāϰ⧇ ]
āĻ…āύ⧇āϕ⧇āχ āĻŦā§āϝāĻ•ā§āϤāĻŋāĻ—āϤ āĻšā§‹āĻ¸ā§āϟāĻŋāĻ‚ āĻ āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄ āĻĒā§āϰ⧇āϏ āχāύāĻ¸ā§āϟāϞ āĻ•āϰ⧇ āĻŦā§āϞāĻ—āĻŋāĻ‚ āĻ•āϰāϛ⧇āύ āĻāĻŦāĻ‚ āĻĒāĻ›āĻ¨ā§āĻĻ⧇āϰ āϕ⧋āύ āĻĢā§āϰāĻŋ āĻĨā§€āĻŽ āχāύāĻ¸ā§āϟāϞ āĻ•āϰ⧇ āĻĻāĻŋāĻŦā§āϝāĻŋ āϏ⧁āĻ¨ā§āĻĻāϰ āĻŦā§āϝāĻ•ā§āϤāĻŋāĻ—āϤ āĻŦā§āϞāĻ— āĻŦāĻžāύāĻŋāϝāĻŧ⧇ āύāĻŋāĻšā§āϛ⧇āύāĨ¤ āϝāĻĻāĻŋ āĻāĻŽāύ āĻšāϝāĻŧ āĻāχ āĻĨā§€āĻŽ āĻ•āĻŋāĻ­āĻžāĻŦ⧇ āĻ•āĻžāϜ āĻ•āϰ⧇ āϤāĻž āϝāĻĻāĻŋ āϜāĻžāύāĻž āĻĨāĻžāϕ⧇ āϤāĻžāĻšāϞ⧇ āφāϰ⧋ āĻŽāϜāĻž āύāĻž ? āχāĻšā§āĻ›āĻž āĻšāϞ⧋ āĻāĻ•āϟ⧁ āϏāĻŽā§āĻĒāĻžāĻĻāύāĻž āĻ•āϰ⧇ āĻĨā§€āĻŽāϟāĻžāϕ⧇ āύāĻŋāĻœā§‡āϰ āĻŽāϤ⧋ āϏāĻžāϜāĻŋāϝāĻŧ⧇ āύāĻŋāϞ⧇āύāĨ¤ āφāĻŽāĻžāϰ āĻŦāĻ•āĻŦāĻ• āĻļ⧁āϰ⧁āϰ āφāϗ⧇ āφāϏ⧁āύ āĻœā§‡āύ⧇ āύ⧇āχ āĻāχ āĻĒā§‹āĻ¸ā§āĻŸā§‡āϰ āωāĻĻā§āĻĻ⧇āĻļā§āϝāϗ⧁āϞ⧋āσ

āĻāĻ•āσ āĻ“āϝāĻŧāĻžāĻ°ā§āĻĄ āĻĒā§āϰ⧇āϏ⧇āϰ āĻĨā§€āĻŽ āĻ•āĻŋāĻ­āĻžāĻŦ⧇ āĻ•āĻžāϜ āĻ•āϰ⧇
āĻĻ⧁āχāσ āĻĨā§€āĻŽ āĻĢā§‹āĻ˛ā§āĻĄāĻžāϰ⧇āϰ āϕ⧋āύ āĻĢāĻžāχāϞ⧇āϰ āĻ•āĻžāϜ āĻ•āĻŋ
āϤāĻŋāύāσ āĻĨā§€āĻŽ āϏāĻŽā§āĻĒāĻžāĻĻāύāĻž āĻ•āϰāĻž
āϚāĻžāϰāσ āχāĻ¤ā§āϝāĻžāĻĻāĻŋ :ttt:
Continue reading