'3', // 1, 2, 3 (the depth of the menu, 1 being no dropdown) 'headerMenu1_display' => 'pages', // pages, categories 'headerMenu1_sortBy' => 'post_title', // [CATEGORIES]: name, ID, count, slug [PAGES]: post_title, ID, post_name (slug), menu_order (the page's Order value) 'headerMenu1_sortOrder' => 'asc', // asc, desc 'headerMenu1_alignment' => 'right', // right, left 'headerMenu1_show' => true, 'headerMenu1_disableParentPageLink' => false, 'headerMenu1_exclude_categories' => '', 'headerMenu1_exclude_pages' => '', 'headerMenu2_dropdown' => '3', // 1, 2, 3 (the depth of the menu, 1 being no dropdown) 'headerMenu2_display' => 'categories', // pages, categories 'headerMenu2_sortBy' => 'name', // [CATEGORIES]: name, ID, count, slug [PAGES]: post_title, ID, post_name (slug), menu_order (the page's Order value) 'headerMenu2_sortOrder' => 'asc', // asc, desc 'headerMenu2_displayHomeButton' => true, 'headerMenu2_displaySeparators' => true, 'headerMenu2_disableParentPageLink' => false, 'headerMenu2_exclude_categories' => '', 'headerMenu2_exclude_pages' => '', 'headerImage' => 'lightBlue', //lightBlue, darkBlue 'commentDisplay' => 'alt', // alt, left, right 'commentDateFormat' => 'timePassed', // timePassed, date 'comments_hideWhenDisabledOnPages' => true, 'comments_hideWhenDisabledOnPosts' => false, 'footerStyle' => 'style1', // style1, style2 'appendToPageTitle' => 'blogName', // blogName, custom 'appendToPageTitleCustom' => '', 'sidebarDisplay' => 'right', // right, left, none 'sidebarWidth' => 'normal', // small, normal, large 'sidebar_showDefault' => true, 'sidebar_showRSSButton' => true, 'sidebar_showTwitterButton' => false, 'sidebar_twitterURL' => '', 'sidebar_showFacebookButton' => false, 'sidebar_facebookURL' => '', 'sidebar_displayButtonTexts' => false, 'enableIE6optimization' => true, 'postsShowAuthor' => true, 'postsShowTime' => false, 'posts_showTopPostLinks' => false, 'posts_showBottomPostLinks' => true, 'pages_showInfoBar' => false, 'customCSS' => false, 'customCSS_input' => '', 'customCSS_useFilesystem' => false, 'pagination' => true, 'pagination_pageRange' => 2, //the number of page buttons to show before and after the current page button 'pagination_pageAnchors' => 1, //the number of buttons to always show at the beginning and end of the pagination bar 'pagination_pageGap' => 1 //the number of pages in a gap before an ellipsis is added ); $optionsSaved = false; function arjuna_create_options() { // Default values $options = $GLOBALS['_arjunaDefaultOptions']; // Overridden values $DBOptions = get_option('arjuna_options'); if ( !is_array($DBOptions) ) $DBOptions = array(); // Merge // Change since Arjuna 1.2: Values that are not used anymore will be deleted foreach ( $options as $key => $value ) if ( isset($DBOptions[$key]) ) $options[$key] = $DBOptions[$key]; update_option('arjuna_options', $options); return $options; } function arjuna_get_options() { static $return = false; if($return !== false) return $return; $options = get_option('arjuna_options'); if(!empty($options) && count($options) == count($GLOBALS['_arjunaDefaultOptions'])) $return = $options; else $return = $GLOBALS['_arjunaDefaultOptions']; return $return; } function arjuna_add_theme_options() { global $optionsSaved; if(isset($_POST['arjuna_save_options'])) { $options = arjuna_create_options(); //Menu 1 dropdown $validOptions = array('1', '2', '3'); if ( in_array($_POST['headerMenu1_dropdown'], $validOptions) ) $options['headerMenu1_dropdown'] = $_POST['headerMenu1_dropdown']; else $options['headerMenu1_dropdown'] = '3'; //Menu 1 display $validOptions = array('pages', 'categories'); if ( in_array($_POST['headerMenu1_display'], $validOptions) ) $options['headerMenu1_display'] = $_POST['headerMenu1_display']; else $options['headerMenu1_display'] = 'pages'; if ($options['headerMenu1_display']=='pages') { //Menu 1 sorting for PAGES $validOptions = array('post_title', 'ID', 'post_name', 'menu_order'); if ( in_array($_POST['headerMenu1_sortBy_pages'], $validOptions) ) $options['headerMenu1_sortBy'] = $_POST['headerMenu1_sortBy_pages']; else $options['headerMenu1_sortBy'] = $validOptions[0]; //Menu 1 sorting order $validOptions = array('asc', 'desc'); if ( in_array($_POST['headerMenu1_sortOrder_pages'], $validOptions) ) $options['headerMenu1_sortOrder'] = $_POST['headerMenu1_sortOrder_pages']; else $options['headerMenu1_sortOrder'] = $validOptions[0]; } elseif ($options['headerMenu1_display']=='categories') { //Menu 1 sorting for CATEGORIES $validOptions = array('name', 'ID', 'count', 'slug'); if ( in_array($_POST['headerMenu1_sortBy_categories'], $validOptions) ) $options['headerMenu1_sortBy'] = $_POST['headerMenu1_sortBy_categories']; else $options['headerMenu1_sortBy'] = $validOptions[0]; //Menu 1 sorting order $validOptions = array('asc', 'desc'); if ( in_array($_POST['headerMenu1_sortOrder_categories'], $validOptions) ) $options['headerMenu1_sortOrder'] = $_POST['headerMenu1_sortOrder_categories']; else $options['headerMenu1_sortOrder'] = $validOptions[0]; } //Menu 1 show if ($_POST['headerMenu1_show']) $options['headerMenu1_show'] = true; else $options['headerMenu1_show'] = false; //Menu 1 alignment $validOptions = array('right', 'left'); if ( in_array($_POST['headerMenu1_alignment'], $validOptions) ) $options['headerMenu1_alignment'] = $_POST['headerMenu1_alignment']; else $options['headerMenu1_alignment'] = $validOptions[0]; // Menu 1 - Disable Parent Page Links in if ($_POST['headerMenu1_disableParentPageLink']) $options['headerMenu1_disableParentPageLink'] = true; else $options['headerMenu1_disableParentPageLink'] = false; // Menu 1 - Exclude items if($_POST['headerMenu1_exclude_categories']) { $options['headerMenu1_exclude_categories'] = implode(',', $_POST['headerMenu1_exclude_categories']); } else $options['headerMenu1_exclude_categories'] = ''; if($_POST['headerMenu1_exclude_pages']) { $options['headerMenu1_exclude_pages'] = implode(',', $_POST['headerMenu1_exclude_pages']); } else $options['headerMenu1_exclude_pages'] = ''; //Menu 2 dropdown $validOptions = array('1', '2', '3'); if ( in_array($_POST['headerMenu2_dropdown'], $validOptions) ) $options['headerMenu2_dropdown'] = $_POST['headerMenu2_dropdown']; else $options['headerMenu2_dropdown'] = '3'; //Menu 2 display $validOptions = array('pages', 'categories'); if ( in_array($_POST['headerMenu2_display'], $validOptions) ) $options['headerMenu2_display'] = $_POST['headerMenu2_display']; else $options['headerMenu2_display'] = 'pages'; if ($options['headerMenu2_display']=='pages') { //Menu 2 sorting for PAGES $validOptions = array('post_title', 'ID', 'post_name', 'menu_order'); if ( in_array($_POST['headerMenu2_sortBy_pages'], $validOptions) ) $options['headerMenu2_sortBy'] = $_POST['headerMenu2_sortBy_pages']; else $options['headerMenu2_sortBy'] = $validOptions[0]; //Menu 2 sorting order $validOptions = array('asc', 'desc'); if ( in_array($_POST['headerMenu2_sortOrder_pages'], $validOptions) ) $options['headerMenu2_sortOrder'] = $_POST['headerMenu2_sortOrder_pages']; else $options['headerMenu2_sortOrder'] = $validOptions[0]; } elseif ($options['headerMenu2_display']=='categories') { //Menu 2 sorting for CATEGORIES $validOptions = array('name', 'ID', 'count', 'slug'); if ( in_array($_POST['headerMenu2_sortBy_categories'], $validOptions) ) $options['headerMenu2_sortBy'] = $_POST['headerMenu2_sortBy_categories']; else $options['headerMenu2_sortBy'] = $validOptions[0]; //Menu 2 sorting order $validOptions = array('asc', 'desc'); if ( in_array($_POST['headerMenu2_sortOrder_categories'], $validOptions) ) $options['headerMenu2_sortOrder'] = $_POST['headerMenu2_sortOrder_categories']; else $options['headerMenu2_sortOrder'] = $validOptions[0]; } //Menu 2 Home Icon if ($_POST['headerMenu2_displayHomeButton']) $options['headerMenu2_displayHomeButton'] = true; else $options['headerMenu2_displayHomeButton'] = false; //Menu 2 Home Icon if ($_POST['headerMenu2_displaySeparators']) $options['headerMenu2_displaySeparators'] = true; else $options['headerMenu2_displaySeparators'] = false; // Menu 2 - Disable Parent Page Links in if ($_POST['headerMenu2_disableParentPageLink']) $options['headerMenu2_disableParentPageLink'] = true; else $options['headerMenu2_disableParentPageLink'] = false; // Menu 2 - Exclude items if($_POST['headerMenu2_exclude_categories']) { $options['headerMenu2_exclude_categories'] = implode(',', $_POST['headerMenu2_exclude_categories']); } else $options['headerMenu2_exclude_categories'] = ''; if($_POST['headerMenu2_exclude_pages']) { $options['headerMenu2_exclude_pages'] = implode(',', $_POST['headerMenu2_exclude_pages']); } else $options['headerMenu2_exclude_pages'] = ''; //Header Image $validOptions = array('lightBlue', 'darkBlue', 'khaki', 'seaGreen'); if ( in_array($_POST['headerImage'], $validOptions) ) $options['headerImage'] = $_POST['headerImage']; else $options['headerImage'] = $validOptions[0]; //Comment display $validOptions = array('alt', 'left', 'right'); if ( in_array($_POST['commentDisplay'], $validOptions) ) $options['commentDisplay'] = $_POST['commentDisplay']; else $options['commentDisplay'] = 'alt'; // Comment display if ($_POST['comments_hideWhenDisabledOnPages']) $options['comments_hideWhenDisabledOnPages'] = true; else $options['comments_hideWhenDisabledOnPages'] = false; if ($_POST['comments_hideWhenDisabledOnPosts']) $options['comments_hideWhenDisabledOnPosts'] = true; else $options['comments_hideWhenDisabledOnPosts'] = false; //Footer style $validOptions = array('style1', 'style2'); if ( in_array($_POST['footerStyle'], $validOptions) ) $options['footerStyle'] = $_POST['footerStyle']; else $options['footerStyle'] = 'style1'; //Comment date format $validOptions = array('timePassed', 'date'); if ( in_array($_POST['commentDateFormat'], $validOptions) ) $options['commentDateFormat'] = $_POST['commentDateFormat']; else $options['commentDateFormat'] = 'timePassed'; //Append to page title $validOptions = array('blogName', 'custom'); if ( in_array($_POST['appendToPageTitle'], $validOptions) ) $options['appendToPageTitle'] = $_POST['appendToPageTitle']; else $options['appendToPageTitle'] = 'blogName'; if ($_POST['appendToPageTitle']=='custom') { $options['appendToPageTitleCustom'] = $_POST['appendToPageTitleCustom']; } //Sidebar display $validOptions = array('right', 'left', 'none'); if ( in_array($_POST['sidebarDisplay'], $validOptions) ) $options['sidebarDisplay'] = $_POST['sidebarDisplay']; else $options['sidebarDisplay'] = $validOptions[0]; // Whether or not to show the default bars (if no widget bars are defined) if ($_POST['sidebar_showDefault']) $options['sidebar_showDefault'] = true; else $options['sidebar_showDefault'] = false; // Sidebar: RSS Button if ($_POST['sidebar_showRSSButton']) $options['sidebar_showRSSButton'] = true; else $options['sidebar_showRSSButton'] = false; // Sidebar: Twitter Button if ($_POST['sidebar_showTwitterButton']) { $twitterURL = trim($_POST['sidebar_twitterURL']); $options['sidebar_showTwitterButton'] = true; if ( !preg_match('/twitter\.com/i', $twitterURL) ) { if(!preg_match('/\.com/i', $twitterURL)) { //Add the twitter host name $twitterURL = "http://twitter.com/" . $twitterURL; } else { $options['sidebar_showTwitterButton'] = false; $twitterURL = ""; } } elseif ( !preg_match('/http[s]?\:\/\//i', $twitterURL) ) { $twitterURL = "http://" . $twitterURL; } elseif ( empty($twitterURL) ) { $options['sidebar_showTwitterButton'] = false; } $options['sidebar_twitterURL'] = $twitterURL; } else $options['sidebar_showTwitterButton'] = false; // Sidebar: Facebook Button if ($_POST['sidebar_showFacebookButton']) { $facebookURL = trim($_POST['sidebar_facebookURL']); $options['sidebar_showFacebookButton'] = true; if ( !preg_match('/facebook\./i', $facebookURL) ) { $twitterURL = "http://facebook.com/" . $facebookURL; } elseif ( !preg_match('/http[s]?\:\/\//i', $facebookURL) ) { $facebookURL = "http://" . $facebookURL; } elseif ( empty($facebookURL) ) { $options['sidebar_showFacebookButton'] = false; } $options['sidebar_facebookURL'] = $facebookURL; } else $options['sidebar_showFacebookButton'] = false; if ($_POST['sidebar_displayButtonTexts']) $options['sidebar_displayButtonTexts'] = true; else $options['sidebar_displayButtonTexts'] = false; //Sidebar Width $validOptions = array('normal', 'small', 'large'); if ( in_array($_POST['sidebarWidth'], $validOptions) ) $options['sidebarWidth'] = $_POST['sidebarWidth']; else $options['sidebarWidth'] = $validOptions[0]; // IE Optimization if ($_POST['enableIE6optimization']) $options['enableIE6optimization'] = true; else $options['enableIE6optimization'] = false; // Posts, Show Author if ($_POST['postsShowAuthor']) $options['postsShowAuthor'] = true; else $options['postsShowAuthor'] = false; // Posts, Show Time if ($_POST['postsShowTime']) $options['postsShowTime'] = true; else $options['postsShowTime'] = false; if ($_POST['pages_showInfoBar']) $options['pages_showInfoBar'] = true; else $options['pages_showInfoBar'] = false; //Navigation links to previous and next posts if ($_POST['posts_showTopPostLinks']) $options['posts_showTopPostLinks'] = true; else $options['posts_showTopPostLinks'] = false; if ($_POST['posts_showBottomPostLinks']) $options['posts_showBottomPostLinks'] = true; else $options['posts_showBottomPostLinks'] = false; if ($_POST['pagination']=='1') { $options['pagination'] = true; $validOptions = array(1,2,3,4,5); if ( in_array($_POST['pagination_pageRange'], $validOptions) ) $options['pagination_pageRange'] = $_POST['pagination_pageRange']; else $options['pagination_pageRange'] = 3; $validOptions = array(1,2,3); if ( in_array($_POST['pagination_pageAnchors'], $validOptions) ) $options['pagination_pageAnchors'] = $_POST['pagination_pageAnchors']; else $options['pagination_pageAnchors'] = 1; $validOptions = array(1,2,3); if ( in_array($_POST['pagination_pageGap'], $validOptions) ) $options['pagination_pageGap'] = $_POST['pagination_pageGap']; else $options['pagination_pageGap'] = 1; } else $options['pagination'] = false; //Custom CSS if ($_POST['customCSS']) { if (trim($_POST['customCSS_input'])) { $options['customCSS'] = true; $input = trim($_POST['customCSS_input']); if (is_writable(dirname(__FILE__).'/')) { //create a new CSS file $handle = fopen(dirname(__FILE__).'/user-style.css', 'w'); fwrite($handle, $input); fclose($handle); $options['customCSS_useFilesystem'] = true; } else { $options['customCSS_useFilesystem'] = false; $options['customCSS_input'] = $input; } } } else $options['customCSS'] = false; update_option('arjuna_options', $options); $optionsSaved = true; } add_theme_page(__('Arjuna Options', 'Arjuna'), __('Arjuna Options', 'Arjuna'), 'edit_themes', basename(__FILE__), 'arjuna_add_theme_page'); } function arjuna_add_theme_page () { global $optionsSaved; $options = arjuna_get_options(); if ( $optionsSaved ) echo '
'.__('The Arjuna options have been saved.', 'Arjuna').'