checked)) return $checked_data; $theme_base = basename(dirname(dirname(__FILE__))); $request = array( 'slug' => $theme_base, 'version' => $checked_data->checked[$theme_base.'/'.$theme_base.'.php'] ); // Start checking for an update $send_for_check = array( 'body' => array( 'action' => 'theme_update', 'request' => serialize($request), 'api-key' => md5(get_bloginfo('url')) // @todo: add username/password check for commercial themes ), 'user-agent' => 'WordPress/'.$wp_version.'; '.get_bloginfo('url') ); $raw_response = wp_remote_post(THEME_UPDATE_URL, $send_for_check); if (!is_wp_error($raw_response) && ($raw_response['response']['code'] == 200)) $response = unserialize($raw_response['body']); // Feed the update data into WP updater if (!empty($response)) $checked_data->response[$theme_base] = $response; return $checked_data; } /** * Get the new version update details * * @since 1.2 */ function atom_update_available(&$update_details){ static $themes_update; $theme = get_theme(THEME_NAME); // need to test this if (!isset($themes_update)) $themes_update = get_site_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 false; if (isset($themes_update->response[$stylesheet])): $update = $themes_update->response[$stylesheet]; $update_details['theme_name'] = is_object($theme) ? $theme->name : (is_array($theme) ? $theme['Name'] : ''); if(!current_user_can('update_themes') || empty($update->package)) $update_details['update_url'] = wp_nonce_url('update.php?action=upgrade-theme&theme='.urlencode($stylesheet), 'upgrade-theme_'.$stylesheet); $update_details['new_version'] = $update['new_version']; $update_details['details_url'] = add_query_arg(array('TB_iframe' => 'true', 'width' => 1024, 'height' => 800), $update['url']); return true; endif; return false; } /** * Displays a warning message telling the user he shouldn't edit the theme files :) * * @since 1.0 */ function atom_editor_warning(){ global $current_screen; if($current_screen->id == 'theme-editor'): ?>

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

id, ATOM)) return false; // get the current settings page; wp should really provide a cleaner page title :( list($junk, $page) = explode("_page_", $current_screen->id); if($page == ATOM) return ATOM; else return str_replace(ATOM.'_', '', $page); } /** * Include admin/interface.css in the admin styles * * @since 1.0 */ function atom_settings_css($dir){ wp_enqueue_style(ATOM.'-settings', THEME_URL.'/core/admin/interface.css'); } /** * Include js * * @since 1.0 */ function atom_settings_js(){ global $current_screen; $page = atom_get_current_settings_page(); // only load if we're one of the theme settings pages -- @todo: need to improve this if($page || in_array($current_screen->id, array('widgets', 'edit-post', 'upload'))): wp_enqueue_script('jquery'); wp_enqueue_script('interface', THEME_URL.'/core/admin/interface.js'); if(in_array($page, array('advanced', 'css', 'content'))) wp_enqueue_script('codemirror', THEME_URL.'/core/admin/codemirror/js/codemirror.js'); wp_enqueue_script('post-message', THEME_URL.'/core/admin/pm.js'); 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, array('widgets', 'edit-post', 'upload'))): $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(_a('Upload Error: %s'), $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)); die(); } /** * Recursively sanitizes theme options (input) * * @since 1.3 * * @param mixed $option * * @return mixed */ function atom_sanitize_option($option){ if(is_array($option)): // could be replaced with array_walk_recursive() in PHP > 5 foreach($option as $key => $value) $option[$key] = atom_sanitize_option($value); return $option; endif; if(!current_user_can('unfiltered_html')) return stripslashes(wp_filter_post_kses((string)$option)); else return stripslashes((string)$option); } /** * 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(_a('You are not authorised to perform this operation.')); $options = atom_get_options(); // only super admins if(!current_user_can('edit_themes') && isset($_POST['functions'])) unset($_POST['functions']); // change options foreach (atom_default_settings() as $key => $value) if(isset($_POST[$key]) && atom_is_option_enabled($key)) $options[$key] = atom_sanitize_option($_POST[$key]); // ads page & no ad blocks? need to improve this... if($_POST['current_page'] == ATOM.'_ads' && !isset($_POST['advertisments'])) $options['advertisments'] = array(); atom_update_options($options); // reset? (super-admins only) if(isset($_POST['reset']) && current_user_can('edit_themes')) atom_setup_options(); if($error) wp_redirect(admin_url('admin.php?page='.esc_attr($_POST['current_page']).'&error='.$error)); else wp_redirect(admin_url('admin.php?page='.esc_attr($_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)); die(); } /** * Retrieve external theme styles (.css files from the styles 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(THEME_STYLES_PATH."/*.css") as $filename) if($meta = get_file_data($filename, $scheme_headers)): $meta['file'] = basename($filename); $schemes[] = $meta; endif; return (!empty($schemes) ? $schemes : array()); } function atom_create_ad(){ check_ajax_referer("theme-settings"); atom_advertisment_form(strip_tags($_GET['key'])); die(); } /** * 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; // only allow users who can at least switch themes to view these pages if(!current_user_can('edit_theme_options')) wp_die(_a('You are not authorised to perform this operation.')); $errors = array( 1 => _a("Import failed. Invalid settings. ") ); $parent_theme = get_theme_data(TEMPLATEPATH.'/style.css'); $update_details = array(); if(atom_update_available($update_details) && isset($update_details['update_url'])) $update_link = "("._a("Update").")"; ?>

