I’ve started writing a plugin for WPMU to allow the management of a ‘premium blog’ option that will control plugin availablity, disble ads and other things.
It’s a long way from done, but I figured I’d post my very early beta here for feedback. This represents only a few hours of work so far, so it has a long way to go, but hopefully you can get an idea of where I am going with it.
It currently consists of three files.
- premium-blog.php - to be placed in /wp-content/mu-plugins
- premium.php - to be placed in /wp-admin
- premium-plugins.php - to be placed in /wp-admin
Also, one line needs to be added to /wp-admin/plugins.php - it is detailed in the comments at the top of premium-plugins.php
In it’s current state it allows a site admin to define premium blogs (through the Site Admin -> Blogs -> Edit interface) and then can manage the plugins available to users (only the plugin management menu, if they are already activated it will not deactivate them).
It also offers the function premiumBlogs::isPremium() which can be called from a theme for example to conditionally include (or exclude) content (such as AdSense code or something).
My immediate plans include:
- Auto de-activate disallowed plugins from non-premium blogs.
- Allow ad management - define code to be used for ads, then simply call premiumBlogs::ad($id) to display that ad in a theme for non-premium blogs.
It should also be possible to make it set arbitary settings for premium blogs (larger upload space in conjuction with my Z-Space plugin perhaps?).
What else?
Download:
Premium Blogs - v0.1a
#1 by mod - March 10th, 2007 at 00:33
Sounds like a great idea. I’m trying this out now.
#2 by Tito - March 10th, 2007 at 13:24
Hi,
this is a nice idea…
But, I’ve this message :
Misc Blog Actions
Warning: call_user_func_array() [function.call-user-func-array]: First argumented is expected to be a valid callback, ‘premium_blog::configure’ was given in /My/Complete/Path/wp-includes/plugin.php on line 123
And I can’t specify a “Premium Blog”.
#3 by John - March 20th, 2007 at 11:18
So far–it seems nice/functional. I can’t find where to make a blog a premium blog though. It does work on the plugins.
Keep working on it–it is a great idea and a great start. If you get it working where you can actually specify premium blogs please let me know!
Thanks!
#4 by John - March 21st, 2007 at 14:15
I got a fix for the inability to choose a Premium Blog. But, of course, I do not know how to do the theme thing or anything like that. If you need to know what I did, I am posting it on the mu-forum with a link to your download + my code, because I do not know how to properly code a plugin.
#5 by John - March 21st, 2007 at 14:39
The following is DrMike’s words, not mine, just edited to make the premium selection work with this plugin.
- Open up wp-admin/upgrade-schema.php for editing.
- Go down until you hit the function populate_options.
- See all those add_option lines? What we need to do is add in our own with a default. For example, we’ll add in the following line:
add_option(’premium_blog’, 0);
This way when a new blog is created, it will already have the flag set in there to be negative.
But what to do with blogs already created? We’re going to have to fake an upgrade.
- Open up wp-includes/version.php for editing.
- See that line that lists the current database version number? Add ‘1′ to it. For example if it’s currently 3845, edit it to show as 3846. Be sure to save the file afterwards. (The software checks against the version numbers. If they match, it assumes it’s already been done.)
- Open up wp-admin/upgrade-functions.php for editing and go about a third of the way down. You should see a bit like the following:
if ( $wp_current_db_version Site Admin -> Blogs -> Find their blog and edit it. Using thte example above, your should now have a field with ‘Premium Blog’ in front of it. Change it to 1 and save.
End Dr Mike and insert me.
When you have this selected, and certain plugins designated as “Premium” under the Premium Menu option, all the plugins will show. The ones that are designated as Premium will not show for those who are not designated as premium.
Now, I want to do this with themes as well. Unfortunately, I am not a coder–I just experimented with DrMike’s advice. (If I knew how to put together the entire plugin I would).
If someone could point me in the right direction, or explain how I could do the same thing for themes–I would appreciate the help. If I could do that, I think I would accomplish everything I need with this plugin.