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

Adding joomla native dropdown menu in frontend

joomla native drop down menu


I think it’s my 4th post about using joomla native resources like tab slider, tooltip, modal/popup window and I am very happy that I just tried to used the joomla admin top menu … the top to bottom drop down menu in front end and it’s working fine. I just used the joomla native resources and changed one line of code in mod_mainmenu module. I think for doing something test or creative things sometimes we can try to change core code little… just keep in mind where u are changing and change again while u upgrade again in future.

Ok then let’s move for how we can use the main menu module as ‘top to bottom‘ drop down menu like the joomla admin panel top menu. we will work on default template of joomla1.5 Continue reading

জুমলাতে নেটিভ টুলটিপ এর ব্যবহার

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

Home made tab and slider module for joomla1.5

Change Log:

Update 14, January, 2010

WOW, This extension has been approved by JED Team. Pls visit it and place you rating.

Update 8, June, 2010(Must see)

  • Fixed a bug for php error, it was a typo error
  • Transition parameter was missing for slider, it’s fixed now
  • Download file is updated! Please reinstall or update the files only. Changes are in the mod_simplejoomlatabslider.xml, mod_simplejoomlatabslider.php and helper.php file

tabIf you check joomla1.5.x backend(joomla1.x had same) in any component or module configuration the right col accordian slider is common. In some components u should see tab too.To make such tab and slider is just so easy !

I think you are thinking about my post title, why I used the words “home made”. Because I am going to show you how u can make such a tab/slider module for front end just using joomla own resource. Joomla gives some execillent api to make html grid, tab, slider etc within a moment. JPane is such an api to make tab and slider. Here you will get some code example about how to make tab using JPane.

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