There is a new version of %1$s available. View %1$s %3$s details or notify the site administrator.'), $update_details['theme_name'], $update_details['details_url'], $update_details['new_version']); else printf(_a('There is a new version of %1$s available. There is a new version of %1$s available. View %1$s %3$s details or upgrade automatically.'), $update_details['theme_name'], $update_details['details_url'], $update_details['new_version'], $update_details['update_url']); ?>

  • '.ATOM_VERSION.''); ?>
  • '.THEME_VERSION.''); ?>

    import_from_file(TEMPLATEPATH.'/lang/'.$lang.'.mo'); //print_r($mo->headers); if(empty($mo->headers)) continue; $translator = preg_replace('/(?headers['Last-Translator']))); ?>
  • headers['X-Poedit-Language']), ''.$translator.'', ''.strip_tags($mo->headers['Project-Id-Version']).''); ?>

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

Note: Import works only in the official release of the theme (from the project page). This is because the WordPress Theme Directory is apparently run by amateurs :(

digitalnature.ro'); ?>

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

'); ?>

" />

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

" />

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


'); ?>



" />

$ad) atom_advertisment_form($key, $ad); ?>

" />

"page=home&place=after_post&n=1&to=1", 'html' => "
\n \"Test\n
")){ $data = array(); parse_str($ad['atts'], &$data); $data['n'] = min(max(intval($data['n']), 1), atom_get_options('posts_per_page')); $ad_context = atom_ad_context(); $wp_roles = new WP_Roles(); ?>

" followAdRules />

'; echo ''; echo ''; endif; } /** * Setup featured column content for Media Library (upload.php) page * * @since 1.3 * * @param string $column_name Current Column * @param string $id Post ID */ function atom_setup_media_column_content($column_name, $id){ if ($column_name == 'featured' && strpos(get_post_mime_type($id), 'image/') !== false): // images only $posts = explode(',', get_option('featured_gallery')); echo ''; echo ''; endif; } /** * Process the featured content actions (AJAX) * * @since 1.0 * @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 = (bool)$_GET['isOn']; $what = ($_GET['what'] == 'post') ? 'featured_posts' : 'featured_gallery'; $featured = atom_get_options($what) ? explode(',', atom_get_options($what)) : array(); // add to array if not on and not currently in the array if (!$is_on && ! in_array($id, $featured)) array_push($featured, $id); rsort($featured); $new_entries = ''; // if not the same as selected, add to the featured str foreach ($featured as $entry) if(!($is_on && $entry == $id)) $new_entries .= "{$entry},"; if($new_entries) $new_entries = substr($new_entries, 0, -1); update_option($what, $new_entries); atom($what == 'post' ? 'feature_posts' : 'feature_galleries'); // reverse classes exit($is_on ? 'off' : 'on'); } ?>