Updates from RSS Toggle Comment Threads | Keyboard Shortcuts

  • Nuno Morgadinho 3:43 pm on 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

     
  • Nuno Morgadinho 6:07 pm on 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

     
  • Nuno Morgadinho 12:58 am on 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.

     
  • Nuno Morgadinho 11:35 pm on 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.

     
  • Nuno Morgadinho 1:06 pm on 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. ^_^

  • Nuno Morgadinho 5:24 pm on November 17, 2009 Permalink | Reply  

    Wordpress JSON API 

    dphiffer created a plugin that exposes a JSON API for Wordpress. This is quite cool and can be used to create a front-end that displays content served from a WordPress back-end. In his case he was using Ruby on Rails for the front-end but I can imagine other cases where this would be useful. I’ll definitely going to give this a try sometime.

    http://wordpress.org/extend/plugins/json-api/

     
  • Nuno Morgadinho 1:58 pm on November 13, 2009 Permalink | Reply  

    Wordpress Child Themes 

    What are Wordpress Child Themes and why are they useful?
    http://themehybrid.com/themes/hybrid/child-themes

    A case for including child themes in the official Wordpress theme directory
    http://developdaly.com/wordpress/child-theme-inclusion-in-the-wordpress-directory/

    Vote for Child Theme Inclusion in the WordPress Directory
    http://wordpress.org/extend/ideas/topic.php?id=3264

     
  • Nuno Morgadinho 12:19 pm on November 12, 2009 Permalink | Reply  

    Our soul does not keep time, it merely records growth 

    Caine: Master, what is the best way to meet the loss of one we love?
    Master: By knowing that when we truly love it is never lost. It is only after death that the depth of the loss is truly felt and our loved one becomes more a part of us than was possible in life.
    Caine: Are we only able to feel this towards those whom we have known and loved for a long time?
    Master: Sometimes a stranger known to us for moments can spark our souls to kinship for eternity.
    Caine: How can strangers take on such much importance to our souls?
    Master: Because our soul does not keep time. It merely records growth.

    caine_and_master_po

     
  • Nuno Morgadinho 12:05 am on November 8, 2009 Permalink | Reply  

    Why 1000 euros today are not worth the same as in a year 

    One thing we were taught at Kickstart, while covering finances and accounting, was that getting 1000€ today is not the same as getting 1000€ in a year from now. This seems to be a basic thing you learn while studying economics but we, mere mortals, have difficulty in understanding. So what is the reasoning behind this principle?

    1) Inflation: the price of goods and services rises and therefore what we can buy with 1000€ today is not the same as what we’ll be able to buy in a year.*

    2) More importantly: even if the inflation was 0%, having 1000€ today is not the same since we can invest the money today and make.. well, more money. Otherwise we’ll have to wait a whole year before investing.

    This becomes more obvious when considering more money and a larger span of time. 10.000€ will not have today’s value in 10 years.

    I couldn’t find the name behind this principle of Economics but if you know tell us.

    * assuming inflation is rising

     
  • Nuno Morgadinho 7:15 pm on November 5, 2009 Permalink  

    JavaScript Resources 

    Time to revisit JavaScript?

    • http://ejohn.org/apps/learn – Do you think you know JavaScript? Well, see if you understand these code challenges. This is a interactive tutorial, that walks you through different examples which you can even run on the same site.
    • http://jsbin.com – perfect to use in conjunction with the previous link. What you don’t understand just copy+paste here and try it out! This is a JavaScript playground so to say.
    • http://tinyurl.com/yqua25 – in this video Douglas Crockford from Yahoo! talks about “The JavaScript Programming Language”.

    If you’re coming from Actionscript then this link is a good read as well.

     
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