开发者

WordPress Theme Installer > Need some advice

I've got a pretty popular WordPress theme that has a template switcher (basically just changes the stylesheet assigned to the theme for a completely different look and stores this as setting in the db).

The way I do this is that I have a "styles" directory under my theme folder and inside of that, I have a single folder for every one of my templates that work with the theme.

Inside each of these folders is a stylesheet, along with any images the template needs.

I'd like to create an uploader in my theme options panel that allows one to select a zip file from their PC and install a new template to the theme.

Basically, I suppose I'm just looking for an upload routine that can take a zip file, extract it and place it in my theme's style folder. If there is already a folder by the same name, I'd like the routine to prompt for overwrite or rename.

Any ideas?

This appears to be the most promising thus far. I just need some tips on how to get this integrated with an file > uploader widget.

// create object
$zip = new ZipArchive() ;

// open archive
if ($zip->open(‘archive. zip’) !== TRUE) {
die (‘Could not open archive’);
}

// extract contents to destination directory
$zip->extractTo(‘/ tmp/extracted/ ‘);

// close archive
// print success message
$zip->close();
e开发者_如何学Ccho ‘Archive extracted to directory’;


Might be worth checking out the PHP filesystem functions: http://www.php.net/manual/en/ref.filesystem.php

If you've tried with some code, I might be able to help some more.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