diff --git a/classes/ComicPressAdmin.inc b/classes/ComicPressAdmin.inc index aea34ea..3e37e9e 100644 --- a/classes/ComicPressAdmin.inc +++ b/classes/ComicPressAdmin.inc @@ -68,7 +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')); + add_theme_page(__("ComicPress Documentation", 'comicpress'), __('ComicPress Docs', '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"); @@ -83,6 +83,13 @@ class ComicPressAdmin { add_action('admin_footer', array(&$this, 'admin_footer')); } + if ($plugin_page == 'comicpress/comicpress_docs') { + wp_enqueue_style('cp-admin', plugin_dir_url(dirname(__FILE__)) . '/css/cp-admin.css'); + wp_enqueue_script('prettify', plugin_dir_url(dirname(__FILE__)) . '/js/prettify/prettify.js'); + wp_enqueue_style('prettify', plugin_dir_url(dirname(__FILE__)) . '/js/prettify/prettify.css'); + wp_enqueue_script('scriptaculous-effects'); + } + if (strpos($pagenow, "-upload") !== false) { wp_enqueue_style('cp-admin', plugin_dir_url(dirname(__FILE__)) . '/css/cp-admin.css'); wp_enqueue_script('cp-media', plugin_dir_url(dirname(__FILE__)) . '/js/MediaUpload.js', array('prototype')); @@ -140,9 +147,37 @@ class ComicPressAdmin { } function render_documentation() { - $default_langauge = 'en_US'; + $path = false; + foreach (array(get_locale(), 'en_US') as $locale) { + if (is_dir(plugin_dir_path(dirname(__FILE__)) . 'docs/' . $locale)) { + $path = plugin_dir_path(dirname(__FILE__)) . 'docs/' . $locale; + } + } - $current_language = get_locale(); + if (!empty($path)) { + $all_docs = array(); + if (($dh = opendir($path)) !== false) { + while (($file = readdir($dh)) !== false) { + $content = file($path . '/' . $file); + $title = false; + foreach ($content as $line) { + if (preg_match('#

(.*)

#', $line, $matches) > 0) { + list($all, $title) = $matches; + + $id = preg_replace('#[^a-z0-9]+#', '_', strtolower($title)); + $content = implode('', $content); + + $all_docs[$id] = compact('title', 'content'); + } + } + } + closedir($dh); + } + + ksort($all_docs); + + include(dirname(__FILE__) . '/partials/documentation-viewer.inc'); + } } function _render_admin_storyline_tree($node, $parent_id = "0") { @@ -461,5 +496,3 @@ class ComicPressAdmin { } // @codeCoverageIgnoreEnd } - -?> diff --git a/classes/ComicPressComicPost.inc b/classes/ComicPressComicPost.inc index 18a363f..7b9e7dc 100644 --- a/classes/ComicPressComicPost.inc +++ b/classes/ComicPressComicPost.inc @@ -131,7 +131,6 @@ 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/partials/documentation-viewer.inc b/classes/partials/documentation-viewer.inc new file mode 100644 index 0000000..7d9ed90 --- /dev/null +++ b/classes/partials/documentation-viewer.inc @@ -0,0 +1,52 @@ +
+

ComicPress Documentation

