How to Insert custom Quicktags into the WordPress Editor

WordPress has two type of editor, one is visual/wysiwyw that is tinymce or replace with other such editors and another is HTML editor that is we call quick tag editor. Today, I want to write something about how to add custom quick tags or custom buttons. I search about it in google and most guides to edit core quick tag javascript file. But I don’t like that and I made my own hack in my own way, though experts may think it’s childish 😛

So let come to point, I wanted to add some buttons that will give me option to add custom class name so that I can format the text well. Same thing can be done via Visual editor but you have to use a plugin named “Tinymce Advanced” which helps to add more advance buttons like styles(class lists) and so on. But for HTML mode or for quick tags editor I didn’t such plugins.
Continue reading

Adding My posts sub menu for posts section in wordpress

Let me explain the situation. Suppose you have contributor access to wordpress. If you go to posts page in admin panel that list all posts   and here you are not author of all posts.  you will see the url like
[code language=”php”]edit.php?post_type=post&all_posts=1[/code] and All( total post number here). There will be another menu named Mine(Current user post number). All link is default. So we can make nother submenu of posts in admin section for Mine link directly. Let me show you the few lines code.
[code language=”php”]add_action(‘admin_menu’, ‘manchu_myposts’);
function manchu_myposts()
{
if (function_exists(‘add_submenu_page’))
{
//$parent, $page_title, $menu_title, $access_level, $file, $function = ”
add_submenu_page(‘edit.php’,’My Posts’,’My posts’, 1, ‘edit.php?post_type=post&author=’.get_current_user_id());
}
}[/code]
You can copy-paste above code in your theme functions.php file and it will show a new sub menu in posts ectin as My posts. Multi user blog users can get easily link for his/her posts.
myposts
it’s just a easy way to make personal posts link for any user have access at leas contributor. Access level 1 belongs to contributor..

Update: 15-09-2011

While working on a project I got a tips from stackoverflow wordpress site about showing only specific author’s posts in author mode.
[code language=”php”]
function cb_posts_for_current_author($query) {
global $pagenow;

if( ‘edit.php’ != $pagenow || !$query->is_admin )
return $query;

if( !current_user_can( ‘manage_options’ ) ) {
global $user_ID;
$query->set(‘author’, $user_ID );
}
return $query;
}
add_filter(‘pre_get_posts’, ‘cb_posts_for_current_author’);
[/code]

thank you

Stuck in wordpress Maintenance Mode?

Are you Stuck in wordpress Maintenance Mode?  I was in that situation and thought to write about my pain and findings so that it may be help to reduce pain in the ass when u are crazy to do some upgrade for plugins and themes and you are stuck  in maintenance mode for “something wrong” in upgrade/upadte process .

This tip is for wordpress3.0+, don’t  know what to do for lower version.  The thing is when wordpress takes the site maintenace mode it creates a file in the site root dir named .maintenance  and when done remove that… 🙂

So, now you know what to do if u are stuck in maintenance mode. I wish I am going to sleep well tonight.

note: check the dicussion in wordpress forum about this issue.

btw, let me show you a sample screenshot about how the error msg look for upgrade failure

failure

āϜ⧁āĻŽāϞāĻžāϤ⧇ āύ⧇āϟāĻŋāĻ­ āϟ⧁āϞāϟāĻŋāĻĒ āĻāϰ āĻŦā§āϝāĻŦāĻšāĻžāϰ

