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('#
R() and RT() find posts that are relative to the current or provided post.
+ +Post Name | +Post Date | +Post Category | +
---|---|---|
First in Blog | +2009-01-01 | +Blog | +
First in Comic | +2009-01-02 | +Comic | +
Previous in Blog | +2009-01-03 | +Blog | +
Previous in Comic | +2009-01-04 | +Comic | +
A Previous Extra Post | +2009-01-05 | +Extra | +
Current Post | +2009-01-06 | +Comic | +
A Next Extra Post | +2009-01-07 | +Extra | +
Next in Comic | +2009-01-08 | +Comic | +
Next in Blog | +2009-01-09 | +Blog | +
Last in Comic | +2009-01-10 | +Comic | +
Last in Blog | +2009-01-11 | +Blog | +
R('first')
R('first', array('child_of' => 'comic'))
- 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.
- -