From 4cb06754c37e893856677c65f49a39363fed9af5 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Mon, 16 Nov 2009 22:30:35 -0500 Subject: [PATCH] a lot of cleanups and starting documentation --- classes/ComicPressAddon.inc | 6 --- classes/ComicPressAdmin.inc | 16 +++++++- classes/ComicPressComicPost.inc | 1 + .../backends/ComicPressBackendAttachment.inc | 6 +++ css/cp-admin.css | 7 ++++ docs/en_US/template-tags.html | 37 +++++++++++++++++++ functions.inc | 18 +++++++++ 7 files changed, 83 insertions(+), 8 deletions(-) delete mode 100644 classes/ComicPressAddon.inc create mode 100644 docs/en_US/template-tags.html diff --git a/classes/ComicPressAddon.inc b/classes/ComicPressAddon.inc deleted file mode 100644 index 80aedfc..0000000 --- a/classes/ComicPressAddon.inc +++ /dev/null @@ -1,6 +0,0 @@ - \ No newline at end of file diff --git a/classes/ComicPressAdmin.inc b/classes/ComicPressAdmin.inc index 6c11dca..aea34ea 100644 --- a/classes/ComicPressAdmin.inc +++ b/classes/ComicPressAdmin.inc @@ -68,6 +68,7 @@ class ComicPressAdmin { global $plugin_page, $pagenow, $post; add_theme_page(__("ComicPress", 'comicpress'), __('ComicPress', 'comicpress'), 'edit_themes', 'comicpress/render_admin', array(&$this, 'render_admin')); + add_theme_page(__("ComicPress Docs", 'comicpress'), __('ComicPress', 'comicpress'), 'edit_themes', 'comicpress/comicpress_docs', array(&$this, 'render_documentation')); if (strpos($pagenow, "post") === 0) { add_meta_box("comic-image-ordering", __("Comic Image Ordering", 'comicpress'), array(&$this, 'render_comic_image_ordering'), "post", "normal", "low"); @@ -138,11 +139,17 @@ class ComicPressAdmin { include(dirname(__FILE__) . '/partials/options-admin.inc'); } + function render_documentation() { + $default_langauge = 'en_US'; + + $current_language = get_locale(); + } + function _render_admin_storyline_tree($node, $parent_id = "0") { foreach ($node as $category_id => $children) { $category = get_category($category_id); echo '
'; - echo '' . $category->name . ''; + echo '' . esc_html($category->name) . ' (slug: ' . esc_html($category->slug) . ')'; if (is_array($children)) { echo '
'; $this->_render_admin_storyline_tree($children, $parent_id . '-' . $category_id); @@ -352,7 +359,12 @@ class ComicPressAdmin { if (is_numeric($_POST['post_ID'])) { if ($post = get_post($_POST['post_ID'])) { $comic_post = new ComicPressComicPost($post); - $comic_post->update_post_media_data($this->_json_decode(stripslashes($_POST['cp']['comic_order']))); + $data = $this->_json_decode(stripslashes($_POST['cp']['comic_order'])); + if (!empty($data)) { + if (is_array($data)) { + $comic_post->update_post_media_data($data); + } + } } } } diff --git a/classes/ComicPressComicPost.inc b/classes/ComicPressComicPost.inc index 7b9e7dc..18a363f 100644 --- a/classes/ComicPressComicPost.inc +++ b/classes/ComicPressComicPost.inc @@ -131,6 +131,7 @@ class ComicPressComicPost { */ function update_post_media_data($info) { $ordering = array(); + var_dump($info); foreach ($info as $image) { $image = (array)$image; if (isset($image['id'])) { diff --git a/classes/backends/ComicPressBackendAttachment.inc b/classes/backends/ComicPressBackendAttachment.inc index 643c06e..ddaca16 100644 --- a/classes/backends/ComicPressBackendAttachment.inc +++ b/classes/backends/ComicPressBackendAttachment.inc @@ -42,6 +42,12 @@ class ComicPressBackendAttachment extends ComicPressBackend { $dims = array(); if (isset($comicpress->comicpress_options['image_types'])) { + if ($size == 'default') { + foreach ($comicpress->comicpress_options['image_types'] as $type => $info) { + if ($info['default']) { $size = $type; break; } + } + } + if (isset($comicpress->comicpress_options['image_types'][$size])) { if (isset($comicpress->comicpress_options['image_types'][$size]['dimensions'])) { $dims = array_combine(array('width', 'height'), explode("x", $comicpress->comicpress_options['image_types'][$size]['dimensions'])); diff --git a/css/cp-admin.css b/css/cp-admin.css index 0fb35da..bd12707 100644 --- a/css/cp-admin.css +++ b/css/cp-admin.css @@ -166,4 +166,11 @@ background: url(../images/comicpress-icon.png) left center no-repeat; float: right; display: inline +} + +.cp-category-info .slug { + font-size: 11px; + font-weight: normal; + font-style: italic; + color: #444 } \ No newline at end of file diff --git a/docs/en_US/template-tags.html b/docs/en_US/template-tags.html new file mode 100644 index 0000000..9c44487 --- /dev/null +++ b/docs/en_US/template-tags.html @@ -0,0 +1,37 @@ +

Template Tags

+ +

Protect(), Unprotect(), and Restore()

+ +

+ By design, WordPress stores information on the current post and page query in what are known as global variables. + In order for ComicPress to be able to work properly, it needs to be able to work with posts that are not part of the current page's Loop. + The best example is on the Home page of a standard webbomic, where the latest comic is pulled in above the list of current blog posts. + Programmtically, it can be tricky to keep track of and manage these variables. ComicPress can handle all of this for you using the Protect(), + Unprotect(), and Restore() functions. +

+ +

+ For example, if you want to display the latest comic at the top of your home page, above your blog posts, you would use Protect() and Restore() like this: +

+ +
+	get_header();
+
+
+
+ +

+ These are also available as action hooks, to keep your theme safe when ComicPress Core is deactivated: +

+ +
+
+
+ +

R() and RT()

+ +

R() and RT() find posts that are in relation to the current or provided post.

+ +
    +
  • child_of: The given category plus any children.
  • +
\ No newline at end of file diff --git a/functions.inc b/functions.inc index e48be3b..f6f1a64 100644 --- a/functions.inc +++ b/functions.inc @@ -1,5 +1,22 @@ 3, + 'Protect' => 0, + 'Restore' => 0, + 'Unprotect' => 0, + 'R' => 3, + 'RT' => 3, + 'M' => 1, + 'EM' => 3 +) as $function => $param_count) { + if ($param_count == 0) { + add_action("comicpress-${function}", $function, 10); + } else { + add_filter("comicpress-${function}", $function, 10, $param_count); + } +} + // Global template functions for ComicPress function F($name, $path, $override_post = null) { @@ -105,6 +122,7 @@ function RT($which, $restrictions = null, $override_post = null) { $post_to_use = (!empty($__post)) ? $__post : $post; } + $post = false; if (($new_post = R($which, $restrictions, $post_to_use)) !== false) { $post = $new_post; setup_postdata($post);