comicpress = $comicpress; } function setup_admin_interface() { add_theme_page(__("ComicPress Core", 'comicpress'), __('ComicPress Core', 'comicpress'), 'edit_themes', basename(__FILE__), array(&$this, 'render_admin')); if (isset($_REQUEST['post'])) { add_meta_box("comic-image-ordering", __("Comic Image Ordering", 'comicpress'), array(&$this, 'render_comic_image_ordering'), "post", "normal", "low"); } } function show_comic($override_post) { global $post; $post_to_use = (is_null($override_post)) ? $this->comicpress->get_last_comic() : $post; $comic_post = new ComicPressComicPost($post_to_use, &$this); $comic_post->display_comics(); } function setup_comic_metadata_buttons($form_fields, $post) { $comic_image_types = array( 'none' => __('Not a comic', 'comicpress'), 'comic' => __('Comic', 'comicpress'), 'rss' => __('RSS', 'comicpress'), 'archive' => __('Archive', 'comicpress'), ); $current_type = get_post_meta($post->ID, 'comic_image_type', true); $field_html_lines = array(); $field_html_lines[] = ''; foreach ($comic_image_types as $field => $label) { $field_html_lines[] = ''; } $form_fields['comic_image_type'] = array( 'label' => __("Comic Image Type", 'comicpress'), 'input' => 'html', 'html' => '
' . implode("\n", $field_html_lines) . '
' ); return $form_fields; } function render_admin() { $nonce = wp_create_nonce('comicpress'); $root_categories = $this->get_root_categories(); include(dirname(__FILE__) . '/partials/options-admin.inc'); } function render_comic_image_ordering() { echo "made it"; } function get_root_categories() { $root_categories = array(); foreach (get_all_category_ids() as $id) { $category = get_category($id); if (!empty($category)) { if ($category->parent == 0) { $root_categories[] = $category; } } } return $root_categories; } function create_category_options($categories, $selected_id) { $output = array(); if (is_array($categories)) { $final_categories = array(); foreach ($categories as $category) { if (is_numeric($category)) { $result = get_category($category); if (!(is_a($result, "WP_Error") || empty($result))) { $final_categories[] = $result; } } if (is_object($category)) { $final_categories[] = $category; } } foreach ($final_categories as $category) { $output[] = ''; } } return implode("\n", $output); } function create_dimension_selector($root, $dimension) { $output = array(); $parts = explode("x", $dimension); foreach (array( 'width' => __('Width', 'comicpress'), 'height' => __('Height', 'comicpress') ) as $id => $name) { $dim = array_shift($parts); if (!empty($dim) && !is_numeric($dim)) { $dim = ""; } $output[] = '
'; } return implode("\n", $output); } function handle_update() { if (isset($_POST['attachments'])) { //coming from media editor foreach ($_POST['attachments'] as $post_id => $settings) { if (isset($settings['comic_image_type'])) { update_post_meta($post_id, 'comic_image_type', $settings['comic_image_type']); } } } else { //coming from us foreach ($this->comicpress->comicpress_options as $option => $value) { if (isset($_POST['cp'][$option])) { switch ($option) { case 'comic_category_id': if (is_numeric($_POST['cp'][$option])) { $result = get_category($_POST['cp'][$option]); if (!(is_a($result, 'WP_Error') || empty($result))) { $this->comicpress->comicpress_options[$option] = $_POST['cp'][$option]; } } break; case 'comic_dimensions': case 'rss_dimensions': case 'archive_dimensions': if (is_array($_POST['cp'][$option])) { $dim_parts = array(); $is_valid = true; foreach (array('width', 'height') as $field) { $requested_dim = trim($_POST['cp'][$option][$field]); if ($requested_dim == "") { $dim_parts[] = $requested_dim; } else { if ((int)$requested_dim == $requested_dim) { $dim_parts[] = $requested_dim; } else { $is_valid = false; break; } } } if ($is_valid) { $this->comicpress->comicpress_options[$option] = implode("x", $dim_parts); } } break; case 'blogpost_count': $this->comicpress->comicpress_options[$option] = (int)$_POST['cp'][$option]; break; } } } $this->comicpress->save(); $this->info("ComicPress configuration updated."); } } } ?>