49

Sometimes I want to develop WordPress themes when I have no internet connection. I need the Function Reference and Template Tags to be productive.

I searched for a downloadable or SVN copy of the Codex but could not find one. I ended up trying to mirror it using wget, but the results were spotty (it's too huge!).

Is there a better way?

1
  • Get an iPad with 3G access? ;-) Aug 12, 2010 at 17:05

8 Answers 8

22
+100

I Use a much faster and easier way to create a local copy of the codex without installing a local server and without installing copy of mediawiki, its called ScrapBook which is a Firefox extension, that helps you to save Web pages and manage the collection. Key features are lightness, speed, accuracy and multi-language support.

using it's Save Web site (In-depth Capture)feature you can set the directories you want to save , which in your case would be Function Reference and Template Tags

enter image description here

you can also organize your collections just like bookmarks, edit saved files and highlight key parts of pages and the best thing about it is the built in full text search.

5
  • This is pretty great. Is there a way to feed it a list of urls to capture for later viewing? And is there a way to say "go refresh this list of urls"?
    – artlung
    Mar 13, 2012 at 22:57
  • Yes and as for refreshing I'm not sure yet.
    – Bainternet
    Mar 13, 2012 at 23:39
  • Just tried it and it has a capture again feature.
    – Bainternet
    Mar 13, 2012 at 23:46
  • This is a great lightweight way to quickly save a large group of files. I was hoping for self-contained, but I've been testing this since I opened the bounty and this is the easiest quickest way to get a local copy of the relevant docs.
    – artlung
    Mar 16, 2012 at 0:21
  • 1
    Is there any way to search the pages you've saved?
    – user55371
    Aug 1, 2014 at 0:16
46

Your best bet is to set up a local copy of MediaWiki. This is the same software that runs Wikipedia, but it's also the application that powers the Codex.

After you've got that installed, you can tell the Codex to export the pages you want and you can import the XML docs into your local installation. It's not automated, but it should give you enough information to work with for quick references.

Get MediaWiki

All of the documentation for downloading, installing, and configuring MediaWiki is available online.

If you can run WordPress locally, you should be able to run MediaWiki locally as well (you need both PHP and MySQL to set things up).

Export the Codex

Make a list of the pages you want to export. I'd love if there were an automated tool to export everything, but in the absence of that let's stick with the manual process.

Navigate to http://codex.wordpress.org/Special:Export. This page lets you mark which pages and categories you want to export.

Lets say you just want to export the Function Reference page. You'd enter "Function_Reference" in the large box for page names. Place one page name per line to export multiple pages at once.

But since that one page isn't very useful ... export the entire Functions category instead. Enter "Functions" in the category box and click add. The Codex will automatically list all 964 function pages for you. Then just add a line for "Function_Reference" so you get the index as well.

Codex with Function Reference pages pre-selected

You can see a list of all available pages at http://codex.wordpress.org/Special:AllPages. The list is quite extensive, so I won't cover it here ... but add every page you want exported anc click away.

Once you've clicked "Export," the Codex will generate a (rather large) XML file containing all of the content.

Import the Codex

Now navigate back to your local MediaWiki installation. You can now import the XML doc and create your local "clone" of the WordPress Codex.

Detailed import instructions are available on MediaWiki's website.

2
  • 4
    Great answer! I just started looking at the MediaWiki API and didn't even realize the Codex had an export.
    – Chris_O
    Mar 10, 2012 at 0:17
  • Some pages now have been transferred to developer.wordpress.org, which excludes them from the Functions category. Exporting the Functions will result in missing pages (e.g. get_permalink won't be included). I'd estimate that roughly 20% is missing.
    – Pim Schaaf
    Nov 8, 2016 at 14:04
10

You can use Dash (OS X) or Zeal (Linux, Windows) applications which have scrape of Codex function reference available as documentation set.

It is easy to install and use, however a little fuzzy how up to date the sets are kept.

4
  • 4
    I'm Dash's developer. I update the WordPress docset each time a new release of WordPress comes out.
    – bogdansrc
    May 13, 2014 at 21:34
  • 1
    am I the only one who thinks that Zeal (or Dash) is extremely underrated and this answer should be the accepted answer now?
    – Ejaz
    Aug 19, 2015 at 11:33
  • @Ejay the accepted answer is the one chosen by OP, as wht worked for them. :) It is normal to have multiple answers offer different takes on the question.
    – Rarst
    Aug 19, 2015 at 11:51
  • Thanks Rarst. Migrated from Mac to Linux recently and Zeal is just what I was looking for. FWIW bogdansrc, I bought Dash a few times on Mac, and because you're being generous with docsets I'll always promote it to mac devs. ;) Jan 13, 2017 at 1:16
6

I think the best thing would be to create bug report and ask the WP foundation to install this extension http://www.mediawiki.org/wiki/Extension:PdfBook If nothing else, mark it for private use and then provide the generated PDF for the users.

4

I did this for myself using HTTrack (http://www.httrack.com/). It wound up being a handful of megabytes (not sure of the exact number now, I lost my local copy to a hard drive failure, and haven't bothered to rebuild it yet), but it worked pretty well.

3
  • :-( Man, there has to be a better way. Thanks for the answer though. Hopefully there's something else!
    – artlung
    Aug 12, 2010 at 15:16
  • is there anything like this for mac?
    – Mild Fuzz
    Oct 11, 2010 at 8:35
  • There's an app called BlueCrab that does something similar, but I can't speak to it's use, as I've never used it.
    – Keith S.
    Oct 12, 2010 at 18:33
2

You can use the MediaWiki API. There is complete documentation on how to mirror a wiki using the API and other methods.

4
  • Is it possible to store into a static set of html, or do I need to be running Apache/PHP (or whatever current MediaWiki requirements are) on the target device? The Implementation details lack a simple set of instructions, they instead point to other solutions in various stages of completeness. sciencemedianetwork.org/wiki/…
    – artlung
    Mar 10, 2012 at 0:25
  • If you're using it to develop WordPress locally, then you're already running Apache/PHP and meet the requirements to run MediaWiki locally.
    – EAMann
    Mar 10, 2012 at 15:57
  • @EAMann actually I know a few folks using IIS but I take your point. I will say again that the instructions linked to lack detail. There's no "recipe" created to actually run the backup.
    – artlung
    Mar 14, 2012 at 0:15
  • Running MediaWiki under IIS would be a separate issue entirely. But I see your point. Even on a Windows box, I'd just install XAMPP or a similar solution to run things locally.
    – EAMann
    Mar 14, 2012 at 1:13
2

I Know this is an old thread but its been gathering hits so I'll add this answer

devdocs.io has all the API's for WordPress that you need, though its not structured like the Codex version it's still helpful in some cases.

NOTE: It's not just WordPress docs but many other popular languages too

1

Cool idea,

There's a few ways to make it "local".

  • You could do a recursive wget on it. This takes a long time. As you mentioned.
  • You could use a screen scraper: http://scraperwiki.com
  • You could write a script that just saves it locally every time you connect to the internet.
  • You could get down right dirty and every time you visit the codex you could just save that to a folder.

In short there's no repository for this at the moment. Although making one would be cool.

Maybe I'll write that...


I'll post back later tonight. I might actually have this done in a little bit.

I'll put it on GitHub.

Update: The MediaWiki answer is how this should really be done.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.