Hei! it’s bengali unicode text, This post is wrriten for amaderprojukti forum.
āĻ…āύ⧇āĻ• āĻĻāĻŋāύ āĻŦāĻžāĻ‚āϞāĻžāϝāĻŧ āĻŦā§āϞāĻ— āĻŦāĻž āϟāĻŋāĻĒā§āϏ āĻ•āĻŋāϛ⧁ āϞ⧇āĻ–āĻž āĻšāϝāĻŧ āύāĻžāĨ¤ āφāϜāϕ⧇āϰ āĻŦāĻŋāώāϝāĻŧ āφāĻŽāĻžāϰ āĻ…āύ⧇āĻ• āϗ⧁āϞ⧋ āĻ—āĻžāĻ°ā§āϞāĻĢā§āϰ⧇āĻ¨ā§āĻĄ āĻāϰ āϭ⧇āϤāϰ āĻ…āĻ¨ā§āϝāϤāĻŽ “āϜ⧁āĻŽāϞāĻž”āĨ¤ āϝāĻĻāĻŋāĻ“ āφāϜāϕ⧇āϰ āϞ⧇āĻ–āĻžāϟāĻž āϜ⧁āĻŽāϞāĻžāϰ āĻāĻ•āϟāĻŋ āĻ—ā§‹āĻĒāύ āϏ⧁āĻ¨ā§āĻĻāϰ āĻĻāĻŋāĻ• āύāĻŋāϝāĻŧ⧇ āφāϰ āϤāĻž āĻšāϞ⧋ āϜ⧁āĻŽāϞāĻž ā§§.ā§Ģ āĻāϰ āύ⧇āϟāĻŋāĻ­ āϟ⧁āϞāϟāĻŋāĻĒāĨ¤
āĻĒā§āϰāĻĨāĻŽ āĻāĻ•āϟāĻŋ āĻ›āĻŦāĻŋ āĻĻ⧇āĻ–āĻžāϝāĻŧāσ
tooltip
āĻāĻĄāĻŽāĻŋāύ āĻĒā§āϝāĻžāύ⧇āϞ⧇ āϕ⧋āύ āĻ•āĻŋāϛ⧁ āĻ•āύāĻĢāĻŋāĻ—āĻžāϰ⧇āĻļāύ⧇ āĻĸ⧁āĻ•āϞ⧇ āĻŦāĻž āĻ…āύ⧇āĻ• āϏāĻŽāϝāĻŧ āϕ⧋āύ āϞāĻŋāĻ™ā§āĻ•āĻ āĻŽāĻžāωāϏ āĻšā§‹āĻ­āĻžāϰ āĻ•āϰāϞ⧇ āωāĻĒāϰ⧇āϰ āĻŽāϤ⧋ āϟ⧁āϞāϟāĻŋāĻĒ āĻĻ⧇āĻ–āĻžāϝāĻŧāĨ¤ āĻāĻ•āχ āϰāĻ•āĻŽ āϟ⧁āĻĒāϟāĻŋāĻĒ āϚāĻžāχāϞ⧇ āφāĻŽāϰāĻž āĻĢā§āϰāĻ¨ā§āϟ āĻāĻ¨ā§āĻĄ āĻ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŋ āφāϰ āϤāĻžāϰ āϜāĻ¨ā§āϝ āĻāĻ•ā§āϟāĻŋāĻ­ āĻŸā§‡āĻŽāĻĒā§āϞ⧇āĻŸā§‡ āĻĻāϰāĻ•āĻžāϰ āϏāĻžāĻŽāĻžāĻ¨ā§āϝ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ, āϏ⧇āχ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āĻŋāĻ­āĻžāĻŦ⧇ āĻ•āϰāĻž āϝāĻžāϝāĻŧ āϤāĻž āύāĻŋāϝāĻŧ⧇āχ āφāϜāϕ⧇āϰ āφāϞ⧋āϚāύāĻžāĨ¤ āĻĒāϰ⧇āϰ āĻ›āĻŦāĻŋāϟāĻŋ āĻĢā§āϰāĻ¨ā§āϟ āĻāĻ¨ā§āĻĄ āĻāϰāĨ¤
tootip

