id == 'theme-editor'): ?>

'.__("User CSS", ATOM).'', ''.__("Custom Functions", ATOM).''); ?>

id); if($page == 'toplevel') return ATOM; elseif(strstr($page, ATOM.'-')) return str_replace(ATOM.'-', '', $page); else return false; } /** * Include admin/interface.css in the admin styles * * @since 1.0 */ function atom_settings_css($dir){ wp_register_style(ATOM.'-settings', THEME_URL. '/admin/interface.css'); wp_enqueue_style(ATOM.'-settings'); } /** * Include js * * @since 1.0 */ function atom_settings_js(){ global $current_screen; $page = atom_get_current_settings_page(); if($page || $current_screen->id == 'widgets'): wp_enqueue_script('jquery'); wp_enqueue_script('interface', THEME_URL.'/c.php?file=admin/interface.js'); wp_enqueue_script('post-message', THEME_URL.'/c.php?file=admin/pm.js'); if($page == 'advanced' || $page == 'css' || $page == 'content'): wp_enqueue_script('codemirror', THEME_URL.'/admin/codemirror/js/codemirror.js'); endif; endif; } /** * Load the site preview iframe with ajax (faster access to theme settings) * * @since 1.0 */ function atom_site_preview() { check_ajax_referer("theme-settings"); ?> id == 'widgets' || $current_screen->id == 'edit-post'): // only load if we're one of the theme settings pages $current_settings = atom_get_options(); $nonce = wp_create_nonce('theme-settings'); ?> false, "action" => 'wp_handle_upload', "mimes" => array( 'jpg|jpeg|jpe' => 'image/jpeg', 'png' => 'image/png' ))); if(!empty($uploaded_file['error'])): $error = sprintf(__('Upload Error: %s', ATOM), $uploaded_file['error']); else: $imageinfo = getimagesize($uploaded_file['file']); list($width, $height) = $imageinfo; $url = $uploaded_file['url']; endif; elseif($_POST['type'] == 'reset_upload'): $options[$option_name] = ''; endif; echo json_encode(array('error' => $error, 'url' => $url)); exit(); } /** * Theme settings update function * * @since 1.0 */ function atom_save_options() { check_admin_referer('theme-settings'); $error = false; // check permissions if(!current_user_can('edit_theme_options')) wp_die(__('You are not authorised to perform this operation.', ATOM)); $options = atom_get_options(); // change options foreach (atom_default_settings() as $key => $value) if(isset($_POST[$key]) && atom_is_option_enabled($key)) $options[$key] = current_user_can('unfiltered_html') ? stripslashes((string)$_POST[$key]) : stripslashes(wp_filter_post_kses(addslashes((string)$_POST[$key]))); atom_update_options($options); // reset? (super-admins only) if (isset($_POST['reset']) && current_user_can('edit_themes')) atom_setup_options(); // import? (super-admins only) // @todo: match $settings fields with the ones from default settings if (isset($_POST['import']) && current_user_can('edit_themes')) if(is_array($settings = unserialize(urldecode($_POST['import_data'])))) atom_update_options($settings); else $error = 1; if ($error) wp_redirect(admin_url('admin.php?page='.strip_tags($_POST['current_page']).'&error='.$error)); else wp_redirect(admin_url('admin.php?page='.strip_tags($_POST['current_page']).'&updated=true')); } /** * Latest News RSS Feed from digitalnature.ro (AJAX) * * @since 1.0 */ function atom_latest_news() { check_ajax_referer("theme-settings"); wp_widget_rss_output('http://digitalnature.ro/feed', array('show_author' => 0, 'show_date' => 1, 'show_summary' => 1, 'items' => 5)); exit(); } /** * Retrieve external theme styles (.css files from the 'makemesexy' folder) * * @since 1.0 * * @return array|bool A array containing each file meta info, or false if not files found. */ function atom_get_schemes(){ $scheme_headers = array( 'name' => 'Style Name', 'color' => 'Color', 'description' => 'Description', 'author' => 'Author', 'version' => 'Version' ); $schemes = array(); foreach (glob(TEMPLATEPATH."/makemesexy/*.css") as $filename) if($meta = get_file_data($filename, $scheme_headers)): $meta['file'] = basename($filename); $schemes[] = $meta; endif; return (!empty($schemes) ? $schemes : array()); } /** * Check for a new theme version on Wordpress.org Theme Directory * from themes.php * * @since 1.0 */ function atom_check_update(){ static $themes_update; $theme = get_theme(THEME_FULL_NAME); // need to test this if (!isset($themes_update)) $themes_update = get_transient('update_themes'); if (is_object($theme) && isset($theme->stylesheet)) $stylesheet = $theme->stylesheet; elseif (is_array($theme) && isset($theme['Stylesheet'])) $stylesheet = $theme['Stylesheet']; else return; if (isset($themes_update->response[$stylesheet])): $update = $themes_update->response[$stylesheet]; $theme_name = is_object($theme) ? $theme->name : (is_array($theme) ? $theme['Name'] : ''); $details_url = add_query_arg(array('TB_iframe' => 'true', 'width' => 1024, 'height' => 800), $update['url']); $update_url = wp_nonce_url('update.php?action=upgrade-theme&theme='.urlencode($stylesheet), 'upgrade-theme_'.$stylesheet); echo '

'; if (!current_user_can('update_themes') || empty($update->package)) printf(__('There is a new version of %1$s available. View version %3$s Details.'), $theme_name, $details_url, $update['new_version']); else printf(__('There is a new version of %1$s available. View version %3$s Details or upgrade automatically.'), $theme_name, $details_url, $update['new_version'], $update_url); echo '

'; endif; } /** * The theme settings pages * * Note: * Because non-checked input field values are not sent trough $_POST, all options that have checkboxes need to have * * before the checkbox option. This trick supposes the inputs are always processed sequentially, * so the hidden input value is sent (0) if the checkbox is not checked. * * @since 1.0 */ function atom_settings() { global $is_IE; $errors = array( 1 => __("Import failed. Invalid settings. ", ATOM) ); // only allow users who can at least switch themes to view these pages if(!current_user_can('edit_theme_options')) wp_die(__('You are not authorised to perform this operation.', ATOM)); ?>

'.__('View site', ATOM).''); ?>



" onclick="if(confirm('')) return true; else return false;" /> " onclick="if(confirm('')) return true; else return false;" />

"> "> "> "> "> "> " />

'); ?>

" />

'.$scheme['name'].''; endforeach; ?> "> " />

" />

" width="16" height="16" />







/>

" />

'; echo ''; echo ''; endif; } /** * Process the featured post actions (AJAX) * * @since 1.0 * @todo Add Gallery Feature (Image/Attachment sources beside posts) * @todo Add User Role for managing Featured Posts */ function atom_process_featured(){ check_ajax_referer("theme-settings"); if(!current_user_can('edit_posts')) return false; // read submitted information $id = intval($_GET['id']); $is_on = $_GET['isOn']; $featured_posts = get_option('featured_posts') ? explode(',', get_option('featured_posts')) : array(); // add to array if not on and not currently in the array if (!$is_on && ! in_array($id, $featured_posts)) array_push($featured_posts, $id); rsort($featured_posts); $new_posts = ''; // if not the same as selected, add to the featured str foreach ($featured_posts as $post_id) if (!($is_on && $post_id == $id)) $new_posts .= $post_id.','; if($new_posts) $new_posts = substr($new_posts, 0, -1); update_option('featured_posts', $new_posts); // reverse classes exit($is_on ? 'off' : 'on'); } ?>