__('Primary Sidebar', 'apollo'), 'before_widget' => '
  • ', 'after_widget' => '
  • ', 'before_title' => '

    ', 'after_title' => '

    ', )); register_sidebar(array( 'name' => __('Secondary Sidebar', 'apollo'), 'before_widget' => '
  • ', 'after_widget' => '
  • ', 'before_title' => '

    ', 'after_title' => '

    ', )); } function ap_buildCategoryMenu(){ $home = '
  • Home
  • '; $args = array( 'show_option_all' => '', 'orderby' => 'name', 'order' => 'ASC', 'show_last_update' => 0, 'style' => 'list', 'show_count' => 0, 'hide_empty' => 1, 'use_desc_for_title' => 0, 'child_of' => 0, 'feed' => '', 'feed_image' => '', 'exclude' => '', 'hierarchical' => false, 'title_li' => __(''), 'echo' => 0, 'depth' => 0 ); return sprintf('', $home, wp_list_categories($args)); } function ap_buildPageMenu(){ $home = '
  • Home
  • '; $args = array( 'depth' => -1, 'show_date' => '', 'date_format' => get_option('date_format'), 'child_of' => 0, 'exclude' => '', 'title_li' => __(''), 'echo' => 0, 'authors' => '', 'sort_column' => 'menu_order, post_title'); return sprintf('', $home, wp_list_pages($args)); } $ap_defaults = array( 'layout' => '0', 'horizMenu' => 'pages', 'useGravatars' => '0', 'usePingbacks' => '0', 'showRSS' => '3', 'linkColour' => '#006699', 'headingColour' => '#333333', 'bodyFont' => '0', 'headingFont' => '0', 'logo' => '0' ); $ap_fonts = array( 'Arial, Helvetica, sans-serif', 'Verdana, Helvetica, sans-serif', 'Georgia, \'Times New Roman\', serif', '\'Trebuchet MS\', Verdana, Helvetica, sans-serif', 'Tahoma, Verdana, Helvetica, sans-serif' ); $ap_logos = array( 'gimp', 'alarm', 'blocks', 'camera', 'games', 'console', 'internet', 'joystick', 'konquest', 'lists', 'lskat', 'movie', 'mp3', 'organiser', 'pda', 'phone', 'view', 'teatime', 'date', 'none' ); $ap_layouts = array( '3col_r', '3col_c', '2col_l', '2col_r' ); function ap_add_theme_page() { global $wpdb; $errorFlag = false; if ($_GET['page'] == basename(__FILE__)) { // save settings if ( 'save' == $_REQUEST['action'] ) { if (valid_colour($_REQUEST['ap_linkColour'])){ update_option('ap_linkColour', $_REQUEST['ap_linkColour']); } else { $errorFlag = true; } if (valid_colour($_REQUEST['ap_headingColour'])){ update_option('ap_headingColour', $_REQUEST['ap_headingColour']); } else { $errorFlag = true; } if(isset($_REQUEST['ap_layout'])){ $insLayout = (int)$_REQUEST['ap_layout']; update_option('ap_layout', $insLayout); } ($_REQUEST['ap_horizMenu'] == 'pages') ? update_option('ap_horizMenu', 'pages') : update_option('ap_horizMenu', 'categories') ; (isset($_REQUEST['ap_useGravatars'])) ? update_option('ap_useGravatars', '0') : update_option('ap_useGravatars', '1') ; (isset($_REQUEST['ap_usePingbacks'])) ? update_option('ap_usePingbacks', '0') : update_option('ap_usePingbacks', '1') ; if(isset($_REQUEST['ap_showRSS'])) { if (($_REQUEST['ap_showRSS'] >= 1) && ($_REQUEST['ap_showRSS'] <= 3)) update_option('ap_showRSS', (int)$_REQUEST['ap_showRSS']); } if(isset($_REQUEST['ap_bodyFont'])){ $insBodyFont = (int)$_REQUEST['ap_bodyFont']; //if (($insBodyFont >= 1) && ($insBodyFont <= 3)) update_option('ap_bodyFont', $insBodyFont); } if(isset($_REQUEST['ap_headingFont'])){ $insHeadingFont = (int)$_REQUEST['ap_headingFont']; //if (($insHeadingFont >= 1) && ($insHeadingFont <= 3)) update_option('ap_headingFont', $insHeadingFont); } if(isset($_REQUEST['ap_logo'])){ $insLogo = (int)$_REQUEST['ap_logo']; //if (($insLogo >= 0) && ($insLogo <= 3)) update_option('ap_logo', $insLogo); } // goto theme edit page if($errorFlag){ header("Location: themes.php?page=functions.php&error=true"); die; } else { header("Location: themes.php?page=functions.php&saved=true"); die; } // reset defaults } else if('reset' == $_REQUEST['action']) { delete_option('ap_layout'); delete_option('ap_horizMenu'); delete_option('ap_useGravatars'); delete_option('ap_usePingbacks'); delete_option('ap_showRSS'); delete_option('ap_linkColour'); delete_option('ap_headingColour'); delete_option('ap_bodyFont'); delete_option('ap_headingFont'); delete_option('ap_logo'); header("Location: themes.php?page=functions.php&reset=true"); die; } } add_theme_page(__('Apollo Theme Options'), __('Apollo Options'), 'edit_themes', basename(__FILE__), 'ap_theme_page'); } function ap_theme_page() { global $wpdb, $ap_defaults, $ap_fonts, $ap_logos; ?>

    '.__('Settings saved.','').'

    '; if ($_REQUEST['reset'] ) echo '

    '.__('Settings reset.','').'

    '; if ($_REQUEST['error'] ) echo '

    '.__('Error - invalid color code','').'

    '; ?>

    Thematology','apollo'); ?>

    Pick a color
    6 figure hex code, with hash'; ap_cth(); ap_th(__('Heading Color','apollo')); $setHeadingColour = get_settings('ap_headingColour'); $valHeadingColour = !empty($setHeadingColour) ? $setHeadingColour : $ap_defaults['headingColour']; ap_input( 'ap_headingColour', 'text', '', $valHeadingColour ); echo ' Pick a color
    6 figure hex code, with hash'; ap_cth(); ap_th(__('Body Font','apollo')); $valBodyFont = get_settings('ap_bodyFont'); if(empty($valBodyFont)) $valBodyFont = $ap_defaults['bodyFont']; print(''); ap_cth(); ap_th(__('Heading Font','apollo')); $valHeadingFont = get_settings('ap_headingFont'); if(empty($valHeadingFont)) $valHeadingFont = $ap_defaults['headingFont']; print(''); ap_cth(); ap_th(__('Logo:','apollo')); $valLogo = get_settings('ap_Logo'); echo ''; for ($m=0; $m<=4;$m++){ echo ''; for ($n=0; $n <=3; $n++){ echo ''; } echo ''; } echo '
    '; ap_logoInput($m*4+$n, $valLogo); echo '
    '; ap_cth(); ?>
    ', $var, $var, $type, $value, $onchange); break; case "submit": printf('

    ', $var, $type, $value); break; case "option": if($selected == $value) $extra = 'selected '; printf('', $value, $extra, $description); break; case "radio": if($selected == $value) $extra = 'checked '; printf('  ', $var, $var, $type, $value, $extra, $description); break; case "checkbox": if($selected == $value) $extra = 'checked '; printf('
    ', $var, $var, $type, $value, $extra, $description); break; case "textarea": printf('',$var, $var, $value ); break; } } function ap_th( $title ) { echo ''; echo ''.$title.' '; echo ''; } function ap_cth() { echo ''; echo ''; } function ap_layout(){ global $ap_layouts; $setLayout = get_settings('ap_layout'); if(!$setLayout) $setLayout = 0; printf ('/style_%s.css', $ap_layouts[$setLayout]); return NULL; } function ap_buildMenu(){ echo (get_option('ap_horizMenu') == 'categories') ? ap_buildCategoryMenu() : ap_buildPageMenu(); return NULL; } function ap_commentPadding(){ echo (get_settings('ap_useGravatars') == 0) ? '70px' : '20px'; return NULL; } function ap_useGravatars(){ return (get_settings('ap_useGravatars') == 0); } function ap_usePingbacks(){ return (get_settings('ap_usePingbacks') == 0); } function ap_showRSS($type=''){ global $ap_defaults; $showRSS = get_settings('ap_showRSS'); $showRSS = (!empty($showRSS)) ? $showRSS : $ap_defaults['showRSS']; if($type == 'comments'){ return ($showRSS == 3); } else { return ($showRSS >= 2); } } function ap_linkColor(){ global $ap_defaults; echo valid_colour(get_settings('ap_linkColour')) ? get_settings('ap_linkColour') : $ap_defaults['linkColour']; return NULL; } function ap_headingColor(){ global $ap_defaults; echo valid_colour(get_settings('ap_headingColour')) ? get_settings('ap_headingColour') : $ap_defaults['headingColour']; return NULL; } function ap_bodyFont(){ global $ap_defaults, $ap_fonts; $bodyFontVal = get_settings('ap_bodyFont'); echo (!empty($ap_fonts[$bodyFontVal])) ? $ap_fonts[$bodyFontVal]: $ap_fonts[$ap_defaults['bodyFont']]; return NULL; } function ap_headingFont(){ global $ap_defaults, $ap_fonts; $headingFontVal = get_settings('ap_headingFont'); echo (!empty($ap_fonts[$headingFontVal])) ? $ap_fonts[$headingFontVal]: $ap_fonts[$ap_defaults['headingFont']]; return NULL; } function ap_get_secondarySidebar(){ $setLayout = get_settings('ap_layout'); if($setLayout > 1) return NULL; if (file_exists(TEMPLATEPATH . '/secondary_sidebar.php')) require_once( TEMPLATEPATH . '/secondary_sidebar.php'); } function valid_colour($var){ $regex = '^#([a-f]|[A-F]|[0-9]){6}^'; return preg_match($regex,$var); } function ap_logoInput($num, $val){ global $ap_logos; ap_input('ap_logo', 'radio', '', $num, $val); } function ap_logo(){ global $ap_logos, $ap_defaults; $setLogo = get_settings('ap_logo'); $logoPath = $ap_logos[$setLogo] . '.gif'; if ($setLogo == 19 || (!file_exists(TEMPLATEPATH . '/images/logos/' . $logoPath ))) { print ('background: #4E4E4E; padding: 0 0 0 20px;'); return NULL; } printf('background: #4E4E4E url("%s/images/logos/%s") top left no-repeat; padding: 0 0 0 100px;', get_bloginfo('template_directory'), $logoPath); return NULL; } ?>