Jotted by brajesh on June 27, 2010
Here I am, once again, but I am not here to say apologies or provide reasons for my past reluctance to blog here. I am writng the new post to let you know, my feelins for this blog has resurfaced again and I am back to have a new begining for ThinkingInWordPress.com
It was always a fun to write here and listening to you all but things changed and I got busy with the other site so never found myself time and energy to blog here and even if I tried to look back sometime, I could not find something good to start with.
Now, as wp3.0 is out and you all must be busy upgrading and having fun with it, I thought it as the right time to start all over again. I am going to write regular again with all the tips/tricks I accumulated in the last 6 months of absence from this site.
There are a few questions though.I see there are more than 100 comments which needs to be answered but they have lost the relevance to be answered as most of them were made 2-3 months ago and even if I reply them now, it won’t be useful. So I am not going to reply those old comments but will be replying any comments from now onwards again. If you have any question/confusion about the things on this site, please feel free to comment, I will be glad to helping you again.
And yes, I will be writing more than 3 posts a week for now couple of months to make it even for my absence. Hope to see you all again here
Posted in Uncategorized | No Comments »
Jotted by brajesh on February 17, 2010
While working with my most recent plugin, I had an issue of finding all the admins of a blog on the wpmu network. after a couple of minutes, I implemented a small hack and It worked like charm.
So here you go.
Please Note, I have used User level, which is backward compatible and is there because of the legacy plugins support(according to codex), But this hack solves the problem to iterate through the Roles/capabilities.
So here is the code.
function get_admin_users_for_blog($blog_id) {
global $wpdb;
$key="wp_".$blog_id."_user_level";
return $wpdb->get_results($wpdb->prepare("SELECT user_id from $wpdb->usermeta AS um WHERE um.meta_key ='". $key."' AND um.meta_value=10"));
}
//and now call it
global $current_blog;
$admins=get_admin_users_for_blog($current_blog->blog_id);
//now you have $admins as an array of object, Just Iterate over it and do some stuff, well, I will just print out
foreach($admins as $admin)
echo "ID:".$admin->ID;
///hmm you can use it for more productive reasons
That’s the shortest code I could produce, I know, The better way will be to loop through the capabilities, but hacks are for you know
Posted in Tutorials, Wordpress Mu | 1 Comment »
Jotted by brajesh on February 6, 2010
Thank you everyone for your comments suggestions and everything. Recently, I have not been able to keep this blog updated, but from the mid of Feb, expect me to update it regularly.
So my question to you all, which of the plugins you would like to see updated. Other than the plugins I will go into details of wp 3.0 and buddypress.
Hope to see you guys here then
Thanks
Brajesh
Posted in Uncategorized | 4 Comments »
Jotted by brajesh on January 21, 2010
If you are using wordpress 2.9+ , It is just so easy. You don’t have to worry about the evil thing called “eval” and you don’t have to worry about including JSON javascript parser with your theme/plugin.
WordPress 2.9+ contains the json2.js from json.org.
So, just put a line in your plugin
wp_enqueue_script("json2");//must be put inside some function called at wp_print_script
Or here is the complete code, how to enqueue the script.
add_action("wp_print_scripts","load_my_script");
function load_my_script(){
//en queue JSON2.js
wp_enqueue_script("json2");
}
and boy! wordpress will load the JSON parser, Now you are ready to use the JSON parser.
Here is more details about what you can do with the JSON parser
http://www.json.org/js.html
Tags: clien-side, javascript, json
Posted in Tutorials, Wordpress | No Comments »