āĻ•āĻŋāĻ­āĻžāĻŦ⧇ āĻĢā§āϰāĻ¨ā§āϟ āĻāĻ¨ā§āĻĄā§‡ āϟ⧁āϞāϟāĻŋāĻĒ āĻĢāĻŋāϚāĻžāϰ āϝ⧁āĻ•ā§āϤ āĻ•āϰāĻŦ⧇āύāσ
āϟ⧁āϞāϟāĻŋāĻĒ āĻĢāĻŋāϚāĻžāϰ āϝ⧁āĻ•ā§āϤ āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ āφāĻĒāύāĻžāϕ⧇ āĻĒā§āϰāĻĨāĻŽ āĻŸā§‡āĻŽāĻĒā§āϞ⧇āĻŸā§‡āϰ āχāĻ¨ā§āĻĄā§‡āĻ•ā§āϏ āĻĢāĻžāχāϞ(index.php) āĻ āĻāĻ•āϟāĻŋ āϞāĻžāχāύ āϝ⧁āĻ•ā§āϤ āĻ•āϰāϤ⧇ āĻšāĻŦ⧇āĨ¤ āϝāĻĻāĻŋ āφāĻĒāύāĻŋ āĻĄāĻŋāĻĢāĻ˛ā§āϟ āĻŸā§‡āĻŽāĻĒā§āϞ⧇āϟ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇āύ āϤāĻžāĻšāϞ⧇ rhuk_milkyway āĻšāĻšā§āϛ⧇ āφāĻĒāύāĻžāϰ āĻŸā§‡āĻŽāĻĒā§āϞ⧇āϟ āĻāϰ āύāĻžāĻŽ, āĻāϰ āϭ⧇āϤāϰ index.php āĻĢāĻžāχāϞāϟāĻŋ āĻ“āĻĒ⧇āύ āĻ•āϰ⧁āύ āϕ⧋āύ āĻāĻĄāĻŋāϟāϰ⧇, āĻāĻ–āύ āĻšā§‡āĻĄ āĻŸā§āϝāĻžāĻ—() āĻāϰ āφāϗ⧇

Continue reading

Fix wp plugin “Post and Page Excerpt Widgets” not to break conditional tag

Post and Page Excerpt Widgets is a nice plugin to show post/page excerpt as as widget in sidebar position. You can download it from wp code from here. One I thing I noticed about this plugin is it has a common bug that I faced many times while using query_posts. When I use this query_posts it’s break some conditional loop like is_home(), is_category() etc but there is another function get_posts in wordpress that does the same thing but don’t have similar problem. Once I discussed about this problem in one of my old posts. Please check that posts for better sense from here is_home-is_single-is_category-is-not-working-in-wp!.

Let me focus to this writing again 😀
As Post and Page Excerpt Widgets is using the query_posts function for custom query it make’s problem for conditional tags. Let me show u solution and it’s like my that posts.
In you theme functions.php add a new function if not exists yet

Continue reading

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

āϜ⧁āĻŽāϞāĻžāϰ āĻĄāĻŋāĻĢāĻ˛ā§āϟ āĻŸā§‡āĻŽāĻĒā§āϞ⧇āĻŸā§‡ āĻĒ⧇āϜāĻŋāύ⧇āĻļāύ⧇ āĻĄāĻŋāϜāĻŋāϟ āĻ•āĻŋāĻ­āĻžāĻŦ⧇ āĻŦāĻžāĻ‚āϞāĻž āĻ•āϰāĻŦ⧇āύ ?