+ +
+ $info) { + $all_doc_links[] = '' . $info['title'] . ''; + } + + echo implode(" | ", $all_doc_links); + ?> +
+ +
+ $info) { ?> +
+ +
+ +
+ +
\ No newline at end of file diff --git a/css/cp-admin.css b/css/cp-admin.css index 5e8dcc1..ce5a1f8 100644 --- a/css/cp-admin.css +++ b/css/cp-admin.css @@ -171,4 +171,46 @@ font-weight: normal; font-style: italic; color: #444 +} + +.cp-documentation { + padding: 10px; + background-color: white; + border: solid #464646 1px; +} + +.cp-documentation h1 { + margin: 0 0 0.5em +} + +#comicpress-doc-titles { + margin: 1em 0 +} + +a.selected { + font-weight: bold +} + +#comicpress-relative-posts { + border: solid #464646 1px; + border-bottom: none +} + +#comicpress-relative-posts th, +#comicpress-relative-posts td { + padding: 0.2em 0.75em; + border-bottom: solid #464646 1px; +} + +#comicpress-relative-posts th { + background-color: #b5bdf5 +} + +#comicpress-relative-post-highlighter code { + font-size: 14px; + cursor: help +} + +tr.highlighted td { + background-color: #ffff30 } \ No newline at end of file diff --git a/docs/en_US/media-uploader.html b/docs/en_US/media-uploader.html new file mode 100644 index 0000000..0979291 --- /dev/null +++ b/docs/en_US/media-uploader.html @@ -0,0 +1,3 @@ +

Uploading Comic Files

+ +

WordPress Media Uploader Integration

diff --git a/docs/en_US/template-tags.html b/docs/en_US/template-tags.html index 9c44487..7b3fa19 100644 --- a/docs/en_US/template-tags.html +++ b/docs/en_US/template-tags.html @@ -1,37 +1,143 @@

Template Tags

+

R() and RT()

+ +

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

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Post NamePost DatePost Category
First in Blog2009-01-01Blog
First in Comic2009-01-02Comic
Previous in Blog2009-01-03Blog
Previous in Comic2009-01-04Comic
A Previous Extra Post2009-01-05Extra
Current Post2009-01-06Comic
A Next Extra Post2009-01-07Extra
Next in Comic2009-01-08Comic
Next in Blog2009-01-09Blog
Last in Comic2009-01-10Comic
Last in Blog2009-01-11Blog
+ +
+ +
+ + + + +

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(), + By design, WordPress stores information on the current page's Loop in what are known as global variables. + In order for ComicPress Core 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 webcomic, where the latest comic is displayed above the list of current blog posts. + Programmtically, it can be tricky to keep track of and manage these variables. ComicPress Core handles 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: + For example, you have a comics category with the slug comic. + 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();
+
+get_header();
 
+Protect();
 
+if (RT('last', array('child_of' => 'comic'))) {
+  foreach (M() as $image) { echo EM('embed'); }
+  ?>
+    <h2><?php the_title() ?></h2>
+  <?php
+}
+
+Unprotect();
 

- These are also available as action hooks, to keep your theme safe when ComicPress Core is deactivated: + These are also available as action and filter hooks, to keep your theme safe when ComicPress Core is deactivated as an alternative to function_exists():

-
+
+get_header();
 
+do_action('comicpress-Protect');
+
+if (apply_filters('comicpress-RT', 'last', array('child_of' => 'comic'))) {
+  foreach (M() as $image) { echo EM('embed'); }
+  ?>
+    <h2><?php the_title() ?></h2>
+  <?php
+}
+
+do_action('comicpress-Unprotect');
 
- -

R() and RT()

- -

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

- - \ No newline at end of file diff --git a/functions.inc b/functions.inc index f6f1a64..bc34aa2 100644 --- a/functions.inc +++ b/functions.inc @@ -66,6 +66,14 @@ function __prep_R($restrictions, $post_to_use) { case 'from_post': $restrictions = array('from_post' => $post_to_use); break; + default: + foreach (get_all_category_ids() as $id) { + $category = get_category($id); + if (strtolower($category->slug) == strtolower($restrictions)) { + $restrictions = array('child_of' => $category->slug); + break; + } + } } } diff --git a/js/prettify/lang-css.js b/js/prettify/lang-css.js new file mode 100755 index 0000000..813a2cd --- /dev/null +++ b/js/prettify/lang-css.js @@ -0,0 +1,2 @@ +PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[ \t\r\n\f]+/,null," \t\r\n\u000c"]],[["str",/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],["str",/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],["kwd",/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],["com", +/^(?: