This repository has been archived by the owner on Dec 1, 2021. It is now read-only.
forked from tmtrademark/cheezcap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheezcap.php
66 lines (58 loc) · 1.92 KB
/
cheezcap.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
//
// CheezCap - Cheezburger Custom Administration Panel
// (c) 2008 - 2010 Cheezburger Network (Pet Holdings, Inc.)
// LOL: http://cheezburger.com
// Source: http://github.com/cheezburger/cheezcap
// Authors: Kyall Barrows, Toby McKes, Stefan Rusek, Scott Porad
// License: GNU General Public License, version 2 (GPL), http://www.gnu.org/licenses/gpl-2.0.html
//
require_once( 'library.php' );
require_once( 'config.php' );
$cap = new autoconfig();
if ( ! defined( 'LOADED_CONFIG' ) ) {
add_action( 'admin_menu', 'cap_add_admin' );
define( 'LOADED_CONFIG', 1 );
}
function cap_add_admin() {
global $themename, $req_cap_to_edit;
if ( ! current_user_can ( $req_cap_to_edit ) )
return;
if ( isset( $_GET['page'] ) && $_GET['page'] == basename( __FILE__ ) ) {
$options = cap_get_options();
$action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';
$method = false;
$done = false;
$data = new ImportData();
switch ( $action ) {
case 'save':
$method = 'Update';
break;
case 'Reset':
$method = 'Reset';
break;
case 'Export':
$method = 'Export';
$done = 'cap_serialize_export';
break;
case 'Import':
$method = 'Import';
$data = unserialize( file_get_contents( $_FILES['file']['tmp_name'] ) );
break;
}
if ( $method ) {
foreach ( $options as $group ) {
foreach ( $group->options as $option ) {
call_user_func( array( $option, $method ), $data );
}
}
if ( $done )
call_user_func( $done, $data );
}
}
$pgName = "$themename Settings";
$hook = add_menu_page( $pgName, $pgName, isset( $req_cap_to_edit ) ? $req_cap_to_edit : 'manage_options', basename( __FILE__ ), 'top_level_settings' );
add_action( "admin_print_scripts-$hook", 'cap_admin_js_libs' );
add_action( "admin_footer-$hook", 'cap_admin_js_footer' );
add_action( "admin_print_styles-$hook", 'cap_admin_css' );
}