Updates from RSS Toggle Comment Threads | Keyboard Shortcuts

  • November 26, 2009 Permalink | Reply  

    Manage Multiple WordPress Installs 

    I was wondering how to admin several WordPress installs from the same interface and came out with this simple idea of having a tab container where each tab would give access to the WordPress admin panel.

    This can be quite simple to develop by putting together a jQuery tab container and iframes.

    This could be further extended in a way that one single login would authenticate across all the WordPress installations. In this way we can manage the several installs from one single interface with full flexibility, i.e. we have exactly the same options as if we open separate windows and log into the installations.

    Check out the example demo. Try going to Tab number 2 and logging in as user: admin / password: demo123

     
  • November 25, 2009 Permalink | Reply  

    Authentication by POST/GET in WordPress 

    For a project I’m working on I needed to trigger an action in a remote WordPress installation. I had a bit of trouble understanding how I could authenticate myself against the remote site. Eventually I found a clean and nice way and I want to share it here with you. Of course, if you’re not into WordPress you can safely skip this post.

    The Problem

    Where I first stumbled was when from my plugin I tried to access directly the other plugin in the remote site. The code I was using for doing this was something like:


    // create curl resource
    $ch = curl_init();
    // set url
    curl_setopt($ch, CURLOPT_URL, "http://wordpress.mu/wp-admin/admin.php?page=myplugin");
    //return the transfer as a string
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    // $output contains the output string
    $output = curl_exec($ch);
    // close curl resource to free up system resources
    curl_close($ch);
    // print the result of the whole request:
    print "CONTENT = ".$output;

    And this wouldn’t work because although I was authenticated in the remote site via the browser, the session that the curl request creates is not, and so this request results in us being redirected to the login page.

    What to do?

    Ideally we want to do a POST request that we execute before and that authenticates us. I searched around on how to do this but couldn’t find anything. What I found was one of the many third-party applications that allow talking to WordPress remotely. I then looked at how they work and how they authenticate themselves.

    Instead of doing a POST request to the plugin page like before, they do a POST request to the site’s index.php. A plugin is registered to catch a particular POST request. Then you simple use the WordPress function user_pass_ok(), that authenticates the user against the database.

    Here I demonstrate how to do this using a GET request, because its simpler, but the same thing would work with a POST request.

    add_action('plugins_loaded', 'unpackimport_createblog', -1);
    function unpackimport_createblog() {
    if(isset($_GET['myplugin'])) {
    if(user_pass_ok($_REQUEST['username'], $_REQUEST['password']))
    echo 'Authentication successful';
    }

    And the client request:

    curl_setopt($ch, CURLOPT_URL, "http://wordpress.mu/index.php?myplugin=true&username=test&password=testpass");

    Screencast

    I wanted to show a working example rather than just saying this works so I did this screencast. You can also download the plugins yourself and try them out.

    Download

    unpack_import_demo.tar.gz
    dump_pack_demo.tar.gz

     
  • November 21, 2009 Permalink | Reply  

    Illusion 

    Masters say this is all a big illusion, that life and everything around it is nothing more than an illusion, Maya. The first reaction when people hear about this is that it’s total crap. How can it be an illusion if I’m seeing it, if it is here happening in front of my eyes?

    Think of a tooth, for example. If you curl your tongue and touch any of your tooth, it really feels like a nice polished surface. Nevertheless, if you zoom into it you’ll see it is actually made of tiny razorblades. It is not that what you see is not real. It’s just you’re probably not seeing it through the right lenses.

     
  • November 20, 2009 Permalink | Reply  

    Trying out a new thing with my blog. Hosting at WordPress.com instead of self-hosted. Let’s see how this pans out.

     
  • November 19, 2009 Permalink | Reply  

    Changing the Default Blog in WordPress MU 

    WordPress MU is a platform that allows you to host and manage multiple WordPress installations. It is used to power WordPress.com, among other sites.

    The basic of WordPress MU is that the user registers and upon the click of a button, a blog is generated for him, available to use immediately.

    The default blog that is generated is the most basic thing you can get. It uses the default Kubrick theme, no plugins or widgets, and a bit of example content (a post, a page, a comment and some links).

    I’m working on a WordPress MU project now and I had to change the default blog to something more elaborate. So I went and researched a bit what can be done and what is supported. Here’s what I’ve found.

    There are a couple of MU plugins that allow you through an admin panel to edit some defaults (blog title, default theme, stuff like that). If you’re into that kind of thing see the New Blog Defaults plugin. But in fact what I wanted was something more along the lines of developing my default blog locally (in a local MU installation) and then deploy to the production site with minimum hassle.

    I found another plugin called Blog Templates and with it you can create a template from a blog. This template will be saved in a different database table ‘wp_gp_templates’ and will contain posts, pages, links, post categories and some blog options. You can easily extend it by adding more options to be saved if you need to. You can then upload the template to the production server and it will be applied as a template to new blogs. Pretty cool.

    exclude pages plugin

    I had a plugin to exclude certain pages from the menu. This was a question of adding an extra option to be saved in the template. *

    copying plugin settings

    Information about what plugins are active is kept inside the options table and so it can be saved quite easily:

    $newoptions['active_plugins'] = get_option(‘active_plugins’);

    A problem with this is you still need to make sure all the plugins you had locally installed are on the server. Not a big deal but something to keep in mind.

    copying widget settings

    Widget settings are also kept inside the options table so it’s not a big deal to extend the plugin to also save them (you still need to work out which options to save though). Because normally widgets are registered from plugins you again need to make sure all the plugins you had locally are on the server.

    theme

    The theme name is saved in the template but you still need to manually make sure all the theme files are on the server, and if not, upload them.

    post meta / custom fields

    I extended the plugin to clone all of the meta items for a post. This seems to work quite well without any problems. I might work together with the plugin author to include this as an option in the plugin or maybe release the code here separately.

    * A problem with this is that because the pages are excluded based on their ID, you need to be sure that the pages will be created with the same ID that is saved to the template (this is a problem if you have created pages and then deleted them because the IDs will not be the first ones).

     
    • dr. noam sadovnik 3:50 pm on November 21, 2009 Permalink

      Are you planning on making your updated version of this plugin available to public either here or via plugin author?

      I’m interested in your modifired version of this plugin and also some other options. What about the ability to manage multiple wodpress MU installs and automate bulk blog creation with blog template preferrences applied?

      I manage a bunch of seperate MU installs and would like the ability to bulk create blogs say 5 at a time each blog though on a seperate MU install.

      Thanks.

    • tabard 11:26 am on November 22, 2009 Permalink

      The most relevant part of it is the functionality that clones the postmeta/custom fields. I’ve sent that to the plugin author and he has integrated it, which is very cool :-)

      Take a look here if you’re interested:
      http://gregbreese.wordpress.com/2009/11/22/cloning-a-blog-now-copies-all-post-meta-items/

    • eDDi Hughes 2:22 pm on December 29, 2009 Permalink

      This is great. I Googled “wordpress mu new blog clone” and found this on the front page. I was wondering if anyone else out there was doing this. Basically what I was looking for was a way to clone a wordpress blog, duplicate a blog or rewrite what the default content was. I looked at wpmu-functions.php and index-install.php – I DID NOT want to alter core files because in an upgrade it would be overwritten.

      Tabard, I’m really happy you blogged about this and provided links. I was worried I’d have to start digging in the trenches!

      I found a similar thread, but they were in the database copying tables. I think it was for a specific application, but I thought I’d shine some light on your post for future searchers.

      Happy Holidays!

    • eDDi Hughes 1:37 pm on December 30, 2009 Permalink

      Question on extending Blog Templates, by extending, do you mean manually adding the wanted options / tabels to ‘wp_gp_templates’?

    • eDDi Hughes 2:48 pm on December 30, 2009 Permalink

      Excuse my previous post, I misunderstood what you mean in your post. I went into template_url/tools/theme_options.php change the defaults, then created default for Blog Templates and went crazy. ^_^

  • Pages: 1 2 3 4 5 6 7 8 9 10 ...54 55 56 Next
c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
l
go to login
h
show/hide help
esc
cancel