function arras_admin_save() { global $arras_options, $arras_image_sizes, $notices; check_admin_referer('arras-admin'); if (isset($_REQUEST['arras-tools-import']) && $_REQUEST['arras-tools-import'] != '') { $new_arras_options = maybe_unserialize(json_decode($_REQUEST['arras-tools-import'])); if (is_a($new_arras_options, 'Options')) { $arras_options = $new_arras_options; arras_update_options(); $notices = '<div class="updated fade"><p>' . __('Your settings have been successfully imported.', 'arras') . '</p></div>'; } } else { if (!isset($_POST['arras-delete-logo'])) { if ($_FILES['arras-logo']['error'] != 4) { $overrides = array('test_form' => false); $file = wp_handle_upload($_FILES['arras-logo'], $overrides); if (isset($file['error'])) { die($file['error']); } $url = $file['url']; $type = $file['type']; $file = $file['file']; $filename = basename($file); // Construct the object array $object = array('post_title' => $filename, 'post_content' => $url, 'post_mime_type' => $type, 'guid' => $url); // Save the data $arras_options->logo = wp_insert_attachment($object, $file); // Force generate the logo thumbnail $fullsizepath = get_attached_file($arras_options->logo); wp_update_attachment_metadata($arras_options->logo, wp_generate_attachment_metadata($arras_options->logo, $fullsizepath)); } } else { $arras_options->logo = ''; } // Hack! $arras_options->layout = (string) $_POST['arras-layout-col']; $arras_image_sizes = array(); arras_add_default_thumbnails(); $arras_custom_image_sizes = array(); foreach ($arras_image_sizes as $id => $args) { if (isset($_POST['arras-reset-thumbs']) && $_POST['arras-reset-thumbs']) { $arras_custom_image_sizes[$id]['w'] = $arras_image_sizes[$id]['dw']; $arras_custom_image_sizes[$id]['h'] = $arras_image_sizes[$id]['dh']; } else { $arras_custom_image_sizes[$id]['w'] = (int) $_POST['arras-' . $id . '-w']; $arras_custom_image_sizes[$id]['h'] = (int) $_POST['arras-' . $id . '-h']; } } $arras_options->custom_thumbs = $arras_custom_image_sizes; $arras_options->save_options(); arras_update_options(); do_action('arras_admin_save'); $notices = '<div class="updated fade"><p>' . __('Your settings have been saved to the database.', 'arras') . '</p></div>'; } }
function arras_setup() { /* Load theme options (to be revamped) */ require_once ARRAS_LIB . '/admin/options.php'; require_once ARRAS_LIB . '/admin/templates/functions.php'; arras_flush_options(); /* Load theme library files */ require_once ARRAS_LIB . '/actions.php'; require_once ARRAS_LIB . '/deprecated.php'; require_once ARRAS_LIB . '/filters.php'; require_once ARRAS_LIB . '/tapestries.php'; require_once ARRAS_LIB . '/template.php'; require_once ARRAS_LIB . '/thumbnails.php'; require_once ARRAS_LIB . '/styles.php'; require_once ARRAS_LIB . '/slideshow.php'; require_once ARRAS_LIB . '/widgets.php'; if (is_admin()) { require_once ARRAS_LIB . '/admin/admin.php'; } require_once ARRAS_LIB . '/admin/background.php'; /* Post meta fields */ define('ARRAS_REVIEW_SCORE', 'score'); define('ARRAS_REVIEW_PROS', 'pros'); define('ARRAS_REVIEW_CONS', 'cons'); define('ARRAS_CUSTOM_FIELDS', false); /* Langauge support */ load_theme_textdomain('arras', TEMPLATEPATH . '/language'); $locale = get_locale(); $locale_file = TEMPLATEPATH . "/languages/{$locale}.php"; if (is_readable($locale_file)) { require_once $locale_file; } /* Theme support */ add_theme_support('post-thumbnails'); add_theme_support('nav-menus'); add_theme_support('automatic-feed-links'); /* Menus locations */ register_nav_menus(array('main-menu' => __('Main Menu', 'arras'), 'top-menu' => __('Top Menu', 'arras'))); /* Thumbnail sizes */ arras_add_default_thumbnails(); /* Register sidebars */ arras_add_sidebars(); /* Custom layouts & styles */ if (!defined('ARRAS_INHERIT_STYLES') || ARRAS_INHERIT_STYLES == true) { add_action('arras_custom_styles', 'arras_layout_styles'); } if (!defined('ARRAS_INHERIT_LAYOUT') || ARRAS_INHERIT_LAYOUT == true) { // Alternate Styles & Layouts register_alternate_layout('1c-fixed', __('1 Column Layout (No Sidebars)', 'arras')); register_alternate_layout('2c-r-fixed', __('2 Column Layout (Right Sidebar)', 'arras')); register_alternate_layout('2c-l-fixed', __('2 Column Layout (Left Sidebar)', 'arras')); register_alternate_layout('3c-fixed', __('3 Column Layout (Left & Right Sidebars)', 'arras')); register_alternate_layout('3c-r-fixed', __('3 Column Layout (Right Sidebars)', 'arras')); register_style_dir(TEMPLATEPATH . '/css/styles/'); } /* Header actions */ remove_action('wp_head', 'pagenavi_css'); add_action('arras_head', 'arras_override_styles'); add_action('arras_custom_styles', 'arras_add_custom_logo'); add_action('arras_custom_styles', 'arras_constrain_footer_sidebars'); add_action('arras_custom_styles', 'arras_add_custom_background'); add_action('arras_beside_nav', 'arras_social_nav'); add_action('wp_head', 'arras_load_styles', 1); add_action('wp_head', 'arras_head'); add_action('wp_head', 'arras_add_facebook_share_meta'); add_action('wp_head', 'arras_add_header_js'); add_action('wp_footer', 'arras_add_footer_js'); /* Filters */ add_filter('arras_postheader', 'arras_post_taxonomies'); add_filter('gallery_style', 'remove_gallery_css'); if (defined('ARRAS_CUSTOM_FIELDS') && ARRAS_CUSTOM_FIELDS == true) { add_filter('arras_postheader', 'arras_postmeta'); } /* Admin actions */ if (is_admin()) { add_action('admin_menu', 'arras_addmenu'); } /* Max image size */ $max_image_size = arras_get_single_thumbs_size(); $content_width = $max_image_size[0]; /* For child themes overrides */ do_action('arras_setup'); // print_r($arras_options); }
<?php // Redirect to theme options after activation if (is_admin() && isset($_GET['activated']) && $pagenow == 'themes.php') { header('Location: ' . admin_url() . 'admin.php?page=arras-options'); } // Add Theme Support add_theme_support('post-thumbnails'); add_theme_support('nav-menus'); if (function_exists('register_nav_menus')) { register_nav_menus(array('main-menu' => __('Main Menu', 'arras'), 'top-menu' => __('Top Menu', 'arras'))); } // Add various default thumbnails used by main theme arras_add_default_thumbnails(); // Remove existing actions remove_action('wp_head', 'pagenavi_css'); // Register Sidebars register_sidebar(array('name' => 'Etusivun sivupalkki', 'before_widget' => '<li id="%1$s" class="widgetcontainer clearfix">', 'after_widget' => '</li>', 'before_title' => '<h5 class="widgettitle">', 'after_title' => '</h5>')); //Otetaas secondary sidebar käytöstä pois, ettei päivittäjät turhaan ihmettele et mikä se on /*register_sidebar( array( 'name' => 'Secondary Sidebar #1', 'before_widget' => '<li id="%1$s" class="widgetcontainer clearfix">', 'after_widget' => '</li>', 'before_title' => '<h5 class="widgettitle">', 'after_title' => '</h5>' ) );*/ /*register_sidebar( array( 'name' => 'Bottom Content #1', 'before_widget' => '<li id="%1$s" class="widgetcontainer clearfix">', 'after_widget' => '</li>', 'before_title' => '<h5 class="widgettitle">',