示例#1
0
文件: admin.php 项目: gp6shc/aok
function upthemes_admin_buy()
{
    require_once 'buy.php';
}
function upthemes_admin_import_export()
{
    require_once 'import-export.php';
}
/******
** Activate UpThemes Framework admin
*************************************/
function upfw_upthemes_admin()
{
    $name = __('WP-Answers', 'upfw');
    if (!defined('THEME_DIR')) {
        define('THEME_DIR', plugins_url('', __FILE__));
    }
    $theme_options_icon = apply_filters('theme_options_icon', THEME_DIR . '/images/tf-icon.png');
    add_menu_page($name, $name, 'edit_theme_options', 'themefurnace', 'upthemes_admin_home', $theme_options_icon);
    //Create tabbed pages from array
    global $up_tabs;
    if (is_array($up_tabs)) {
        foreach ($up_tabs as $tab) {
            foreach ($tab as $title => $shortname) {
                add_submenu_page('themefurnace', $title, $title, 'edit_theme_options', 'themefurnace#/' . $shortname, 'upthemes_admin_' . $shortname);
            }
        }
    }
    // check for theme options
    $themepath = get_theme_root() . '/' . get_template();
    // include theme options if user has plugin + theme
    if (is_dir($themepath . '/theme-options/') && ($handle = opendir($themepath . '/theme-options/'))) {
        while (false !== ($entry = readdir($handle))) {
            if ($entry != "." && $entry != "..") {
                $tmp = explode("_", $entry);
                array_pop($tmp);
                $opt_name = implode(' ', $tmp);
                add_submenu_page('themefurnace', ucwords($opt_name), ucwords($opt_name), 'edit_theme_options', 'themefurnace#/wpanswers-' . str_replace(' ', '-', $opt_name), 'upthemes_admin_' . str_replace(' ', '-', $opt_name));
            }
        }
        closedir($handle);
    }
    //Static subpages
    add_submenu_page('themefurnace', __('Import/Export', 'upfw'), __('Import/Export', 'upfw'), 'edit_theme_options', 'themefurnace#/import-export', 'upthemes_admin_import_export');
    add_submenu_page('themefurnace', __('Word Count and Limit', 'upfw'), __('Word Count Limit', 'upfw'), 'edit_theme_options', 'themefurnace#/wordcount', 'show_limit_fields');
    add_submenu_page('themefurnace', __('Response Limit', 'upfw'), __('Limit Responses', 'upfw'), 'edit_theme_options', 'themefurnace#/limitresponse', 'limit_responses_show_settings');
    add_submenu_page('themefurnace', __('New User Approve', 'upfw'), __('New User Approve', 'upfw'), 'edit_theme_options', 'themefurnace#/userapprove', 'limit_responses_show_settings');
}
add_action('admin_menu', 'upfw_upthemes_admin', 2);
/******
** Find default options
*************************************/
function find_defaults($options)
{
    global $up_defaults;
    print_r($options);
}
/******
** Render theme options
*************************************/
function render_options($options)
{
    //Check if theme options set
    global $default_check;
    global $default_options;
    global $attr;
    $attr = '';
    if (!$default_check) {
        foreach ($options as $option) {
            if ($option['type'] != 'image') {
                $default_options[$option['id']] = $option['value'];
            } else {
                $default_options[$option['id']] = $option['url'];
            }
        }
        $update_option = get_option('up_themes_' . UPTHEMES_SHORT_NAME);
        if (is_array($update_option)) {
            $update_option = array_merge($update_option, $default_options);
            update_option('up_themes_' . UPTHEMES_SHORT_NAME, $update_option);
        } else {
            update_option('up_themes_' . UPTHEMES_SHORT_NAME, $default_options);
        }
    }
    foreach ($options as $value) {
        //Check if there are additional attributes
        if (isset($value['attr']) && is_array($value['attr'])) {
            $i = $value['attr'];
            //Convert array into a string
            foreach ($i as $k => $v) {
                $attr .= $k . '="' . $v . '" ';
            }
        }
        //Determine the type of input field
        switch ($value['type']) {
            //Render Text Input
            case 'text':
                upfw_text_field($value, $attr);
                break;
                //Render Custom User Text Inputs
            //Render Custom User Text Inputs
            case 'text_list':
                upfw_text_list($value, $attr);
                break;
                //Render textarea options
            //Render textarea options
            case 'textarea':
                upfw_textarea($value, $attr);
                break;
                //Render select dropdowns
            //Render select dropdowns
            case 'select':
                upfw_select($value, $attr);
                break;
                //Render multple selects
            //Render multple selects
            case 'multiple':
                upfw_multiple($value, $attr);
                break;
                //Render checkboxes
            //Render checkboxes
            case 'checkbox':
                upfw_checkbox($value, $attr);
                break;
                //Render color picker
            //Render color picker
            case 'color':
                upfw_color($value, $attr);
                break;
                //Render upload image
            //Render upload image
            case 'image':
                upfw_image($value, $attr);
                break;
                //Render category dropdown
/**
 * Callback for get_settings_field()
 */
function upfw_setting_callback($option)
{
    $upfw_options = upfw_get_options();
    //print_r($upfw_options);
    $option_parameters = upfw_get_option_parameters();
    $optionname = $option['name'];
    $optiontitle = $option['title'];
    $optiondescription = $option['description'];
    $fieldtype = $option['type'];
    $fieldname = "theme_" . get_current_theme_id() . "_options[{$optionname}]";
    $attr = $option_parameters[$option['name']];
    $value = $upfw_options[$optionname];
    //Determine the type of input field
    switch ($fieldtype) {
        //Render Text Input
        case 'text':
            upfw_text_field($value, $attr);
            break;
            //Render Custom User Text Inputs
        //Render Custom User Text Inputs
        case 'text_list':
            upfw_text_list($value, $attr);
            break;
            //Render textarea options
        //Render textarea options
        case 'textarea':
            upfw_textarea($value, $attr);
            break;
            //Render select dropdowns
        //Render select dropdowns
        case 'select':
            upfw_select($value, $attr);
            break;
            //Render multple selects
        //Render multple selects
        case 'multiple':
            upfw_multiple($value, $attr);
            break;
            //Render checkboxes
        //Render checkboxes
        case 'checkbox':
            upfw_checkbox($value, $attr);
            break;
            //Render color picker
        //Render color picker
        case 'color':
            upfw_color($value, $attr);
            break;
            //Render upload image
        //Render upload image
        case 'image':
            upfw_image($value, $attr);
            break;
            //Render category dropdown
        //Render category dropdown
        case 'category':
            upfw_category($value, $attr);
            break;
            //Render categories multiple select
        //Render categories multiple select
        case 'categories':
            upfw_categories($value, $attr);
            break;
            //Render page dropdown
        //Render page dropdown
        case 'page':
            upfw_page($value, $attr);
            break;
            //Render pages muliple select
        //Render pages muliple select
        case 'pages':
            upfw_pages($value, $attr);
            break;
            //Render Form Button
        //Render Form Button
        case 'submit':
            upfw_submit($value, $attr);
            break;
            //Render taxonomy multiple select
        //Render taxonomy multiple select
        case 'taxonomy':
            upfw_taxonomy($value, $attr);
            break;
            //Render Typography Selector
        //Render Typography Selector
        case 'typography':
            upfw_typography($value, $attr);
            break;
            //Render Style Selector
        //Render Style Selector
        case 'styles':
            upfw_style($value, $attr);
            break;
            //Render Form Button
        //Render Form Button
        case 'button':
            upfw_button($value, $attr);
            break;
            //Render Text Input
        //Render Text Input
        case 'divider':
            upfw_divider($value, $attr);
            break;
            //Render Layouts
        //Render Layouts
        case 'layouts':
            upfw_layouts($value, $attr);
            break;
        default:
            break;
    }
}