a lot of cleanups and starting documentation

This commit is contained in:
John Bintz 2009-11-16 22:30:35 -05:00
parent b87600e92c
commit 4cb06754c3
7 changed files with 83 additions and 8 deletions

View File

@ -1,6 +0,0 @@
<?php
class ComicPressAddon {
}
?>

View File

@ -68,6 +68,7 @@ class ComicPressAdmin {
global $plugin_page, $pagenow, $post; 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", '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) { if (strpos($pagenow, "post") === 0) {
add_meta_box("comic-image-ordering", __("Comic Image Ordering", 'comicpress'), array(&$this, 'render_comic_image_ordering'), "post", "normal", "low"); 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'); 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") { function _render_admin_storyline_tree($node, $parent_id = "0") {
foreach ($node as $category_id => $children) { foreach ($node as $category_id => $children) {
$category = get_category($category_id); $category = get_category($category_id);
echo '<div id="category_' . $parent_id . '-' . $category_id . '" class="cp-category-info">'; echo '<div id="category_' . $parent_id . '-' . $category_id . '" class="cp-category-info">';
echo '<span>' . $category->name . '</span>'; echo '<span>' . esc_html($category->name) . ' <span class="slug">(slug: ' . esc_html($category->slug) . ')</span></span>';
if (is_array($children)) { if (is_array($children)) {
echo '<div class="cp-children">'; echo '<div class="cp-children">';
$this->_render_admin_storyline_tree($children, $parent_id . '-' . $category_id); $this->_render_admin_storyline_tree($children, $parent_id . '-' . $category_id);
@ -352,7 +359,12 @@ class ComicPressAdmin {
if (is_numeric($_POST['post_ID'])) { if (is_numeric($_POST['post_ID'])) {
if ($post = get_post($_POST['post_ID'])) { if ($post = get_post($_POST['post_ID'])) {
$comic_post = new ComicPressComicPost($post); $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);
}
}
} }
} }
} }

View File

@ -131,6 +131,7 @@ class ComicPressComicPost {
*/ */
function update_post_media_data($info) { function update_post_media_data($info) {
$ordering = array(); $ordering = array();
var_dump($info);
foreach ($info as $image) { foreach ($info as $image) {
$image = (array)$image; $image = (array)$image;
if (isset($image['id'])) { if (isset($image['id'])) {

View File

@ -42,6 +42,12 @@ class ComicPressBackendAttachment extends ComicPressBackend {
$dims = array(); $dims = array();
if (isset($comicpress->comicpress_options['image_types'])) { 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])) {
if (isset($comicpress->comicpress_options['image_types'][$size]['dimensions'])) { if (isset($comicpress->comicpress_options['image_types'][$size]['dimensions'])) {
$dims = array_combine(array('width', 'height'), explode("x", $comicpress->comicpress_options['image_types'][$size]['dimensions'])); $dims = array_combine(array('width', 'height'), explode("x", $comicpress->comicpress_options['image_types'][$size]['dimensions']));

View File

@ -167,3 +167,10 @@
float: right; float: right;
display: inline display: inline
} }
.cp-category-info .slug {
font-size: 11px;
font-weight: normal;
font-style: italic;
color: #444
}

View File

@ -0,0 +1,37 @@
<h1>Template Tags</h1>
<h2>Protect(), Unprotect(), and Restore()</h2>
<p>
By design, WordPress stores information on the current post and page query in what are known as <strong>global variables</strong>.
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.
</p>
<p>
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:
</p>
<pre>
get_header();
</pre>
<p>
These are also available as action hooks, to keep your theme safe when ComicPress Core is deactivated:
</p>
<pre>
</pre>
<h2>R() and RT()</h2>
<p>R() and RT() find posts that are in relation to the current or provided post.</p>
<ul>
<li><strong>child_of</strong>: The given category plus any children.</li>
</ul>

View File

@ -1,5 +1,22 @@
<?php <?php
foreach (array(
'F' => 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 // Global template functions for ComicPress
function F($name, $path, $override_post = null) { 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_to_use = (!empty($__post)) ? $__post : $post;
} }
$post = false;
if (($new_post = R($which, $restrictions, $post_to_use)) !== false) { if (($new_post = R($which, $restrictions, $post_to_use)) !== false) {
$post = $new_post; $post = $new_post;
setup_postdata($post); setup_postdata($post);