āφāĻŽāĻŋ āĻŦā§āϝāĻ•ā§āϤāĻŋāĻ—āϤ āĻ­āĻžāĻŦ⧇ āϝāĻž āĻ•āϰāĻŋ āϝāĻ–āύ āϜ⧁āĻŽāϞāĻžāϰ āϜāĻ¨ā§āϝ āϕ⧋āύ āύāϤ⧁āύ āĻŸā§‡āĻŽāĻĒā§āϞ⧇āϟ āĻŦāĻžāύāĻžā§Ÿ āϤāĻ–āύ āĻĄāĻŋāĻĢāĻ˛ā§āϟ āĻŸā§‡āĻŽāĻĒā§āϞ⧇āϟ rhuk_milkyway āĻ•āĻĒāĻŋ āĻ•āϰ⧇ āύāϤ⧁āύ āύāĻžāĻŽ āĻĻāĻŋā§Ÿā§‡ āĻ…āĻĒā§āĻ°ā§Ÿā§‹āϜāĻ¨ā§€ā§Ÿ āĻ›āĻŦāĻŋ, āϏāĻŋāĻāϏāĻāϏ āϕ⧋āĻĄ āχāĻ¤ā§āϝāĻžāĻĻāĻŋ āϏāĻŦ āĻŽā§āϛ⧇ āĻĢ⧇āϞāĻŋāĨ¤ āĻāϰāĻĒāϰ āύāĻŋāĻœā§‡āϰ āĻŽāϤ⧋ āĻ•āϰ⧇ āϕ⧋āĻĄ āĻ•āϰāĻŋ āϏāĻŦ āĻ•āĻŋāϛ⧁āĨ¤ āĻāĻ•āĻĨāĻž āĻŦāϞāĻžāϰ āĻ•āĻžāϰāĻŖ āĻāχāϟāĻž āϝ⧇ āφāĻŽāϰāĻž āϝāĻĻāĻŋ āĻĄāĻŋāĻĢāĻ˛ā§āϟ āĻŸā§‡āĻŽāĻĒā§āϞ⧇āϟ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāĻŋ āϤāĻžāĻšāϞ⧇ āĻāĻ•āϟāĻž āĻĢāĻžāχāϞ⧇ āϏāĻžāĻŽāĻžāĻ¨ā§āϝ āĻ•āĻŋāϛ⧁ āϕ⧋āĻĄ āϝ⧁āĻ•ā§āϤ āĻ•āϰ⧇āχ āĻĒ⧇āϜāĻŋāύ⧇āĻļāύ⧇āϰ āĻĄāĻŋāϜāĻŋāϟāϗ⧁āϞ⧋ āĻŦāĻžāĻ‚āϞāĻž āĻ•āϰ⧇ āĻĢ⧇āϞāϤ⧇ āĻĒāĻžāϰāĻŋāĨ¤

āĻāĻ–āύ āĻĻ⧇āĻ–āĻŋ āĻ•āĻŋ āĻ•āϰ⧇ āĻ•āϰāĻž āϝāĻžā§ŸāĨ¤ āϝāĻĻāĻŋ āĻ­āĻžāϞ⧋ āĻ•āϰ⧇ āĻ–ā§‡ā§ŸāĻžāϞ āĻ•āϰ⧇āύ āϤāĻžāĻšāϞ⧇ āύāĻŋāĻļā§āϚ⧟ templates\rhuk_milkyway\html āĻāχ āĻĄāĻŋāϰ⧇āĻ•ā§āϟāϰ⧀āϤ⧇ pagination.php āύāĻžāĻŽā§‡ āĻāĻ•āϟāĻž āĻĢāĻžāχāϞ āφāϛ⧇āĨ¤ āĻāχ āĻĢāĻžāχāϞāϟāĻž āĻĒā§āϰāĻĨāĻŽā§‡ utf-8 āĻšāĻŋāϏāĻžāĻŦ⧇ āϏāĻ‚āϰāĻ•ā§āώāĻŖ(save) āĻ•āϰ⧁āύāĨ¤ āĻāϰāĻĒāϰ
āĻĢāĻžāχāϞ⧇āϰ āĻāĻ•āĻĻāĻŽ āĻļ⧇āώ⧇ ?> āĻāϰ āφāϗ⧇ āύāĻŋāĻšā§‡āϰ āϕ⧋āĻĄ āĻ•āĻĒāĻŋ āĻĒ⧇āĻ¸ā§āϟ āĻ•āϰ⧁āύāĨ¤ 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